@namewta/skills-hub 0.1.49 → 0.1.51
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.
- package/README.md +4 -1
- package/THIRD_PARTY_NOTICES.md +19 -7
- package/cli.mjs +2 -2
- package/install.mjs +11 -4
- package/package.json +1 -1
- package/scripts/persistence/home.md +1 -1
- package/skills/dev/dev-build/SKILL.md +2 -0
- package/skills/dev/dev-build/references/implement-request.md +7 -2
- package/skills/dev/dev-formal-verify/SKILL.md +2 -1
- package/skills/dev/dev-formal-verify/references/create-check.md +3 -1
- package/skills/dev/dev-formal-verify/references/example.md +1 -1
- package/skills/dev/dev-formal-verify/references/tool-choice.md +1 -1
- package/skills/dev/dev-help/references/capabilities.md +6 -6
- package/skills/dev/dev-help/references/guide-verification.md +7 -1
- package/skills/dev/dev-help/references/help-method.md +7 -1
- package/skills/dev/dev-issue/SKILL.md +1 -0
- package/skills/dev/dev-issue/references/github-operations.md +8 -0
- package/skills/dev/dev-plan/references/plan-template.md +1 -0
- package/skills/dev/dev-plan/references/vertical-slicing.md +2 -0
- package/skills/dev/dev-pr/references/pull-request-evidence.md +2 -0
- package/skills/dev/dev-review/references/host-parity.md +12 -0
- package/skills/dev/dev-review/references/review-baseline.md +2 -0
- package/skills/dev/dev-setup/references/formal-options.md +1 -1
- package/skills/dev/dev-statechart/SKILL.md +17 -19
- package/skills/dev/dev-statechart/agents/openai.yaml +3 -3
- package/skills/dev/dev-statechart/assets/theme.css +135 -0
- package/skills/dev/dev-statechart/references/lean-proof.md +47 -0
- package/skills/dev/dev-statechart/references/render.md +15 -83
- package/skills/dev/dev-statechart/references/runtime.md +21 -1
- package/skills/dev/dev-statechart/scripts/lean/backends/lemma-chart.mjs +285 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/mermaid.mjs +174 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/proof-chart.mjs +540 -0
- package/skills/dev/dev-statechart/scripts/lean/backends/report.mjs +242 -0
- package/skills/dev/dev-statechart/scripts/lean/frontends/facts.mjs +234 -0
- package/skills/dev/dev-statechart/scripts/lean/frontends/view.mjs +217 -0
- package/skills/dev/dev-statechart/scripts/lean/ir.mjs +226 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/attribute.mjs +148 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/blocks.mjs +32 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/budget.mjs +167 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/check.mjs +70 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/contract.mjs +160 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/fold.mjs +206 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/inline.mjs +84 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/mark.mjs +432 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/reduce.mjs +73 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/trust.mjs +111 -0
- package/skills/dev/dev-statechart/scripts/lean/passes/view-lemmas.mjs +155 -0
- package/skills/dev/dev-statechart/scripts/lean/pipeline.mjs +164 -0
- package/skills/dev/dev-statechart/scripts/lean/run.mjs +168 -0
- package/skills/dev/dev-statechart/scripts/statechart.mjs +42 -23
- package/skills/dev/dev-statechart/scripts/worker.mjs +33 -7
- package/skills/dev/dev-ui-design/SKILL.md +2 -2
- package/skills/dev/dev-ui-design/references/interaction-review.md +9 -0
- package/skills/dev/dev-verify/SKILL.md +1 -1
- package/skills/dev/dev-verify/references/evidence-storage.md +12 -0
- package/skills/dev/dev-workflow/SKILL.md +6 -6
- package/skills/dev/dev-workflow/references/method-handoffs.md +7 -1
- package/skills/dev/dev-writing/SKILL.md +2 -0
- package/skills/dev/dev-writing/references/library-docs.md +37 -0
- package/skills/home/home-doctor/references/diagnosis.md +2 -2
- package/skills/home/home-doctor/scripts/doctor.mjs +68 -38
- package/skills/home/home-project-changelog/SKILL.md +6 -6
- package/skills/home/home-project-changelog/assets/project-changelog.example.json +188 -0
- package/skills/home/home-project-changelog/assets/project-changelog.schema.json +156 -0
- package/skills/home/home-project-changelog/assets/worker-brief.md +1 -1
- package/skills/home/home-project-changelog/references/git-ranges.md +2 -2
- package/skills/home/home-project-changelog/references/schema.md +60 -0
- package/skills/home/home-project-changelog/references/tools.md +27 -22
- package/skills/home/home-project-changelog/references/workflow.md +12 -9
- package/skills/home/home-project-changelog/references/writing.md +5 -3
- package/skills/home/home-project-changelog/scripts/changelog.mjs +34 -37
- package/skills/home/home-project-changelog/scripts/contract.mjs +39 -3
- package/skills/home/home-project-changelog/scripts/legacy-markdown.mjs +116 -0
- package/skills/home/home-project-changelog/scripts/migrate.mjs +122 -0
- package/skills/home/home-project-changelog/scripts/revision.mjs +2 -196
- package/skills/home/home-project-changelog/scripts/storage.mjs +120 -125
- package/skills/home/home-project-changelog/scripts/summary.mjs +0 -60
- package/skills/home/home-route/SKILL.md +2 -2
- package/skills/home/home-route/references/routing.md +3 -1
- package/skills/home/home-route/scripts/route.mjs +79 -11
- package/skills/home/home-setup/SKILL.md +2 -1
- package/skills/home/home-setup/assets/repos.schema.json +10 -0
- package/skills/home/home-setup/references/registry.md +18 -1
- package/skills/home/home-setup/scripts/registry.mjs +67 -7
- package/skills/home/home-website/SKILL.md +13 -9
- package/skills/home/home-website/assets/website/scripts/inputs.mjs +136 -128
- package/skills/home/home-website/assets/website/scripts/render.mjs +3 -3
- package/skills/home/home-website/assets/website/scripts/site.mjs +21 -10
- package/skills/home/home-website/assets/website/site/public/home-assets/app.js +69 -23
- package/skills/home/home-website/assets/website/site/public/home-assets/site.css +74 -42
- package/skills/home/home-website/assets/website/site/templates/layout.mjs +2 -6
- package/skills/home/home-website/assets/website/site/templates/ledger.mjs +33 -24
- package/skills/home/home-website/assets/website/site/templates/model.mjs +28 -5
- package/skills/home/home-website/assets/website/site/templates/pages.mjs +48 -19
- package/skills/home/home-website/assets/website/site/templates/project-logs.mjs +2 -107
- package/skills/home/home-website/assets/website/site.config.json +1 -1
- package/skills/home/home-website/references/website.md +64 -46
- package/skills/home/home-website/scripts/activate.mjs +105 -0
- package/skills/home/home-website/scripts/init.mjs +79 -11
- package/skills/home/home-workflow/SKILL.md +6 -4
- package/skills/system/system-clash-proxy-config/SKILL.md +21 -0
- package/skills/system/system-clash-proxy-config/agents/openai.yaml +4 -0
- package/skills/system/system-clash-proxy-config/assets/clash-override.js +328 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/browser-privacy.md +2 -2
- package/skills/system/{system-config → system-clash-proxy-config}/references/changes.md +2 -2
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/clash-verge.md +1 -1
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/diagnosis.md +1 -1
- package/skills/system/system-clash-proxy-config/references/dns-workflow.md +42 -0
- package/skills/system/system-clash-proxy-config/references/egress-macos.md +31 -0
- package/skills/system/system-clash-proxy-config/references/egress-windows.md +37 -0
- package/skills/system/system-clash-proxy-config/references/egress.md +12 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/flclash.md +1 -1
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/index.md +1 -1
- package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/linux-cutover.md +29 -0
- package/skills/system/system-clash-proxy-config/references/locale-workflow.md +9 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/mihomo.md +1 -25
- package/skills/system/system-clash-proxy-config/references/session.md +34 -0
- package/skills/system/system-clash-proxy-config/references/subscription.md +29 -0
- package/skills/system/{system-proxy → system-clash-proxy-config}/references/troubleshooting.md +7 -7
- package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/verification.md +2 -0
- package/skills/system/system-clash-proxy-config/scripts/prepare-session.mjs +155 -0
- package/skills/system/system-clash-proxy-config/scripts/run-session.mjs +138 -0
- package/skills/system/system-inspect/SKILL.md +1 -1
- package/skills/system/system-inspect/references/health-audit.md +1 -1
- package/upstream-skills/zh-archify/SKILL.md +11 -11
- package/upstream-skills/zh-archify/assets/template.html +6 -3
- package/upstream-skills/zh-archify/bin/archify.mjs +67 -4
- package/upstream-skills/zh-archify/modules/code-analysis/ARCHITECTURE.md +7 -1
- package/upstream-skills/zh-archify/modules/code-analysis/bin/analyze-run.mjs +2 -1
- package/upstream-skills/zh-archify/modules/code-analysis/bin/check.mjs +29 -15
- package/upstream-skills/zh-archify/modules/code-analysis/bin/drift.mjs +3 -3
- package/upstream-skills/zh-archify/modules/code-analysis/bin/prepare.mjs +5 -6
- package/upstream-skills/zh-archify/modules/code-analysis/bin/serve.mjs +66 -36
- package/upstream-skills/zh-archify/modules/code-analysis/bin/verify-change.mjs +43 -13
- package/upstream-skills/zh-archify/modules/code-analysis/docs/TECH-GUIDE.md +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/docs/USAGE.md +37 -4
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/functions.mjs +7 -5
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/index.mjs +4 -1
- package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/snapshot-host.mjs +9 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/architecture-drift.mjs +28 -7
- package/upstream-skills/zh-archify/modules/code-analysis/lib/drift-capture.mjs +4 -3
- package/upstream-skills/zh-archify/modules/code-analysis/lib/git-sources.mjs +5 -3
- package/upstream-skills/zh-archify/modules/code-analysis/lib/output.mjs +272 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/pull-request.mjs +34 -4
- package/upstream-skills/zh-archify/modules/code-analysis/lib/task.mjs +4 -2
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification-context.mjs +13 -1
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification-history.mjs +112 -0
- package/upstream-skills/zh-archify/modules/code-analysis/lib/verification.mjs +6 -2
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/atlas.mjs +71 -5
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas.css +16 -2
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas.js +121 -5
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas3d.js +38 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/overlay.css +14 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/overlay.js +187 -27
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/verification.js +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/i18n.mjs +9 -0
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/inject.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/page.mjs +11 -6
- package/upstream-skills/zh-archify/modules/code-analysis/overlay/pull-request.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/schemas/ai-task.schema.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/atlas.test.mjs +88 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/duplicates.test.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/external-workflow.test.mjs +1 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/boundary.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/boundary.task.missing.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/complexity.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/complexity.task.valid.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/import-cycle.task.changed.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/import-cycle.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/module-cycle.task.json +1 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/function-source-range.test.mjs +10 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/output-recovery.test.mjs +626 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/pull-request.test.mjs +98 -2
- package/upstream-skills/zh-archify/modules/code-analysis/test/review.test.mjs +37 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/source-panel.test.mjs +2 -1
- package/upstream-skills/zh-archify/modules/code-analysis/test/task.test.mjs +3 -2
- package/upstream-skills/zh-archify/modules/code-analysis/test/verification-history.test.mjs +216 -0
- package/upstream-skills/zh-archify/modules/code-analysis/test/verification.test.mjs +122 -0
- package/upstream-skills/zh-archify/package-lock.json +2 -2
- package/upstream-skills/zh-archify/package.json +1 -1
- package/upstream-skills/zh-archify/references/authoring-contract.md +2 -0
- package/upstream-skills/zh-archify/references/explainer-authoring.md +1 -1
- package/upstream-skills/zh-archify/renderers/architecture/render-architecture.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/class/render-class.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/dataflow/render-dataflow.mjs +2 -1
- package/upstream-skills/zh-archify/renderers/erd/render-erd.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/lifecycle/render-lifecycle.mjs +4 -2
- package/upstream-skills/zh-archify/renderers/sequence/render-sequence.mjs +4 -2
- package/upstream-skills/zh-archify/renderers/shared/cli.mjs +7 -1
- package/upstream-skills/zh-archify/renderers/timeline/render-timeline.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/tree/render-tree.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/waterfall/render-waterfall.mjs +1 -0
- package/upstream-skills/zh-archify/renderers/workflow/render-workflow.mjs +3 -2
- package/upstream-skills/zh-archify/renderers/workflow/workflow-compiler.mjs +68 -7
- package/upstream-skills/zh-archify/skill-release.json +1 -1
- package/upstream-skills/zh-modern-web-guidance/SKILL.md +4 -11
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/language-detection.md +20 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/language-model.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/prompt-api.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/summarizer.md +20 -0
- package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/translator.md +22 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/custom-ml-model-inference.md +342 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/data-parallel-computation.md +337 -0
- package/upstream-skills/zh-modern-web-guidance/guides/performance/improve-next-page-load-performance.md +4 -1
- package/upstream-skills/zh-modern-web-guidance/guides/performance/large-scene-rendering.md +350 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-atoms/position-aware-tooltips.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-atoms/viewport-aware-dropdowns.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/animate-to-from-top-layer.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/declarative-dialog-popover-control.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/scroll-target-on-load.md +29 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/sortable-table.md +1 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/app-menus.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/context-menu.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/copy-button.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/dialog.md +10 -1
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/hovercard.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/menu.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/navbar.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/persistent-app-tours.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/persistent-toast-notifications.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/ui-components/toolbar.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/user-experience/content-first-noise-reduction.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/user-experience/natural-interactions.md +9 -0
- package/upstream-skills/zh-modern-web-guidance/guides/webmcp/agentic-javascript-tools.md +27 -0
- package/skills/home/home-project-changelog/assets/project-changelog.md +0 -35
- package/skills/system/system-clash-tun-egress/SKILL.md +0 -22
- package/skills/system/system-clash-tun-egress/agents/openai.yaml +0 -4
- package/skills/system/system-config/SKILL.md +0 -37
- package/skills/system/system-config/agents/openai.yaml +0 -4
- package/skills/system/system-config/references/ai-cli-config.md +0 -75
- package/skills/system/system-config/references/ai-cli-optimization.md +0 -37
- package/skills/system/system-config/references/index.md +0 -12
- package/skills/system/system-config/references/locale-workflow.md +0 -33
- package/skills/system/system-config/references/locale.md +0 -50
- package/skills/system/system-proxy/SKILL.md +0 -40
- package/skills/system/system-proxy/agents/openai.yaml +0 -4
- package/skills/system/system-proxy/assets/protected-rules.yaml +0 -7
- package/skills/system/system-proxy/references/dns-workflow.md +0 -152
- /package/skills/system/{system-config → system-clash-proxy-config}/assets/configuration.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/assets/network.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/acceptance.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/dns-fields.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/dns-misconceptions.md +0 -0
- /package/skills/system/{system-clash-tun-egress/references/troubleshooting.md → system-clash-proxy-config/references/egress-troubleshooting.md} +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-linux.md +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-macos.md +0 -0
- /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-windows.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/network-performance.md +0 -0
- /package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/nodes-and-dns.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/platform-dns.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/platforms.md +0 -0
- /package/skills/system/{system-proxy → system-clash-proxy-config}/references/tun-dns.md +0 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
export const FORMAT_VERSION = 1;
|
|
2
|
+
export const SUPPORTED_LEAN = "v4.34.1";
|
|
3
|
+
export const STANDARD_AXIOMS = ["propext", "Classical.choice", "Quot.sound"];
|
|
4
|
+
export const COMPILER_AXIOMS = [
|
|
5
|
+
"Lean.ofReduceBool",
|
|
6
|
+
"Lean.ofReduceNat",
|
|
7
|
+
"Lean.trustCompiler",
|
|
8
|
+
];
|
|
9
|
+
export const LEMMA_NODES = 60;
|
|
10
|
+
export const PROOF_BLOCKS = 40;
|
|
11
|
+
export const BLOCK_LINES = 8;
|
|
12
|
+
export const BLOCK_HYPS = 3;
|
|
13
|
+
export const LINE_WIDTH = 64;
|
|
14
|
+
export const DECL_KINDS = [
|
|
15
|
+
"theorem",
|
|
16
|
+
"axiom",
|
|
17
|
+
"def",
|
|
18
|
+
"opaque",
|
|
19
|
+
"inductive",
|
|
20
|
+
"constructor",
|
|
21
|
+
"recursor",
|
|
22
|
+
"quot",
|
|
23
|
+
];
|
|
24
|
+
export const leanViewChecked = Symbol("leanViewChecked");
|
|
25
|
+
const STANDARD_SET = new Set(STANDARD_AXIOMS);
|
|
26
|
+
const COMPILER_SET = new Set(COMPILER_AXIOMS);
|
|
27
|
+
const NATIVE_AXIOM_RE = /(?:^|\.)_native\.[^.]+\.ax(?:_\d+)?$/;
|
|
28
|
+
const STANDARD_CASE_TAGS = {
|
|
29
|
+
mp: "正向",
|
|
30
|
+
mpr: "反向",
|
|
31
|
+
inl: "左分支",
|
|
32
|
+
inr: "右分支",
|
|
33
|
+
zero: "基础情形",
|
|
34
|
+
succ: "归纳步骤",
|
|
35
|
+
nil: "空列表",
|
|
36
|
+
cons: "非空列表",
|
|
37
|
+
true: "为真时",
|
|
38
|
+
false: "为假时",
|
|
39
|
+
};
|
|
40
|
+
export const byText = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
41
|
+
export const list = (items, join = "and") =>
|
|
42
|
+
items.length <= 2
|
|
43
|
+
? items.join(` ${join} `)
|
|
44
|
+
: `${items.slice(0, -1).join(", ")}, ${join} ${items[items.length - 1]}`;
|
|
45
|
+
export const isStandardAxiom = (name) => STANDARD_SET.has(name);
|
|
46
|
+
export const isCompilerAxiom = (name) => COMPILER_SET.has(name);
|
|
47
|
+
export const isNativeAxiom = (name) =>
|
|
48
|
+
COMPILER_SET.has(name) || NATIVE_AXIOM_RE.test(name);
|
|
49
|
+
export const isSyntheticNativeAx = (name) => NATIVE_AXIOM_RE.test(name);
|
|
50
|
+
export const sortUnique = (items) => [...new Set(items)].sort(byText);
|
|
51
|
+
export const must = (map, key) => {
|
|
52
|
+
const value = map.get(key);
|
|
53
|
+
if (value === undefined) throw new Error(`找不到键 ${String(key)}。`);
|
|
54
|
+
return value;
|
|
55
|
+
};
|
|
56
|
+
export const append = (map, key, value) => {
|
|
57
|
+
const listValue = map.get(key);
|
|
58
|
+
if (listValue) listValue.push(value);
|
|
59
|
+
else map.set(key, [value]);
|
|
60
|
+
};
|
|
61
|
+
export const edgeKey = (edge) => `${edge.from}\0${edge.to}`;
|
|
62
|
+
export const shortName = (name) => {
|
|
63
|
+
const parts = name.split(".");
|
|
64
|
+
return parts[parts.length - 1] ?? name;
|
|
65
|
+
};
|
|
66
|
+
export const firstSentence = (doc) => {
|
|
67
|
+
const clean = doc.replace(/\s+/g, " ").trim();
|
|
68
|
+
const match = clean.match(/^(.+?[.!?])(?:\s|$)/);
|
|
69
|
+
return match ? match[1] : clean;
|
|
70
|
+
};
|
|
71
|
+
export const clipLine = (text, width = LINE_WIDTH) => {
|
|
72
|
+
const clean = text.replace(/\s+/g, " ").trim();
|
|
73
|
+
const points = Array.from(clean);
|
|
74
|
+
if (points.length <= width) return clean;
|
|
75
|
+
const maxContent = Math.max(1, width - 1);
|
|
76
|
+
if (points[maxContent] === " ") {
|
|
77
|
+
return `${points
|
|
78
|
+
.slice(0, maxContent)
|
|
79
|
+
.join("")
|
|
80
|
+
.replace(/[,:;([-]+$/, "")
|
|
81
|
+
.trimEnd()}…`;
|
|
82
|
+
}
|
|
83
|
+
const slice = points.slice(0, maxContent);
|
|
84
|
+
const lastSpace = slice.lastIndexOf(" ");
|
|
85
|
+
if (lastSpace > 0) {
|
|
86
|
+
return `${slice
|
|
87
|
+
.slice(0, lastSpace)
|
|
88
|
+
.join("")
|
|
89
|
+
.replace(/[,:;([-]+$/, "")
|
|
90
|
+
.trimEnd()}…`;
|
|
91
|
+
}
|
|
92
|
+
return `${slice.join("")}…`;
|
|
93
|
+
};
|
|
94
|
+
export const summarizeDoc = (doc, width = LINE_WIDTH) => {
|
|
95
|
+
const clean = firstSentence(doc)
|
|
96
|
+
.replaceAll("`", "")
|
|
97
|
+
.replace(/\s+/g, " ")
|
|
98
|
+
.trim();
|
|
99
|
+
const points = Array.from(clean);
|
|
100
|
+
if (points.length <= width) return clean;
|
|
101
|
+
const colonAt = clean.indexOf(": ");
|
|
102
|
+
if (colonAt >= 0) {
|
|
103
|
+
const prefix = clean.slice(0, colonAt).trimEnd();
|
|
104
|
+
const prefixLen = Array.from(prefix).length;
|
|
105
|
+
if (prefixLen >= 12 && prefixLen <= width) return prefix;
|
|
106
|
+
}
|
|
107
|
+
return clipLine(clean, width);
|
|
108
|
+
};
|
|
109
|
+
export const stripCasePrefix = (input) => {
|
|
110
|
+
let best = input.rawTag;
|
|
111
|
+
let longest = -1;
|
|
112
|
+
for (const anc of input.ancestorTags) {
|
|
113
|
+
if (!anc) continue;
|
|
114
|
+
const prefix = `${anc}.`;
|
|
115
|
+
if (input.rawTag.startsWith(prefix) && prefix.length > longest) {
|
|
116
|
+
longest = prefix.length;
|
|
117
|
+
best = input.rawTag.slice(prefix.length);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return best;
|
|
121
|
+
};
|
|
122
|
+
export const humanCaseTag = (tag) =>
|
|
123
|
+
tag
|
|
124
|
+
.split(".")
|
|
125
|
+
.map((segment) => Object.hasOwn(STANDARD_CASE_TAGS, segment) ? STANDARD_CASE_TAGS[segment] : segment)
|
|
126
|
+
.join(" / ");
|
|
127
|
+
export const formatPlace = (at) => (at ? `${at.line}:${at.column}` : "");
|
|
128
|
+
export const placeLeq = (a, b) =>
|
|
129
|
+
a.line < b.line || (a.line === b.line && a.column <= b.column);
|
|
130
|
+
export const spanContainsPlace = (span, at) =>
|
|
131
|
+
placeLeq(
|
|
132
|
+
{
|
|
133
|
+
line: span.line,
|
|
134
|
+
column: span.column,
|
|
135
|
+
},
|
|
136
|
+
at,
|
|
137
|
+
) &&
|
|
138
|
+
placeLeq(at, {
|
|
139
|
+
line: span.endLine,
|
|
140
|
+
column: span.endColumn,
|
|
141
|
+
});
|
|
142
|
+
export const spanContainsSpan = (outer, inner) =>
|
|
143
|
+
placeLeq(
|
|
144
|
+
{
|
|
145
|
+
line: outer.line,
|
|
146
|
+
column: outer.column,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
line: inner.line,
|
|
150
|
+
column: inner.column,
|
|
151
|
+
},
|
|
152
|
+
) &&
|
|
153
|
+
placeLeq(
|
|
154
|
+
{
|
|
155
|
+
line: inner.endLine,
|
|
156
|
+
column: inner.endColumn,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
line: outer.endLine,
|
|
160
|
+
column: outer.endColumn,
|
|
161
|
+
},
|
|
162
|
+
);
|
|
163
|
+
export const spanStrictlyInside = (outer, inner) =>
|
|
164
|
+
spanContainsSpan(outer, inner) &&
|
|
165
|
+
(outer.line !== inner.line ||
|
|
166
|
+
outer.column !== inner.column ||
|
|
167
|
+
outer.endLine !== inner.endLine ||
|
|
168
|
+
outer.endColumn !== inner.endColumn);
|
|
169
|
+
export const spanSize = (span) =>
|
|
170
|
+
(span.endLine - span.line) * 10000 + (span.endColumn - span.column);
|
|
171
|
+
export const hasSubtreeMark = (block) => {
|
|
172
|
+
if (block.marks.size > 0) return true;
|
|
173
|
+
for (const child of block.into) {
|
|
174
|
+
if (hasSubtreeMark(child)) return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
};
|
|
178
|
+
export const trustStatusOf = (input) => {
|
|
179
|
+
if (input.own.some((d) => d.kind === "error")) return "error";
|
|
180
|
+
if (input.own.some((d) => d.kind === "sorry")) return "sorry";
|
|
181
|
+
if (input.own.some((d) => d.kind === "native")) return "native";
|
|
182
|
+
if (input.own.some((d) => d.kind === "axiom")) return "axiom";
|
|
183
|
+
if (input.below.length > 0) return "restsOn";
|
|
184
|
+
return "clean";
|
|
185
|
+
};
|
|
186
|
+
export const branchStatusOf = (marks) => {
|
|
187
|
+
if (marks.has("error")) return "error";
|
|
188
|
+
if (marks.has("sorry")) return "sorry";
|
|
189
|
+
if (marks.has("open")) return "open";
|
|
190
|
+
if (marks.has("restsOn")) return "restsOn";
|
|
191
|
+
return "clean";
|
|
192
|
+
};
|
|
193
|
+
export const doubtKey = (d) => {
|
|
194
|
+
switch (d.kind) {
|
|
195
|
+
case "sorry":
|
|
196
|
+
case "error":
|
|
197
|
+
return `${d.kind}\0${d.in}\0${d.at ? `${d.at.line}:${d.at.column}` : ""}`;
|
|
198
|
+
case "axiom":
|
|
199
|
+
case "native":
|
|
200
|
+
return `${d.kind}\0${d.name}`;
|
|
201
|
+
default: {
|
|
202
|
+
const _exhaustive = d;
|
|
203
|
+
return _exhaustive;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export const formatDoubt = (d) => {
|
|
208
|
+
switch (d.kind) {
|
|
209
|
+
case "sorry":
|
|
210
|
+
return d.at
|
|
211
|
+
? `${d.in} 有未证缺口(sorry) (${d.at.line}:${d.at.column})`
|
|
212
|
+
: `${d.in} 有未证缺口(sorry)`;
|
|
213
|
+
case "error":
|
|
214
|
+
return d.at
|
|
215
|
+
? `${d.in} 有失败步骤 (${d.at.line}:${d.at.column})`
|
|
216
|
+
: `${d.in} 有失败步骤`;
|
|
217
|
+
case "native":
|
|
218
|
+
return `未经内核核验的原生计算(${d.name})`;
|
|
219
|
+
case "axiom":
|
|
220
|
+
return `自定义公理 ${d.name}`;
|
|
221
|
+
default: {
|
|
222
|
+
const _exhaustive = d;
|
|
223
|
+
return _exhaustive;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const dedupe = (items) => {
|
|
2
|
+
const seen = new Set();
|
|
3
|
+
const out = [];
|
|
4
|
+
for (const id of items) {
|
|
5
|
+
if (seen.has(id)) continue;
|
|
6
|
+
seen.add(id);
|
|
7
|
+
out.push(id);
|
|
8
|
+
}
|
|
9
|
+
return out;
|
|
10
|
+
};
|
|
11
|
+
export function attribute(script) {
|
|
12
|
+
const goalById = new Map();
|
|
13
|
+
for (const g of script.goals) goalById.set(g.id, g);
|
|
14
|
+
const rootSet = new Set(script.roots.map((r) => r.goal));
|
|
15
|
+
const closes = new Map();
|
|
16
|
+
const notes = [];
|
|
17
|
+
const isGone = (id) => goalById.get(id)?.final === "gone";
|
|
18
|
+
const walk = (ev) => {
|
|
19
|
+
const belowClosed = new Set();
|
|
20
|
+
const belowOpened = new Set();
|
|
21
|
+
const childEnteredRaw = [];
|
|
22
|
+
for (const child of ev.children) {
|
|
23
|
+
const sub = walk(child);
|
|
24
|
+
for (const g of sub.closed) belowClosed.add(g);
|
|
25
|
+
for (const g of sub.opened) belowOpened.add(g);
|
|
26
|
+
for (const g of sub.entered) childEnteredRaw.push(g);
|
|
27
|
+
}
|
|
28
|
+
const afterSet = new Set(ev.after);
|
|
29
|
+
for (const g of ev.after) {
|
|
30
|
+
if (belowClosed.has(g)) {
|
|
31
|
+
belowClosed.delete(g);
|
|
32
|
+
closes.delete(g);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const childRoots = dedupe(childEnteredRaw).filter(
|
|
36
|
+
(g) => !belowOpened.has(g) && !isGone(g) && !afterSet.has(g),
|
|
37
|
+
);
|
|
38
|
+
const assignedSet = new Set(ev.assigned);
|
|
39
|
+
const beforeRank = new Map();
|
|
40
|
+
for (const [i, g] of ev.before.entries()) {
|
|
41
|
+
if (!beforeRank.has(g)) beforeRank.set(g, i);
|
|
42
|
+
}
|
|
43
|
+
const declaredSet = new Set(ev.declared);
|
|
44
|
+
const reachMap = new Map();
|
|
45
|
+
for (const [from, tos] of ev.reach) reachMap.set(from, tos);
|
|
46
|
+
const hasGoneReach = (g) => (reachMap.get(g) ?? []).some(isGone);
|
|
47
|
+
const mine = dedupe(ev.assigned)
|
|
48
|
+
.filter(
|
|
49
|
+
(g) =>
|
|
50
|
+
!declaredSet.has(g) &&
|
|
51
|
+
!belowClosed.has(g) &&
|
|
52
|
+
!afterSet.has(g) &&
|
|
53
|
+
!isGone(g) &&
|
|
54
|
+
!hasGoneReach(g),
|
|
55
|
+
)
|
|
56
|
+
.sort((a, b) => {
|
|
57
|
+
const ra = beforeRank.get(a) ?? Number.MAX_SAFE_INTEGER;
|
|
58
|
+
const rb = beforeRank.get(b) ?? Number.MAX_SAFE_INTEGER;
|
|
59
|
+
return ra - rb;
|
|
60
|
+
});
|
|
61
|
+
const mineSet = new Set(mine);
|
|
62
|
+
const openedNow = new Set();
|
|
63
|
+
if (mine.length > 0) {
|
|
64
|
+
const poolRaw = [...childRoots, ...ev.after];
|
|
65
|
+
for (const g of mine) {
|
|
66
|
+
const rs = reachMap.get(g);
|
|
67
|
+
if (rs) {
|
|
68
|
+
for (const c of rs) poolRaw.push(c);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const pool = dedupe(poolRaw).filter(
|
|
72
|
+
(c) =>
|
|
73
|
+
declaredSet.has(c) &&
|
|
74
|
+
!mineSet.has(c) &&
|
|
75
|
+
!rootSet.has(c) &&
|
|
76
|
+
!belowOpened.has(c) &&
|
|
77
|
+
!isGone(c),
|
|
78
|
+
);
|
|
79
|
+
const claimed = new Set();
|
|
80
|
+
const opensByGoal = new Map();
|
|
81
|
+
for (const g of mine) {
|
|
82
|
+
const reach = reachMap.get(g);
|
|
83
|
+
const opens = [];
|
|
84
|
+
if (reach !== undefined) {
|
|
85
|
+
const reachSet = new Set(reach);
|
|
86
|
+
for (const c of pool) {
|
|
87
|
+
if (reachSet.has(c) && !claimed.has(c) && c !== g) {
|
|
88
|
+
claimed.add(c);
|
|
89
|
+
opens.push(c);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} else if (mine.length === 1) {
|
|
93
|
+
for (const c of pool) {
|
|
94
|
+
if (!claimed.has(c) && c !== g) {
|
|
95
|
+
claimed.add(c);
|
|
96
|
+
opens.push(c);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
opensByGoal.set(g, opens);
|
|
101
|
+
}
|
|
102
|
+
const unclaimed = pool.filter((c) => !claimed.has(c));
|
|
103
|
+
if (unclaimed.length > 0) {
|
|
104
|
+
const owner = mine[0];
|
|
105
|
+
const list = opensByGoal.get(owner) ?? [];
|
|
106
|
+
for (const c of unclaimed) {
|
|
107
|
+
if (c === owner) continue;
|
|
108
|
+
claimed.add(c);
|
|
109
|
+
list.push(c);
|
|
110
|
+
}
|
|
111
|
+
opensByGoal.set(owner, list);
|
|
112
|
+
if (reachMap.size > 0 && mine.length > 1) {
|
|
113
|
+
notes.push(
|
|
114
|
+
`步骤 ${ev.step} 将 ${unclaimed.length} 个未归属的子目标按回退规则连接到目标 ${owner}。`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
for (const g of mine) {
|
|
119
|
+
const opens = opensByGoal.get(g) ?? [];
|
|
120
|
+
closes.set(g, {
|
|
121
|
+
step: ev.step,
|
|
122
|
+
opens,
|
|
123
|
+
});
|
|
124
|
+
for (const c of opens) openedNow.add(c);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const closed = new Set(belowClosed);
|
|
128
|
+
for (const g of mine) closed.add(g);
|
|
129
|
+
const opened = new Set(belowOpened);
|
|
130
|
+
for (const g of openedNow) opened.add(g);
|
|
131
|
+
const entered = dedupe([...mine, ...childRoots, ...ev.before]).filter(
|
|
132
|
+
(g) =>
|
|
133
|
+
!opened.has(g) &&
|
|
134
|
+
(assignedSet.has(g) || closed.has(g) || ev.before.includes(g)),
|
|
135
|
+
);
|
|
136
|
+
return {
|
|
137
|
+
closed,
|
|
138
|
+
opened,
|
|
139
|
+
entered,
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
for (const ev of script.events) walk(ev);
|
|
143
|
+
return {
|
|
144
|
+
roots: script.roots,
|
|
145
|
+
closes,
|
|
146
|
+
notes,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function buildBlocks(tree) {
|
|
2
|
+
const buildFrom = (entry) => {
|
|
3
|
+
const steps = [];
|
|
4
|
+
let cur = entry;
|
|
5
|
+
let into = [];
|
|
6
|
+
for (;;) {
|
|
7
|
+
const close = tree.closes.get(cur);
|
|
8
|
+
if (!close) break;
|
|
9
|
+
steps.push(close.step);
|
|
10
|
+
if (close.opens.length === 0) break;
|
|
11
|
+
if (close.opens.length === 1) {
|
|
12
|
+
cur = close.opens[0];
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
into = close.opens.map((childGoal) => buildFrom(childGoal));
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
entry,
|
|
20
|
+
steps,
|
|
21
|
+
inlined: new Map(),
|
|
22
|
+
errorLabel: undefined,
|
|
23
|
+
last: cur,
|
|
24
|
+
into,
|
|
25
|
+
marks: new Set(),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
return tree.roots.map((root) => ({
|
|
29
|
+
root,
|
|
30
|
+
block: buildFrom(root.goal),
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { byText, hasSubtreeMark, LEMMA_NODES, PROOF_BLOCKS } from "../ir.mjs";
|
|
2
|
+
export function budgetLemmas(input) {
|
|
3
|
+
const { graph, trust, limit = LEMMA_NODES } = input;
|
|
4
|
+
const kept = new Set([graph.target]);
|
|
5
|
+
for (const entry of trust.paths) {
|
|
6
|
+
for (const node of entry.path) kept.add(node);
|
|
7
|
+
}
|
|
8
|
+
const parent = new Map([[graph.target, undefined]]);
|
|
9
|
+
const bfsOrder = [graph.target];
|
|
10
|
+
for (let i = 0; i < bfsOrder.length; i++) {
|
|
11
|
+
const cur = bfsOrder[i];
|
|
12
|
+
const lemma = graph.lemmas.get(cur);
|
|
13
|
+
if (!lemma) continue;
|
|
14
|
+
for (const next of lemma.to.map((e) => e.name).sort(byText)) {
|
|
15
|
+
if (parent.has(next)) continue;
|
|
16
|
+
parent.set(next, cur);
|
|
17
|
+
bfsOrder.push(next);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
for (const [name, ownDoubts] of trust.own) {
|
|
21
|
+
if (ownDoubts.length === 0 || !parent.has(name)) continue;
|
|
22
|
+
let cur = name;
|
|
23
|
+
while (cur !== undefined) {
|
|
24
|
+
kept.add(cur);
|
|
25
|
+
cur = parent.get(cur);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let frontier = [graph.target];
|
|
29
|
+
const visited = new Set([graph.target]);
|
|
30
|
+
while (frontier.length > 0 && kept.size < limit) {
|
|
31
|
+
const nextLevel = new Set();
|
|
32
|
+
for (const node of frontier) {
|
|
33
|
+
const lemma = graph.lemmas.get(node);
|
|
34
|
+
if (!lemma) continue;
|
|
35
|
+
for (const edge of lemma.to) {
|
|
36
|
+
if (!visited.has(edge.name)) nextLevel.add(edge.name);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const sorted = [...nextLevel].sort(byText);
|
|
40
|
+
for (const node of sorted) {
|
|
41
|
+
visited.add(node);
|
|
42
|
+
if (kept.size < limit) kept.add(node);
|
|
43
|
+
}
|
|
44
|
+
frontier = sorted;
|
|
45
|
+
}
|
|
46
|
+
const hidden = new Map();
|
|
47
|
+
for (const node of kept) {
|
|
48
|
+
const lemma = graph.lemmas.get(node);
|
|
49
|
+
if (!lemma) continue;
|
|
50
|
+
let cutChildren = 0;
|
|
51
|
+
for (const edge of lemma.to) {
|
|
52
|
+
if (!kept.has(edge.name)) cutChildren++;
|
|
53
|
+
}
|
|
54
|
+
if (cutChildren > 0) hidden.set(node, cutChildren);
|
|
55
|
+
}
|
|
56
|
+
const total = graph.lemmas.size;
|
|
57
|
+
return {
|
|
58
|
+
graph,
|
|
59
|
+
kept,
|
|
60
|
+
hidden,
|
|
61
|
+
total,
|
|
62
|
+
cut: Math.max(0, total - kept.size),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function countBlocks(node) {
|
|
66
|
+
let total = 1;
|
|
67
|
+
for (const child of node.into) total += countBlocks(child);
|
|
68
|
+
return total;
|
|
69
|
+
}
|
|
70
|
+
function summarizeSubtree(node) {
|
|
71
|
+
if (node.hidden)
|
|
72
|
+
return {
|
|
73
|
+
steps: node.hidden.steps,
|
|
74
|
+
cases: node.hidden.cases,
|
|
75
|
+
};
|
|
76
|
+
if (node.into.length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
steps: node.steps.length * node.times,
|
|
79
|
+
cases: node.times,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
let steps = node.steps.length * node.times;
|
|
83
|
+
let cases = 0;
|
|
84
|
+
for (const child of node.into) {
|
|
85
|
+
const sub = summarizeSubtree(child);
|
|
86
|
+
steps += sub.steps * node.times;
|
|
87
|
+
cases += sub.cases * node.times;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
steps,
|
|
91
|
+
cases,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function cloneDrawn(node) {
|
|
95
|
+
return {
|
|
96
|
+
...node,
|
|
97
|
+
steps: [...node.steps],
|
|
98
|
+
inlined: new Map(node.inlined),
|
|
99
|
+
marks: new Set(node.marks),
|
|
100
|
+
restsOnKinds: node.restsOnKinds ? new Set(node.restsOnKinds) : undefined,
|
|
101
|
+
tags: [...node.tags],
|
|
102
|
+
differentGoals: node.differentGoals,
|
|
103
|
+
foldedEntries: node.foldedEntries.map((e) => ({
|
|
104
|
+
...e,
|
|
105
|
+
steps: [...e.steps],
|
|
106
|
+
inlined: new Map(e.inlined),
|
|
107
|
+
})),
|
|
108
|
+
hidden: node.hidden
|
|
109
|
+
? {
|
|
110
|
+
...node.hidden,
|
|
111
|
+
}
|
|
112
|
+
: undefined,
|
|
113
|
+
into: node.into.map(cloneDrawn),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function collectCandidates(node, depth, out) {
|
|
117
|
+
for (let i = 0; i < node.into.length; i++) {
|
|
118
|
+
const child = node.into[i];
|
|
119
|
+
if (child.hidden !== undefined) continue;
|
|
120
|
+
if (!hasSubtreeMark(child) && child.errorLabel === undefined) {
|
|
121
|
+
const size = countBlocks(child);
|
|
122
|
+
if (size > 1) {
|
|
123
|
+
out.push({
|
|
124
|
+
parent: node,
|
|
125
|
+
index: i,
|
|
126
|
+
size,
|
|
127
|
+
depth: depth + 1,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
collectCandidates(child, depth + 1, out);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export function budgetBlocks(input) {
|
|
135
|
+
const { limit = PROOF_BLOCKS } = input;
|
|
136
|
+
const roots = input.roots.map(({ root, block }) => ({
|
|
137
|
+
root,
|
|
138
|
+
block: cloneDrawn(block),
|
|
139
|
+
}));
|
|
140
|
+
const totalBlocks = roots.reduce((sum, r) => sum + countBlocks(r.block), 0);
|
|
141
|
+
let shownBlocks = totalBlocks;
|
|
142
|
+
while (shownBlocks > limit) {
|
|
143
|
+
const candidates = [];
|
|
144
|
+
for (const r of roots) collectCandidates(r.block, 0, candidates);
|
|
145
|
+
if (candidates.length === 0) break;
|
|
146
|
+
candidates.sort(
|
|
147
|
+
(a, b) => b.size - a.size || b.depth - a.depth || b.index - a.index,
|
|
148
|
+
);
|
|
149
|
+
const pick = candidates[0];
|
|
150
|
+
const target = pick.parent.into[pick.index];
|
|
151
|
+
const summary = summarizeSubtree(target);
|
|
152
|
+
pick.parent.into[pick.index] = {
|
|
153
|
+
...target,
|
|
154
|
+
steps: [],
|
|
155
|
+
inlined: new Map(),
|
|
156
|
+
into: [],
|
|
157
|
+
hidden: summary,
|
|
158
|
+
};
|
|
159
|
+
shownBlocks -= pick.size - 1;
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
roots,
|
|
163
|
+
totalBlocks,
|
|
164
|
+
shownBlocks,
|
|
165
|
+
hiddenBlocks: Math.max(0, totalBlocks - shownBlocks),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { byText } from "../ir.mjs";
|
|
2
|
+
export function checkAxioms(input) {
|
|
3
|
+
const { facts, graph } = input;
|
|
4
|
+
const drawn = new Set();
|
|
5
|
+
const seen = new Set();
|
|
6
|
+
const stack = [graph.target];
|
|
7
|
+
while (stack.length > 0) {
|
|
8
|
+
const name = stack.pop();
|
|
9
|
+
if (seen.has(name)) continue;
|
|
10
|
+
seen.add(name);
|
|
11
|
+
const lemma = graph.lemmas.get(name);
|
|
12
|
+
if (!lemma) continue;
|
|
13
|
+
if (lemma.decl.kind === "axiom") drawn.add(lemma.decl.name);
|
|
14
|
+
for (const ax of lemma.axioms) drawn.add(ax);
|
|
15
|
+
for (const edge of lemma.to) stack.push(edge.name);
|
|
16
|
+
}
|
|
17
|
+
const expected = new Set(facts.axioms);
|
|
18
|
+
const missing = [...expected].filter((ax) => !drawn.has(ax)).sort(byText);
|
|
19
|
+
const extra = [...drawn].filter((ax) => !expected.has(ax)).sort(byText);
|
|
20
|
+
if (missing.length > 0 || extra.length > 0) {
|
|
21
|
+
const parts = [];
|
|
22
|
+
if (missing.length > 0) parts.push(`缺少 [${missing.join(", ")}]`);
|
|
23
|
+
if (extra.length > 0) parts.push(`多出 [${extra.join(", ")}]`);
|
|
24
|
+
throw new Error(
|
|
25
|
+
`${facts.target} 的公理一致性检查失败:引理图与 Lean.collectAxioms 的结果不一致(${parts.join(",")})。`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function checkTree(input) {
|
|
30
|
+
const { script, tree } = input;
|
|
31
|
+
const goalById = new Map();
|
|
32
|
+
for (const g of script.goals) goalById.set(g.id, g);
|
|
33
|
+
const parentOf = new Map();
|
|
34
|
+
const visiting = new Set();
|
|
35
|
+
const walk = (gid, parent) => {
|
|
36
|
+
const goal = goalById.get(gid);
|
|
37
|
+
if (!goal) throw new Error(`证明树一致性检查失败:未知目标 ${gid}。`);
|
|
38
|
+
if (goal.final === "gone") {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`证明树一致性检查失败:可达目标 ${gid} 在根 MetavarContext 中已消失。`,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if (visiting.has(gid)) {
|
|
44
|
+
throw new Error(`证明树一致性检查失败:经过目标 ${gid} 时出现循环。`);
|
|
45
|
+
}
|
|
46
|
+
const existing = parentOf.get(gid);
|
|
47
|
+
if (existing !== undefined) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`证明树一致性检查失败:目标 ${gid} 有多个父目标(${String(existing)}、${String(parent)})。`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
parentOf.set(gid, parent);
|
|
53
|
+
const close = tree.closes.get(gid);
|
|
54
|
+
if (close) {
|
|
55
|
+
if (goal.final === "open") {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`证明树一致性检查失败:目标 ${gid} 已被步骤 ${close.step} 闭合,但在根 MetavarContext 中仍为开放。`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
visiting.add(gid);
|
|
61
|
+
for (const child of close.opens) walk(child, gid);
|
|
62
|
+
visiting.delete(gid);
|
|
63
|
+
} else if (goal.final === "assigned" && goal.closedBy === "proof") {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`证明树一致性检查失败:叶子目标 ${gid} 在根 MetavarContext 中已证明,但找不到闭合步骤。`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
for (const root of tree.roots) walk(root.goal, "root");
|
|
70
|
+
}
|