lean-pkg 0.25.0__py3-none-any.whl
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.
- lean_pkg/__init__.py +3 -0
- lean_pkg/adapters/__init__.py +148 -0
- lean_pkg/adapters/github.py +65 -0
- lean_pkg/adapters/leansearch.py +68 -0
- lean_pkg/adapters/loogle.py +45 -0
- lean_pkg/adapters/palomar.py +170 -0
- lean_pkg/adapters/reservoir.py +127 -0
- lean_pkg/anchor.py +678 -0
- lean_pkg/audit.py +716 -0
- lean_pkg/binding_file.py +446 -0
- lean_pkg/blueprint.py +213 -0
- lean_pkg/build_scope.py +282 -0
- lean_pkg/ci_github.py +917 -0
- lean_pkg/claim_axioms.py +421 -0
- lean_pkg/claims.py +1155 -0
- lean_pkg/claims_mark.py +197 -0
- lean_pkg/cli.py +5208 -0
- lean_pkg/cli_parser.py +768 -0
- lean_pkg/command_tree.py +615 -0
- lean_pkg/comparator_config.py +990 -0
- lean_pkg/comparator_contracts.py +382 -0
- lean_pkg/comparator_receipt.py +2854 -0
- lean_pkg/comparator_stage.py +623 -0
- lean_pkg/comparator_types.py +830 -0
- lean_pkg/container.py +172 -0
- lean_pkg/core.py +1570 -0
- lean_pkg/coverage.py +1278 -0
- lean_pkg/data/stacks/lts-2026.10.yaml +73 -0
- lean_pkg/data/toolchain-advisories.yaml +77 -0
- lean_pkg/data/upgrade-breaking.yaml +20 -0
- lean_pkg/data/verify-workflow-pins.yaml +14 -0
- lean_pkg/deps_closure.py +512 -0
- lean_pkg/deps_fill.py +445 -0
- lean_pkg/dup_constants.py +448 -0
- lean_pkg/exercise.py +828 -0
- lean_pkg/exercise_forbid.py +288 -0
- lean_pkg/export_paths.py +77 -0
- lean_pkg/extract.py +1172 -0
- lean_pkg/extract_decls.py +501 -0
- lean_pkg/extract_ledger.py +1408 -0
- lean_pkg/extract_summary.py +132 -0
- lean_pkg/extract_types.py +502 -0
- lean_pkg/extract_write.py +138 -0
- lean_pkg/formalization.py +1078 -0
- lean_pkg/formalization_kept.py +182 -0
- lean_pkg/fresh_repo.py +709 -0
- lean_pkg/gate.py +2141 -0
- lean_pkg/headline.py +211 -0
- lean_pkg/help_topics.py +442 -0
- lean_pkg/holes.py +289 -0
- lean_pkg/host_routes.py +376 -0
- lean_pkg/hypotheses.py +788 -0
- lean_pkg/index.py +1749 -0
- lean_pkg/json_stdout.py +48 -0
- lean_pkg/lake_hygiene.py +289 -0
- lean_pkg/lean_diag.py +280 -0
- lean_pkg/lean_scan.py +1300 -0
- lean_pkg/ledger.py +582 -0
- lean_pkg/next_step.py +510 -0
- lean_pkg/page.py +1831 -0
- lean_pkg/page_html.py +153 -0
- lean_pkg/palomar.py +316 -0
- lean_pkg/palomar_check.py +1027 -0
- lean_pkg/port_modules.py +677 -0
- lean_pkg/prior_art.py +286 -0
- lean_pkg/producer.py +212 -0
- lean_pkg/producer_skew.py +208 -0
- lean_pkg/public_safety.py +1487 -0
- lean_pkg/publish.py +402 -0
- lean_pkg/rebase.py +984 -0
- lean_pkg/receipt.py +2385 -0
- lean_pkg/receipt_check.py +1064 -0
- lean_pkg/receipt_ci.py +660 -0
- lean_pkg/receipt_systemd.py +890 -0
- lean_pkg/recommended.py +232 -0
- lean_pkg/report.py +727 -0
- lean_pkg/reservoir.py +203 -0
- lean_pkg/scaffold.py +588 -0
- lean_pkg/schemas/formalization-0.4.schema.json +344 -0
- lean_pkg/schemas/formalization-0.4.schema.source.txt +15 -0
- lean_pkg/scripts/ClaimAxioms.lean +47 -0
- lean_pkg/scripts/ContractsOnly.lean +300 -0
- lean_pkg/scripts/DupConstants.lean +149 -0
- lean_pkg/scripts/HypProbe.lean +257 -0
- lean_pkg/scripts/comparator-check.sh +396 -0
- lean_pkg/scripts/verify-comparator.sh +135 -0
- lean_pkg/seal_bundle.py +647 -0
- lean_pkg/search.py +865 -0
- lean_pkg/site_profiles/easley.yaml +10 -0
- lean_pkg/site_profiles/github-actions.yaml +12 -0
- lean_pkg/sites.py +225 -0
- lean_pkg/stacks.py +373 -0
- lean_pkg/statements_module.py +217 -0
- lean_pkg/templates/Apache-2.0.txt +202 -0
- lean_pkg/toolchain_advisories.py +225 -0
- lean_pkg/upgrade.py +706 -0
- lean_pkg/verify.py +495 -0
- lean_pkg-0.25.0.dist-info/METADATA +93 -0
- lean_pkg-0.25.0.dist-info/RECORD +103 -0
- lean_pkg-0.25.0.dist-info/WHEEL +5 -0
- lean_pkg-0.25.0.dist-info/entry_points.txt +5 -0
- lean_pkg-0.25.0.dist-info/licenses/LICENSE +202 -0
- lean_pkg-0.25.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/mathlib-initiative/formalization.yaml/main/schema/v0.4.schema.json",
|
|
4
|
+
"title": "formalization.yaml (v0.4)",
|
|
5
|
+
"description": "Repo-root metadata schema for formalization projects (v0.4). Validates a filled-in formalization.yaml.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"$comment": "Permissive: extra keys allowed everywhere. Required fields use minLength/minItems so a blank template is invalid.",
|
|
8
|
+
"required": ["project", "sources", "automation", "review"],
|
|
9
|
+
"properties": {
|
|
10
|
+
"version": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"project": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"description": "the formalization itself (not the source)",
|
|
16
|
+
"required": ["name", "authors", "license"],
|
|
17
|
+
"properties": {
|
|
18
|
+
"name": { "type": "string", "minLength": 1 },
|
|
19
|
+
"description": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "a concise account of the mathematical content and principal results of the formalization"
|
|
22
|
+
},
|
|
23
|
+
"authors": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"minItems": 1,
|
|
26
|
+
"items": { "type": "string", "minLength": 1 },
|
|
27
|
+
"description": "who did the formalization"
|
|
28
|
+
},
|
|
29
|
+
"responsible_maintainers": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"items": { "type": "string" },
|
|
32
|
+
"description": "people responsible for the formalization repository"
|
|
33
|
+
},
|
|
34
|
+
"license": { "type": "string", "minLength": 1 }
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"description": "optional relationship to a separately pinned substantive formalization; omission means this repository is the substantive development",
|
|
40
|
+
"properties": {
|
|
41
|
+
"role": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"enum": ["", "substantive-development", "thin-wrapper"]
|
|
44
|
+
},
|
|
45
|
+
"substantive_formalization": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"required": ["id"],
|
|
48
|
+
"properties": {
|
|
49
|
+
"id": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"minLength": 1,
|
|
52
|
+
"description": "repository URL or another stable identifier"
|
|
53
|
+
},
|
|
54
|
+
"revision": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"description": "immutable commit or revision when available"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"allOf": [
|
|
62
|
+
{
|
|
63
|
+
"if": { "properties": { "role": { "const": "thin-wrapper" } }, "required": ["role"] },
|
|
64
|
+
"then": { "required": ["substantive_formalization"] }
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"if": { "properties": { "role": { "const": "substantive-development" } }, "required": ["role"] },
|
|
68
|
+
"then": {
|
|
69
|
+
"not": { "required": ["substantive_formalization"] }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"sources": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"minItems": 1,
|
|
77
|
+
"description": "what was formalized; use an original-proof entry when the theorem is first presented by the formalization",
|
|
78
|
+
"items": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"required": ["title"],
|
|
81
|
+
"properties": {
|
|
82
|
+
"title": { "type": "string", "minLength": 1 },
|
|
83
|
+
"authors": {
|
|
84
|
+
"type": "array",
|
|
85
|
+
"items": { "type": "string", "minLength": 1 },
|
|
86
|
+
"description": "bibliographic authors of this source"
|
|
87
|
+
},
|
|
88
|
+
"contributors": {
|
|
89
|
+
"type": "array",
|
|
90
|
+
"description": "people credited for non-author roles associated with this source",
|
|
91
|
+
"items": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"required": ["name", "role"],
|
|
94
|
+
"properties": {
|
|
95
|
+
"name": { "type": "string", "minLength": 1 },
|
|
96
|
+
"role": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"minLength": 1,
|
|
99
|
+
"description": "free-form contribution role, e.g. editor or problem-proposer"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"id": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"description": "optional URL, DOI, ISBN, arXiv ID, citation, or other stable identifier"
|
|
107
|
+
},
|
|
108
|
+
"type": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"description": "kind of source (article, book, web post, folklore, conversation, original-proof, ...)"
|
|
111
|
+
},
|
|
112
|
+
"location": {
|
|
113
|
+
"type": "string",
|
|
114
|
+
"description": "theorem, section, page, post, answer, or other locator within the source"
|
|
115
|
+
},
|
|
116
|
+
"relationship": {
|
|
117
|
+
"type": "string",
|
|
118
|
+
"enum": ["", "formalizes", "adapts", "independently-proves", "background", "other"]
|
|
119
|
+
},
|
|
120
|
+
"note": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"description": "free-form source detail; use this to explain relationship or author_endorsement: other"
|
|
123
|
+
},
|
|
124
|
+
"license": { "type": "string" },
|
|
125
|
+
"author_endorsement": {
|
|
126
|
+
"type": "string",
|
|
127
|
+
"enum": ["", "participated", "endorsed", "no-response", "not-contacted", "declined", "n/a", "other"],
|
|
128
|
+
"description": "source-author involvement or response; separate from repository submission authorization; explain other in note"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"related_formalizations": {
|
|
134
|
+
"type": "array",
|
|
135
|
+
"description": "prior or parallel formalizations, if known",
|
|
136
|
+
"items": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"required": ["id"],
|
|
139
|
+
"properties": {
|
|
140
|
+
"id": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"minLength": 1,
|
|
143
|
+
"description": "URL or stable identifier"
|
|
144
|
+
},
|
|
145
|
+
"relationship": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"enum": ["", "builds-on", "adapts", "independent", "supersedes", "other"]
|
|
148
|
+
},
|
|
149
|
+
"note": { "type": "string" }
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"classification": {
|
|
154
|
+
"type": "object",
|
|
155
|
+
"description": "what area of mathematics the formalized result belongs to",
|
|
156
|
+
"properties": {
|
|
157
|
+
"arxiv": {
|
|
158
|
+
"type": "array",
|
|
159
|
+
"items": { "type": "string", "minLength": 1 },
|
|
160
|
+
"description": "arXiv categories, e.g. [\"math.NT\", \"math.CO\"]"
|
|
161
|
+
},
|
|
162
|
+
"msc2020": {
|
|
163
|
+
"type": "array",
|
|
164
|
+
"items": { "type": "string", "minLength": 1 },
|
|
165
|
+
"description": "MSC2020 codes, e.g. [\"11N25\", \"05C35\"]"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"automation": {
|
|
170
|
+
"type": "object",
|
|
171
|
+
"description": "how it was produced",
|
|
172
|
+
"required": ["methods"],
|
|
173
|
+
"properties": {
|
|
174
|
+
"methods": {
|
|
175
|
+
"type": "array",
|
|
176
|
+
"minItems": 1,
|
|
177
|
+
"description": "one entry per distinct phase/run/tool",
|
|
178
|
+
"items": {
|
|
179
|
+
"type": "object",
|
|
180
|
+
"required": ["method"],
|
|
181
|
+
"properties": {
|
|
182
|
+
"method": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"enum": ["manual", "copilot", "agent", "autonomous", "other"],
|
|
185
|
+
"description": "manual | copilot | agent | autonomous | other"
|
|
186
|
+
},
|
|
187
|
+
"models": {
|
|
188
|
+
"type": "array",
|
|
189
|
+
"items": { "type": "string" },
|
|
190
|
+
"description": "e.g. [\"claude-opus-4-7\", \"gpt-5\"]"
|
|
191
|
+
},
|
|
192
|
+
"framework": {
|
|
193
|
+
"type": "string",
|
|
194
|
+
"description": "e.g. \"Claude Code\", \"OpenClaw\", \"LeanCopilot\""
|
|
195
|
+
},
|
|
196
|
+
"tool_setup": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"description": "tools, harnesses, plugins, orchestration, customizations"
|
|
199
|
+
},
|
|
200
|
+
"cost": {
|
|
201
|
+
"type": "object",
|
|
202
|
+
"properties": {
|
|
203
|
+
"wall_time": {
|
|
204
|
+
"type": ["string", "number"],
|
|
205
|
+
"description": "e.g. \"3 weeks\" or \"240 GPU-hours\""
|
|
206
|
+
},
|
|
207
|
+
"spend_usd": {
|
|
208
|
+
"type": ["string", "number"],
|
|
209
|
+
"description": "spend for this method, e.g. \"$10 API credits\""
|
|
210
|
+
},
|
|
211
|
+
"hardware": {
|
|
212
|
+
"type": ["string", "number"],
|
|
213
|
+
"description": "GPU count, \"API-only\", \"my laptop\", whatever's relevant"
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
"prompting_notes": {
|
|
218
|
+
"type": "string",
|
|
219
|
+
"description": "freeform notes/examples about the prompts or task specs used"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
"spend_usd": {
|
|
225
|
+
"type": ["string", "number"],
|
|
226
|
+
"description": "total spend across the project, e.g. \"$10 API credits\" or \"subscription-based usage\""
|
|
227
|
+
},
|
|
228
|
+
"notes": {
|
|
229
|
+
"type": "string",
|
|
230
|
+
"description": "freeform details on the overall process and interaction setup"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"status": {
|
|
235
|
+
"type": "object",
|
|
236
|
+
"description": "project status",
|
|
237
|
+
"properties": {
|
|
238
|
+
"scope": {
|
|
239
|
+
"type": "string",
|
|
240
|
+
"description": "describe the scope of the project"
|
|
241
|
+
},
|
|
242
|
+
"sorry_count": {
|
|
243
|
+
"type": "integer",
|
|
244
|
+
"minimum": 0,
|
|
245
|
+
"description": "number of unresolved sorries in the proof development, excluding deliberate placeholders in Comparator challenge modules"
|
|
246
|
+
},
|
|
247
|
+
"sorry_in_definitions": {
|
|
248
|
+
"type": "integer",
|
|
249
|
+
"minimum": 0,
|
|
250
|
+
"description": "number of unresolved sorries in proof-development definitions, excluding deliberate definition holes in Comparator challenge modules"
|
|
251
|
+
},
|
|
252
|
+
"axioms": {
|
|
253
|
+
"type": "array",
|
|
254
|
+
"items": { "type": "string" },
|
|
255
|
+
"description": "list all axioms used (including standard axioms such as `Quot.sound`)"
|
|
256
|
+
},
|
|
257
|
+
"main_results": {
|
|
258
|
+
"type": "array",
|
|
259
|
+
"description": "list the main results of the project",
|
|
260
|
+
"items": {
|
|
261
|
+
"type": "object",
|
|
262
|
+
"properties": {
|
|
263
|
+
"declaration": {
|
|
264
|
+
"type": "string",
|
|
265
|
+
"description": "declaration proving this main result"
|
|
266
|
+
},
|
|
267
|
+
"file": {
|
|
268
|
+
"type": "string",
|
|
269
|
+
"description": "file containing the declaration"
|
|
270
|
+
},
|
|
271
|
+
"sorry_count": {
|
|
272
|
+
"type": "integer",
|
|
273
|
+
"minimum": 0,
|
|
274
|
+
"description": "number of unresolved sorries in the proved declaration, excluding the deliberate placeholder in its Comparator challenge module"
|
|
275
|
+
},
|
|
276
|
+
"axioms": {
|
|
277
|
+
"type": "array",
|
|
278
|
+
"items": { "type": "string" },
|
|
279
|
+
"description": "axioms used for this result"
|
|
280
|
+
},
|
|
281
|
+
"comparator_config": {
|
|
282
|
+
"type": "string",
|
|
283
|
+
"description": "path to the comparator (leanprover/comparator) JSON config that verifies this result"
|
|
284
|
+
},
|
|
285
|
+
"literature_dependencies": {
|
|
286
|
+
"type": "array",
|
|
287
|
+
"description": "results this result relies on but does not prove, assumed from the literature",
|
|
288
|
+
"items": {
|
|
289
|
+
"type": "object",
|
|
290
|
+
"properties": {
|
|
291
|
+
"statement": {
|
|
292
|
+
"type": "string",
|
|
293
|
+
"description": "the result being relied on"
|
|
294
|
+
},
|
|
295
|
+
"source": {
|
|
296
|
+
"type": "string",
|
|
297
|
+
"description": "the specific source it comes from (reference a `sources` entry)"
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
"fidelity": {
|
|
308
|
+
"type": "object",
|
|
309
|
+
"properties": {
|
|
310
|
+
"divergences": {
|
|
311
|
+
"type": "string",
|
|
312
|
+
"description": "places the formalization deviates from sources: generalizations, weakened hypotheses, renamed lemmas, etc."
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
"review": {
|
|
317
|
+
"type": "object",
|
|
318
|
+
"description": "review status",
|
|
319
|
+
"required": ["status"],
|
|
320
|
+
"properties": {
|
|
321
|
+
"status": {
|
|
322
|
+
"type": "string",
|
|
323
|
+
"minLength": 1,
|
|
324
|
+
"description": "unchecked | agent-reviewed | self-assessed | peer-reviewed | author-verified | other/freeform"
|
|
325
|
+
},
|
|
326
|
+
"reviewers": {
|
|
327
|
+
"type": "array",
|
|
328
|
+
"items": { "type": "string" }
|
|
329
|
+
},
|
|
330
|
+
"notes": {
|
|
331
|
+
"type": "string",
|
|
332
|
+
"description": "more details on the review process"
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
"alignment": {
|
|
337
|
+
"description": "freeform YAML describing how source statements map to formal declarations. The structured table in the template is only a suggested shape; replace or extend as useful."
|
|
338
|
+
},
|
|
339
|
+
"acknowledgements": {
|
|
340
|
+
"type": "string",
|
|
341
|
+
"description": "optional credits for libraries, tools, discussions, etc."
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
formalization-0.4.schema.json -- vendored copy, byte-for-byte, of
|
|
2
|
+
|
|
3
|
+
https://raw.githubusercontent.com/mathlib-initiative/formalization.yaml/main/schema/v0.4.schema.json
|
|
4
|
+
|
|
5
|
+
Repository: https://github.com/mathlib-initiative/formalization.yaml (Apache-2.0)
|
|
6
|
+
Upstream commit: 99c678e569c7c4c0772db297c5ddd5e4c9b6322e (main, 2026-08-25T17:06:01Z;
|
|
7
|
+
the last commit touching schema/v0.4.schema.json at fetch time)
|
|
8
|
+
Fetched: 2026-10-07
|
|
9
|
+
SHA-256: 25ff6b25ca4511635aff4443cf20480c15e59dddf19591c730950b442ea54fce
|
|
10
|
+
|
|
11
|
+
Upstream publishes a dispatcher, schema/formalization.schema.json, that routes on the
|
|
12
|
+
file's `version` ("v0.3" | "v0.4"; latest when unset) to this leaf schema. lean-pkg
|
|
13
|
+
emits `version: v0.4` and validates against the leaf directly, so no network and no
|
|
14
|
+
`$ref` resolution are needed. Refresh: re-download, update the commit, date and hash
|
|
15
|
+
above, and run the test suite (tests/test_formalization.py pins the hash).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/-
|
|
2
|
+
Copyright 2026 Le Chen. SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
-/
|
|
4
|
+
-- lean_pkg.claim_axioms: the Lean half. Read-only probe of a compiled environment.
|
|
5
|
+
--
|
|
6
|
+
-- Usage: LEAN_PATH=<the package's> lean --run ClaimAxioms.lean MOD [MOD ...] -- NAME [NAME ...]
|
|
7
|
+
--
|
|
8
|
+
-- Imports MOD... exactly as `import MOD` would (data only: no extension state is loaded and no
|
|
9
|
+
-- initializer runs, so Lean walks every constant body itself instead of reading axiom lists cached in
|
|
10
|
+
-- the .olean files), then runs core Lean's `collectAxioms` on every NAME and prints one line per name:
|
|
11
|
+
-- claim-axioms: NAME AX1,AX2,... (sorted; `none` when it depends on no axiom)
|
|
12
|
+
-- claim-missing: NAME (no constant of that name in the environment)
|
|
13
|
+
-- and a final `claim-axioms-done: N` line (N = the number of names). A run without that line is
|
|
14
|
+
-- incomplete; lean_pkg/claim_axioms.py refuses it. Nothing is judged here. Core Lean only.
|
|
15
|
+
import Lean
|
|
16
|
+
|
|
17
|
+
open Lean
|
|
18
|
+
|
|
19
|
+
/-- The monad `collectAxioms` needs: an environment that can be read. -/
|
|
20
|
+
abbrev ClaimAxiomsM := StateM Environment
|
|
21
|
+
|
|
22
|
+
instance : MonadEnv ClaimAxiomsM where
|
|
23
|
+
getEnv := get
|
|
24
|
+
modifyEnv f := modify f
|
|
25
|
+
|
|
26
|
+
def main (args : List String) : IO UInt32 := do
|
|
27
|
+
let mods := args.takeWhile (· != "--")
|
|
28
|
+
let names := (args.dropWhile (· != "--")).drop 1
|
|
29
|
+
if mods.isEmpty || names.isEmpty then
|
|
30
|
+
IO.eprintln "usage: lean --run ClaimAxioms.lean MOD [MOD ...] -- NAME [NAME ...]"
|
|
31
|
+
return 2
|
|
32
|
+
initSearchPath (← findSysroot)
|
|
33
|
+
let imports := mods.toArray.map fun m => ({ module := m.toName } : Import)
|
|
34
|
+
let env ← importModules imports {} (loadExts := false)
|
|
35
|
+
let mut n := 0
|
|
36
|
+
for s in names do
|
|
37
|
+
n := n + 1
|
|
38
|
+
let name := s.toName
|
|
39
|
+
if (env.find? name).isNone then
|
|
40
|
+
IO.println s!"claim-missing: {s}"
|
|
41
|
+
else
|
|
42
|
+
let (axs, _) := (collectAxioms name : ClaimAxiomsM (Array Name)).run env
|
|
43
|
+
let sorted := (axs.map toString).qsort (· < ·)
|
|
44
|
+
let shown := if sorted.isEmpty then "none" else ",".intercalate sorted.toList
|
|
45
|
+
IO.println s!"claim-axioms: {s} {shown}"
|
|
46
|
+
IO.println s!"claim-axioms-done: {n}"
|
|
47
|
+
return 0
|