{
 "schema": 1,
 "book": "lean-verified",
 "title": "What 'Lean-verified' means",
 "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/lean-verified",
 "written_recipe": "the chapter 'Check it yourself: what \"Lean-verified\" covers' in https://gocheckyourself.org/text/lean-verified-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 seven demonstration files are in the book's demos folder (demos/Demo/*.lean); step 3 downloads them, and chapter 3 of the text edition prints each one in full.",
  "Every demonstration needs Lean (elan). The chapter says leanchecker --fresh takes about 100 seconds and 1 GB per demo; the nanoda step needs Lean 4.35.0 and its own tools. None of this was run here."
 ],
 "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/lean-verified\"\nNew-Item -ItemType Directory -Force check-lean-verified | Out-Null\nSet-Location check-lean-verified",
    "bash": "BASE=\"https://gocheckyourself.org/data/files/lean-verified\"\nmkdir -p check-lean-verified && cd check-lean-verified"
   },
   "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": "ffcf1c2c7578280fae9a3f7b90fda3065fdcbd6ded07bbe55da9cf407190cd1d"
    }
   ],
   "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",
    "bash": "mkdir -p certificates\ncurl -fsSL \"$BASE/certificates/SHA256SUMS.txt\" -o certificates/SHA256SUMS.txt"
   },
   "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-lean-zip",
   "purpose": "Download the build files (lean-verified-lean.zip), unpack them as a folder called lean next to certificates, and download the seven demonstration files into demos/Demo.",
   "inputs": [
    {
     "path": "downloads/lean-verified-lean.zip",
     "sha256": "5b6d730ccf9ad8c464d49ba19e2e4f503b83aac21ef29552d78cd1d23aa7591c"
    }
   ],
   "command": {
    "powershell": "New-Item -ItemType Directory -Force downloads | Out-Null\n$DL = $BASE + '/downloads'\nInvoke-WebRequest -UseBasicParsing -UserAgent \"Mozilla/5.0\" \"$DL/lean-verified-lean.zip\" -OutFile downloads/lean-verified-lean.zip\n\"zip sha256: \" + (Get-FileHash -Algorithm SHA256 downloads/lean-verified-lean.zip).Hash.ToLower()\nExpand-Archive -Force downloads/lean-verified-lean.zip -DestinationPath .\nif (Test-Path lean) { Remove-Item -Recurse -Force lean }\nRename-Item lean-verified-lean lean\nNew-Item -ItemType Directory -Force demos/Demo | Out-Null\nforeach ($n in \"AddedAxiom\",\"Honest\",\"RedefinedPlus\",\"SkipKernelTC\",\"SmallerNumberSystem\",\"UsesSorry\",\"WrongDefinition\") { Invoke-WebRequest -UseBasicParsing -UserAgent \"Mozilla/5.0\" \"$BASE/demos/Demo/$n.lean\" -OutFile \"demos/Demo/$n.lean\" }",
    "bash": "mkdir -p downloads\nDL=\"$BASE\"'/downloads'\ncurl -fsSL \"$DL/lean-verified-lean.zip\" -o downloads/lean-verified-lean.zip\necho \"zip sha256: $( (sha256sum downloads/lean-verified-lean.zip 2>/dev/null || shasum -a 256 downloads/lean-verified-lean.zip) | cut -c1-64 )\"\nunzip -q -o downloads/lean-verified-lean.zip\nrm -rf lean; mv lean-verified-lean lean\nmkdir -p demos/Demo\nfor n in AddedAxiom Honest RedefinedPlus SkipKernelTC SmallerNumberSystem UsesSorry WrongDefinition; do curl -fsSL \"$BASE/demos/Demo/$n.lean\" -o \"demos/Demo/$n.lean\"; done"
   },
   "expected_output": "zip sha256: 5b6d730ccf9ad8c464d49ba19e2e4f503b83aac21ef29552d78cd1d23aa7591c",
   "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": "hash-check",
   "purpose": "Compare the SHA-256 fingerprint of every downloaded file with the published list.",
   "inputs": [
    {
     "path": "certificates/SHA256SUMS.txt",
     "sha256": "ffcf1c2c7578280fae9a3f7b90fda3065fdcbd6ded07bbe55da9cf407190cd1d"
    }
   ],
   "command": {
    "powershell": "$ok = 0; $bad = 0\nGet-Content certificates/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 certificates/SHA256SUMS.txt 2>&1 | grep -v \": OK$\" ; echo \"$($C certificates/SHA256SUMS.txt 2>/dev/null | grep -c \": OK$\") OK\""
   },
   "expected_output": "PowerShell prints the line \"10 OK, 0 not OK\". bash prints \"10 OK\" and nothing else.",
   "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": "lean-demos",
   "purpose": "HEAVY: for each demo name run the three Lean commands (needs Lean through elan, and the seven demonstration files from step 3 in demos/Demo/).",
   "inputs": [],
   "command": {
    "any": "# from the lean folder of the book, for each of: Honest AddedAxiom UsesSorry SmallerNumberSystem RedefinedPlus WrongDefinition SkipKernelTC\nlake build Demo.<Name>\nlake env leanchecker Demo.<Name>\nlake env leanchecker --fresh Demo.<Name>"
   },
   "expected_output": "Per the chapter's table: the build prints the axiom report; leanchecker prints nothing and exits 0 when it accepts (exit 1 and a message when it rejects; the kernel-check-off demo is rejected).",
   "does_not_show": "It shows which check catches which kind of fault in a small file. It shows nothing about other files.",
   "cost": "about 100 seconds and 1 GB per demo for the fresh mode",
   "runnable_by_assistant": false
  }
 ]
}