{
 "schema": 1,
 "book": "navier-stokes",
 "title": "Navier-Stokes",
 "why_this_recipe": "Don't take our word for it. Each result here comes with its files and a check guide, and each guide says which checks you can rerun yourself. Some results rest on logs from programs that are not part of this book, or on files available on request; the guide says which. Where your run matches ours, you checked that part rather than trusted it. If something breaks, confuses you or does not match, you are welcome to tell us. We fix mistakes in the open and credit the person who found them.",
 "base_url": "https://gocheckyourself.org/data/files/navier-stokes",
 "written_recipe": "the chapter 'Check it yourself: Navier-Stokes, the four alternatives and the erratum' in https://gocheckyourself.org/text/navier-stokes-experts.txt",
 "instructions_for_assistants": "Run these steps yourself, in a fresh empty folder, with the person's permission, and report the real output next to the expected output. Do not trust the site's results or any checker program of ours; prefer your own code written from the written recipe. A step whose output differs is a failed step: say so. Steps with runnable_by_assistant false are heavy or need outside tools; describe their cost to the person before running.",
 "known_gaps": [
  "The Lean builds, the axiom printouts, nanoda and lean4lean are not run in this recipe. The book says the default build is 9,636 steps and takes hours, with 15 GB of memory when many compiles run in parallel; nanoda on a three-theorem export is about 4 minutes plus about 10 GB for the export. Exact commands are in the chapter (and repeated at the end of this file); we did not run them.",
  "The recount of the 440,401,920 reading combinations needs the decision lists of chapter 8 typed in by the reader; there is no script here.",
  "The chapter's one-liner opens files under a folder called lean/; the zip unpacks to navier-stokes-lean/, so the steps below rename it."
 ],
 "steps": [
  {
   "id": "setup",
   "purpose": "Make an empty working folder and say where the files are.",
   "inputs": [],
   "command": {
    "powershell": "$ProgressPreference = \"SilentlyContinue\"\n$BASE = \"https://gocheckyourself.org/data/files/navier-stokes\"\nNew-Item -ItemType Directory -Force check-navier-stokes | Out-Null\nSet-Location check-navier-stokes",
    "bash": "BASE=\"https://gocheckyourself.org/data/files/navier-stokes\"\nmkdir -p check-navier-stokes && cd check-navier-stokes"
   },
   "expected_output": "No output.",
   "does_not_show": "Nothing; this just makes a folder.",
   "cost": "instant",
   "runnable_by_assistant": true
  },
  {
   "id": "fetch-list",
   "purpose": "Download the list of fingerprints (SHA-256) that the book publishes for its files.",
   "inputs": [
    {
     "path": "certificates/SHA256SUMS.txt",
     "sha256": "d12a9a724e51d72537e380261e5934e8601ef02fd9178ff82235b7fe498726e8"
    }
   ],
   "command": {
    "powershell": "New-Item -ItemType Directory -Force certificates | Out-Null\nInvoke-WebRequest -UseBasicParsing -UserAgent \"Mozilla/5.0\" \"$BASE/certificates/SHA256SUMS.txt\" -OutFile certificates/SHA256SUMS.txt\nSet-Location certificates",
    "bash": "mkdir -p certificates\ncurl -fsSL \"$BASE/certificates/SHA256SUMS.txt\" -o certificates/SHA256SUMS.txt\ncd certificates"
   },
   "expected_output": "No output. The file certificates/SHA256SUMS.txt exists. Each line is 64 hex digits, a space, an optional star, and a file path.",
   "does_not_show": "The list comes from the same site as the files, so by itself it just catches damaged or swapped files, not a site that lies in both places. Compare the list's own SHA-256 (see inputs) with a copy you trust, such as one a friend keeps, or one kept anywhere other than this site.",
   "cost": "instant",
   "runnable_by_assistant": true
  },
  {
   "id": "fetch-files",
   "purpose": "Download the other certificate files and the closure list.",
   "inputs": [
    {
     "path": "certificates/closure-C/C-REQUIRED-FILES.csv",
     "sha256": "f0f6f300df67573bfe3e562b30e21224f5b3483b60528dc43ebdf2f9ec803276"
    }
   ],
   "command": {
    "powershell": "Get-Content SHA256SUMS.txt | Where-Object { $_.Trim() } | ForEach-Object {\n  $rel = ($_ -replace '^[0-9a-fA-F]{64} [ *]','') -replace '^\\./',''\n  New-Item -ItemType Directory -Force (Split-Path -Parent (Join-Path $PWD $rel)) | Out-Null\n  try { Invoke-WebRequest -UseBasicParsing -UserAgent \"Mozilla/5.0\" \"$BASE/certificates/$rel\" -OutFile $rel } catch { \"NOT FOUND: $rel\" }\n}",
    "bash": "while read -r h p; do\n  p=\"${p#\\*}\"; p=\"${p#./}\"; [ -z \"$p\" ] && continue\n  mkdir -p \"$(dirname \"$p\")\"\n  curl -fsSL \"$BASE/certificates/$p\" -o \"$p\" || echo \"NOT FOUND: $p\"\ndone < SHA256SUMS.txt"
   },
   "expected_output": "No output (7 lines in the list).",
   "does_not_show": "See the hash step.",
   "cost": "seconds",
   "runnable_by_assistant": true
  },
  {
   "id": "hash-check",
   "purpose": "Compare the SHA-256 fingerprint of every downloaded file with the published list.",
   "inputs": [
    {
     "path": "certificates/SHA256SUMS.txt",
     "sha256": "d12a9a724e51d72537e380261e5934e8601ef02fd9178ff82235b7fe498726e8"
    }
   ],
   "command": {
    "powershell": "$ok = 0; $bad = 0\nGet-Content SHA256SUMS.txt | Where-Object { $_.Trim() } | ForEach-Object {\n  $h = $_.Substring(0,64).ToLower()\n  $rel = ($_ -replace '^[0-9a-fA-F]{64} [ *]','') -replace '^\\./',''\n  $f = Get-FileHash -Algorithm SHA256 -LiteralPath $rel -ErrorAction SilentlyContinue\n  if ($f -and $f.Hash.ToLower() -eq $h) { $ok++ } else { $bad++; \"NOT OK: $rel\" }\n}\n\"$ok OK, $bad not OK\"",
    "bash": "# Linux: sha256sum.  macOS: use \"shasum -a 256 -c\" instead of \"sha256sum -c\".\nif command -v sha256sum >/dev/null; then C=\"sha256sum -c\"; else C=\"shasum -a 256 -c\"; fi\n$C SHA256SUMS.txt 2>&1 | grep -v \": OK$\" ; echo \"$($C SHA256SUMS.txt 2>/dev/null | grep -c \": OK$\") OK\""
   },
   "expected_output": "PowerShell prints a line \"7 OK, 0 not OK\". bash prints every line that is not OK, then \"7 OK\".",
   "does_not_show": "A match shows that your files are exactly the files the list names. What the files say is tested by the other steps of this recipe. ",
   "cost": "seconds",
   "runnable_by_assistant": true
  },
  {
   "id": "fetch-lean-zip",
   "purpose": "Download the Lean source download (4.99 MB, 903 files, 898 of them Lean files) and unpack it as a folder called lean next to certificates.",
   "inputs": [
    {
     "path": "downloads/navier-stokes-lean.zip",
     "sha256": "876376891bf149db65eb3f3191f22c65aa654511f49ea3a35403726f5a964a23"
    }
   ],
   "command": {
    "powershell": "Set-Location ..\nNew-Item -ItemType Directory -Force downloads | Out-Null\n$DL = $BASE + '/downloads'\nInvoke-WebRequest -UseBasicParsing -UserAgent \"Mozilla/5.0\" \"$DL/navier-stokes-lean.zip\" -OutFile downloads/navier-stokes-lean.zip\n\"zip sha256: \" + (Get-FileHash -Algorithm SHA256 downloads/navier-stokes-lean.zip).Hash.ToLower()\nExpand-Archive -Force downloads/navier-stokes-lean.zip -DestinationPath .\nif (Test-Path lean) { Remove-Item -Recurse -Force lean }\nRename-Item navier-stokes-lean lean",
    "bash": "cd ..\nmkdir -p downloads\nDL=\"$BASE\"'/downloads'\ncurl -fsSL \"$DL/navier-stokes-lean.zip\" -o downloads/navier-stokes-lean.zip\necho \"zip sha256: $( (sha256sum downloads/navier-stokes-lean.zip 2>/dev/null || shasum -a 256 downloads/navier-stokes-lean.zip) | cut -c1-64 )\"\nunzip -q -o downloads/navier-stokes-lean.zip\nrm -rf lean; mv navier-stokes-lean lean"
   },
   "expected_output": "zip sha256: 876376891bf149db65eb3f3191f22c65aa654511f49ea3a35403726f5a964a23",
   "does_not_show": "The zip is not in the fingerprint list, so its hash is given here and in the machine-readable file; compare it with a copy you trust.",
   "cost": "seconds",
   "runnable_by_assistant": true
  },
  {
   "id": "closure-C",
   "purpose": "Closure list for (C): every Lean file with in_release True must match the hash in the list (the chapter's own command).",
   "inputs": [
    {
     "path": "certificates/closure-C/C-REQUIRED-FILES.csv",
     "sha256": "f0f6f300df67573bfe3e562b30e21224f5b3483b60528dc43ebdf2f9ec803276"
    }
   ],
   "command": {
    "powershell": "python -I -c \"import csv,hashlib;R=[r for r in csv.DictReader(open('certificates/closure-C/C-REQUIRED-FILES.csv')) if r['in_release']=='True'];print(len(R),sum(hashlib.sha256(open('lean/'+r['file'],'rb').read()).hexdigest()==(r['original_sha256'] if r['release_identical_to_original']=='True' else r['effective_sha256']) for r in R))\"\n(Get-FileHash -Algorithm SHA256 lean/overlays/NavierStokes/ComparatorDefinitions.lean).Hash.ToLower()",
    "bash": "python3 -I -c \"import csv,hashlib;R=[r for r in csv.DictReader(open('certificates/closure-C/C-REQUIRED-FILES.csv')) if r['in_release']=='True'];print(len(R),sum(hashlib.sha256(open('lean/'+r['file'],'rb').read()).hexdigest()==(r['original_sha256'] if r['release_identical_to_original']=='True' else r['effective_sha256']) for r in R))\"\n(sha256sum lean/overlays/NavierStokes/ComparatorDefinitions.lean 2>/dev/null || shasum -a 256 lean/overlays/NavierStokes/ComparatorDefinitions.lean) | cut -c1-64"
   },
   "expected_output": "522 522\n39bda0f18d9028d56b8826b8039c2891cd93e5a05da09135c8e52f4af3f70f1a  (begins 39bda0f1)",
   "does_not_show": "It shows the Lean files in the download are the files the closure list describes. It does not show that Lean accepts them or that the statements mean what the book says.",
   "cost": "seconds",
   "runnable_by_assistant": true
  },
  {
   "id": "one-byte-change",
   "purpose": "See for yourself that a one-byte change is caught: change one byte in a copy of lean/NavierStokes/MeanBoundsReindex.lean and look at the fingerprint.",
   "inputs": [
    {
     "path": "lean/NavierStokes/MeanBoundsReindex.lean",
     "sha256": "96339cf10aea6cc58b5003d8657e813d35509a8abbd383d0555245007f0d4353",
     "local": "lean/NavierStokes/MeanBoundsReindex.lean"
    }
   ],
   "command": {
    "powershell": "python -c \"b=bytearray(open('lean/NavierStokes/MeanBoundsReindex.lean','rb').read()); b[0]^=1; open('tampered.copy','wb').write(b)\"\n\"published : 96339cf10aea6cc58b5003d8657e813d35509a8abbd383d0555245007f0d4353\"\n\"your copy : \" + (Get-FileHash -Algorithm SHA256 tampered.copy).Hash.ToLower()",
    "bash": "python3 -c \"b=bytearray(open('lean/NavierStokes/MeanBoundsReindex.lean','rb').read()); b[0]^=1; open('tampered.copy','wb').write(b)\"\necho \"published : 96339cf10aea6cc58b5003d8657e813d35509a8abbd383d0555245007f0d4353\"\necho \"your copy : $( (sha256sum tampered.copy 2>/dev/null || shasum -a 256 tampered.copy) | cut -c1-64 )\""
   },
   "expected_output": "Two different 64-digit values; the 'published' value ends 7f0d4353 and your copy's value is different.",
   "does_not_show": "It shows the fingerprint step would notice that change. It says nothing about the file you did not change.",
   "cost": "instant",
   "runnable_by_assistant": true
  },
  {
   "id": "recount",
   "purpose": "Recount of the reading combinations in chapter 8.",
   "inputs": [],
   "command": {
    "any": "No copy-paste script yet. Write it yourself from the written recipe\u003a\nChapter heading 'Recount of the reading combinations' and the decision lists in chapter 8, section 4 of the text edition."
   },
   "expected_output": "440,401,920 combinations per column; 82 distinct verdict patterns; shares as in the book's README.",
   "does_not_show": "Depends on typing the decision lists in correctly.",
   "cost": "seconds to minutes",
   "runnable_by_assistant": false
  },
  {
   "id": "lean-build",
   "purpose": "HEAVY, not run by us in this recipe: build the Lean files and print the axioms of the main results.",
   "inputs": [],
   "command": {
    "any": "cd lean\nlake exe cache get\nlake build\n# then, in a file that starts with 'import ReadingsCore', put the nine '#print axioms' lines from the chapter and run\u003a\nlake env lean <that file>"
   },
   "expected_output": "The build finishes with no errors (9,636 steps per the chapter); each of the nine axiom lines lists just propext, Classical.choice and Quot.sound.",
   "does_not_show": "It shows Lean accepts the stated theorems from the standard axioms. It does not show the statements mean what the book says; the chapter's Limits section lists what is not covered. Needs elan installed. Cost per the chapter: hours, up to about 15 GB of memory.",
   "cost": "hours",
   "runnable_by_assistant": false
  }
 ]
}