machinechecked 0.1.18__tar.gz → 0.1.19__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.
- {machinechecked-0.1.18 → machinechecked-0.1.19}/PKG-INFO +1 -1
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/machinechecked.egg-info/PKG-INFO +1 -1
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/machinechecked.egg-info/SOURCES.txt +5 -2
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/assess.py +369 -35
- machinechecked-0.1.19/engine/python/prooflens/changes.py +924 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/cli.py +113 -4
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/compare.py +21 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/config.py +83 -3
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/data/ProofLensProbe.lean +84 -14
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/data/schema/inventory.schema.json +18 -1
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/data/schema/manifest-index.schema.json +4 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/export.py +11 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/manifest.py +5 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/paper.py +34 -5
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/pipeline.py +52 -11
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/probe.py +106 -8
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/promote.py +10 -2
- machinechecked-0.1.19/engine/python/prooflens/rebound.py +312 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/repin.py +319 -40
- machinechecked-0.1.19/engine/python/prooflens/review_citations.py +141 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/review_sources.py +53 -8
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/simple.py +20 -4
- machinechecked-0.1.19/engine/python/prooflens/source_regions.py +899 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/steps.py +4 -2
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/targets.py +18 -0
- machinechecked-0.1.19/engine/python/prooflens/web/assets/index-CwFwjzOl.js +279 -0
- machinechecked-0.1.18/engine/python/prooflens/web/assets/index-Cf1MUHrg.css → machinechecked-0.1.19/engine/python/prooflens/web/assets/index-DSx7JAZ4.css +1 -1
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/index.html +2 -2
- {machinechecked-0.1.18 → machinechecked-0.1.19}/pyproject.toml +1 -1
- machinechecked-0.1.18/engine/python/prooflens/source_regions.py +0 -312
- machinechecked-0.1.18/engine/python/prooflens/web/assets/index-Buyx92N7.js +0 -279
- {machinechecked-0.1.18 → machinechecked-0.1.19}/LICENSE +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/README.md +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/machinechecked.egg-info/dependency_links.txt +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/machinechecked.egg-info/entry_points.txt +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/machinechecked.egg-info/requires.txt +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/machinechecked.egg-info/top_level.txt +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/__init__.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/__main__.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/audit.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/authoring.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/bundle.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/cache.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/composition.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/data/prooflens.sty +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/data/schema/evidence.schema.json +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/data/schema/manifest-claim.schema.json +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/data/schema/published-work.schema.json +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/data/statuses.json +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/deps.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/estimates.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/evidence.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/excerpt.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/facts.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/formalization.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/moddocs.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/numbering.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/pdfclaims.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/proof_facts.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/published.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/published_work.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/replay.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/requirements.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/retrieval.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/review_cli.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/review_queue.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/reviews.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/schemas.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/server.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/sources.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/status.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/symbols.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/tex.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/uses.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/util.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/versions.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/web/theme.css +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/prooflens/workspace.py +0 -0
- {machinechecked-0.1.18 → machinechecked-0.1.19}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: machinechecked
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.19
|
|
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
|
{machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/machinechecked.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: machinechecked
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.19
|
|
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
|
{machinechecked-0.1.18 → machinechecked-0.1.19}/engine/python/machinechecked.egg-info/SOURCES.txt
RENAMED
|
@@ -14,6 +14,7 @@ engine/python/prooflens/audit.py
|
|
|
14
14
|
engine/python/prooflens/authoring.py
|
|
15
15
|
engine/python/prooflens/bundle.py
|
|
16
16
|
engine/python/prooflens/cache.py
|
|
17
|
+
engine/python/prooflens/changes.py
|
|
17
18
|
engine/python/prooflens/cli.py
|
|
18
19
|
engine/python/prooflens/compare.py
|
|
19
20
|
engine/python/prooflens/composition.py
|
|
@@ -36,10 +37,12 @@ engine/python/prooflens/promote.py
|
|
|
36
37
|
engine/python/prooflens/proof_facts.py
|
|
37
38
|
engine/python/prooflens/published.py
|
|
38
39
|
engine/python/prooflens/published_work.py
|
|
40
|
+
engine/python/prooflens/rebound.py
|
|
39
41
|
engine/python/prooflens/repin.py
|
|
40
42
|
engine/python/prooflens/replay.py
|
|
41
43
|
engine/python/prooflens/requirements.py
|
|
42
44
|
engine/python/prooflens/retrieval.py
|
|
45
|
+
engine/python/prooflens/review_citations.py
|
|
43
46
|
engine/python/prooflens/review_cli.py
|
|
44
47
|
engine/python/prooflens/review_queue.py
|
|
45
48
|
engine/python/prooflens/review_sources.py
|
|
@@ -88,6 +91,6 @@ engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2
|
|
|
88
91
|
engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2
|
|
89
92
|
engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2
|
|
90
93
|
engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg
|
|
91
|
-
engine/python/prooflens/web/assets/index-
|
|
92
|
-
engine/python/prooflens/web/assets/index-
|
|
94
|
+
engine/python/prooflens/web/assets/index-CwFwjzOl.js
|
|
95
|
+
engine/python/prooflens/web/assets/index-DSx7JAZ4.css
|
|
93
96
|
engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs
|
|
@@ -27,7 +27,7 @@ from .status import fields
|
|
|
27
27
|
|
|
28
28
|
from . import review_sources
|
|
29
29
|
from .reviews import Review, history
|
|
30
|
-
from .source_regions import
|
|
30
|
+
from .source_regions import SCHEMES as SOURCE_SCHEMES, changed_line, matches as source_matches
|
|
31
31
|
|
|
32
32
|
OUT_OF_SCOPE = {"expository", "literature", "empirical", "proof-step", "part-of", "duplicate"}
|
|
33
33
|
|
|
@@ -57,8 +57,55 @@ TOTALISED = {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
# Totalised operations so common in analysis that a warning about them is rarely informative
|
|
61
|
-
|
|
60
|
+
# Totalised operations so common in analysis that a warning about them is rarely informative,
|
|
61
|
+
# and propositions whose only hypotheses are instances of inhabited classes.
|
|
62
|
+
LOW_SIGNAL = {"HDiv.hDiv", "Inv.inv", "witness-instances"}
|
|
63
|
+
|
|
64
|
+
# Type classes whose instances exist at a canonical type (ℝ, Unit, `Fin 1`, a Dirac measure)
|
|
65
|
+
# whenever their arguments are free variables of the proposition. A proposition whose only
|
|
66
|
+
# hypotheses are such instances gets a low-signal warning instead of a witness obligation. A
|
|
67
|
+
# project sets its own list with `inhabited_classes` in `machinechecked.toml` (`[]` restores
|
|
68
|
+
# the obligation everywhere). `Fact`, `Subsingleton`, `Nontrivial` and the project's own
|
|
69
|
+
# classes are deliberately absent: their instances need not exist, or not together.
|
|
70
|
+
INHABITED_CLASSES = [
|
|
71
|
+
"Inhabited", "Nonempty", "DecidableEq", "Fintype", "Finite", "Countable", "Encodable",
|
|
72
|
+
"NeZero",
|
|
73
|
+
"Preorder", "PartialOrder", "LinearOrder", "Lattice",
|
|
74
|
+
"AddMonoid", "AddCommMonoid", "AddGroup", "AddCommGroup", "Monoid", "CommMonoid", "Group",
|
|
75
|
+
"CommGroup", "Semiring", "CommSemiring", "Ring", "CommRing", "Field", "Module", "Algebra",
|
|
76
|
+
"TopologicalSpace", "UniformSpace", "PseudoMetricSpace", "MetricSpace",
|
|
77
|
+
"PseudoEMetricSpace", "EMetricSpace", "T2Space", "CompleteSpace", "CompactSpace",
|
|
78
|
+
"LocallyCompactSpace", "ProperSpace", "TopologicalSpace.SecondCountableTopology",
|
|
79
|
+
"TopologicalSpace.SeparableSpace",
|
|
80
|
+
"SeminormedAddCommGroup", "NormedAddCommGroup", "NormedSpace", "InnerProductSpace",
|
|
81
|
+
"NormedField", "NontriviallyNormedField", "RCLike", "FiniteDimensional", "Module.Finite",
|
|
82
|
+
"MeasurableSpace", "MeasureTheory.MeasureSpace", "BorelSpace", "OpensMeasurableSpace",
|
|
83
|
+
"MeasurableSingletonClass", "StandardBorelSpace", "MeasurableSpace.CountablyGenerated",
|
|
84
|
+
"MeasureTheory.IsProbabilityMeasure", "MeasureTheory.IsFiniteMeasure",
|
|
85
|
+
"MeasureTheory.IsZeroOrProbabilityMeasure", "MeasureTheory.SigmaFinite",
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
# Constants an instance's argument may be, besides a variable of the proposition: the number
|
|
89
|
+
# systems, at which the classes above have their canonical instances.
|
|
90
|
+
_STANDARD_TYPES = {"ℕ", "ℤ", "ℚ", "ℝ", "ℂ", "ℝ≥0", "ℝ≥0∞", "Nat", "Int", "Rat", "Real",
|
|
91
|
+
"Complex", "NNReal", "ENNReal"}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def instance_class(binder: dict, earlier: set[str], allowed: set[str]) -> str | None:
|
|
95
|
+
"""The class of an instance binder when it is in `allowed` and applied only to variables
|
|
96
|
+
bound before it (or to a number system): `[NormedAddCommGroup F]`, `[NeZero N]`,
|
|
97
|
+
`[InnerProductSpace ℝ F]`. None for any other instance (`[Fact (1 < p)]`, `[NeZero 0]`,
|
|
98
|
+
a class outside the list), which needs a witness like a hypothesis."""
|
|
99
|
+
text = ((binder.get("type") or {}).get("text") or "").strip()
|
|
100
|
+
if not text or any(ch in text for ch in "()[]{}⟨⟩:,"):
|
|
101
|
+
return None
|
|
102
|
+
head, *args = text.split()
|
|
103
|
+
head = head.lstrip("@")
|
|
104
|
+
if head not in allowed:
|
|
105
|
+
return None
|
|
106
|
+
if not all(a in earlier or a in _STANDARD_TYPES for a in args):
|
|
107
|
+
return None
|
|
108
|
+
return head
|
|
62
109
|
|
|
63
110
|
|
|
64
111
|
def _finding(tier, code, subject, message, **extra):
|
|
@@ -108,6 +155,9 @@ class Assessor:
|
|
|
108
155
|
self.authors = set(cfg.statement_authors)
|
|
109
156
|
self._history = None
|
|
110
157
|
self._unlisted: list[str] | None = None
|
|
158
|
+
self._pins: dict[str, str | None] | None = None
|
|
159
|
+
self._witness_only: dict[str, list[str]] | None = None
|
|
160
|
+
self._unpinned: dict[str, str] | None = None
|
|
111
161
|
|
|
112
162
|
# -- declarations the probe did not find ------------------------------------------------
|
|
113
163
|
|
|
@@ -146,12 +196,14 @@ class Assessor:
|
|
|
146
196
|
passage; without one, the current passage of every claim it reads. The record is the
|
|
147
197
|
last marker at the declaration's current hash that did, provided the declaration's last
|
|
148
198
|
marker is at that hash. A marker without digests read a passage only while the history
|
|
149
|
-
shows it unchanged since the marker was written.
|
|
199
|
+
shows it unchanged since the marker was written. A marker with no review text records
|
|
200
|
+
no reading and does not count (`why` "no-reading"), unless its reviewer is one the
|
|
201
|
+
configuration allows bare markers by (`bare_markers_by`)."""
|
|
150
202
|
hist = history(self.reviews, target, name)
|
|
151
203
|
last = hist[-1] if hist else None
|
|
152
|
-
readers = review_sources.digests(self.inv, target, name)
|
|
204
|
+
readers = review_sources.digests(self.inv, target, name, self.tex)
|
|
153
205
|
need = {claim: readers[claim]} if claim in readers else readers
|
|
154
|
-
why = source_claim = None
|
|
206
|
+
why = source_claim = bare = None
|
|
155
207
|
record = last
|
|
156
208
|
if last is None:
|
|
157
209
|
state = "pending"
|
|
@@ -159,8 +211,11 @@ class Assessor:
|
|
|
159
211
|
state, why = "stale", "declaration"
|
|
160
212
|
else:
|
|
161
213
|
at = [r for r in hist if r.hash in _hashes(rec)]
|
|
162
|
-
|
|
163
|
-
if
|
|
214
|
+
read = [r for r in at if self._reads(r, need)]
|
|
215
|
+
record = next((r for r in reversed(read) if self.has_reading(r)), None)
|
|
216
|
+
if record is None and read:
|
|
217
|
+
why, state, bare = "no-reading", "stale", read[-1]
|
|
218
|
+
elif record is None:
|
|
164
219
|
why, source_claim = self._unread(last, need)
|
|
165
220
|
state = "stale"
|
|
166
221
|
else:
|
|
@@ -173,11 +228,30 @@ class Assessor:
|
|
|
173
228
|
out["why"] = why
|
|
174
229
|
if source_claim:
|
|
175
230
|
out["source_claim"] = source_claim
|
|
231
|
+
if bare is not None:
|
|
232
|
+
out["marker"] = {"file": bare.file, "line": bare.line}
|
|
176
233
|
return out
|
|
177
234
|
|
|
235
|
+
def has_reading(self, review: Review) -> bool:
|
|
236
|
+
"""Whether a marker records a reading: review text precedes it (its section, or the
|
|
237
|
+
`Review by` line promotion wrote), or its reviewer is allowed bare markers."""
|
|
238
|
+
return bool(review.text.strip()) or review.by in set(
|
|
239
|
+
getattr(self.cfg, "bare_markers_by", None) or [])
|
|
240
|
+
|
|
178
241
|
def _read_one(self, review: Review, cid: str, sha: str) -> str:
|
|
179
242
|
"""Whether `review` read the current passage `sha` of claim `cid`
|
|
180
|
-
(`review_sources.marker_state`).
|
|
243
|
+
(`review_sources.marker_state`). When `sha` covers listed notation macros, a marker that
|
|
244
|
+
records only the claim's pin, or no digests, read the passage without their definitions
|
|
245
|
+
(`notation-unrecorded`). A passage the manuscript no longer matches (`unpinned_passages`)
|
|
246
|
+
is unread by every marker until it is pinned again and read at the new pin
|
|
247
|
+
(`unpinned`)."""
|
|
248
|
+
if cid in self.unpinned():
|
|
249
|
+
return "unpinned"
|
|
250
|
+
if self._pins is None:
|
|
251
|
+
self._pins = {c["id"]: c.get("source_sha256") for c in self.inv["claims"]}
|
|
252
|
+
pin = self._pins.get(cid)
|
|
253
|
+
if pin and sha != pin and (review.source is None or review.source.get(cid) == pin):
|
|
254
|
+
return "notation-unrecorded"
|
|
181
255
|
if review.source is None and self._history is None:
|
|
182
256
|
self._history = review_sources.History(getattr(self.cfg, "root", None),
|
|
183
257
|
getattr(self.cfg, "inventory", None), self.inv)
|
|
@@ -193,9 +267,23 @@ class Assessor:
|
|
|
193
267
|
st = self._read_one(review, cid, sha)
|
|
194
268
|
if st != "current":
|
|
195
269
|
return {"changed": "source-changed", "unread": "source-unread",
|
|
196
|
-
"unrecorded": "source-unrecorded"
|
|
270
|
+
"unrecorded": "source-unrecorded",
|
|
271
|
+
"notation-unrecorded": "source-notation-unrecorded",
|
|
272
|
+
"unpinned": "source-unpinned"}[st], cid
|
|
197
273
|
return "source-changed", sorted(need)[0] # not reached: the last marker read them
|
|
198
274
|
|
|
275
|
+
def unpinned(self) -> dict[str, str]:
|
|
276
|
+
"""The claims whose passage in the manuscript no longer matches their pin, each with
|
|
277
|
+
where it differs (`unpinned_passages`)."""
|
|
278
|
+
if self._unpinned is None:
|
|
279
|
+
self._unpinned = unpinned_passages(self.inv, self.tex)
|
|
280
|
+
return self._unpinned
|
|
281
|
+
|
|
282
|
+
def unpinned_note(self, cid: str | None) -> str:
|
|
283
|
+
"""Why the claim `cid`'s passage reads as unread, for a reason or a finding."""
|
|
284
|
+
return (f"the manuscript no longer matches the pin of {self._claim_label(cid)}: "
|
|
285
|
+
f"{self.unpinned().get(cid, 'its text differs')}")
|
|
286
|
+
|
|
199
287
|
def _claim_label(self, cid: str | None) -> str:
|
|
200
288
|
c = next((c for c in self.inv["claims"] if c["id"] == cid), None)
|
|
201
289
|
if c is None:
|
|
@@ -208,11 +296,25 @@ class Assessor:
|
|
|
208
296
|
return ""
|
|
209
297
|
why = r.get("why")
|
|
210
298
|
if why == "source-changed":
|
|
211
|
-
|
|
212
|
-
|
|
299
|
+
c = next((c for c in self.inv["claims"] if c["id"] == r.get("source_claim")), None)
|
|
300
|
+
notation = c is not None and (review_sources.region_of(self.tex, c) or {}).get(
|
|
301
|
+
"notation")
|
|
302
|
+
return (f" (the source text of {self._claim_label(r.get('source_claim'))}"
|
|
303
|
+
+ (", or a definition of the notation it uses," if notation else "")
|
|
304
|
+
+ " changed since its last reading)")
|
|
305
|
+
if why == "source-unpinned":
|
|
306
|
+
return (f" ({self.unpinned_note(r.get('source_claim'))}; pin the passage again and "
|
|
307
|
+
"record a reading of the new text)")
|
|
213
308
|
if why == "source-unread":
|
|
214
309
|
return (f" (its last review did not read the passage of "
|
|
215
310
|
f"{self._claim_label(r.get('source_claim'))})")
|
|
311
|
+
if why == "no-reading":
|
|
312
|
+
m = r.get("marker") or {}
|
|
313
|
+
return (f" (its marker at {m.get('file')}:{m.get('line')} records no reading: no "
|
|
314
|
+
"review text precedes it)")
|
|
315
|
+
if why == "source-notation-unrecorded":
|
|
316
|
+
return (f" (its last review of {self._claim_label(r.get('source_claim'))} did not "
|
|
317
|
+
"record the definitions of the notation macros its passage uses)")
|
|
216
318
|
if why == "source-unrecorded":
|
|
217
319
|
return (" (its last review was made before source pins were recorded, and the "
|
|
218
320
|
f"source text of {self._claim_label(r.get('source_claim'))} cannot be shown "
|
|
@@ -221,6 +323,8 @@ class Assessor:
|
|
|
221
323
|
|
|
222
324
|
@staticmethod
|
|
223
325
|
def _stale_fields(r: dict) -> dict:
|
|
326
|
+
if r.get("why") == "no-reading":
|
|
327
|
+
return {"reason": "no-reading", **(r.get("marker") or {})}
|
|
224
328
|
if r["state"] == "stale" and r.get("why", "declaration") != "declaration":
|
|
225
329
|
return {"reason": r["why"], "source_claim": r.get("source_claim")}
|
|
226
330
|
return {}
|
|
@@ -240,6 +344,56 @@ class Assessor:
|
|
|
240
344
|
out[d] = self.review_state("def", d, lean["decls"].get(d))
|
|
241
345
|
return out
|
|
242
346
|
|
|
347
|
+
def witness_only(self) -> dict[str, list[str]]:
|
|
348
|
+
"""The project declarations in the closure of a witness's statement that the assessment
|
|
349
|
+
asks no review for otherwise (outside every proposition, its closure, the definitions a
|
|
350
|
+
definition claim maps and their closures), each with the witnesses that use it."""
|
|
351
|
+
if self._witness_only is None:
|
|
352
|
+
lean = self.lean
|
|
353
|
+
covered = set(lean["specs"])
|
|
354
|
+
for rec in lean["specs"].values():
|
|
355
|
+
covered.update(rec.get("closure") or [])
|
|
356
|
+
out: dict[str, set[str]] = {}
|
|
357
|
+
for c in self.inv["claims"]:
|
|
358
|
+
for cl in c.get("clauses") or []:
|
|
359
|
+
for d in cl.get("defs") or []:
|
|
360
|
+
covered.add(d)
|
|
361
|
+
covered.update((lean["defs"].get(d) or {}).get("closure") or [])
|
|
362
|
+
for w in self._witnesses(cl):
|
|
363
|
+
for d in (self._proof("witness", w, None) or {}).get("closure") or []:
|
|
364
|
+
out.setdefault(d, set()).add(w)
|
|
365
|
+
self._witness_only = {d: sorted(ws) for d, ws in out.items() if d not in covered}
|
|
366
|
+
return self._witness_only
|
|
367
|
+
|
|
368
|
+
@staticmethod
|
|
369
|
+
def _witnesses(cl: dict) -> list[str]:
|
|
370
|
+
return [w for w in [cl.get("witness")] + [r.get("witness")
|
|
371
|
+
for r in cl.get("regimes") or []] if w]
|
|
372
|
+
|
|
373
|
+
def witness_defs(self, cl: dict) -> dict[str, tuple[list[str], dict]]:
|
|
374
|
+
"""The witness-only declarations (`witness_only`) the witnesses of clause `cl` use, each
|
|
375
|
+
with those witnesses and its review state. A list for the reviewer: unless the
|
|
376
|
+
configuration requires their reviews (`require_witness_def_reviews`), they change no
|
|
377
|
+
status."""
|
|
378
|
+
only = self.witness_only()
|
|
379
|
+
mine = self._witnesses(cl)
|
|
380
|
+
out = {}
|
|
381
|
+
for d, ws in only.items():
|
|
382
|
+
used = [w for w in ws if w in mine]
|
|
383
|
+
if used:
|
|
384
|
+
out[d] = (used, self.review_state("def", d, self.lean["decls"].get(d)))
|
|
385
|
+
return out
|
|
386
|
+
|
|
387
|
+
def witness_candidates(self, defs: list[str]) -> list[dict]:
|
|
388
|
+
"""The witness-only declarations whose type or body uses one of `defs` (the definitions
|
|
389
|
+
a definition claim maps): candidates for its mapping, for the reader. Display only."""
|
|
390
|
+
out = []
|
|
391
|
+
for d, ws in sorted(self.witness_only().items()):
|
|
392
|
+
uses = sorted(set((self.lean["decls"].get(d) or {}).get("uses") or []) & set(defs))
|
|
393
|
+
if uses:
|
|
394
|
+
out.append({"name": d, "uses": uses, "witnesses": ws})
|
|
395
|
+
return out
|
|
396
|
+
|
|
243
397
|
# -- clauses --------------------------------------------------------------------------
|
|
244
398
|
|
|
245
399
|
def replay(self, thm: str) -> dict:
|
|
@@ -347,6 +501,32 @@ class Assessor:
|
|
|
347
501
|
dr.update({d: r for d, r in self.closure_reviews(names).items() if d not in dr})
|
|
348
502
|
res["spec_review"] = None
|
|
349
503
|
states = [d["state"] for d in dr.values()]
|
|
504
|
+
wd = self.witness_defs(cl)
|
|
505
|
+
if wd and getattr(self.cfg, "require_witness_def_reviews", False):
|
|
506
|
+
# Declared required: each is reviewed like a definition of the proposition, so it
|
|
507
|
+
# can only hold a status back.
|
|
508
|
+
for n in wd:
|
|
509
|
+
if n not in dr:
|
|
510
|
+
dr[n] = self.review_state("def", n, lean["decls"].get(n))
|
|
511
|
+
states += [dr[n]["state"] for n in wd]
|
|
512
|
+
wd = {}
|
|
513
|
+
res["witness_defs"] = [
|
|
514
|
+
{"name": n, "witnesses": w, "state": r["state"]}
|
|
515
|
+
for n, (w, r) in sorted(wd.items())
|
|
516
|
+
if r["state"] not in ("reviewed", "author-reviewed")]
|
|
517
|
+
for e in res["witness_defs"]:
|
|
518
|
+
rec = lean["decls"].get(e["name"]) or {}
|
|
519
|
+
self.add_warning(
|
|
520
|
+
"witness-def-review", subj, e["name"],
|
|
521
|
+
{"fingerprint": rec.get("fingerprint") or rec.get("legacy_hash")},
|
|
522
|
+
f"the witness {', '.join(e['witnesses'])} uses {e['name']}, which is in no "
|
|
523
|
+
"proposition's definitions and "
|
|
524
|
+
+ ("has no review" if e["state"] == "pending" else
|
|
525
|
+
"has no current review")
|
|
526
|
+
+ "; the instance a witness exhibits is fixed by such declarations",
|
|
527
|
+
",".join(e["witnesses"]))
|
|
528
|
+
if cl.get("defs") and not spec:
|
|
529
|
+
res["witness_candidates"] = self.witness_candidates(cl["defs"])
|
|
350
530
|
res["def_reviews"] = dr
|
|
351
531
|
for n, d in dr.items():
|
|
352
532
|
if d["state"] in ("pending", "stale"):
|
|
@@ -386,14 +566,10 @@ class Assessor:
|
|
|
386
566
|
"stated" if cl.get("defs") else "unspecified")
|
|
387
567
|
|
|
388
568
|
if srec:
|
|
389
|
-
roles = [b["role"] for b in srec.get("binders", [])]
|
|
390
569
|
# A checked refutation needs no witness: a proof of ¬S exhibits an instance meeting
|
|
391
570
|
# S's hypotheses (were they never met, S would hold vacuously and not be refutable).
|
|
392
|
-
if ("
|
|
393
|
-
|
|
394
|
-
self.findings.append(_finding(
|
|
395
|
-
"obligation", "witness", subj,
|
|
396
|
-
f"{spec} has hypotheses but no witness that they can be met"))
|
|
571
|
+
if not cl.get("witness") and not res.get("refute_ok"):
|
|
572
|
+
self.witness_check(subj, spec, srec)
|
|
397
573
|
for c in srec.get("consts", []):
|
|
398
574
|
if c in TOTALISED:
|
|
399
575
|
self.add_warning("totalised", subj, spec, srec,
|
|
@@ -414,6 +590,42 @@ class Assessor:
|
|
|
414
590
|
res["regimes"] = regs
|
|
415
591
|
return res
|
|
416
592
|
|
|
593
|
+
def witness_check(self, subj: str, spec: str, srec: dict) -> None:
|
|
594
|
+
"""The witness a proposition without one needs. A hypothesis, or an instance of a class
|
|
595
|
+
not known to be inhabited, raises the `witness` obligation, naming the binders that need
|
|
596
|
+
it. A proposition whose only hypotheses are instances of `inhabited_classes` over its
|
|
597
|
+
own variables gets a low-signal `witness-instances` warning instead: no theorem shows
|
|
598
|
+
them met, but each has a canonical instance. Neither changes a status."""
|
|
599
|
+
configured = getattr(self.cfg, "inhabited_classes", None)
|
|
600
|
+
allowed = set(INHABITED_CLASSES if configured is None else configured)
|
|
601
|
+
earlier: set[str] = set()
|
|
602
|
+
needs, classes = [], []
|
|
603
|
+
for b in srec.get("binders", []):
|
|
604
|
+
role, text = b.get("role"), (b.get("type") or {}).get("text", "?")
|
|
605
|
+
if role == "hypothesis":
|
|
606
|
+
needs.append(f"{b.get('name', '?')} : {text}")
|
|
607
|
+
elif role == "instance":
|
|
608
|
+
cls = instance_class(b, earlier, allowed)
|
|
609
|
+
if cls is None:
|
|
610
|
+
needs.append(f"[{text}]")
|
|
611
|
+
else:
|
|
612
|
+
classes.append(cls)
|
|
613
|
+
if b.get("name"):
|
|
614
|
+
earlier.add(b["name"])
|
|
615
|
+
if needs:
|
|
616
|
+
shown = "; ".join(needs[:3]) + ("; …" if len(needs) > 3 else "")
|
|
617
|
+
self.findings.append(_finding(
|
|
618
|
+
"obligation", "witness", subj,
|
|
619
|
+
f"{spec} has hypotheses but no witness that they can be met ({shown})",
|
|
620
|
+
binders=needs))
|
|
621
|
+
elif classes:
|
|
622
|
+
names = ", ".join(dict.fromkeys(classes))
|
|
623
|
+
self.add_warning(
|
|
624
|
+
"witness-instances", subj, spec, srec,
|
|
625
|
+
f"{spec} has no witness; its only hypotheses are instances of classes treated "
|
|
626
|
+
f"as inhabited ({names}), and no theorem shows them met together",
|
|
627
|
+
"witness-instances")
|
|
628
|
+
|
|
417
629
|
def add_warning(self, code, subj, name, rec, message, trigger):
|
|
418
630
|
fp = rec.get("fingerprint")
|
|
419
631
|
f = _finding("warning", code, subj, message, trigger=trigger, fingerprint=fp,
|
|
@@ -514,13 +726,24 @@ class Assessor:
|
|
|
514
726
|
"source-unread": "the proposition's last review did not read this "
|
|
515
727
|
"claim's passage",
|
|
516
728
|
"source-unrecorded": "the proposition was reviewed before source pins "
|
|
517
|
-
"were recorded"
|
|
729
|
+
"were recorded",
|
|
730
|
+
"source-notation-unrecorded": "the proposition's last review did not "
|
|
731
|
+
"record the definitions of the notation "
|
|
732
|
+
"macros this claim's passage uses",
|
|
733
|
+
"source-unpinned": (
|
|
734
|
+
f"{self.unpinned_note(c['spec_review'].get('source_claim'))}; "
|
|
735
|
+
"the proposition's review counts only once the passage is pinned "
|
|
736
|
+
"again and read"),
|
|
737
|
+
"no-reading": "the proposition's review marker records no reading "
|
|
738
|
+
"(no review text)"}.get(
|
|
518
739
|
c["spec_review"].get("why"),
|
|
519
740
|
"the proposition changed after its last review"), c)
|
|
520
741
|
for d, r in (c.get("def_reviews") or {}).items():
|
|
521
742
|
why = r.get("why")
|
|
522
743
|
defs[d] = why if r["state"] == "stale" and why in (
|
|
523
|
-
"source-changed", "source-unread", "source-unrecorded"
|
|
744
|
+
"source-changed", "source-unread", "source-unrecorded",
|
|
745
|
+
"source-notation-unrecorded", "source-unpinned", "no-reading") \
|
|
746
|
+
else r["state"]
|
|
524
747
|
if c.get("witness") and not c.get("witness_ok"):
|
|
525
748
|
add("the witness that the hypotheses can be met fails its check", c)
|
|
526
749
|
if any(not r["discharged"] for r in c.get("regimes", [])):
|
|
@@ -545,8 +768,14 @@ class Assessor:
|
|
|
545
768
|
("source-changed", "have a paper text that changed after their "
|
|
546
769
|
"review"),
|
|
547
770
|
("source-unread", "have a review that did not read their passage"),
|
|
771
|
+
("source-unpinned", "have a passage the manuscript no longer "
|
|
772
|
+
"matches: their review counts only once it "
|
|
773
|
+
"is pinned again and read"),
|
|
548
774
|
("source-unrecorded", "were reviewed before source pins were "
|
|
549
775
|
"recorded"),
|
|
776
|
+
("no-reading", "have a review marker that records no reading"),
|
|
777
|
+
("source-notation-unrecorded", "have a review that did not record "
|
|
778
|
+
"the definitions of their notation"),
|
|
550
779
|
("author-reviewed", "were reviewed only by the author")):
|
|
551
780
|
if counts.get(state):
|
|
552
781
|
out.append(f"{counts[state]} definition{'s' if counts[state] > 1 else ''} its "
|
|
@@ -563,8 +792,9 @@ class Assessor:
|
|
|
563
792
|
if not is_step(claim, region):
|
|
564
793
|
return {}
|
|
565
794
|
marks = [r for r in self.reviews if r.target == "step" and r.name == claim["id"]]
|
|
566
|
-
|
|
567
|
-
|
|
795
|
+
# A step whose passage the manuscript no longer matches has no current reading.
|
|
796
|
+
sha = None if claim["id"] in self.unpinned() else claim.get("source_sha256")
|
|
797
|
+
return {"step_review": marker_review(marks, claim["id"], sha, self.authors)}
|
|
568
798
|
|
|
569
799
|
def run(self) -> dict:
|
|
570
800
|
claims = []
|
|
@@ -574,15 +804,34 @@ class Assessor:
|
|
|
574
804
|
claims.append({"id": c["id"], **state, "clauses": clauses,
|
|
575
805
|
"blockers": self.blockers(c, clauses), **self.step_review(c)})
|
|
576
806
|
self.inventory_checks()
|
|
807
|
+
self.bare_marker_checks()
|
|
577
808
|
if self.lean:
|
|
578
809
|
for v in self.lean.get("layering", []):
|
|
579
810
|
self.findings.append(_finding(
|
|
580
811
|
"violation", "layering", v["module"],
|
|
581
812
|
f"the specification module {v['module']} imports {v['imports']}"))
|
|
582
813
|
self.module_doc_checks()
|
|
814
|
+
self.review_citation_checks()
|
|
583
815
|
gates = self.gates(claims)
|
|
584
816
|
return {"claims": claims, "findings": self.findings, "gates": gates}
|
|
585
817
|
|
|
818
|
+
def bare_marker_checks(self):
|
|
819
|
+
"""An obligation for each declaration whose last review marker has no review text
|
|
820
|
+
(`has_reading`), with the marker's file and line: a marker records a reading, and one
|
|
821
|
+
without text, copied between files say, records none. Such a marker never counts as a
|
|
822
|
+
review (`review_state`)."""
|
|
823
|
+
last: dict[tuple[str, str], Review] = {}
|
|
824
|
+
for r in self.reviews:
|
|
825
|
+
if r.target in ("spec", "def"):
|
|
826
|
+
last[(r.target, r.name)] = r
|
|
827
|
+
for (target, name), r in last.items():
|
|
828
|
+
if not self.has_reading(r):
|
|
829
|
+
kind = "proposition" if target == "spec" else "definition"
|
|
830
|
+
self.findings.append(_finding(
|
|
831
|
+
"obligation", "review-without-reading", name,
|
|
832
|
+
f"{r.file}:{r.line}: the review marker of the {kind} {name} records no "
|
|
833
|
+
"reading: no review text precedes it", file=r.file, line=r.line))
|
|
834
|
+
|
|
586
835
|
def module_doc_checks(self):
|
|
587
836
|
"""A warning for each name a module docstring lists that nothing declares: prose that
|
|
588
837
|
advertises a result the project does not contain. It never changes a status, and an
|
|
@@ -595,6 +844,34 @@ class Assessor:
|
|
|
595
844
|
stale_doc_message(d), d["name"])
|
|
596
845
|
self.findings[-1].update(file=d["file"], line=d["line"])
|
|
597
846
|
|
|
847
|
+
def review_citation_checks(self):
|
|
848
|
+
"""A warning for each name or path cited in backticks by the review files that nothing
|
|
849
|
+
resolves (`review_citations.py`), with its file and line; a violation when the
|
|
850
|
+
configuration says `review_citations_strict`. The warning never changes a status, and
|
|
851
|
+
an auditor can dismiss it (code `review-citation`, the review file as subject, the
|
|
852
|
+
token as trigger)."""
|
|
853
|
+
from . import review_citations as rc
|
|
854
|
+
files = getattr(self.cfg, "reviews", None)
|
|
855
|
+
root = getattr(self.cfg, "root", None)
|
|
856
|
+
if not files or root is None:
|
|
857
|
+
return
|
|
858
|
+
cites = rc.citations(files, root, getattr(self.cfg, "review_citations_ignore", None))
|
|
859
|
+
lean_root = getattr(self.cfg, "lean_root", None) or root
|
|
860
|
+
bases = [root] + ([lean_root] if not lean_root.is_relative_to(root) else [])
|
|
861
|
+
seen = set()
|
|
862
|
+
for c in rc.unresolved(cites, self.lean.get("names"), bases):
|
|
863
|
+
if (c["file"], c["token"]) in seen:
|
|
864
|
+
continue
|
|
865
|
+
seen.add((c["file"], c["token"]))
|
|
866
|
+
if getattr(self.cfg, "review_citations_strict", False):
|
|
867
|
+
self.findings.append(_finding("violation", "review-citation", c["file"],
|
|
868
|
+
rc.message(c), trigger=c["token"],
|
|
869
|
+
file=c["file"], line=c["line"]))
|
|
870
|
+
else:
|
|
871
|
+
self.add_warning("review-citation", c["file"], c["file"],
|
|
872
|
+
{"fingerprint": rc.fingerprint(c)}, rc.message(c), c["token"])
|
|
873
|
+
self.findings[-1].update(file=c["file"], line=c["line"])
|
|
874
|
+
|
|
598
875
|
# -- gates ----------------------------------------------------------------------------
|
|
599
876
|
|
|
600
877
|
def gates(self, claims: list[dict]) -> dict:
|
|
@@ -695,21 +972,33 @@ class Assessor:
|
|
|
695
972
|
line = line_location(c)
|
|
696
973
|
if line is not None:
|
|
697
974
|
region = (t.get("regions") or {}).get(c["id"], {})
|
|
698
|
-
if c.get("source_hash_scheme")
|
|
975
|
+
if c.get("source_hash_scheme") not in SOURCE_SCHEMES:
|
|
699
976
|
self.findings.append(_finding(
|
|
700
977
|
"violation", "source-hash-scheme", c["id"],
|
|
701
978
|
f"{c['location']}: source regions must be pinned at the original "
|
|
702
979
|
"revision (python -m prooflens.source_regions --config FILE "
|
|
703
980
|
f"--paper {pid}); then rebuild"))
|
|
704
|
-
elif
|
|
705
|
-
where = changed_line(c, region) if region else None
|
|
706
|
-
detail = region.get("error") or (
|
|
707
|
-
"is missing; rebuild the source evidence" if not region else
|
|
708
|
-
"differs from the frozen source region"
|
|
709
|
-
+ (f": {where}" if where else ""))
|
|
981
|
+
elif c["id"] in self.unpinned():
|
|
710
982
|
self.findings.append(_finding(
|
|
711
983
|
"violation", "source-changed", c["id"],
|
|
712
|
-
|
|
984
|
+
self.unpinned()[c["id"]]))
|
|
985
|
+
self.region_advice(c, region)
|
|
986
|
+
macros = region.get("macros") or []
|
|
987
|
+
if macros:
|
|
988
|
+
# One warning per passage. Its trigger is the set of macros, so a
|
|
989
|
+
# dismissal (tied to the passage's digest) reopens when another macro
|
|
990
|
+
# defined outside the passage comes into use.
|
|
991
|
+
names = " ".join(m["macro"] for m in macros)
|
|
992
|
+
where = "; ".join(f"{m['macro']} at {', '.join(m['defined'])}"
|
|
993
|
+
for m in macros)
|
|
994
|
+
self.add_warning(
|
|
995
|
+
"source-macro-unpinned", c["id"], c["id"],
|
|
996
|
+
{"fingerprint": c.get("source_sha256")},
|
|
997
|
+
f"the source region at {c['location']} uses macros defined outside "
|
|
998
|
+
f"it ({where}); a change to those definitions does not change the "
|
|
999
|
+
"pin. Pin the definitions whose values are part of the claim "
|
|
1000
|
+
"(machinechecked inventory rebound --macro NAME), and list the "
|
|
1001
|
+
"notation in notation_macros", names)
|
|
713
1002
|
continue
|
|
714
1003
|
a = match_anchor(c, anchors)
|
|
715
1004
|
if a is None:
|
|
@@ -719,12 +1008,9 @@ class Assessor:
|
|
|
719
1008
|
f"{c.get('number', c['id'])} is not found in the compiled paper"))
|
|
720
1009
|
continue
|
|
721
1010
|
matched.add(a["id"])
|
|
722
|
-
if c
|
|
723
|
-
c["source_sha256"] != a["source_sha256"]:
|
|
1011
|
+
if c["id"] in self.unpinned():
|
|
724
1012
|
self.findings.append(_finding(
|
|
725
|
-
"violation", "source-changed", c["id"],
|
|
726
|
-
f"the source of {c.get('number', c['id'])} differs from the frozen "
|
|
727
|
-
f"inventory"))
|
|
1013
|
+
"violation", "source-changed", c["id"], self.unpinned()[c["id"]]))
|
|
728
1014
|
for a in anchors:
|
|
729
1015
|
if a["id"] not in matched:
|
|
730
1016
|
self.findings.append(_finding(
|
|
@@ -732,6 +1018,54 @@ class Assessor:
|
|
|
732
1018
|
f"{a['env'].capitalize()} {a.get('number')} ({a['file']}:{a['line']}) "
|
|
733
1019
|
f"is in the paper but not in the inventory"))
|
|
734
1020
|
|
|
1021
|
+
def region_advice(self, claim: dict, region: dict):
|
|
1022
|
+
"""A warning for each way the claim's source region may not hold its text
|
|
1023
|
+
(`source_regions.advice`): a label line, a region that starts or ends inside a sentence,
|
|
1024
|
+
one that runs into another section, one that cuts an environment. It names the passage likely meant, never changes a
|
|
1025
|
+
status, and an auditor can dismiss it (code `source-region`, the claim as subject, the
|
|
1026
|
+
kind as trigger); a dismissal lapses when the region's text changes."""
|
|
1027
|
+
from .source_regions import SCHEME, advice_message
|
|
1028
|
+
# The digest of the claim's own passage (a pin of several passages records it apart).
|
|
1029
|
+
passage = region.get("passage_sha256") or region.get("sha256")
|
|
1030
|
+
for a in region.get("advice") or []:
|
|
1031
|
+
self.add_warning("source-region", claim["id"], claim["id"],
|
|
1032
|
+
{"fingerprint": f"{SCHEME}:{passage}"},
|
|
1033
|
+
advice_message(claim["id"], region, a), a["kind"])
|
|
1034
|
+
if a.get("suggested"):
|
|
1035
|
+
self.findings[-1]["suggested"] = a["suggested"]
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
def unpinned_passages(inventory: dict, tex: dict | None) -> dict[str, str]:
|
|
1039
|
+
"""The claims whose passage in the manuscript no longer matches their pin, each with the
|
|
1040
|
+
message of the source check's finding (`source-changed`), which says where it differs. Only a paper read from its LaTeX
|
|
1041
|
+
source is compared. A line-located claim is compared by its region (each further passage
|
|
1042
|
+
and macro definition included); a statement environment by the digest of its text. A pin
|
|
1043
|
+
under a scheme the check does not accept is reported apart (`source-hash-scheme`) and is not
|
|
1044
|
+
listed.
|
|
1045
|
+
|
|
1046
|
+
A review reads the paper's text, so a reading of such a passage does not count until the
|
|
1047
|
+
passage is pinned again and read at the new pin (`Assessor._read_one`)."""
|
|
1048
|
+
out: dict[str, str] = {}
|
|
1049
|
+
for c in inventory.get("claims", []):
|
|
1050
|
+
t = (tex or {}).get(c.get("paper")) or {}
|
|
1051
|
+
if t.get("mode") != "latex":
|
|
1052
|
+
continue
|
|
1053
|
+
if line_location(c) is not None:
|
|
1054
|
+
if c.get("source_hash_scheme") not in SOURCE_SCHEMES or source_matches(c, t):
|
|
1055
|
+
continue
|
|
1056
|
+
region = (t.get("regions") or {}).get(c["id"], {})
|
|
1057
|
+
where = changed_line(c, region) if region else None
|
|
1058
|
+
out[c["id"]] = f"the source region at {c['location']} " + (region.get("error") or (
|
|
1059
|
+
"is missing; rebuild the source evidence" if not region else
|
|
1060
|
+
"differs from the frozen source region" + (f": {where}" if where else "")))
|
|
1061
|
+
continue
|
|
1062
|
+
a = match_anchor(c, t.get("anchors") or [])
|
|
1063
|
+
if a and c.get("source_sha256") and a.get("source_sha256") and \
|
|
1064
|
+
c["source_sha256"] != a["source_sha256"]:
|
|
1065
|
+
out[c["id"]] = (f"the source of {c.get('number', c['id'])} differs from the frozen "
|
|
1066
|
+
"inventory")
|
|
1067
|
+
return out
|
|
1068
|
+
|
|
735
1069
|
|
|
736
1070
|
def line_location(claim: dict) -> int | None:
|
|
737
1071
|
"""The line of a claim recorded as `<file>:<line>`, else None."""
|