machinechecked 0.1.24__tar.gz → 0.1.25__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 (114) hide show
  1. {machinechecked-0.1.24 → machinechecked-0.1.25}/PKG-INFO +1 -1
  2. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/machinechecked.egg-info/PKG-INFO +1 -1
  3. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/machinechecked.egg-info/SOURCES.txt +4 -2
  4. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/assess.py +128 -45
  5. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/audit.py +17 -6
  6. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/cli.py +11 -3
  7. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/config.py +2 -1
  8. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/content.py +5 -4
  9. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/ProofLensProbe.lean +496 -73
  10. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/deps.py +5 -3
  11. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/estimates.py +2 -1
  12. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/export.py +20 -7
  13. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/facts.py +2 -1
  14. machinechecked-0.1.25/engine/python/prooflens/layout.py +154 -0
  15. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/moddocs.py +2 -1
  16. machinechecked-0.1.25/engine/python/prooflens/notation_plan.py +186 -0
  17. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/numbering.py +14 -8
  18. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/probe.py +2 -1
  19. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/proof_facts.py +2 -1
  20. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/rebound.py +11 -4
  21. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/review_citations.py +148 -12
  22. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/simple.py +13 -17
  23. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/source_names.py +27 -9
  24. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/source_regions.py +196 -18
  25. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/targets.py +2 -1
  26. machinechecked-0.1.24/engine/python/prooflens/web/assets/index-CiqXTIbk.css → machinechecked-0.1.25/engine/python/prooflens/web/assets/index-AZS58fGU.css +1 -1
  27. machinechecked-0.1.25/engine/python/prooflens/web/assets/index-D9PVfZb1.js +289 -0
  28. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/index.html +2 -2
  29. {machinechecked-0.1.24 → machinechecked-0.1.25}/pyproject.toml +1 -1
  30. machinechecked-0.1.24/engine/python/prooflens/web/assets/index-BecdhdKZ.js +0 -289
  31. {machinechecked-0.1.24 → machinechecked-0.1.25}/LICENSE +0 -0
  32. {machinechecked-0.1.24 → machinechecked-0.1.25}/README.md +0 -0
  33. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/machinechecked.egg-info/dependency_links.txt +0 -0
  34. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/machinechecked.egg-info/entry_points.txt +0 -0
  35. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/machinechecked.egg-info/requires.txt +0 -0
  36. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/machinechecked.egg-info/top_level.txt +0 -0
  37. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/__init__.py +0 -0
  38. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/__main__.py +0 -0
  39. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/authoring.py +0 -0
  40. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/bundle.py +0 -0
  41. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/cache.py +0 -0
  42. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/changes.py +0 -0
  43. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/compare.py +0 -0
  44. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/composition.py +0 -0
  45. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/connections.py +0 -0
  46. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/prooflens.sty +0 -0
  47. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/schema/evidence.schema.json +0 -0
  48. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/schema/inventory.schema.json +0 -0
  49. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/schema/manifest-claim.schema.json +0 -0
  50. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/schema/manifest-index.schema.json +0 -0
  51. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/schema/published-work.schema.json +0 -0
  52. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/semantic.json +0 -0
  53. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/data/statuses.json +0 -0
  54. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/dependencies.py +0 -0
  55. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/evidence.py +0 -0
  56. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/excerpt.py +0 -0
  57. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/expressions.py +0 -0
  58. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/formalization.py +0 -0
  59. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/impact.py +0 -0
  60. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/manifest.py +0 -0
  61. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/objects.py +0 -0
  62. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/paper.py +0 -0
  63. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/pdfclaims.py +0 -0
  64. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/pipeline.py +0 -0
  65. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/promote.py +0 -0
  66. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/published.py +0 -0
  67. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/published_work.py +0 -0
  68. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/readable.py +0 -0
  69. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/reopen.py +0 -0
  70. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/repin.py +0 -0
  71. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/replay.py +0 -0
  72. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/requirements.py +0 -0
  73. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/retire.py +0 -0
  74. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/retrieval.py +0 -0
  75. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/review_cli.py +0 -0
  76. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/review_queue.py +0 -0
  77. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/review_sources.py +0 -0
  78. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/reviews.py +0 -0
  79. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/schemas.py +0 -0
  80. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/semantic.py +0 -0
  81. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/server.py +0 -0
  82. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/sources.py +0 -0
  83. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/status.py +0 -0
  84. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/steps.py +0 -0
  85. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/symbols.py +0 -0
  86. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/tex.py +0 -0
  87. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/uses.py +0 -0
  88. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/util.py +0 -0
  89. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/version_map.py +0 -0
  90. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/versions.py +0 -0
  91. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  92. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  93. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  94. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  95. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  96. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  97. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  98. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  99. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  100. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  101. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  102. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  103. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  104. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  105. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  106. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  107. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  108. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  109. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  110. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg +0 -0
  111. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs +0 -0
  112. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/web/theme.css +0 -0
  113. {machinechecked-0.1.24 → machinechecked-0.1.25}/engine/python/prooflens/workspace.py +0 -0
  114. {machinechecked-0.1.24 → machinechecked-0.1.25}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machinechecked
3
- Version: 0.1.24
3
+ Version: 0.1.25
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.24
3
+ Version: 0.1.25
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
@@ -31,8 +31,10 @@ engine/python/prooflens/expressions.py
31
31
  engine/python/prooflens/facts.py
32
32
  engine/python/prooflens/formalization.py
33
33
  engine/python/prooflens/impact.py
34
+ engine/python/prooflens/layout.py
34
35
  engine/python/prooflens/manifest.py
35
36
  engine/python/prooflens/moddocs.py
37
+ engine/python/prooflens/notation_plan.py
36
38
  engine/python/prooflens/numbering.py
37
39
  engine/python/prooflens/objects.py
38
40
  engine/python/prooflens/paper.py
@@ -104,6 +106,6 @@ engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2
104
106
  engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2
105
107
  engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2
106
108
  engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg
107
- engine/python/prooflens/web/assets/index-BecdhdKZ.js
108
- engine/python/prooflens/web/assets/index-CiqXTIbk.css
109
+ engine/python/prooflens/web/assets/index-AZS58fGU.css
110
+ engine/python/prooflens/web/assets/index-D9PVfZb1.js
109
111
  engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs
@@ -233,15 +233,51 @@ def _rule(c: str, o: dict) -> tuple[str, str | None]:
233
233
  return "applies", TOTALISED[c]
234
234
 
235
235
 
236
+ def _binder_names(srec: dict) -> dict[str, str]:
237
+ """The name the statement record gives each of its binders, by the binder's identity: those
238
+ that open it (an unnamed hypothesis is `h1`, `h2`, …) and those inside its tree."""
239
+ out: dict[str, str] = {}
240
+
241
+ def walk(n):
242
+ if not isinstance(n, dict):
243
+ return
244
+ if n.get("id") is not None and n.get("name"):
245
+ out.setdefault(n["id"], n["name"])
246
+ walk(n.get("logic"))
247
+ for a in n.get("args") or []:
248
+ walk(a)
249
+ for b in srec.get("binders") or []:
250
+ if b.get("id") is not None and b.get("name"):
251
+ out[b["id"]] = b["name"]
252
+ walk(srec.get("tree"))
253
+ return out
254
+
255
+
256
+ def _subterms(o: dict, names: dict[str, str]) -> list[dict]:
257
+ """The sub-term at each position of one recorded application (`at`, and `text` when the
258
+ probe printed it), with the binder or hypothesis around it (`within`), named as the
259
+ statement names it."""
260
+ out = []
261
+ for s in o.get("subterms") or []:
262
+ rec = {"at": s.get("at"), "text": s.get("text")}
263
+ w = s.get("within")
264
+ if isinstance(w, dict):
265
+ rec["within"] = {**w, "name": names.get(w.get("id")) or w.get("name")}
266
+ out.append(rec)
267
+ return out
268
+
269
+
236
270
  def occurrences(srec: dict, c: str) -> list[dict] | None:
237
271
  """The applications of the totalised operation `c` that the probe read in a statement, each
238
272
  with its type (`type`, its head constant `type_head`), the structure on it that decides the
239
- rule (`structure`), the state of the rule there and the rule itself, and the positions of
240
- the application in the proposition (`at`). None for an operation the probe does not read
241
- by type, and for a record from before it read them."""
273
+ rule (`structure`), the state of the rule there and the rule itself, the positions of the
274
+ application in the proposition (`at`), and the sub-term at each with the binder or
275
+ hypothesis around it (`subterms`, when the probe printed them). None for an operation the
276
+ probe does not read by type, and for a record from before it read them."""
242
277
  ops = srec.get("order_ops")
243
278
  if not isinstance(ops, dict) or c not in READ_BY_TYPE:
244
279
  return None
280
+ names = _binder_names(srec)
245
281
  out = []
246
282
  for o in _occurrences(c, ops):
247
283
  state, rule = _rule(c, o)
@@ -250,6 +286,8 @@ def occurrences(srec: dict, c: str) -> list[dict] | None:
250
286
  rec = {"operation": c, "type": o.get("carrier") or None,
251
287
  "type_head": o.get("carrier_head") or None, "structure": structure,
252
288
  "state": state, "rule": rule, "at": list(o.get("at") or [])}
289
+ if o.get("subterms"):
290
+ rec["subterms"] = _subterms(o, names)
253
291
  if state == "applies" and o.get("conditions"):
254
292
  conds = [{k: d[k] for k in ("condition", "state", "by", "premise", "statement")
255
293
  if k in d} for d in o["conditions"]]
@@ -1046,8 +1084,10 @@ class Assessor:
1046
1084
  (with the statement's as `statement_fingerprint`), and its id ends in `@` and that
1047
1085
  position. A dismissal naming `at` and an application's fingerprint dismisses that
1048
1086
  application only: the one at `at` when its fingerprint matches, otherwise the one
1049
- application with that fingerprint (it moved), and it lapses when the application at `at`
1050
- changes. A dismissal without `at` (the form before applications were read one by one)
1087
+ application with that fingerprint (it moved). It lapses when the application at `at`
1088
+ changes and it follows no application, and the warning at `at` is then marked
1089
+ `dismissal_stale` unless a dismissal of its own matches it. A dismissal without `at`
1090
+ (the form before applications were read one by one)
1051
1091
  dismisses every warning of its operation in the statement while the statement's
1052
1092
  fingerprint matches, and says so (`dismissed.form`: `statement`)."""
1053
1093
  fp = srec.get("fingerprint")
@@ -1063,7 +1103,11 @@ class Assessor:
1063
1103
  if d["at"] in same:
1064
1104
  targets[(d["trigger"], d["at"])] = ("dismissed", d)
1065
1105
  elif len(same) == 1:
1066
- targets.setdefault((d["trigger"], same[0]), ("dismissed", d))
1106
+ # It follows its application, which moved there: a lapsed dismissal given at that
1107
+ # position does not override it, and its own old position is not marked stale.
1108
+ if targets.get((d["trigger"], same[0]), ("stale",))[0] == "stale":
1109
+ targets[(d["trigger"], same[0])] = ("dismissed", d)
1110
+ continue
1067
1111
  if d["at"] not in same and any(a == d["at"] for a, _ in here):
1068
1112
  targets.setdefault((d["trigger"], d["at"]), ("stale", d))
1069
1113
  for i in items:
@@ -1094,27 +1138,32 @@ class Assessor:
1094
1138
  f["dismissal_stale"] = True
1095
1139
 
1096
1140
  def add_warning(self, code, subj, name, rec, message, trigger, fingerprint=None,
1097
- legacy_only=False, **extra):
1141
+ legacy_only=False, reported=(), **extra):
1098
1142
  """A warning, dismissed by a dismissal of its code, subject (`name`) and trigger whose
1099
- fingerprint is the subject's current one (`rec`'s), and marked `dismissal_stale` when
1100
- such a dismissal's fingerprint is another. The finding records `fingerprint` when given
1101
- (what a dismissal of it records) and `rec`'s otherwise. With `legacy_only`, only
1102
- dismissals without `at` are considered here, and one that applies is marked as naming
1103
- the whole statement (`form`: `statement`)."""
1143
+ fingerprint is the subject's current one (`rec`'s). A warning no dismissal matches is
1144
+ marked `dismissal_stale` when such a dismissal has another fingerprint that is not in
1145
+ `reported`, the fingerprints of the other warnings of this code, subject and trigger
1146
+ that the assessment reports: a dismissal of one of those is that warning's, not a
1147
+ lapsed dismissal of this one. The finding records `fingerprint` when given (what a
1148
+ dismissal of it records) and `rec`'s otherwise. With `legacy_only`, only dismissals
1149
+ without `at` are considered here, and one that applies is marked as naming the whole
1150
+ statement (`form`: `statement`)."""
1104
1151
  fp = rec.get("fingerprint")
1105
1152
  f = _finding("warning", code, subj, message, trigger=trigger,
1106
1153
  fingerprint=fingerprint or fp,
1107
1154
  signal="low" if trigger in LOW_SIGNAL else "normal", **extra)
1108
- for d in self.dismissals:
1109
- if d.get("code") == code and d.get("subject") == name and d.get("trigger") == trigger:
1110
- if "at" in d and (legacy_only or code == "totalised"):
1111
- continue
1112
- if d.get("fingerprint") == fp:
1113
- f["dismissed"] = {"rationale": d.get("rationale", ""), "by": d.get("by", "")}
1114
- if legacy_only:
1115
- f["dismissed"]["form"] = "statement"
1116
- else:
1117
- f["dismissal_stale"] = True
1155
+ same = [d for d in self.dismissals
1156
+ if d.get("code") == code and d.get("subject") == name
1157
+ and d.get("trigger") == trigger
1158
+ and not ("at" in d and (legacy_only or code == "totalised"))]
1159
+ hits = [d for d in same if d.get("fingerprint") == fp]
1160
+ if hits:
1161
+ f["dismissed"] = {"rationale": hits[-1].get("rationale", ""),
1162
+ "by": hits[-1].get("by", "")}
1163
+ if legacy_only:
1164
+ f["dismissed"]["form"] = "statement"
1165
+ elif any(d.get("fingerprint") not in reported for d in same):
1166
+ f["dismissal_stale"] = True
1118
1167
  self.findings.append(f)
1119
1168
 
1120
1169
  # -- claims ---------------------------------------------------------------------------
@@ -1342,39 +1391,46 @@ class Assessor:
1342
1391
  plain = [d for d in docs if d.get("kind", "none") == "none"]
1343
1392
  found = {id(d) for d in plain} - {id(d) for d in undeclared_doc_names(plain, lean_root)}
1344
1393
  docs = [d for d in docs if id(d) not in found]
1345
- for d in docs:
1346
- self.add_warning("module-doc-name", d["module"], d["module"],
1347
- {"fingerprint": stale_doc_fingerprint(d)},
1348
- stale_doc_message(d), d["name"])
1394
+ # A name under two headings of one docstring is two warnings with two fingerprints; a
1395
+ # dismissal of one is not a lapsed dismissal of the other.
1396
+ fps = [stale_doc_fingerprint(d) for d in docs]
1397
+ for d, fp in zip(docs, fps):
1398
+ reported = {g for e, g in zip(docs, fps)
1399
+ if (e["module"], e["name"]) == (d["module"], d["name"])}
1400
+ self.add_warning("module-doc-name", d["module"], d["module"], {"fingerprint": fp},
1401
+ stale_doc_message(d), d["name"], reported=reported)
1349
1402
  self.findings[-1].update(file=d["file"], line=d["line"])
1350
1403
 
1351
1404
  def review_citation_checks(self):
1352
1405
  """A warning for each name or path cited in backticks by the review files that nothing
1353
- resolves (`review_citations.py`), with its file and line; a violation when the
1354
- configuration says `review_citations_strict`. The warning never changes a status, and
1355
- an auditor can dismiss it (code `review-citation`, the review file as subject, the
1356
- token as trigger)."""
1406
+ resolves (`review_citations.py`), one for each block of review text that cites it,
1407
+ with its file and lines; a violation when the configuration says
1408
+ `review_citations_strict`. The warning never changes a status, and an auditor can
1409
+ dismiss it (code `review-citation`, the review file as subject, the token as trigger,
1410
+ the block as `at`); a dismissal covers its block only (`review_citations.dismiss`)."""
1357
1411
  from . import review_citations as rc
1358
1412
  files = getattr(self.cfg, "reviews", None)
1359
1413
  root = getattr(self.cfg, "root", None)
1360
1414
  if not files or root is None:
1361
1415
  return
1362
- cites = rc.citations(files, root, getattr(self.cfg, "review_citations_ignore", None))
1416
+ ignore = getattr(self.cfg, "review_citations_ignore", None)
1417
+ cites = rc.citations(files, root, ignore)
1363
1418
  lean_root = getattr(self.cfg, "lean_root", None) or root
1364
1419
  bases = [root] + ([lean_root] if not lean_root.is_relative_to(root) else [])
1365
- seen = set()
1366
- for c in rc.unresolved(cites, self.lean.get("names"), bases):
1367
- if (c["file"], c["token"]) in seen:
1368
- continue
1369
- seen.add((c["file"], c["token"]))
1370
- if getattr(self.cfg, "review_citations_strict", False):
1371
- self.findings.append(_finding("violation", "review-citation", c["file"],
1372
- rc.message(c), trigger=c["token"],
1373
- file=c["file"], line=c["line"]))
1374
- else:
1375
- self.add_warning("review-citation", c["file"], c["file"],
1376
- {"fingerprint": rc.fingerprint(c)}, rc.message(c), c["token"])
1377
- self.findings[-1].update(file=c["file"], line=c["line"])
1420
+ strict = getattr(self.cfg, "review_citations_strict", False)
1421
+ warnings = []
1422
+ for w in rc.blocks(rc.unresolved(cites, self.lean.get("names"), bases)):
1423
+ f = _finding("violation" if strict else "warning", "review-citation", w["file"],
1424
+ rc.message(w) + rc.replaced_default(w["token"], ignore),
1425
+ trigger=w["token"], file=w["file"], line=w["line"],
1426
+ lines=w["lines"], at=w["at"])
1427
+ f["id"] += "@" + w["at"]
1428
+ if not strict:
1429
+ f.update(fingerprint=w["fingerprint"],
1430
+ signal="low" if w["token"] in LOW_SIGNAL else "normal")
1431
+ warnings.append(f)
1432
+ self.findings.append(f)
1433
+ rc.dismiss(warnings, self.dismissals)
1378
1434
 
1379
1435
  # -- gates ----------------------------------------------------------------------------
1380
1436
 
@@ -1501,8 +1557,11 @@ class Assessor:
1501
1557
  f"the source region at {c['location']} uses macros defined outside "
1502
1558
  f"it ({where}); a change to those definitions does not change the "
1503
1559
  "pin. Pin the definitions whose values are part of the claim "
1504
- "(machinechecked inventory rebound --macro NAME), and list the "
1560
+ "(machinechecked inventory rebound --macro NAME). Listing a macro "
1561
+ "as notation reopens the readings of the passages that use it "
1562
+ "(machinechecked inventory notation --add NAME lists them); list the "
1505
1563
  "notation in notation_macros", names)
1564
+ self.macros_pinned_elsewhere(c, region.get("pinned_elsewhere") or [])
1506
1565
  continue
1507
1566
  a = match_anchor(c, anchors)
1508
1567
  if a is None:
@@ -1538,6 +1597,30 @@ class Assessor:
1538
1597
  if a.get("suggested"):
1539
1598
  self.findings[-1]["suggested"] = a["suggested"]
1540
1599
 
1600
+ def macros_pinned_elsewhere(self, claim: dict, macros: list[dict]):
1601
+ """One warning per passage that uses macros whose definitions another claim's pin holds
1602
+ (`source_regions.pinned_elsewhere`): a change to such a definition fails that claim's
1603
+ source check, and reopens no reading of this passage. Its trigger is the set of macros;
1604
+ its fingerprint covers the passage's pin and the digests of the definitions, so a
1605
+ dismissal lapses when either changes."""
1606
+ if not macros:
1607
+ return
1608
+ import hashlib
1609
+ names = " ".join(m["macro"] for m in macros)
1610
+ where = "; ".join(f"{m['macro']} at {', '.join(m['defined'])}, pinned by "
1611
+ f"{', '.join(m['claims'])}" for m in macros)
1612
+ fingerprint = hashlib.sha256("".join(
1613
+ [f"passage {claim.get('source_sha256')}\n"]
1614
+ + [f"macro {m['macro']} {m['sha256']}\n" for m in macros]).encode()).hexdigest()
1615
+ self.add_warning(
1616
+ "source-macro-pinned-elsewhere", claim["id"], claim["id"],
1617
+ {"fingerprint": fingerprint},
1618
+ f"the source region at {claim['location']} uses macros whose definitions another "
1619
+ f"claim pins ({where}); a change to those definitions fails that claim's source "
1620
+ "check but reopens no reading of this passage. Pin them in this claim too "
1621
+ "(machinechecked inventory rebound --macro NAME) for its readings to depend on "
1622
+ "them", names)
1623
+
1541
1624
 
1542
1625
  def unpinned_passages(inventory: dict, tex: dict | None) -> dict[str, str]:
1543
1626
  """The claims whose passage in the manuscript no longer matches their pin, each with the
@@ -125,8 +125,9 @@ def source_path(lean_root: Path, module: str | None) -> str | None:
125
125
  project rather than in a dependency."""
126
126
  if not module or not re.fullmatch(r"[\w.']+", module):
127
127
  return None
128
+ from .layout import module_file
128
129
  sr = source_root(lean_root)
129
- rel = module.replace(".", "/") + ".lean"
130
+ rel = module_file(lean_root, module)
130
131
  if sr is None or not (lean_root / rel).is_file():
131
132
  return None
132
133
  return sr[1] + rel
@@ -136,13 +137,23 @@ def source_info(lean_root: Path | None, roots: list[str], repository: str | None
136
137
  private: bool = False) -> dict:
137
138
  """Where the reader's Lean source links point: the GitHub repository (given, else the
138
139
  project's `origin` remote), whether it is private (the reader then does not show its name;
139
- the links still name it), the project's path inside it, and the top-level module names whose
140
- files are the project's own."""
140
+ the links still name it), the path inside it of the folder that holds the modules
141
+ (`source_prefix`: the project's path joined with its libraries' source folder), and the
142
+ top-level module names whose files are the project's own and in that folder. When the
143
+ libraries keep their sources in different folders, the folder most of them use is given,
144
+ and the roots in the others get no source link."""
145
+ from collections import Counter
146
+ from .layout import library_dir
141
147
  if lean_root is None:
142
148
  return {}
143
149
  sr = source_root(lean_root)
150
+ dirs = {r: library_dir(lean_root, r.split(".")[0]) for r in roots}
151
+ present = {r: d for r, d in dirs.items()
152
+ if (lean_root / d / r).is_dir() or (lean_root / d / f"{r}.lean").is_file()}
153
+ counts = Counter(present.values())
154
+ common = min(counts, key=lambda d: (-counts[d], d != ".", d)) if counts else "."
155
+ prefix = None if sr is None else sr[1] + ("" if common == "." else common + "/")
144
156
  return {"repository": repository or github_repository(lean_root),
145
157
  "repository_private": bool(private),
146
- "source_prefix": sr[1] if sr else None,
147
- "source_roots": sorted(r for r in roots if (lean_root / r).is_dir()
148
- or (lean_root / f"{r}.lean").is_file())}
158
+ "source_prefix": prefix,
159
+ "source_roots": sorted(r for r, d in present.items() if d == common)}
@@ -931,7 +931,7 @@ NO_MODULES = ("--fix-modules: only a project with a machinechecked.toml lists `m
931
931
  "zero configuration reads every built module")
932
932
 
933
933
 
934
- FINDING_KEYS = ("id", "tier", "code", "subject", "message", "trigger", "file", "line",
934
+ FINDING_KEYS = ("id", "tier", "code", "subject", "message", "trigger", "file", "line", "lines",
935
935
  "fingerprint", "at", "dismissed", "dismissal_stale", "resolved", "occurrences",
936
936
  "occurrences_complete")
937
937
 
@@ -1167,6 +1167,13 @@ def _build_full(a, site: str | None = None, refresh: bool = False, fix_modules:
1167
1167
  print(f"note: {len(whole)} totalisation warning(s) are dismissed by a dismissal of the "
1168
1168
  "operation in the whole statement, which holds until the statement changes; a "
1169
1169
  "dismissal with the warning's `at` and `fingerprint` names one application")
1170
+ by_file = [f for f in details if f["code"] == "review-citation"
1171
+ and (f.get("dismissed") or {}).get("form") == "file"]
1172
+ if by_file:
1173
+ print(f"note: {len(by_file)} review-citation warning(s) are dismissed by a dismissal "
1174
+ "without `at`, which covers the first block of review text citing the token in "
1175
+ "its file and no other; a dismissal with the warning's `at` and `fingerprint` "
1176
+ "names one block")
1170
1177
  rg = _replay_guard(cfg, res["evidence"])
1171
1178
  if rg and rg["message"]:
1172
1179
  print(f"note: independent replay: {rg['message']}")
@@ -1789,7 +1796,7 @@ def cmd_review_promote(a):
1789
1796
 
1790
1797
 
1791
1798
  INVENTORY = {"regions": "source_regions", "repin": "repin", "rebound": "rebound",
1792
- "retire": "retire"}
1799
+ "retire": "retire", "notation": "notation_plan"}
1793
1800
 
1794
1801
 
1795
1802
  def cmd_inventory(a):
@@ -2184,7 +2191,8 @@ def _add_inventory(sub) -> None:
2184
2191
  description="regions: hash line pins as regions at the revision they were pinned at "
2185
2192
  "(docs/SOURCE_REGIONS.md); rebound: change the bounds of claims' regions there; repin: "
2186
2193
  "move the claims to a new revision of the paper; retire: remove the readings review markers "
2187
- "record of passages that no longer use their declaration. "
2194
+ "record of passages that no longer use their declaration; notation: report the readings "
2195
+ "a change to notation_macros would reopen (it writes nothing). "
2188
2196
  "Each prints a plan, and changes files only with --write; pass --help after the action "
2189
2197
  "for its options.")
2190
2198
  iv.add_argument("action", choices=sorted(INVENTORY))
@@ -81,7 +81,8 @@ class Config:
81
81
  repository: str | None = None # "owner/repo" of the Lean source, if not the git remote
82
82
  repository_private: bool = False # the reader does not show the repository's name
83
83
  # Citations in review text (`review_citations.py`): patterns of backticked tokens that are
84
- # notation, not names (None: the default), and whether an unresolved one is a violation.
84
+ # notation, not names, which replace the default ones (None: the defaults,
85
+ # `review_citations.DEFAULT_IGNORE`), and whether an unresolved one is a violation.
85
86
  review_citations_ignore: list[str] | None = None
86
87
  review_citations_strict: bool = False
87
88
  # Reviewers whose review markers count without review text before them (`assess.py`).
@@ -75,14 +75,14 @@ def claim_declarations(c: dict, defs: bool = True) -> set[str]:
75
75
 
76
76
 
77
77
  def several(papers, tex: dict, inv_claims: list[dict], auxes: dict, full: list[dict],
78
- blocks: list[dict], fy, retrieval, notes: list[str]) -> dict:
78
+ blocks: list[dict], fy, retrieval, notes: list[str], root=None) -> dict:
79
79
  """The Lean's references to the numbers of a configuration's several papers: each is
80
80
  attributed to one paper (`numbering.attribute`) and checked against that paper's numbering;
81
81
  one that cannot be attributed stays unchecked, with the reason."""
82
82
  from . import formalization as fz
83
83
  from . import numbering as nb
84
84
  from .simple import claim_text
85
- refs = nb.find_references(full, blocks)
85
+ refs = nb.find_references(full, blocks, root=root)
86
86
  def named(pid, defs):
87
87
  return set().union(set(), *(claim_declarations(c, defs) for c in inv_claims
88
88
  if c.get("paper") == pid))
@@ -160,14 +160,15 @@ def build(cfg, tex: dict, inv_claims: list[dict], auxes: dict, lake: str = "lake
160
160
  paper = cfg.papers[0]
161
161
  claims, inv = paper_inventory(paper.id, tex, inv_claims, auxes)
162
162
  foreign = fz.foreign_roots(fy, paper.title) if fy and "error" not in fy else set()
163
- numbering = nb.analyse(full, claims, inv, blocks, foreign, retrieval, claim_text)
163
+ numbering = nb.analyse(full, claims, inv, blocks, foreign, retrieval, claim_text,
164
+ root=root)
164
165
  note = nb.drift_note(numbering["pattern"], numbering["references"],
165
166
  suggestions=False)
166
167
  if note:
167
168
  notes.append(note)
168
169
  else:
169
170
  numbering = several(cfg.papers, tex, inv_claims, auxes, full, blocks, fy, retrieval,
170
- notes)
171
+ notes, root)
171
172
  return {"schema": SCHEMA, "retrieval": retrieval.export(), "numbering": numbering,
172
173
  "notes": notes, "modules": {"indexed": len(built) - len(failed),
173
174
  "failed": len(failed), "unbuilt": len(unbuilt)}}