machinechecked 0.1.6__tar.gz → 0.1.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {machinechecked-0.1.6 → machinechecked-0.1.8}/PKG-INFO +1 -1
  2. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/machinechecked.egg-info/PKG-INFO +1 -1
  3. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/machinechecked.egg-info/SOURCES.txt +3 -2
  4. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/cli.py +101 -6
  5. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/data/ProofLensProbe.lean +56 -23
  6. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/pipeline.py +7 -4
  7. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/promote.py +15 -4
  8. machinechecked-0.1.8/engine/python/prooflens/review_cli.py +296 -0
  9. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/review_queue.py +55 -0
  10. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/reviews.py +7 -2
  11. machinechecked-0.1.8/engine/python/prooflens/web/assets/index--l_fVRcG.css +1 -0
  12. machinechecked-0.1.6/engine/python/prooflens/web/assets/index-DgRDdITJ.js → machinechecked-0.1.8/engine/python/prooflens/web/assets/index-CJsp3IHP.js +30 -30
  13. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/index.html +2 -2
  14. {machinechecked-0.1.6 → machinechecked-0.1.8}/pyproject.toml +1 -1
  15. machinechecked-0.1.6/engine/python/prooflens/web/assets/index-T9UdK0vf.css +0 -1
  16. {machinechecked-0.1.6 → machinechecked-0.1.8}/LICENSE +0 -0
  17. {machinechecked-0.1.6 → machinechecked-0.1.8}/README.md +0 -0
  18. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/machinechecked.egg-info/dependency_links.txt +0 -0
  19. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/machinechecked.egg-info/entry_points.txt +0 -0
  20. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/machinechecked.egg-info/requires.txt +0 -0
  21. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/machinechecked.egg-info/top_level.txt +0 -0
  22. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/__init__.py +0 -0
  23. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/__main__.py +0 -0
  24. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/assess.py +0 -0
  25. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/audit.py +0 -0
  26. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/bundle.py +0 -0
  27. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/cache.py +0 -0
  28. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/config.py +0 -0
  29. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/data/prooflens.sty +0 -0
  30. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/data/schema/evidence.schema.json +0 -0
  31. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/data/schema/inventory.schema.json +0 -0
  32. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/data/schema/manifest-claim.schema.json +0 -0
  33. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/data/schema/manifest-index.schema.json +0 -0
  34. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/deps.py +0 -0
  35. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/evidence.py +0 -0
  36. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/export.py +0 -0
  37. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/formalization.py +0 -0
  38. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/manifest.py +0 -0
  39. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/paper.py +0 -0
  40. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/pdfclaims.py +0 -0
  41. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/probe.py +0 -0
  42. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/replay.py +0 -0
  43. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/schemas.py +0 -0
  44. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/server.py +0 -0
  45. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/simple.py +0 -0
  46. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/sources.py +0 -0
  47. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/tex.py +0 -0
  48. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/util.py +0 -0
  49. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  50. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  51. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  52. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  53. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  54. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  55. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  56. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  57. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  58. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  59. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  60. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  61. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  62. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  63. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  64. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  65. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  66. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  67. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  68. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs +0 -0
  69. {machinechecked-0.1.6 → machinechecked-0.1.8}/engine/python/prooflens/web/theme.css +0 -0
  70. {machinechecked-0.1.6 → machinechecked-0.1.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machinechecked
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: Read a mathematical paper beside its Lean formalisation, and see claim by claim what Lean establishes.
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://machinechecked.org
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machinechecked
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: Read a mathematical paper beside its Lean formalisation, and see claim by claim what Lean establishes.
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://machinechecked.org
@@ -26,6 +26,7 @@ engine/python/prooflens/pipeline.py
26
26
  engine/python/prooflens/probe.py
27
27
  engine/python/prooflens/promote.py
28
28
  engine/python/prooflens/replay.py
29
+ engine/python/prooflens/review_cli.py
29
30
  engine/python/prooflens/review_queue.py
30
31
  engine/python/prooflens/reviews.py
31
32
  engine/python/prooflens/schemas.py
@@ -61,6 +62,6 @@ engine/python/prooflens/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2
61
62
  engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2
62
63
  engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2
63
64
  engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2
64
- engine/python/prooflens/web/assets/index-DgRDdITJ.js
65
- engine/python/prooflens/web/assets/index-T9UdK0vf.css
65
+ engine/python/prooflens/web/assets/index--l_fVRcG.css
66
+ engine/python/prooflens/web/assets/index-CJsp3IHP.js
66
67
  engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs
@@ -22,6 +22,7 @@ import functools
22
22
  import http.server
23
23
  import json
24
24
  import re
25
+ import os
25
26
  import sys
26
27
  from pathlib import Path
27
28
 
@@ -245,6 +246,17 @@ def cmd_view(a):
245
246
  serve(site, a.port, on_link, not a.no_browser)
246
247
 
247
248
 
249
+ def _site_dest(site: str, root: Path) -> Path:
250
+ """The directory `--site` names, refused when it is the project (or holds it), or when it
251
+ has other content than a previous site: writing the site replaces it."""
252
+ dest = Path(site).resolve()
253
+ if dest == root.resolve() or root.resolve().is_relative_to(dest):
254
+ sys.exit(f"--site {site}: choose a new directory, not the project")
255
+ if dest.exists() and not (dest / "audit.json").exists() and any(dest.iterdir()):
256
+ sys.exit(f"--site {site}: not empty and not a previous site; choose another")
257
+ return dest
258
+
259
+
248
260
  def cmd_build_simple(a):
249
261
  from .bundle import bundle
250
262
  root, paper = _simple_target(a)
@@ -253,12 +265,8 @@ def cmd_build_simple(a):
253
265
  _print_simple(view["body"])
254
266
  if a.site:
255
267
  import shutil
256
- dest = Path(a.site).resolve()
257
- if dest == root.resolve() or root.resolve().is_relative_to(dest):
258
- sys.exit(f"--site {a.site}: choose a new directory, not the project")
268
+ dest = _site_dest(a.site, root)
259
269
  if dest.exists():
260
- if not (dest / "audit.json").exists() and any(dest.iterdir()):
261
- sys.exit(f"--site {a.site}: not empty and not a previous site; choose another")
262
270
  shutil.rmtree(dest)
263
271
  shutil.copytree(site, dest)
264
272
  print(f"wrote the reader to {dest}: publish this directory as it is "
@@ -365,6 +373,7 @@ def cmd_build(a):
365
373
  return cmd_build_simple(a)
366
374
  from .pipeline import build
367
375
  cfg = cfgmod.load(_config_arg(a))
376
+ dest = _site_dest(a.site, cfg.root) if getattr(a, "site", None) else None
368
377
  res = build(cfg, release=a.release, skip_lean=a.skip_lean, skip_tex=a.skip_tex, lake=a.lake,
369
378
  web_dist=_web_dist(a.web), lean_build=not a.no_lean_build,
370
379
  reuse_lean=a.reuse_lean)
@@ -381,6 +390,16 @@ def cmd_build(a):
381
390
  print(f" {f['tier']} {f['subject']}: {f['message']}")
382
391
  if idx["findings"]["total"].get("warning"):
383
392
  print(" (warnings: see `check --json` or the reader)")
393
+ if dest is not None:
394
+ # The site to publish is the audit's public export: what the configuration publishes,
395
+ # scanned for private material, as `export --out` writes it.
396
+ from .export import ExportError, export
397
+ try:
398
+ out = export(cfg, dest, res["release"], _web_dist(a.web))
399
+ except ExportError as e:
400
+ sys.exit(str(e))
401
+ print(f"wrote the audit to {out['out']}: publish this directory as it is "
402
+ "(audit.json describes it)")
384
403
  if a.fail_on_violation and idx["findings"]["total"].get("violation"):
385
404
  sys.exit(1)
386
405
 
@@ -515,6 +534,48 @@ def cmd_serve(a):
515
534
  http.server.ThreadingHTTPServer(("127.0.0.1", a.port), handler).serve_forever()
516
535
 
517
536
 
537
+ def _text_arg(v: str | None) -> str:
538
+ if v is None:
539
+ return ""
540
+ return sys.stdin.read() if v == "-" else Path(v).read_text(encoding="utf-8")
541
+
542
+
543
+ def cmd_review_step(a):
544
+ from . import review_cli as rc
545
+ cfg = cfgmod.load(_config_arg(a))
546
+ try:
547
+ s = rc.Session(cfg, rc.parse_reviewer(a.reviewer, a.same_family))
548
+ if a.action == "next":
549
+ u = next(iter(s.open_units()), None)
550
+ print(f"{u['id']} ({u['reason']})" if u else "nothing left to review")
551
+ elif a.action == "status":
552
+ print(f"{len(s.work['reports'])} report(s), {len(s.work['drafts'])} in progress, "
553
+ f"{len(s.open_units())} unit(s) left to review (release {s.index['release']})")
554
+ for uid, d in s.work["drafts"].items():
555
+ print(f" {uid}: at step '{d['stage']}'")
556
+ elif a.action == "read":
557
+ print(s.read(a.unit))
558
+ elif a.action == "lock":
559
+ s.lock(a.unit, _text_arg(a.text))
560
+ print(f"reading locked; `review show {a.unit}` shows the Lean")
561
+ elif a.action == "show":
562
+ print(s.show(a.unit))
563
+ elif a.action == "decide":
564
+ s.decide(a.unit, a.verdict, _text_arg(a.comparison), _text_arg(a.detail),
565
+ _text_arg(a.witness))
566
+ print(f"verdict recorded; `review author {a.unit}` shows the author's review")
567
+ elif a.action == "author":
568
+ print(s.author(a.unit))
569
+ elif a.action == "submit":
570
+ r = s.submit(a.unit, _text_arg(a.text).strip())
571
+ print(f"report recorded: {r['unit']['id']}, {r['verdict']['value']}; "
572
+ "`review export --out FILE` writes your reports for the maintainer")
573
+ elif a.action == "export":
574
+ print(f"wrote {s.export(Path(a.out))}")
575
+ except (rc.ReviewError, OSError) as e:
576
+ sys.exit(f"machinechecked: {e}")
577
+
578
+
518
579
  def cmd_review(a):
519
580
  import shlex
520
581
  import subprocess
@@ -523,7 +584,7 @@ def cmd_review(a):
523
584
  cfg = cfgmod.load(_config_arg(a))
524
585
  try:
525
586
  steps = pr.plan(cfg, pr.load_reports([Path(f) for f in a.reports]),
526
- a.accept_same_family)
587
+ a.accept_same_family, a.allow_revealed)
527
588
  except pr.PromoteError as e:
528
589
  sys.exit(f"machinechecked: {e}")
529
590
  ok = []
@@ -725,7 +786,41 @@ def main(argv=None):
725
786
  pm.add_argument("--yes", action="store_true", help="write without asking")
726
787
  pm.add_argument("--accept-same-family", action="store_true",
727
788
  help="accept a model reviewer of the author's family, or of unknown family")
789
+ pm.add_argument("--allow-revealed", action="store_true",
790
+ help="accept a report whose reviewer had seen the unit's Lean or author's "
791
+ "review before writing their reading")
728
792
  pm.set_defaults(func=cmd_review)
793
+ # The protocol's steps, for a reviewer without a browser (`review_cli`).
794
+ steps = {
795
+ "next": "the next unit to review",
796
+ "read": "step 1: the paper's statement of a unit",
797
+ "lock": "lock your reading (a file, or - for standard input)",
798
+ "show": "step 2, after lock: the unit's Lean",
799
+ "decide": "record your verdict and comparison",
800
+ "author": "step 3, after decide: the author's review",
801
+ "submit": "record your disagreements with it and finish the report",
802
+ "status": "your progress on this release's queue",
803
+ "export": "write your reports as one file, for the maintainer",
804
+ }
805
+ for name, help_ in steps.items():
806
+ sp = rvs.add_parser(name, help=help_)
807
+ if name not in ("next", "status", "export"):
808
+ sp.add_argument("unit", help="a unit id of the queue, e.g. spec:Foo.thm_bar")
809
+ if name in ("lock", "submit"):
810
+ sp.add_argument("text", help="a file holding your text, or - to read it from standard input")
811
+ if name == "decide":
812
+ sp.add_argument("verdict")
813
+ sp.add_argument("comparison", help="a file holding your comparison, or -")
814
+ sp.add_argument("--detail", help="a file holding what the verdict needs said")
815
+ sp.add_argument("--witness", help="a file holding your note on the witness")
816
+ if name == "export":
817
+ sp.add_argument("--out", required=True)
818
+ sp.add_argument("--as", dest="reviewer", default=os.environ.get("MACHINECHECKED_REVIEWER"),
819
+ help="human:NAME or llm:MODEL (default: $MACHINECHECKED_REVIEWER)")
820
+ sp.add_argument("--same-family", choices=["yes", "no", "unknown"], default="unknown",
821
+ help="for a model: whether it is of the statements' author's family")
822
+ sp.add_argument("-c", "--config", default=None)
823
+ sp.set_defaults(func=cmd_review_step)
729
824
 
730
825
  v = sub.add_parser("validate")
731
826
  v.add_argument("file")
@@ -97,8 +97,13 @@ partial def deepHash (e : Expr) : StateM (Std.HashMap Expr UInt64) UInt64 := do
97
97
  modify (·.insert e h)
98
98
  return h
99
99
 
100
+ /-- The first `n` characters of `s`. (`String.take` returns a slice on some Lean versions and a
101
+ string on others; this is the same on all.) -/
102
+ def prefixOf (s : String) (n : Nat) : String :=
103
+ (s.toList.take n).foldl String.push ""
104
+
100
105
  def hex (h : UInt64) : String :=
101
- let s := String.ofList (Nat.toDigits 16 h.toNat)
106
+ let s := (Nat.toDigits 16 h.toNat).foldl String.push ""
102
107
  "".pushn '0' (16 - s.length) ++ s
103
108
 
104
109
  /-- State of the canonical serialisation: the index of every node already emitted. -/
@@ -160,33 +165,55 @@ def constPrint (ci : ConstantInfo) : MetaM (String × String × Array Name) := d
160
165
 
161
166
  /-! ## Pretty-printing with navigation -/
162
167
 
163
- /-- Flatten tagged code into segments; a segment carries the constant it names when the
164
- innermost subexpression around it is a constant. -/
165
- partial def segments (t : Widget.CodeWithInfos) (ref : Option Name) (acc : Array Json) : Array Json :=
168
+ /-- Flatten tagged code into segments; a segment carries the constant it names (`ref`), or the
169
+ index of the statement's binder it refers to (`var`, a position in `vars`), when the innermost
170
+ subexpression around it is one. -/
171
+ partial def segments (vars : Array FVarId) (t : Widget.CodeWithInfos) (ref : Option (String × Json))
172
+ (acc : Array Json) : Array Json :=
166
173
  match t with
167
174
  | Widget.TaggedText.text s =>
168
175
  match ref with
169
- | some n => acc.push (Json.mkObj [("t", s), ("ref", n.toString)])
176
+ | some (k, v) => acc.push (Json.mkObj [("t", s), (k, v)])
170
177
  | none => acc.push (Json.mkObj [("t", s)])
171
- | Widget.TaggedText.append xs => xs.foldl (fun a x => segments x ref a) acc
178
+ | Widget.TaggedText.append xs => xs.foldl (fun a x => segments vars x ref a) acc
172
179
  | Widget.TaggedText.tag info sub =>
173
180
  let r := match info.info.val.info with
174
- | .ofTermInfo ti => if let .const n _ := ti.expr then some n else none
181
+ | .ofTermInfo ti => match ti.expr with
182
+ | .const n _ => some ("ref", Json.str n.toString)
183
+ | .fvar id => (vars.findIdx? (· == id)).map fun i => ("var", toJson i)
184
+ | _ => none
175
185
  | _ => none
176
- segments sub (r <|> none) acc
186
+ segments vars sub r acc
177
187
 
178
- /-- The pretty-printed expression with navigable constants; plain text if tagging fails, and a
179
- marker if printing fails, so that one large term cannot stop the probe. -/
180
- def ppJson (e : Expr) : MetaM Json := do
188
+ /-- The fields of a pretty-printed expression with navigable constants and binders; plain text
189
+ if tagging fails, and a marker if printing fails, so that one large term cannot stop the probe. -/
190
+ def ppFields (e : Expr) (vars : Array FVarId := #[]) : MetaM (List (String × Json)) := do
181
191
  try
182
- let code ← Widget.ppExprTagged e
192
+ -- The head of every application is tagged too (`pp.tagAppFns`), so that the function a
193
+ -- term applies is a constant the reader can name; the text is the same.
194
+ let code ← withOptions (fun o => o.setBool `pp.tagAppFns true) (Widget.ppExprTagged e)
183
195
  let text := toString (← ppExpr e)
184
- return Json.mkObj [("text", text), ("segments", Json.arr (segments code none #[]))]
196
+ return [("text", Json.str text), ("segments", Json.arr (segments vars code none #[]))]
185
197
  catch _ =>
186
198
  try
187
- return Json.mkObj [("text", toString (← ppExpr e))]
199
+ return [("text", Json.str (toString (← ppExpr e)))]
188
200
  catch err =>
189
- return Json.mkObj [("text", "(not printable)"), ("error", toString (← err.toMessageData.toString))]
201
+ return [("text", Json.str "(not printable)"),
202
+ ("error", Json.str (toString (← err.toMessageData.toString)))]
203
+
204
+ def ppJson (e : Expr) (vars : Array FVarId := #[]) : MetaM Json :=
205
+ return Json.mkObj (← ppFields e vars)
206
+
207
+ /-- The logical shape of a conclusion: a conjunction, disjunction or equivalence as a tree whose
208
+ leaves are pretty-printed propositions. Display only; it changes no record that is assessed. -/
209
+ partial def logicJson (vars : Array FVarId) (e : Expr) : MetaM Json := do
210
+ let op := if e.isAppOfArity ``And 2 then some "and"
211
+ else if e.isAppOfArity ``Or 2 then some "or"
212
+ else if e.isAppOfArity ``Iff 2 then some "iff" else none
213
+ match op with
214
+ | some o => return Json.mkObj [("op", o),
215
+ ("args", Json.arr #[← logicJson vars e.appFn!.appArg!, ← logicJson vars e.appArg!])]
216
+ | none => return Json.mkObj [("leaf", ← ppJson e vars)]
190
217
 
191
218
  /-! ## The inspection representation -/
192
219
 
@@ -200,29 +227,35 @@ def isExistsApp (e : Expr) : Option (Name × Expr) :=
200
227
  /-- Split a proposition into its quantifier prefix and its conclusion. Universal binders are
201
228
  `forall` (data), `hypothesis` (a proposition) or `instance`; existential binders are `exists`.
202
229
  Definitions are not unfolded: the prefix is the one written in the specification. -/
203
- partial def telescope (e : Expr) (acc : Array Json) : MetaM (Array Json × Json) := do
230
+ partial def telescope (e : Expr) (acc : Array Json) (vars : Array FVarId := #[]) :
231
+ MetaM (Array Json × Json) := do
204
232
  match e with
205
233
  | .forallE n t body bi =>
206
234
  let isHyp ← isProp t
207
235
  let role :=
208
236
  if bi.isInstImplicit then "instance" else if isHyp then "hypothesis" else "forall"
209
- let tj ← ppJson t
237
+ let tj ← ppJson t vars
210
238
  withLocalDecl n bi t fun x => do
211
239
  let hyps := (acc.filter fun j => j.getObjValD "role" == Json.str "hypothesis").size
212
240
  let nm := if n.hasMacroScopes || n.isAnonymous then s!"h{hyps + 1}"
213
241
  else n.toString
214
242
  let j := Json.mkObj [("role", role), ("name", nm),
215
243
  ("type", tj), ("binder", binderStr bi)]
216
- telescope (body.instantiate1 x) (acc.push j)
244
+ telescope (body.instantiate1 x) (acc.push j) (vars.push x.fvarId!)
217
245
  | _ =>
218
246
  match isExistsApp e with
219
247
  | some (_, .lam n t body bi) =>
220
- let tj ← ppJson t
248
+ let tj ← ppJson t vars
221
249
  withLocalDecl n bi t fun x => do
222
250
  let j := Json.mkObj [("role", "exists"), ("name", n.eraseMacroScopes.toString),
223
251
  ("type", tj), ("binder", binderStr bi)]
224
- telescope (body.instantiate1 x) (acc.push j)
225
- | _ => return (acc, ← ppJson e)
252
+ telescope (body.instantiate1 x) (acc.push j) (vars.push x.fvarId!)
253
+ | _ =>
254
+ -- The conclusion, with its logical shape when it has one (`logic`, display only).
255
+ let fields ← ppFields e vars
256
+ let logic ← logicJson vars e
257
+ let shaped := (logic.getObjVal? "op").toOption.isSome
258
+ return (acc, Json.mkObj (if shaped then fields ++ [("logic", logic)] else fields))
226
259
  where
227
260
  binderStr : BinderInfo → String
228
261
  | .default => "explicit" | .implicit => "implicit"
@@ -377,7 +410,7 @@ def indexRecords (h : IO.FS.Handle) (roots : Array Name) : MetaM Unit := do
377
410
  emit h (Json.mkObj [("record", "index"), ("name", n.toString), ("kind", k),
378
411
  ("module", mod.toString), ("range", ← rangeJson n),
379
412
  ("doc", match doc with | some d => Json.str d | none => Json.null),
380
- ("type", if ty.length > 4000 then (ty.take 4000).toString ++ " …" else ty)])
413
+ ("type", if ty.length > 4000 then prefixOf ty 4000 ++ " …" else ty)])
381
414
 
382
415
  /-- A theorem of a link: its statement split like a specification, and its axioms. -/
383
416
  def linkRecord (h : IO.FS.Handle) (q : Query) (roots : Array Name) (seen : IO.Ref NameSet)
@@ -439,7 +472,7 @@ def depNode (roots : Array Name) (n : Name) (ci : ConstantInfo) (depth : Nat) :
439
472
  ("module", (moduleOf env n).toString), ("range", ← rangeJson n),
440
473
  ("user_facing", toJson (userFacing n)), ("depth", toJson depth),
441
474
  ("doc", match doc with | some d => Json.str d | none => Json.null),
442
- ("type", if ty.length > 4000 then (ty.take 4000).toString ++ " …" else ty),
475
+ ("type", if ty.length > 4000 then prefixOf ty 4000 ++ " …" else ty),
443
476
  ("statement_uses", inside st), ("value_uses", inside va),
444
477
  ("statement_external", outside st), ("value_external", outside va)]
445
478
 
@@ -24,10 +24,13 @@ from .util import (canonical_json, git_dirty, git_head, link_or_copy, norm_ws, p
24
24
 
25
25
 
26
26
  def tool_version() -> str:
27
- try:
28
- return version("prooflens")
29
- except PackageNotFoundError:
30
- return "0.1.0+src"
27
+ """The installed MachineChecked release (`prooflens` was the package's earlier name)."""
28
+ for dist in ("machinechecked", "prooflens"):
29
+ try:
30
+ return version(dist)
31
+ except PackageNotFoundError:
32
+ pass
33
+ return "0.1.0+src"
31
34
 
32
35
 
33
36
  def project_provenance(cfg: Config) -> dict:
@@ -12,7 +12,11 @@ it now is, or that the acceptance rules cannot count as an independent review:
12
12
  * the reading must have been locked before the verdict, and the verdict recorded before the
13
13
  author's review was shown;
14
14
  * the reviewer must not be an author of the statements, and a model of the same family as the
15
- author (or of unknown family) is refused unless the maintainer accepts it explicitly.
15
+ author (or of unknown family) is refused unless the maintainer accepts it explicitly;
16
+ * the reading must have been blind: a report whose unit's Lean or author's review the reviewer
17
+ had already seen while reviewing another unit (`reading.revealed_by`) is refused unless the
18
+ maintainer accepts it explicitly. The page records this from the work kept in the reviewer's
19
+ browser; it cannot see what they read elsewhere.
16
20
 
17
21
  For each report it accepts, it archives the report (JSON and the protocol's text block) and
18
22
  writes `<!-- spec-review: NAME HASH by=REVIEWER -->` (or `def-review`) after the declaration's
@@ -56,7 +60,8 @@ def load_reports(paths: list[Path]) -> list[dict]:
56
60
  return out
57
61
 
58
62
 
59
- def check_report(r: dict, body: dict, cfg: Config, accept_same_family: bool) -> list[str]:
63
+ def check_report(r: dict, body: dict, cfg: Config, accept_same_family: bool,
64
+ allow_revealed: bool = False) -> list[str]:
60
65
  """Why `r` cannot be promoted against the evidence `body` (empty if it can)."""
61
66
  why = []
62
67
  if r.get("schema") != "prooflens/review-report@1":
@@ -98,6 +103,11 @@ def check_report(r: dict, body: dict, cfg: Config, accept_same_family: bool) ->
98
103
  and not accept_same_family:
99
104
  why.append("a model reviewer of the same family as the author, or of unknown family "
100
105
  "(pass --accept-same-family to accept it)")
106
+ seen = r["reading"].get("revealed_by") or []
107
+ if seen and not allow_revealed:
108
+ what = ", ".join(f"{s.get('what')} of it in {s.get('unit')}" for s in seen)
109
+ why.append(f"the reading was not blind: the reviewer had seen the {what} "
110
+ "(pass --allow-revealed to accept it)")
101
111
  if not re.fullmatch(r"\S+", rid):
102
112
  why.append(f"reviewer id {rid!r} has spaces")
103
113
  return why
@@ -161,7 +171,8 @@ def reports_dir(cfg: Config) -> Path:
161
171
  return first / "reports"
162
172
 
163
173
 
164
- def plan(cfg: Config, reports: list[dict], accept_same_family: bool = False):
174
+ def plan(cfg: Config, reports: list[dict], accept_same_family: bool = False,
175
+ allow_revealed: bool = False):
165
176
  """For each report: (report, current record, reasons it is refused)."""
166
177
  body = latest_record(cfg)["body"]
167
178
  from .pipeline import lean_inputs_digest
@@ -174,7 +185,7 @@ def plan(cfg: Config, reports: list[dict], accept_same_family: bool = False):
174
185
  u = r.get("unit", {})
175
186
  cur = (lean.get("specs" if u.get("kind") == "spec" else "decls", {}) or {}).get(
176
187
  u.get("name"))
177
- out.append((r, cur, check_report(r, body, cfg, accept_same_family)))
188
+ out.append((r, cur, check_report(r, body, cfg, accept_same_family, allow_revealed)))
178
189
  return out
179
190
 
180
191