# Check it yourself: Navier-Stokes

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. Why a recipe and not our program: https://gocheckyourself.org/how-to-check/

You do not have to trust our results or our programs. This page tells you, step by step, how to check the published files with tools you already have. The full written recipe is the chapter 'Check it yourself: Navier-Stokes, the four alternatives and the erratum' in https://gocheckyourself.org/text/navier-stokes-experts.txt.

Steps 1 to 7, 9 have the command for Windows PowerShell and for macOS or Linux (bash), the output you should see, and a plain sentence on what a match means and what it does not. Steps 8 have no copy-paste script yet: each names the recipe to write yourself and the output to expect. If your output is different, the step has failed; do not skip it.

You need: a command line, and Python 3.8 or later (python on Windows, python3 on macOS or Linux) for the steps that run a script. Windows PowerShell 5.1 or later (pwsh also works). Scripts are short; read them before you run them.

## What is known not to work today

- 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.

## Step 1: Make an empty working folder and say where the files are.

Windows PowerShell:

```powershell
$ProgressPreference = "SilentlyContinue"
$BASE = "https://gocheckyourself.org/data/files/navier-stokes"
New-Item -ItemType Directory -Force check-navier-stokes | Out-Null
Set-Location check-navier-stokes
```

macOS or Linux (bash):

```bash
BASE="https://gocheckyourself.org/data/files/navier-stokes"
mkdir -p check-navier-stokes && cd check-navier-stokes
```

You should see:

```
No output.
```

What a match shows, and what it does not: Nothing; this just makes a folder.

Cost: instant.

## Step 2: Download the list of fingerprints (SHA-256) that the book publishes for its files.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/navier-stokes/certificates/SHA256SUMS.txt  d12a9a724e51d72537e380261e5934e8601ef02fd9178ff82235b7fe498726e8

Windows PowerShell:

```powershell
New-Item -ItemType Directory -Force certificates | Out-Null
Invoke-WebRequest -UseBasicParsing -UserAgent "Mozilla/5.0" "$BASE/certificates/SHA256SUMS.txt" -OutFile certificates/SHA256SUMS.txt
Set-Location certificates
```

macOS or Linux (bash):

```bash
mkdir -p certificates
curl -fsSL "$BASE/certificates/SHA256SUMS.txt" -o certificates/SHA256SUMS.txt
cd certificates
```

You should see:

```
No output. The file certificates/SHA256SUMS.txt exists. Each line is 64 hex digits, a space, an optional star, and a file path.
```

What a match shows, and what it does not: 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.

## Step 3: Download the other certificate files and the closure list.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/navier-stokes/certificates/closure-C/C-REQUIRED-FILES.csv  f0f6f300df67573bfe3e562b30e21224f5b3483b60528dc43ebdf2f9ec803276

Windows PowerShell:

```powershell
Get-Content SHA256SUMS.txt | Where-Object { $_.Trim() } | ForEach-Object {
  $rel = ($_ -replace '^[0-9a-fA-F]{64} [ *]','') -replace '^\./',''
  New-Item -ItemType Directory -Force (Split-Path -Parent (Join-Path $PWD $rel)) | Out-Null
  try { Invoke-WebRequest -UseBasicParsing -UserAgent "Mozilla/5.0" "$BASE/certificates/$rel" -OutFile $rel } catch { "NOT FOUND: $rel" }
}
```

macOS or Linux (bash):

```bash
while read -r h p; do
  p="${p#\*}"; p="${p#./}"; [ -z "$p" ] && continue
  mkdir -p "$(dirname "$p")"
  curl -fsSL "$BASE/certificates/$p" -o "$p" || echo "NOT FOUND: $p"
done < SHA256SUMS.txt
```

You should see:

```
No output (7 lines in the list).
```

What a match shows, and what it does not: See the hash step.

Cost: seconds.

## Step 4: Compare the SHA-256 fingerprint of every downloaded file with the published list.

Files used (SHA-256):
- https://gocheckyourself.org/data/files/navier-stokes/certificates/SHA256SUMS.txt  d12a9a724e51d72537e380261e5934e8601ef02fd9178ff82235b7fe498726e8

Windows PowerShell:

```powershell
$ok = 0; $bad = 0
Get-Content SHA256SUMS.txt | Where-Object { $_.Trim() } | ForEach-Object {
  $h = $_.Substring(0,64).ToLower()
  $rel = ($_ -replace '^[0-9a-fA-F]{64} [ *]','') -replace '^\./',''
  $f = Get-FileHash -Algorithm SHA256 -LiteralPath $rel -ErrorAction SilentlyContinue
  if ($f -and $f.Hash.ToLower() -eq $h) { $ok++ } else { $bad++; "NOT OK: $rel" }
}
"$ok OK, $bad not OK"
```

macOS or Linux (bash):

```bash
# Linux: sha256sum.  macOS: use "shasum -a 256 -c" instead of "sha256sum -c".
if command -v sha256sum >/dev/null; then C="sha256sum -c"; else C="shasum -a 256 -c"; fi
$C SHA256SUMS.txt 2>&1 | grep -v ": OK$" ; echo "$($C SHA256SUMS.txt 2>/dev/null | grep -c ": OK$") OK"
```

You should see:

```
PowerShell prints a line "7 OK, 0 not OK". bash prints every line that is not OK, then "7 OK".
```

What a match shows, and what it does not: 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.

## Step 5: 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.

Files used (SHA-256):
- navier-stokes-lean.zip, in the book's downloads folder (its address is in the commands below)  876376891bf149db65eb3f3191f22c65aa654511f49ea3a35403726f5a964a23

Windows PowerShell:

```powershell
Set-Location ..
New-Item -ItemType Directory -Force downloads | Out-Null
$DL = $BASE + '/downloads'
Invoke-WebRequest -UseBasicParsing -UserAgent "Mozilla/5.0" "$DL/navier-stokes-lean.zip" -OutFile downloads/navier-stokes-lean.zip
"zip sha256: " + (Get-FileHash -Algorithm SHA256 downloads/navier-stokes-lean.zip).Hash.ToLower()
Expand-Archive -Force downloads/navier-stokes-lean.zip -DestinationPath .
if (Test-Path lean) { Remove-Item -Recurse -Force lean }
Rename-Item navier-stokes-lean lean
```

macOS or Linux (bash):

```bash
cd ..
mkdir -p downloads
DL="$BASE"'/downloads'
curl -fsSL "$DL/navier-stokes-lean.zip" -o downloads/navier-stokes-lean.zip
echo "zip sha256: $( (sha256sum downloads/navier-stokes-lean.zip 2>/dev/null || shasum -a 256 downloads/navier-stokes-lean.zip) | cut -c1-64 )"
unzip -q -o downloads/navier-stokes-lean.zip
rm -rf lean; mv navier-stokes-lean lean
```

You should see:

```
zip sha256: 876376891bf149db65eb3f3191f22c65aa654511f49ea3a35403726f5a964a23
```

What a match shows, and what it does not: 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.

## Step 6: Closure list for (C): every Lean file with in_release True must match the hash in the list (the chapter's own command).

Files used (SHA-256):
- https://gocheckyourself.org/data/files/navier-stokes/certificates/closure-C/C-REQUIRED-FILES.csv  f0f6f300df67573bfe3e562b30e21224f5b3483b60528dc43ebdf2f9ec803276

Windows PowerShell:

```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))"
(Get-FileHash -Algorithm SHA256 lean/overlays/NavierStokes/ComparatorDefinitions.lean).Hash.ToLower()
```

macOS or Linux (bash):

```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))"
(sha256sum lean/overlays/NavierStokes/ComparatorDefinitions.lean 2>/dev/null || shasum -a 256 lean/overlays/NavierStokes/ComparatorDefinitions.lean) | cut -c1-64
```

You should see:

```
522 522
39bda0f18d9028d56b8826b8039c2891cd93e5a05da09135c8e52f4af3f70f1a  (begins 39bda0f1)
```

What a match shows, and what it does not: 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.

## Step 7: 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.

Files used (SHA-256):
- lean/NavierStokes/MeanBoundsReindex.lean (made by an earlier step in your folder; not a separate download)  96339cf10aea6cc58b5003d8657e813d35509a8abbd383d0555245007f0d4353

Windows PowerShell:

```powershell
python -c "b=bytearray(open('lean/NavierStokes/MeanBoundsReindex.lean','rb').read()); b[0]^=1; open('tampered.copy','wb').write(b)"
"published : 96339cf10aea6cc58b5003d8657e813d35509a8abbd383d0555245007f0d4353"
"your copy : " + (Get-FileHash -Algorithm SHA256 tampered.copy).Hash.ToLower()
```

macOS or Linux (bash):

```bash
python3 -c "b=bytearray(open('lean/NavierStokes/MeanBoundsReindex.lean','rb').read()); b[0]^=1; open('tampered.copy','wb').write(b)"
echo "published : 96339cf10aea6cc58b5003d8657e813d35509a8abbd383d0555245007f0d4353"
echo "your copy : $( (sha256sum tampered.copy 2>/dev/null || shasum -a 256 tampered.copy) | cut -c1-64 )"
```

You should see:

```
Two different 64-digit values; the 'published' value ends 7f0d4353 and your copy's value is different.
```

What a match shows, and what it does not: It shows the fingerprint step would notice that change. It says nothing about the file you did not change.

Cost: instant.

## Step 8: Recount of the reading combinations in chapter 8.

Commands (same on both platforms; not run by us unless stated):

```
No copy-paste script yet. Write it yourself from the written recipe:
Chapter heading 'Recount of the reading combinations' and the decision lists in chapter 8, section 4 of the text edition.
```

You should see:

```
440,401,920 combinations per column; 82 distinct verdict patterns; shares as in the book's README.
```

What a match shows, and what it does not: Depends on typing the decision lists in correctly.

Cost: seconds to minutes.

## Step 9: HEAVY, not run by us in this recipe: build the Lean files and print the axioms of the main results.

Commands (same on both platforms; not run by us unless stated):

```
cd lean
lake exe cache get
lake build
# then, in a file that starts with 'import ReadingsCore', put the nine '#print axioms' lines from the chapter and run:
lake env lean <that file>
```

You should see:

```
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.
```

What a match shows, and what it does not: 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.

