@stevenvo780/st-lang 4.13.0 → 4.14.1
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 +6 -6
- package/dist/ast/nodes.d.ts +50 -0
- package/dist/ast/nodes.d.ts.map +1 -1
- package/dist/format/stnb/parser.d.ts +14 -0
- package/dist/format/stnb/parser.d.ts.map +1 -0
- package/dist/format/stnb/parser.js +123 -0
- package/dist/format/stnb/parser.js.map +1 -0
- package/dist/format/stnb/types.d.ts +45 -0
- package/dist/format/stnb/types.d.ts.map +1 -0
- package/dist/format/stnb/types.js +7 -0
- package/dist/format/stnb/types.js.map +1 -0
- package/dist/logic/profile-bridge/index.d.ts.map +1 -1
- package/dist/logic/profile-bridge/index.js +20 -3
- package/dist/logic/profile-bridge/index.js.map +1 -1
- package/dist/logic/profiles/classical/propositional.d.ts.map +1 -1
- package/dist/logic/profiles/classical/propositional.js.map +1 -1
- package/dist/logic/profiles/ctl/check.d.ts.map +1 -1
- package/dist/logic/profiles/ctl/check.js +21 -11
- package/dist/logic/profiles/ctl/check.js.map +1 -1
- package/dist/logic/profiles/ctl/witness.d.ts.map +1 -1
- package/dist/logic/profiles/ctl/witness.js +2 -0
- package/dist/logic/profiles/ctl/witness.js.map +1 -1
- package/dist/logic/profiles/description-logic/types.d.ts +15 -0
- package/dist/logic/profiles/description-logic/types.d.ts.map +1 -1
- package/dist/logic/profiles/description-logic/types.js +13 -0
- package/dist/logic/profiles/description-logic/types.js.map +1 -1
- package/dist/logic/profiles/hybrid-logic/types.d.ts +17 -0
- package/dist/logic/profiles/hybrid-logic/types.d.ts.map +1 -1
- package/dist/logic/profiles/hybrid-logic/types.js +17 -0
- package/dist/logic/profiles/hybrid-logic/types.js.map +1 -1
- package/dist/logic/profiles/intuitionistic-nj/kripke.d.ts.map +1 -1
- package/dist/logic/profiles/intuitionistic-nj/kripke.js +8 -5
- package/dist/logic/profiles/intuitionistic-nj/kripke.js.map +1 -1
- package/dist/logic/profiles/ltl-sat/tableau.d.ts +31 -0
- package/dist/logic/profiles/ltl-sat/tableau.d.ts.map +1 -1
- package/dist/logic/profiles/ltl-sat/tableau.js +18 -0
- package/dist/logic/profiles/ltl-sat/tableau.js.map +1 -1
- package/dist/logic/profiles/ltl-sat/types.d.ts +15 -0
- package/dist/logic/profiles/ltl-sat/types.d.ts.map +1 -1
- package/dist/logic/profiles/ltl-sat/types.js +2 -1
- package/dist/logic/profiles/ltl-sat/types.js.map +1 -1
- package/dist/logic/profiles/modal-frame-axioms/formula.d.ts +10 -0
- package/dist/logic/profiles/modal-frame-axioms/formula.d.ts.map +1 -1
- package/dist/logic/profiles/modal-frame-axioms/formula.js +10 -0
- package/dist/logic/profiles/modal-frame-axioms/formula.js.map +1 -1
- package/dist/logic/profiles/mu-calculus/check.d.ts.map +1 -1
- package/dist/logic/profiles/mu-calculus/check.js +7 -4
- package/dist/logic/profiles/mu-calculus/check.js.map +1 -1
- package/dist/logic/profiles/natural-deduction-nk/formula.d.ts +8 -0
- package/dist/logic/profiles/natural-deduction-nk/formula.d.ts.map +1 -1
- package/dist/logic/profiles/natural-deduction-nk/formula.js +8 -0
- package/dist/logic/profiles/natural-deduction-nk/formula.js.map +1 -1
- package/dist/logic/profiles/quantum/index.d.ts.map +1 -1
- package/dist/logic/profiles/quantum/index.js +11 -8
- package/dist/logic/profiles/quantum/index.js.map +1 -1
- package/dist/logic/profiles/sequent-lj/index.d.ts +90 -0
- package/dist/logic/profiles/sequent-lj/index.d.ts.map +1 -0
- package/dist/logic/profiles/sequent-lj/index.js +903 -0
- package/dist/logic/profiles/sequent-lj/index.js.map +1 -0
- package/dist/logic/profiles/shared/tableau-engine.d.ts.map +1 -1
- package/dist/logic/profiles/shared/tableau-engine.js +0 -17
- package/dist/logic/profiles/shared/tableau-engine.js.map +1 -1
- package/dist/namespaces/proof-systems.d.ts +1 -1
- package/dist/namespaces/proof-systems.d.ts.map +1 -1
- package/dist/namespaces/proof-systems.js.map +1 -1
- package/dist/namespaces/semantics.d.ts +1 -1
- package/dist/namespaces/semantics.d.ts.map +1 -1
- package/dist/namespaces/semantics.js.map +1 -1
- package/dist/proof-systems/distributed-exchange/index.d.ts +29 -0
- package/dist/proof-systems/distributed-exchange/index.d.ts.map +1 -1
- package/dist/proof-systems/distributed-exchange/index.js +18 -0
- package/dist/proof-systems/distributed-exchange/index.js.map +1 -1
- package/dist/proof-systems/fol-prover/types.d.ts +16 -0
- package/dist/proof-systems/fol-prover/types.d.ts.map +1 -1
- package/dist/proof-systems/fol-prover/types.js +7 -0
- package/dist/proof-systems/fol-prover/types.js.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/index.d.ts +3 -3
- package/dist/proof-systems/fol-prover-advanced/index.d.ts.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/index.js.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/ordering.js +1 -1
- package/dist/proof-systems/fol-prover-advanced/prover.d.ts.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/prover.js +19 -12
- package/dist/proof-systems/fol-prover-advanced/prover.js.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/resolve.d.ts.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/resolve.js +7 -7
- package/dist/proof-systems/fol-prover-advanced/resolve.js.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/subsumption.d.ts.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/subsumption.js.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/types.d.ts +12 -0
- package/dist/proof-systems/fol-prover-advanced/types.d.ts.map +1 -1
- package/dist/proof-systems/fol-prover-advanced/unify.js +2 -2
- package/dist/proof-systems/fol-prover-equality/term-utils.d.ts +46 -0
- package/dist/proof-systems/fol-prover-equality/term-utils.d.ts.map +1 -1
- package/dist/proof-systems/fol-prover-equality/term-utils.js +46 -0
- package/dist/proof-systems/fol-prover-equality/term-utils.js.map +1 -1
- package/dist/proof-systems/proof-nets/correctness.d.ts.map +1 -1
- package/dist/proof-systems/proof-nets/correctness.js +24 -12
- package/dist/proof-systems/proof-nets/correctness.js.map +1 -1
- package/dist/proof-systems/proof-nets/types.d.ts +18 -0
- package/dist/proof-systems/proof-nets/types.d.ts.map +1 -1
- package/dist/proof-systems/proof-nets/types.js +6 -0
- package/dist/proof-systems/proof-nets/types.js.map +1 -1
- package/dist/proof-systems/tableau-framework/TableauProver.d.ts.map +1 -1
- package/dist/proof-systems/tableau-framework/TableauProver.js +5 -5
- package/dist/proof-systems/tableau-framework/TableauProver.js.map +1 -1
- package/dist/proof-systems/tableau-framework/propositional.d.ts.map +1 -1
- package/dist/proof-systems/tableau-framework/propositional.js +21 -21
- package/dist/proof-systems/tableau-framework/propositional.js.map +1 -1
- package/dist/reasoning/ban-logic/terms.d.ts +24 -0
- package/dist/reasoning/ban-logic/terms.d.ts.map +1 -1
- package/dist/reasoning/ban-logic/terms.js +24 -0
- package/dist/reasoning/ban-logic/terms.js.map +1 -1
- package/dist/reasoning/bayesian/factor.js +8 -8
- package/dist/reasoning/bayesian/factor.js.map +1 -1
- package/dist/reasoning/bayesian/inference.d.ts.map +1 -1
- package/dist/reasoning/bayesian/inference.js +11 -5
- package/dist/reasoning/bayesian/inference.js.map +1 -1
- package/dist/reasoning/combinatorics/generators.js.map +1 -1
- package/dist/reasoning/combinatorics/index.d.ts +3 -3
- package/dist/reasoning/combinatorics/index.d.ts.map +1 -1
- package/dist/reasoning/combinatorics/index.js.map +1 -1
- package/dist/reasoning/combinatorics/set-partitions.js.map +1 -1
- package/dist/reasoning/combinatorics/special-numbers.d.ts.map +1 -1
- package/dist/reasoning/combinatorics/special-numbers.js.map +1 -1
- package/dist/reasoning/constructive-analysis/cauchy.js +2 -2
- package/dist/reasoning/constructive-analysis/compact.js +1 -1
- package/dist/reasoning/constructive-analysis/continuity.d.ts.map +1 -1
- package/dist/reasoning/constructive-analysis/continuity.js +4 -4
- package/dist/reasoning/constructive-analysis/continuity.js.map +1 -1
- package/dist/reasoning/constructive-analysis/index.d.ts.map +1 -1
- package/dist/reasoning/constructive-analysis/index.js.map +1 -1
- package/dist/reasoning/constructive-analysis/ivt.d.ts.map +1 -1
- package/dist/reasoning/constructive-analysis/ivt.js +2 -2
- package/dist/reasoning/constructive-analysis/ivt.js.map +1 -1
- package/dist/reasoning/constructive-reals/index.d.ts.map +1 -1
- package/dist/reasoning/constructive-reals/index.js +4 -8
- package/dist/reasoning/constructive-reals/index.js.map +1 -1
- package/dist/reasoning/galois-fields/index.d.ts +64 -0
- package/dist/reasoning/galois-fields/index.d.ts.map +1 -1
- package/dist/reasoning/galois-fields/index.js +56 -6
- package/dist/reasoning/galois-fields/index.js.map +1 -1
- package/dist/reasoning/graph-theory/index.d.ts +31 -0
- package/dist/reasoning/graph-theory/index.d.ts.map +1 -1
- package/dist/reasoning/graph-theory/index.js +28 -10
- package/dist/reasoning/graph-theory/index.js.map +1 -1
- package/dist/reasoning/hoare-logic/index.d.ts +164 -0
- package/dist/reasoning/hoare-logic/index.d.ts.map +1 -0
- package/dist/reasoning/hoare-logic/index.js +561 -0
- package/dist/reasoning/hoare-logic/index.js.map +1 -0
- package/dist/reasoning/hyperreal/index.d.ts +30 -0
- package/dist/reasoning/hyperreal/index.d.ts.map +1 -1
- package/dist/reasoning/hyperreal/index.js +25 -0
- package/dist/reasoning/hyperreal/index.js.map +1 -1
- package/dist/reasoning/information-theory/index.d.ts +34 -0
- package/dist/reasoning/information-theory/index.d.ts.map +1 -1
- package/dist/reasoning/information-theory/index.js +27 -44
- package/dist/reasoning/information-theory/index.js.map +1 -1
- package/dist/reasoning/lemma-synthesis/index.d.ts +36 -0
- package/dist/reasoning/lemma-synthesis/index.d.ts.map +1 -1
- package/dist/reasoning/lemma-synthesis/index.js +12 -0
- package/dist/reasoning/lemma-synthesis/index.js.map +1 -1
- package/dist/reasoning/linear-algebra/index.d.ts +38 -0
- package/dist/reasoning/linear-algebra/index.d.ts.map +1 -1
- package/dist/reasoning/linear-algebra/index.js +34 -5
- package/dist/reasoning/linear-algebra/index.js.map +1 -1
- package/dist/reasoning/markov-logic/grounding.js +1 -1
- package/dist/reasoning/markov-logic/grounding.js.map +1 -1
- package/dist/reasoning/markov-logic/inference.js +1 -1
- package/dist/reasoning/markov-logic/inference.js.map +1 -1
- package/dist/reasoning/model-checking/index.d.ts +113 -0
- package/dist/reasoning/model-checking/index.d.ts.map +1 -0
- package/dist/reasoning/model-checking/index.js +786 -0
- package/dist/reasoning/model-checking/index.js.map +1 -0
- package/dist/reasoning/order-theory/index.d.ts +121 -0
- package/dist/reasoning/order-theory/index.d.ts.map +1 -0
- package/dist/reasoning/order-theory/index.js +562 -0
- package/dist/reasoning/order-theory/index.js.map +1 -0
- package/dist/reasoning/peano-arithmetic/index.d.ts +114 -0
- package/dist/reasoning/peano-arithmetic/index.d.ts.map +1 -0
- package/dist/reasoning/peano-arithmetic/index.js +650 -0
- package/dist/reasoning/peano-arithmetic/index.js.map +1 -0
- package/dist/reasoning/polynomial-ring/index.d.ts +80 -0
- package/dist/reasoning/polynomial-ring/index.d.ts.map +1 -1
- package/dist/reasoning/polynomial-ring/index.js +75 -0
- package/dist/reasoning/polynomial-ring/index.js.map +1 -1
- package/dist/reasoning/separation-logic/index.d.ts +220 -0
- package/dist/reasoning/separation-logic/index.d.ts.map +1 -0
- package/dist/reasoning/separation-logic/index.js +779 -0
- package/dist/reasoning/separation-logic/index.js.map +1 -0
- package/dist/reasoning/set-theory/hf-functions.js +3 -3
- package/dist/reasoning/set-theory/hf-sets.js +1 -1
- package/dist/reasoning/set-theory/index.d.ts +3 -3
- package/dist/reasoning/set-theory/index.d.ts.map +1 -1
- package/dist/reasoning/set-theory/zfc-axioms.js +4 -4
- package/dist/reasoning/tactic-dsl/tactics.d.ts +87 -0
- package/dist/reasoning/tactic-dsl/tactics.d.ts.map +1 -1
- package/dist/reasoning/tactic-dsl/tactics.js +86 -36
- package/dist/reasoning/tactic-dsl/tactics.js.map +1 -1
- package/dist/reasoning/topology/index.d.ts +81 -0
- package/dist/reasoning/topology/index.d.ts.map +1 -1
- package/dist/reasoning/topology/index.js +69 -45
- package/dist/reasoning/topology/index.js.map +1 -1
- package/dist/reasoning/universal-algebra/index.d.ts +196 -0
- package/dist/reasoning/universal-algebra/index.d.ts.map +1 -0
- package/dist/reasoning/universal-algebra/index.js +865 -0
- package/dist/reasoning/universal-algebra/index.js.map +1 -0
- package/dist/runtime/countermodel-min/minimize.js +0 -0
- package/dist/runtime/countermodel-min/minimize.js.map +1 -1
- package/dist/runtime/csp-hoare/semantics.d.ts +12 -0
- package/dist/runtime/csp-hoare/semantics.d.ts.map +1 -1
- package/dist/runtime/csp-hoare/semantics.js +12 -0
- package/dist/runtime/csp-hoare/semantics.js.map +1 -1
- package/dist/runtime/symbolic-diff/constructors.d.ts +20 -0
- package/dist/runtime/symbolic-diff/constructors.d.ts.map +1 -1
- package/dist/runtime/symbolic-diff/constructors.js +20 -0
- package/dist/runtime/symbolic-diff/constructors.js.map +1 -1
- package/dist/runtime/term-rewriting/term-utils.d.ts.map +1 -1
- package/dist/runtime/term-rewriting/term-utils.js +33 -2
- package/dist/runtime/term-rewriting/term-utils.js.map +1 -1
- package/dist/runtime/typecheck/checker.js +2 -2
- package/dist/runtime/typecheck/checker.js.map +1 -1
- package/dist/runtime/typecheck/levenshtein.js +1 -1
- package/dist/runtime/typecheck/levenshtein.js.map +1 -1
- package/dist/semantics/categorical/fin-set.d.ts.map +1 -1
- package/dist/semantics/categorical/fin-set.js +8 -1
- package/dist/semantics/categorical/fin-set.js.map +1 -1
- package/dist/semantics/categorical/free.d.ts.map +1 -1
- package/dist/semantics/categorical/free.js +8 -2
- package/dist/semantics/categorical/free.js.map +1 -1
- package/dist/semantics/categorical/limits.d.ts.map +1 -1
- package/dist/semantics/categorical/limits.js +13 -4
- package/dist/semantics/categorical/limits.js.map +1 -1
- package/dist/semantics/categorical/monoidal.d.ts.map +1 -1
- package/dist/semantics/categorical/monoidal.js +3 -1
- package/dist/semantics/categorical/monoidal.js.map +1 -1
- package/dist/semantics/text-layer/compiler.d.ts +46 -0
- package/dist/semantics/text-layer/compiler.d.ts.map +1 -1
- package/dist/semantics/text-layer/compiler.js +46 -11
- package/dist/semantics/text-layer/compiler.js.map +1 -1
- package/dist/solver/cdcl-v2/index.d.ts +8 -0
- package/dist/solver/cdcl-v2/index.d.ts.map +1 -1
- package/dist/solver/cdcl-v2/index.js +8 -0
- package/dist/solver/cdcl-v2/index.js.map +1 -1
- package/dist/solver/smt-z3/z3-wasm-backend.d.ts +0 -1
- package/dist/solver/smt-z3/z3-wasm-backend.d.ts.map +1 -1
- package/dist/solver/smt-z3/z3-wasm-backend.js +2 -3
- package/dist/solver/smt-z3/z3-wasm-backend.js.map +1 -1
- package/dist/tests/agora-integration-fixtures.test.js +7 -2
- package/dist/tests/agora-integration-fixtures.test.js.map +1 -1
- package/dist/tests/coverage-90/coverage-90-cdcl-v2-deep.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-cdcl-v2-deep.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-cdcl-v2-deep.test.js +123 -0
- package/dist/tests/coverage-90/coverage-90-cdcl-v2-deep.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-certificate-rules.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-certificate-rules.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-certificate-rules.test.js +172 -0
- package/dist/tests/coverage-90/coverage-90-certificate-rules.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-interpreter-extra.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-interpreter-extra.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-interpreter-extra.test.js +326 -0
- package/dist/tests/coverage-90/coverage-90-interpreter-extra.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-interpreter-features.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-interpreter-features.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-interpreter-features.test.js +418 -0
- package/dist/tests/coverage-90/coverage-90-interpreter-features.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-modal-temporal.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-modal-temporal.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-modal-temporal.test.js +162 -0
- package/dist/tests/coverage-90/coverage-90-modal-temporal.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-nk-prover.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-nk-prover.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-nk-prover.test.js +104 -0
- package/dist/tests/coverage-90/coverage-90-nk-prover.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-parser-deep.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-parser-deep.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-parser-deep.test.js +262 -0
- package/dist/tests/coverage-90/coverage-90-parser-deep.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-sat-engines.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-sat-engines.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-sat-engines.test.js +101 -0
- package/dist/tests/coverage-90/coverage-90-sat-engines.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-sequent-lk.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-sequent-lk.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-sequent-lk.test.js +219 -0
- package/dist/tests/coverage-90/coverage-90-sequent-lk.test.js.map +1 -0
- package/dist/tests/coverage-90/coverage-90-smt-lib-parser.test.d.ts +2 -0
- package/dist/tests/coverage-90/coverage-90-smt-lib-parser.test.d.ts.map +1 -0
- package/dist/tests/coverage-90/coverage-90-smt-lib-parser.test.js +154 -0
- package/dist/tests/coverage-90/coverage-90-smt-lib-parser.test.js.map +1 -0
- package/dist/tests/coverage-95/first-order.test.js.map +1 -1
- package/dist/tests/coverage-95/fol-prover.test.js.map +1 -1
- package/dist/tests/integration/cross-modules.test.js +43 -19
- package/dist/tests/integration/cross-modules.test.js.map +1 -1
- package/dist/tests/logic/ctl/check.test.js.map +1 -1
- package/dist/tests/logic/profile-bridge/translations.test.js +3 -3
- package/dist/tests/logic/profile-bridge/translations.test.js.map +1 -1
- package/dist/tests/logic/profiles/sequent-lj/lj.test.d.ts +2 -0
- package/dist/tests/logic/profiles/sequent-lj/lj.test.d.ts.map +1 -0
- package/dist/tests/logic/profiles/sequent-lj/lj.test.js +400 -0
- package/dist/tests/logic/profiles/sequent-lj/lj.test.js.map +1 -0
- package/dist/tests/logic/sequent-g3/prover.test.js.map +1 -1
- package/dist/tests/logic/substructural/prover.test.js.map +1 -1
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.js +40 -13
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.js.map +1 -1
- package/dist/tests/proof-systems/higher-order-unify/ho-unify.test.js.map +1 -1
- package/dist/tests/proof-systems/tableau-framework/tableau.test.js +8 -8
- package/dist/tests/proof-systems/tableau-framework/tableau.test.js.map +1 -1
- package/dist/tests/properties/agm.property.test.js +1 -1
- package/dist/tests/properties/agm.property.test.js.map +1 -1
- package/dist/tests/properties/anti-unification.property.test.js.map +1 -1
- package/dist/tests/properties/argumentation.property.test.js.map +1 -1
- package/dist/tests/properties/bisimulation.property.test.js.map +1 -1
- package/dist/tests/properties/cdcl.property.test.js.map +1 -1
- package/dist/tests/properties/coinduction.property.test.js.map +1 -1
- package/dist/tests/properties/constructive-reals.property.test.js.map +1 -1
- package/dist/tests/properties/csp.property.test.js +1 -3
- package/dist/tests/properties/csp.property.test.js.map +1 -1
- package/dist/tests/properties/generators.d.ts +1 -1
- package/dist/tests/properties/generators.d.ts.map +1 -1
- package/dist/tests/properties/generators.js +22 -30
- package/dist/tests/properties/generators.js.map +1 -1
- package/dist/tests/properties/intuit-nj.property.test.js +3 -1
- package/dist/tests/properties/intuit-nj.property.test.js.map +1 -1
- package/dist/tests/properties/lambda-calc.property.test.js.map +1 -1
- package/dist/tests/properties/mln.property.test.js +1 -3
- package/dist/tests/properties/mln.property.test.js.map +1 -1
- package/dist/tests/properties/planning.property.test.js.map +1 -1
- package/dist/tests/properties/profile-bridge.property.test.js.map +1 -1
- package/dist/tests/properties/theorem-cache.property.test.js.map +1 -1
- package/dist/tests/protocol-text-layer.test.js.map +1 -1
- package/dist/tests/reasoning/combinatorics/combinatorics.test.js +1 -1
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.js +9 -9
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.js.map +1 -1
- package/dist/tests/reasoning/hoare-logic/hoare-logic.test.d.ts +2 -0
- package/dist/tests/reasoning/hoare-logic/hoare-logic.test.d.ts.map +1 -0
- package/dist/tests/reasoning/hoare-logic/hoare-logic.test.js +340 -0
- package/dist/tests/reasoning/hoare-logic/hoare-logic.test.js.map +1 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.js +80 -38
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.js.map +1 -1
- package/dist/tests/reasoning/model-checking/model-checking.test.d.ts +2 -0
- package/dist/tests/reasoning/model-checking/model-checking.test.d.ts.map +1 -0
- package/dist/tests/reasoning/model-checking/model-checking.test.js +222 -0
- package/dist/tests/reasoning/model-checking/model-checking.test.js.map +1 -0
- package/dist/tests/reasoning/order-theory/order-theory.test.d.ts +2 -0
- package/dist/tests/reasoning/order-theory/order-theory.test.d.ts.map +1 -0
- package/dist/tests/reasoning/order-theory/order-theory.test.js +211 -0
- package/dist/tests/reasoning/order-theory/order-theory.test.js.map +1 -0
- package/dist/tests/reasoning/peano-arithmetic/peano.test.d.ts +2 -0
- package/dist/tests/reasoning/peano-arithmetic/peano.test.d.ts.map +1 -0
- package/dist/tests/reasoning/peano-arithmetic/peano.test.js +159 -0
- package/dist/tests/reasoning/peano-arithmetic/peano.test.js.map +1 -0
- package/dist/tests/reasoning/separation-logic/separation-logic.test.d.ts +2 -0
- package/dist/tests/reasoning/separation-logic/separation-logic.test.d.ts.map +1 -0
- package/dist/tests/reasoning/separation-logic/separation-logic.test.js +311 -0
- package/dist/tests/reasoning/separation-logic/separation-logic.test.js.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.js +11 -11
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.js +1 -1
- package/dist/tests/reasoning/universal-algebra/universal-algebra.test.d.ts +2 -0
- package/dist/tests/reasoning/universal-algebra/universal-algebra.test.d.ts.map +1 -0
- package/dist/tests/reasoning/universal-algebra/universal-algebra.test.js +289 -0
- package/dist/tests/reasoning/universal-algebra/universal-algebra.test.js.map +1 -0
- package/dist/tests/semantics/text-layer-v2/claim-graph.test.js.map +1 -1
- package/dist/tests/solver/smt-lib/emitter.test.js.map +1 -1
- package/dist/tests/solver/smt-z3/z3-wasm-backend.test.js.map +1 -1
- package/dist/tests/tooling/test-harness/test-harness.test.js +9 -6
- package/dist/tests/tooling/test-harness/test-harness.test.js.map +1 -1
- package/dist/tooling/lsp/types.d.ts +13 -0
- package/dist/tooling/lsp/types.d.ts.map +1 -1
- package/dist/tooling/lsp/types.js +1 -0
- package/dist/tooling/lsp/types.js.map +1 -1
- package/dist/tooling/test-harness/combinators.d.ts.map +1 -1
- package/dist/tooling/test-harness/combinators.js +4 -4
- package/dist/tooling/test-harness/combinators.js.map +1 -1
- package/dist/tooling/test-harness/coverage.js +1 -1
- package/dist/tooling/test-harness/generators.d.ts.map +1 -1
- package/dist/tooling/test-harness/generators.js.map +1 -1
- package/dist/tooling/test-harness/index.d.ts +1 -1
- package/dist/tooling/test-harness/index.d.ts.map +1 -1
- package/dist/tooling/test-harness/index.js.map +1 -1
- package/dist/tooling/test-harness/snapshot.d.ts.map +1 -1
- package/dist/tooling/test-harness/snapshot.js +2 -2
- package/dist/tooling/test-harness/snapshot.js.map +1 -1
- package/dist/type-theory/cubical/types.d.ts +25 -0
- package/dist/type-theory/cubical/types.d.ts.map +1 -1
- package/dist/type-theory/cubical/types.js +20 -0
- package/dist/type-theory/cubical/types.js.map +1 -1
- package/dist/type-theory/curry-howard/types.d.ts +27 -0
- package/dist/type-theory/curry-howard/types.d.ts.map +1 -1
- package/dist/type-theory/curry-howard/types.js +18 -0
- package/dist/type-theory/curry-howard/types.js.map +1 -1
- package/dist/type-theory/hindley-milner/substitution.d.ts +39 -0
- package/dist/type-theory/hindley-milner/substitution.d.ts.map +1 -1
- package/dist/type-theory/hindley-milner/substitution.js +37 -0
- package/dist/type-theory/hindley-milner/substitution.js.map +1 -1
- package/dist/type-theory/hindley-milner/types.d.ts +25 -0
- package/dist/type-theory/hindley-milner/types.d.ts.map +1 -1
- package/dist/type-theory/hindley-milner/types.js +22 -2
- package/dist/type-theory/hindley-milner/types.js.map +1 -1
- package/dist/type-theory/hol/rules.d.ts +36 -0
- package/dist/type-theory/hol/rules.d.ts.map +1 -1
- package/dist/type-theory/hol/rules.js +36 -0
- package/dist/type-theory/hol/rules.js.map +1 -1
- package/dist/type-theory/hott/types.d.ts +32 -0
- package/dist/type-theory/hott/types.d.ts.map +1 -1
- package/dist/type-theory/hott/types.js +31 -1
- package/dist/type-theory/hott/types.js.map +1 -1
- package/dist/type-theory/lambda-cube/types.d.ts +17 -0
- package/dist/type-theory/lambda-cube/types.d.ts.map +1 -1
- package/dist/type-theory/lambda-cube/types.js +13 -0
- package/dist/type-theory/lambda-cube/types.js.map +1 -1
- package/dist/type-theory/mltt/types.d.ts +19 -0
- package/dist/type-theory/mltt/types.d.ts.map +1 -1
- package/dist/type-theory/mltt/types.js +15 -1
- package/dist/type-theory/mltt/types.js.map +1 -1
- package/dist/type-theory/nbe/types.d.ts +21 -0
- package/dist/type-theory/nbe/types.d.ts.map +1 -1
- package/dist/type-theory/nbe/types.js +13 -1
- package/dist/type-theory/nbe/types.js.map +1 -1
- package/dist/type-theory/refinement-types/types.d.ts +38 -0
- package/dist/type-theory/refinement-types/types.d.ts.map +1 -1
- package/dist/type-theory/refinement-types/types.js +35 -0
- package/dist/type-theory/refinement-types/types.js.map +1 -1
- package/dist/type-theory/system-f/types.d.ts +30 -0
- package/dist/type-theory/system-f/types.d.ts.map +1 -1
- package/dist/type-theory/system-f/types.js +24 -3
- package/dist/type-theory/system-f/types.js.map +1 -1
- package/dist/types/index.d.ts +42 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Peano Arithmetic — Axiomas, inducción y verificación
|
|
4
|
+
// ============================================================
|
|
5
|
+
//
|
|
6
|
+
// Formalización mínima de la aritmética de Peano de primer orden
|
|
7
|
+
// (PA, signatura {0, succ, +, ·}). Cubre los seis axiomas no-
|
|
8
|
+
// inductivos clásicos, el esquema (paramétrico) de inducción,
|
|
9
|
+
// algunos teoremas elementales (commutativa, asociativa,
|
|
10
|
+
// distributiva) y un verificador de teoremas por muestreo
|
|
11
|
+
// numérico — equivalente a refutación finita en el modelo
|
|
12
|
+
// estándar ℕ.
|
|
13
|
+
//
|
|
14
|
+
// El sistema NO pretende ser un demostrador de PA: ni siquiera
|
|
15
|
+
// existe un procedimiento de decisión (PA es indecidible). El
|
|
16
|
+
// objetivo es:
|
|
17
|
+
// 1. Tener una sintaxis sólida para términos y fórmulas de PA.
|
|
18
|
+
// 2. Evaluar fórmulas en el modelo estándar.
|
|
19
|
+
// 3. Refutar conjeturas por contraejemplo cuando son falsas en ℕ.
|
|
20
|
+
// 4. Ofrecer una codificación de Gödel (numeración por pares
|
|
21
|
+
// de Cantor recursivos) para que el caller pueda manipular
|
|
22
|
+
// fórmulas como números.
|
|
23
|
+
//
|
|
24
|
+
// El esquema de inducción se construye como una `PeanoFormula`
|
|
25
|
+
// real (no como un truco de TS): dado un predicado P sobre un
|
|
26
|
+
// término, devuelve `P(0) ∧ ∀x.(P(x) → P(succ(x))) → ∀x.P(x)`.
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.PEANO_AXIOMS = exports.AXIOM_P6 = exports.AXIOM_P5 = exports.AXIOM_P4 = exports.AXIOM_P3 = exports.AXIOM_P2 = exports.AXIOM_P1 = exports.exists = exports.forall = exports.implies = exports.orF = exports.andF = exports.notF = exports.le = exports.lt = exports.eq = exports.mul = exports.add = exports.vt = exports.succ = exports.zero = void 0;
|
|
29
|
+
exports.numeral = numeral;
|
|
30
|
+
exports.inductionSchema = inductionSchema;
|
|
31
|
+
exports.evalNat = evalNat;
|
|
32
|
+
exports.freeVars = freeVars;
|
|
33
|
+
exports.evalFormula = evalFormula;
|
|
34
|
+
exports.theoremAddCommutative = theoremAddCommutative;
|
|
35
|
+
exports.theoremAddAssociative = theoremAddAssociative;
|
|
36
|
+
exports.theoremMulCommutative = theoremMulCommutative;
|
|
37
|
+
exports.theoremMulDistOverAdd = theoremMulDistOverAdd;
|
|
38
|
+
exports.verifyTheoremBySampling = verifyTheoremBySampling;
|
|
39
|
+
exports.godelNumber = godelNumber;
|
|
40
|
+
exports.fromGodel = fromGodel;
|
|
41
|
+
// ── Constructores de conveniencia ────────────────────────────
|
|
42
|
+
/** Constante 0 de la aritmética de Peano. */
|
|
43
|
+
exports.zero = { kind: 'zero' };
|
|
44
|
+
/** Constructor sucesor: `succ(t)` representa t+1. */
|
|
45
|
+
const succ = (arg) => ({ kind: 'succ', arg });
|
|
46
|
+
exports.succ = succ;
|
|
47
|
+
/** Variable de término de Peano referenciada por nombre. */
|
|
48
|
+
const vt = (name) => ({ kind: 'var', name });
|
|
49
|
+
exports.vt = vt;
|
|
50
|
+
/** Constructor de suma de términos de Peano. */
|
|
51
|
+
const add = (left, right) => ({
|
|
52
|
+
kind: 'add',
|
|
53
|
+
left,
|
|
54
|
+
right,
|
|
55
|
+
});
|
|
56
|
+
exports.add = add;
|
|
57
|
+
/** Constructor de multiplicación de términos de Peano. */
|
|
58
|
+
const mul = (left, right) => ({
|
|
59
|
+
kind: 'mul',
|
|
60
|
+
left,
|
|
61
|
+
right,
|
|
62
|
+
});
|
|
63
|
+
exports.mul = mul;
|
|
64
|
+
/** Constructor de la fórmula de igualdad: `left = right`. */
|
|
65
|
+
const eq = (left, right) => ({
|
|
66
|
+
kind: 'eq',
|
|
67
|
+
left,
|
|
68
|
+
right,
|
|
69
|
+
});
|
|
70
|
+
exports.eq = eq;
|
|
71
|
+
/** Constructor de la fórmula de orden estricto: `left < right`. */
|
|
72
|
+
const lt = (left, right) => ({
|
|
73
|
+
kind: 'lt',
|
|
74
|
+
left,
|
|
75
|
+
right,
|
|
76
|
+
});
|
|
77
|
+
exports.lt = lt;
|
|
78
|
+
/** Constructor de la fórmula de orden no estricto: `left ≤ right`. */
|
|
79
|
+
const le = (left, right) => ({
|
|
80
|
+
kind: 'le',
|
|
81
|
+
left,
|
|
82
|
+
right,
|
|
83
|
+
});
|
|
84
|
+
exports.le = le;
|
|
85
|
+
/** Constructor de la negación de una fórmula de Peano. */
|
|
86
|
+
const notF = (arg) => ({ kind: 'not', arg });
|
|
87
|
+
exports.notF = notF;
|
|
88
|
+
/** Constructor de conjunción (n-aria) de fórmulas de Peano. */
|
|
89
|
+
const andF = (...args) => ({
|
|
90
|
+
kind: 'and',
|
|
91
|
+
args,
|
|
92
|
+
});
|
|
93
|
+
exports.andF = andF;
|
|
94
|
+
/** Constructor de disyunción (n-aria) de fórmulas de Peano. */
|
|
95
|
+
const orF = (...args) => ({ kind: 'or', args });
|
|
96
|
+
exports.orF = orF;
|
|
97
|
+
/** Constructor de implicación: `left → right`. */
|
|
98
|
+
const implies = (left, right) => ({
|
|
99
|
+
kind: 'implies',
|
|
100
|
+
left,
|
|
101
|
+
right,
|
|
102
|
+
});
|
|
103
|
+
exports.implies = implies;
|
|
104
|
+
/** Constructor del cuantificador universal: `∀bind. body`. */
|
|
105
|
+
const forall = (bind, body) => ({
|
|
106
|
+
kind: 'forall',
|
|
107
|
+
bind,
|
|
108
|
+
body,
|
|
109
|
+
});
|
|
110
|
+
exports.forall = forall;
|
|
111
|
+
/** Constructor del cuantificador existencial: `∃bind. body`. */
|
|
112
|
+
const exists = (bind, body) => ({
|
|
113
|
+
kind: 'exists',
|
|
114
|
+
bind,
|
|
115
|
+
body,
|
|
116
|
+
});
|
|
117
|
+
exports.exists = exists;
|
|
118
|
+
// Construye un numeral cerrado succ^n(0).
|
|
119
|
+
function numeral(n) {
|
|
120
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
121
|
+
throw new RangeError(`numeral expects a non-negative integer, got ${n}`);
|
|
122
|
+
}
|
|
123
|
+
let t = exports.zero;
|
|
124
|
+
for (let i = 0; i < n; i += 1) {
|
|
125
|
+
t = (0, exports.succ)(t);
|
|
126
|
+
}
|
|
127
|
+
return t;
|
|
128
|
+
}
|
|
129
|
+
// ── Axiomas de Peano (sin el esquema de inducción) ──────────
|
|
130
|
+
// P1: ∀x. ¬(succ(x) = 0)
|
|
131
|
+
/** P1: ∀x. ¬(succ(x) = 0) — el cero no es sucesor de ningún número. */
|
|
132
|
+
exports.AXIOM_P1 = (0, exports.forall)('x', (0, exports.notF)((0, exports.eq)((0, exports.succ)((0, exports.vt)('x')), exports.zero)));
|
|
133
|
+
// P2: ∀x,y. succ(x) = succ(y) → x = y
|
|
134
|
+
/** P2: ∀x,y. succ(x) = succ(y) → x = y — inyectividad del sucesor. */
|
|
135
|
+
exports.AXIOM_P2 = (0, exports.forall)('x', (0, exports.forall)('y', (0, exports.implies)((0, exports.eq)((0, exports.succ)((0, exports.vt)('x')), (0, exports.succ)((0, exports.vt)('y'))), (0, exports.eq)((0, exports.vt)('x'), (0, exports.vt)('y')))));
|
|
136
|
+
// P3: ∀x. x + 0 = x
|
|
137
|
+
/** P3: ∀x. x + 0 = x — neutro derecho de la suma. */
|
|
138
|
+
exports.AXIOM_P3 = (0, exports.forall)('x', (0, exports.eq)((0, exports.add)((0, exports.vt)('x'), exports.zero), (0, exports.vt)('x')));
|
|
139
|
+
// P4: ∀x,y. x + succ(y) = succ(x + y)
|
|
140
|
+
/** P4: ∀x,y. x + succ(y) = succ(x + y) — recursión de la suma. */
|
|
141
|
+
exports.AXIOM_P4 = (0, exports.forall)('x', (0, exports.forall)('y', (0, exports.eq)((0, exports.add)((0, exports.vt)('x'), (0, exports.succ)((0, exports.vt)('y'))), (0, exports.succ)((0, exports.add)((0, exports.vt)('x'), (0, exports.vt)('y'))))));
|
|
142
|
+
// P5: ∀x. x · 0 = 0
|
|
143
|
+
/** P5: ∀x. x · 0 = 0 — absorción del cero en la multiplicación. */
|
|
144
|
+
exports.AXIOM_P5 = (0, exports.forall)('x', (0, exports.eq)((0, exports.mul)((0, exports.vt)('x'), exports.zero), exports.zero));
|
|
145
|
+
// P6: ∀x,y. x · succ(y) = (x · y) + x
|
|
146
|
+
/** P6: ∀x,y. x · succ(y) = (x · y) + x — recursión de la multiplicación. */
|
|
147
|
+
exports.AXIOM_P6 = (0, exports.forall)('x', (0, exports.forall)('y', (0, exports.eq)((0, exports.mul)((0, exports.vt)('x'), (0, exports.succ)((0, exports.vt)('y'))), (0, exports.add)((0, exports.mul)((0, exports.vt)('x'), (0, exports.vt)('y')), (0, exports.vt)('x')))));
|
|
148
|
+
/** Los seis axiomas no-inductivos de la aritmética de Peano (P1–P6). */
|
|
149
|
+
exports.PEANO_AXIOMS = [
|
|
150
|
+
exports.AXIOM_P1,
|
|
151
|
+
exports.AXIOM_P2,
|
|
152
|
+
exports.AXIOM_P3,
|
|
153
|
+
exports.AXIOM_P4,
|
|
154
|
+
exports.AXIOM_P5,
|
|
155
|
+
exports.AXIOM_P6,
|
|
156
|
+
];
|
|
157
|
+
// ── Esquema de inducción ─────────────────────────────────────
|
|
158
|
+
//
|
|
159
|
+
// (P(0) ∧ ∀x.(P(x) → P(succ(x)))) → ∀x.P(x)
|
|
160
|
+
//
|
|
161
|
+
// El caller pasa un constructor `P(n) ↦ formula(n)`. La variable
|
|
162
|
+
// `x` introducida es fresca (ix-XXX) para evitar colisiones con
|
|
163
|
+
// variables libres del cuerpo.
|
|
164
|
+
let inductionVarCounter = 0;
|
|
165
|
+
function freshVar() {
|
|
166
|
+
inductionVarCounter += 1;
|
|
167
|
+
return `ix_${inductionVarCounter}`;
|
|
168
|
+
}
|
|
169
|
+
/** Genera el esquema de inducción para un predicado P: (P(0) ∧ ∀x.(P(x) → P(succ(x)))) → ∀x.P(x). */
|
|
170
|
+
function inductionSchema(P) {
|
|
171
|
+
const x = freshVar();
|
|
172
|
+
const base = P(exports.zero);
|
|
173
|
+
const step = (0, exports.forall)(x, (0, exports.implies)(P((0, exports.vt)(x)), P((0, exports.succ)((0, exports.vt)(x)))));
|
|
174
|
+
const concl = (0, exports.forall)(x, P((0, exports.vt)(x)));
|
|
175
|
+
return (0, exports.implies)((0, exports.andF)(base, step), concl);
|
|
176
|
+
}
|
|
177
|
+
// ── Evaluación en el modelo estándar ℕ ──────────────────────
|
|
178
|
+
//
|
|
179
|
+
// Devuelve `null` si el término menciona una variable libre que
|
|
180
|
+
// no está en el entorno. Las operaciones se ejecutan en number
|
|
181
|
+
// regular; si el caller espera valores muy grandes debería usar
|
|
182
|
+
// `numeralFromBigInt` + un evaluador BigInt (no incluido aquí).
|
|
183
|
+
/** Evalúa un término de Peano en el modelo estándar ℕ con el entorno dado. Devuelve `null` si hay variables libres sin valor. */
|
|
184
|
+
function evalNat(term, env = {}) {
|
|
185
|
+
switch (term.kind) {
|
|
186
|
+
case 'zero':
|
|
187
|
+
return 0;
|
|
188
|
+
case 'succ': {
|
|
189
|
+
const a = evalNat(term.arg, env);
|
|
190
|
+
return a === null ? null : a + 1;
|
|
191
|
+
}
|
|
192
|
+
case 'var': {
|
|
193
|
+
const v = env[term.name];
|
|
194
|
+
return v === undefined ? null : v;
|
|
195
|
+
}
|
|
196
|
+
case 'add': {
|
|
197
|
+
const l = evalNat(term.left, env);
|
|
198
|
+
const r = evalNat(term.right, env);
|
|
199
|
+
if (l === null || r === null)
|
|
200
|
+
return null;
|
|
201
|
+
return l + r;
|
|
202
|
+
}
|
|
203
|
+
case 'mul': {
|
|
204
|
+
const l = evalNat(term.left, env);
|
|
205
|
+
const r = evalNat(term.right, env);
|
|
206
|
+
if (l === null || r === null)
|
|
207
|
+
return null;
|
|
208
|
+
return l * r;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Devuelve las variables libres de una fórmula (excluye las
|
|
213
|
+
// ligadas por forall/exists).
|
|
214
|
+
function freeVars(formula) {
|
|
215
|
+
const out = new Set();
|
|
216
|
+
collectFreeFormula(formula, new Set(), out);
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
function collectFreeTerm(t, bound, out) {
|
|
220
|
+
switch (t.kind) {
|
|
221
|
+
case 'zero':
|
|
222
|
+
return;
|
|
223
|
+
case 'succ':
|
|
224
|
+
collectFreeTerm(t.arg, bound, out);
|
|
225
|
+
return;
|
|
226
|
+
case 'var':
|
|
227
|
+
if (!bound.has(t.name))
|
|
228
|
+
out.add(t.name);
|
|
229
|
+
return;
|
|
230
|
+
case 'add':
|
|
231
|
+
case 'mul':
|
|
232
|
+
collectFreeTerm(t.left, bound, out);
|
|
233
|
+
collectFreeTerm(t.right, bound, out);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function collectFreeFormula(f, bound, out) {
|
|
238
|
+
switch (f.kind) {
|
|
239
|
+
case 'eq':
|
|
240
|
+
case 'lt':
|
|
241
|
+
case 'le':
|
|
242
|
+
collectFreeTerm(f.left, bound, out);
|
|
243
|
+
collectFreeTerm(f.right, bound, out);
|
|
244
|
+
return;
|
|
245
|
+
case 'not':
|
|
246
|
+
collectFreeFormula(f.arg, bound, out);
|
|
247
|
+
return;
|
|
248
|
+
case 'and':
|
|
249
|
+
case 'or':
|
|
250
|
+
for (const a of f.args)
|
|
251
|
+
collectFreeFormula(a, bound, out);
|
|
252
|
+
return;
|
|
253
|
+
case 'implies':
|
|
254
|
+
collectFreeFormula(f.left, bound, out);
|
|
255
|
+
collectFreeFormula(f.right, bound, out);
|
|
256
|
+
return;
|
|
257
|
+
case 'forall':
|
|
258
|
+
case 'exists': {
|
|
259
|
+
const inner = new Set(bound);
|
|
260
|
+
inner.add(f.bind);
|
|
261
|
+
collectFreeFormula(f.body, inner, out);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Evaluación de fórmulas en ℕ con cuantificadores acotados.
|
|
267
|
+
// `maxN` (default 8) limita el rango de los cuantificadores.
|
|
268
|
+
// Devuelve `null` cuando hay variables libres no en el entorno
|
|
269
|
+
// fuera de los cuantificadores.
|
|
270
|
+
function evalFormula(formula, env = {}, maxN = 8) {
|
|
271
|
+
switch (formula.kind) {
|
|
272
|
+
case 'eq': {
|
|
273
|
+
const l = evalNat(formula.left, env);
|
|
274
|
+
const r = evalNat(formula.right, env);
|
|
275
|
+
if (l === null || r === null)
|
|
276
|
+
return null;
|
|
277
|
+
return l === r;
|
|
278
|
+
}
|
|
279
|
+
case 'lt': {
|
|
280
|
+
const l = evalNat(formula.left, env);
|
|
281
|
+
const r = evalNat(formula.right, env);
|
|
282
|
+
if (l === null || r === null)
|
|
283
|
+
return null;
|
|
284
|
+
return l < r;
|
|
285
|
+
}
|
|
286
|
+
case 'le': {
|
|
287
|
+
const l = evalNat(formula.left, env);
|
|
288
|
+
const r = evalNat(formula.right, env);
|
|
289
|
+
if (l === null || r === null)
|
|
290
|
+
return null;
|
|
291
|
+
return l <= r;
|
|
292
|
+
}
|
|
293
|
+
case 'not': {
|
|
294
|
+
const v = evalFormula(formula.arg, env, maxN);
|
|
295
|
+
return v === null ? null : !v;
|
|
296
|
+
}
|
|
297
|
+
case 'and': {
|
|
298
|
+
for (const a of formula.args) {
|
|
299
|
+
const v = evalFormula(a, env, maxN);
|
|
300
|
+
if (v === null)
|
|
301
|
+
return null;
|
|
302
|
+
if (!v)
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
case 'or': {
|
|
308
|
+
for (const a of formula.args) {
|
|
309
|
+
const v = evalFormula(a, env, maxN);
|
|
310
|
+
if (v === null)
|
|
311
|
+
return null;
|
|
312
|
+
if (v)
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
case 'implies': {
|
|
318
|
+
const l = evalFormula(formula.left, env, maxN);
|
|
319
|
+
if (l === null)
|
|
320
|
+
return null;
|
|
321
|
+
if (!l)
|
|
322
|
+
return true;
|
|
323
|
+
const r = evalFormula(formula.right, env, maxN);
|
|
324
|
+
return r;
|
|
325
|
+
}
|
|
326
|
+
case 'forall': {
|
|
327
|
+
for (let n = 0; n <= maxN; n += 1) {
|
|
328
|
+
const inner = { ...env, [formula.bind]: n };
|
|
329
|
+
const v = evalFormula(formula.body, inner, maxN);
|
|
330
|
+
if (v === null)
|
|
331
|
+
return null;
|
|
332
|
+
if (!v)
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
case 'exists': {
|
|
338
|
+
for (let n = 0; n <= maxN; n += 1) {
|
|
339
|
+
const inner = { ...env, [formula.bind]: n };
|
|
340
|
+
const v = evalFormula(formula.body, inner, maxN);
|
|
341
|
+
if (v === null)
|
|
342
|
+
return null;
|
|
343
|
+
if (v)
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
// ── Teoremas estándar ────────────────────────────────────────
|
|
351
|
+
//
|
|
352
|
+
// Todos son demostrables en PA (con el esquema de inducción
|
|
353
|
+
// adecuado) y deben sostenerse en cualquier modelo de PA, por
|
|
354
|
+
// supuesto incluido ℕ.
|
|
355
|
+
function theoremAddCommutative() {
|
|
356
|
+
return (0, exports.forall)('x', (0, exports.forall)('y', (0, exports.eq)((0, exports.add)((0, exports.vt)('x'), (0, exports.vt)('y')), (0, exports.add)((0, exports.vt)('y'), (0, exports.vt)('x')))));
|
|
357
|
+
}
|
|
358
|
+
function theoremAddAssociative() {
|
|
359
|
+
return (0, exports.forall)('x', (0, exports.forall)('y', (0, exports.forall)('z', (0, exports.eq)((0, exports.add)((0, exports.add)((0, exports.vt)('x'), (0, exports.vt)('y')), (0, exports.vt)('z')), (0, exports.add)((0, exports.vt)('x'), (0, exports.add)((0, exports.vt)('y'), (0, exports.vt)('z')))))));
|
|
360
|
+
}
|
|
361
|
+
function theoremMulCommutative() {
|
|
362
|
+
return (0, exports.forall)('x', (0, exports.forall)('y', (0, exports.eq)((0, exports.mul)((0, exports.vt)('x'), (0, exports.vt)('y')), (0, exports.mul)((0, exports.vt)('y'), (0, exports.vt)('x')))));
|
|
363
|
+
}
|
|
364
|
+
// x · (y + z) = (x · y) + (x · z)
|
|
365
|
+
function theoremMulDistOverAdd() {
|
|
366
|
+
return (0, exports.forall)('x', (0, exports.forall)('y', (0, exports.forall)('z', (0, exports.eq)((0, exports.mul)((0, exports.vt)('x'), (0, exports.add)((0, exports.vt)('y'), (0, exports.vt)('z'))), (0, exports.add)((0, exports.mul)((0, exports.vt)('x'), (0, exports.vt)('y')), (0, exports.mul)((0, exports.vt)('x'), (0, exports.vt)('z')))))));
|
|
367
|
+
}
|
|
368
|
+
function verifyTheoremBySampling(thm, maxN = 6) {
|
|
369
|
+
const free = Array.from(freeVars(thm));
|
|
370
|
+
if (free.length === 0) {
|
|
371
|
+
const v = evalFormula(thm, {}, maxN);
|
|
372
|
+
if (v === null)
|
|
373
|
+
return { valid: false };
|
|
374
|
+
return v ? { valid: true } : { valid: false, counterexample: {} };
|
|
375
|
+
}
|
|
376
|
+
// Producto cartesiano [0..maxN]^free.length.
|
|
377
|
+
const idxs = new Array(free.length).fill(0);
|
|
378
|
+
while (true) {
|
|
379
|
+
const env = {};
|
|
380
|
+
for (let i = 0; i < free.length; i += 1) {
|
|
381
|
+
env[free[i]] = idxs[i];
|
|
382
|
+
}
|
|
383
|
+
const v = evalFormula(thm, env, maxN);
|
|
384
|
+
if (v === null)
|
|
385
|
+
return { valid: false, counterexample: { ...env } };
|
|
386
|
+
if (!v)
|
|
387
|
+
return { valid: false, counterexample: { ...env } };
|
|
388
|
+
// Incrementar índice.
|
|
389
|
+
let pos = 0;
|
|
390
|
+
while (pos < idxs.length) {
|
|
391
|
+
idxs[pos] = (idxs[pos] ?? 0) + 1;
|
|
392
|
+
if ((idxs[pos] ?? 0) <= maxN)
|
|
393
|
+
break;
|
|
394
|
+
idxs[pos] = 0;
|
|
395
|
+
pos += 1;
|
|
396
|
+
}
|
|
397
|
+
if (pos === idxs.length)
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
return { valid: true };
|
|
401
|
+
}
|
|
402
|
+
// ── Codificación de Gödel ────────────────────────────────────
|
|
403
|
+
//
|
|
404
|
+
// Codificación inyectiva fórmula ↔ BigInt usando una función de
|
|
405
|
+
// emparejamiento de Cantor sobre BigInt: pair(a, b) = ((a+b)²+
|
|
406
|
+
// 3a+b)/2 (variante estándar). Las constantes del lenguaje se
|
|
407
|
+
// distinguen por un tag entero y luego se anidan recursivamente.
|
|
408
|
+
// La decodificación es la inversa exacta (round-trip).
|
|
409
|
+
//
|
|
410
|
+
// Tags (term): zero=0, succ=1, var=2, add=3, mul=4
|
|
411
|
+
// Tags (form): eq=5, lt=6, le=7, not=8, and=9, or=10,
|
|
412
|
+
// implies=11, forall=12, exists=13
|
|
413
|
+
//
|
|
414
|
+
// Para nombres de variables usamos un diccionario ordenado por
|
|
415
|
+
// orden de aparición (asignación 0..N) y lo serializamos al
|
|
416
|
+
// final como una lista de longitudes. Esto basta para nuestro
|
|
417
|
+
// uso (las variables tienen nombres alfanuméricos cortos en
|
|
418
|
+
// ASCII imprimible).
|
|
419
|
+
const TAG = {
|
|
420
|
+
zero: 0n,
|
|
421
|
+
succ: 1n,
|
|
422
|
+
vart: 2n,
|
|
423
|
+
add: 3n,
|
|
424
|
+
mul: 4n,
|
|
425
|
+
eq: 5n,
|
|
426
|
+
lt: 6n,
|
|
427
|
+
le: 7n,
|
|
428
|
+
not: 8n,
|
|
429
|
+
and: 9n,
|
|
430
|
+
or: 10n,
|
|
431
|
+
implies: 11n,
|
|
432
|
+
forall: 12n,
|
|
433
|
+
exists: 13n,
|
|
434
|
+
};
|
|
435
|
+
function pair(a, b) {
|
|
436
|
+
// Función de emparejamiento de Cantor sobre BigInt.
|
|
437
|
+
const sum = a + b;
|
|
438
|
+
return (sum * (sum + 1n)) / 2n + b;
|
|
439
|
+
}
|
|
440
|
+
function isqrt(n) {
|
|
441
|
+
// Newton: O(log log n) iteraciones. Para n grande es lineal en
|
|
442
|
+
// el número de dígitos, no en el valor. Búsqueda binaria sobre
|
|
443
|
+
// [0..n] era O(log n) bits pero con multiplicaciones de
|
|
444
|
+
// tamaño-full → cuadrático en dígitos.
|
|
445
|
+
if (n < 0n)
|
|
446
|
+
throw new RangeError('isqrt of negative');
|
|
447
|
+
if (n < 2n)
|
|
448
|
+
return n;
|
|
449
|
+
// Seed inicial: 2^ceil(bitlen(n)/2).
|
|
450
|
+
let bits = 0;
|
|
451
|
+
let m = n;
|
|
452
|
+
while (m > 0n) {
|
|
453
|
+
m >>= 1n;
|
|
454
|
+
bits += 1;
|
|
455
|
+
}
|
|
456
|
+
let x = 1n << BigInt(Math.ceil(bits / 2) + 1);
|
|
457
|
+
while (true) {
|
|
458
|
+
const y = (x + n / x) >> 1n;
|
|
459
|
+
if (y >= x)
|
|
460
|
+
return x;
|
|
461
|
+
x = y;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function unpair(z) {
|
|
465
|
+
// w = floor((sqrt(8z+1) - 1)/2). Usamos isqrt (Newton sobre
|
|
466
|
+
// BigInt) en lugar de Math.sqrt para no perder precisión.
|
|
467
|
+
const t = 8n * z + 1n;
|
|
468
|
+
const s = isqrt(t);
|
|
469
|
+
const w = (s - 1n) / 2n;
|
|
470
|
+
const triangular = (w * (w + 1n)) / 2n;
|
|
471
|
+
const b = z - triangular;
|
|
472
|
+
const a = w - b;
|
|
473
|
+
return [a, b];
|
|
474
|
+
}
|
|
475
|
+
function tagged(tag, payload) {
|
|
476
|
+
return pair(tag, payload);
|
|
477
|
+
}
|
|
478
|
+
function encodeString(s) {
|
|
479
|
+
// Codifica el string como base-256 (cada char un byte UTF-16
|
|
480
|
+
// LSB; los nombres en uso son ASCII). Prefijo de longitud para
|
|
481
|
+
// permitir decodificación.
|
|
482
|
+
const len = BigInt(s.length);
|
|
483
|
+
let body = 0n;
|
|
484
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
485
|
+
body = body * 256n + BigInt(s.charCodeAt(i) & 0xff);
|
|
486
|
+
}
|
|
487
|
+
return pair(len, body);
|
|
488
|
+
}
|
|
489
|
+
function decodeString(n) {
|
|
490
|
+
const [len, body] = unpair(n);
|
|
491
|
+
const chars = [];
|
|
492
|
+
let rest = body;
|
|
493
|
+
const length = Number(len);
|
|
494
|
+
for (let i = 0; i < length; i += 1) {
|
|
495
|
+
const code = Number(rest % 256n);
|
|
496
|
+
chars.push(String.fromCharCode(code));
|
|
497
|
+
rest = rest / 256n;
|
|
498
|
+
}
|
|
499
|
+
return chars.reverse().join('');
|
|
500
|
+
}
|
|
501
|
+
function encodeTerm(t) {
|
|
502
|
+
switch (t.kind) {
|
|
503
|
+
case 'zero':
|
|
504
|
+
return tagged(TAG.zero, 0n);
|
|
505
|
+
case 'succ':
|
|
506
|
+
return tagged(TAG.succ, encodeTerm(t.arg));
|
|
507
|
+
case 'var':
|
|
508
|
+
return tagged(TAG.vart, encodeString(t.name));
|
|
509
|
+
case 'add':
|
|
510
|
+
return tagged(TAG.add, pair(encodeTerm(t.left), encodeTerm(t.right)));
|
|
511
|
+
case 'mul':
|
|
512
|
+
return tagged(TAG.mul, pair(encodeTerm(t.left), encodeTerm(t.right)));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
function encodeList(items) {
|
|
516
|
+
// Lista codificada como (len, fold derecha de pair).
|
|
517
|
+
let acc = 0n;
|
|
518
|
+
for (let i = items.length - 1; i >= 0; i -= 1) {
|
|
519
|
+
acc = pair(items[i], acc);
|
|
520
|
+
}
|
|
521
|
+
return pair(BigInt(items.length), acc);
|
|
522
|
+
}
|
|
523
|
+
function decodeList(n) {
|
|
524
|
+
const [len, body] = unpair(n);
|
|
525
|
+
const out = [];
|
|
526
|
+
let rest = body;
|
|
527
|
+
const length = Number(len);
|
|
528
|
+
for (let i = 0; i < length; i += 1) {
|
|
529
|
+
const [head, tail] = unpair(rest);
|
|
530
|
+
out.push(head);
|
|
531
|
+
rest = tail;
|
|
532
|
+
}
|
|
533
|
+
return out;
|
|
534
|
+
}
|
|
535
|
+
function encodeFormula(f) {
|
|
536
|
+
switch (f.kind) {
|
|
537
|
+
case 'eq':
|
|
538
|
+
return tagged(TAG.eq, pair(encodeTerm(f.left), encodeTerm(f.right)));
|
|
539
|
+
case 'lt':
|
|
540
|
+
return tagged(TAG.lt, pair(encodeTerm(f.left), encodeTerm(f.right)));
|
|
541
|
+
case 'le':
|
|
542
|
+
return tagged(TAG.le, pair(encodeTerm(f.left), encodeTerm(f.right)));
|
|
543
|
+
case 'not':
|
|
544
|
+
return tagged(TAG.not, encodeFormula(f.arg));
|
|
545
|
+
case 'and':
|
|
546
|
+
return tagged(TAG.and, encodeList(f.args.map(encodeFormula)));
|
|
547
|
+
case 'or':
|
|
548
|
+
return tagged(TAG.or, encodeList(f.args.map(encodeFormula)));
|
|
549
|
+
case 'implies':
|
|
550
|
+
return tagged(TAG.implies, pair(encodeFormula(f.left), encodeFormula(f.right)));
|
|
551
|
+
case 'forall':
|
|
552
|
+
return tagged(TAG.forall, pair(encodeString(f.bind), encodeFormula(f.body)));
|
|
553
|
+
case 'exists':
|
|
554
|
+
return tagged(TAG.exists, pair(encodeString(f.bind), encodeFormula(f.body)));
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function godelNumber(formula) {
|
|
558
|
+
return encodeFormula(formula);
|
|
559
|
+
}
|
|
560
|
+
function decodeTerm(n) {
|
|
561
|
+
const [tag, payload] = unpair(n);
|
|
562
|
+
if (tag === TAG.zero)
|
|
563
|
+
return exports.zero;
|
|
564
|
+
if (tag === TAG.succ) {
|
|
565
|
+
const inner = decodeTerm(payload);
|
|
566
|
+
return inner === null ? null : (0, exports.succ)(inner);
|
|
567
|
+
}
|
|
568
|
+
if (tag === TAG.vart) {
|
|
569
|
+
return (0, exports.vt)(decodeString(payload));
|
|
570
|
+
}
|
|
571
|
+
if (tag === TAG.add) {
|
|
572
|
+
const [l, r] = unpair(payload);
|
|
573
|
+
const lt = decodeTerm(l);
|
|
574
|
+
const rt = decodeTerm(r);
|
|
575
|
+
if (lt === null || rt === null)
|
|
576
|
+
return null;
|
|
577
|
+
return (0, exports.add)(lt, rt);
|
|
578
|
+
}
|
|
579
|
+
if (tag === TAG.mul) {
|
|
580
|
+
const [l, r] = unpair(payload);
|
|
581
|
+
const lt = decodeTerm(l);
|
|
582
|
+
const rt = decodeTerm(r);
|
|
583
|
+
if (lt === null || rt === null)
|
|
584
|
+
return null;
|
|
585
|
+
return (0, exports.mul)(lt, rt);
|
|
586
|
+
}
|
|
587
|
+
return null;
|
|
588
|
+
}
|
|
589
|
+
function decodeFormula(n) {
|
|
590
|
+
const [tag, payload] = unpair(n);
|
|
591
|
+
if (tag === TAG.eq || tag === TAG.lt || tag === TAG.le) {
|
|
592
|
+
const [l, r] = unpair(payload);
|
|
593
|
+
const lt = decodeTerm(l);
|
|
594
|
+
const rt = decodeTerm(r);
|
|
595
|
+
if (lt === null || rt === null)
|
|
596
|
+
return null;
|
|
597
|
+
if (tag === TAG.eq)
|
|
598
|
+
return (0, exports.eq)(lt, rt);
|
|
599
|
+
if (tag === TAG.lt)
|
|
600
|
+
return lt2lt(lt, rt);
|
|
601
|
+
return (0, exports.le)(lt, rt);
|
|
602
|
+
}
|
|
603
|
+
if (tag === TAG.not) {
|
|
604
|
+
const inner = decodeFormula(payload);
|
|
605
|
+
return inner === null ? null : (0, exports.notF)(inner);
|
|
606
|
+
}
|
|
607
|
+
if (tag === TAG.and || tag === TAG.or) {
|
|
608
|
+
const items = decodeList(payload);
|
|
609
|
+
const args = [];
|
|
610
|
+
for (const it of items) {
|
|
611
|
+
const f = decodeFormula(it);
|
|
612
|
+
if (f === null)
|
|
613
|
+
return null;
|
|
614
|
+
args.push(f);
|
|
615
|
+
}
|
|
616
|
+
return tag === TAG.and ? (0, exports.andF)(...args) : (0, exports.orF)(...args);
|
|
617
|
+
}
|
|
618
|
+
if (tag === TAG.implies) {
|
|
619
|
+
const [l, r] = unpair(payload);
|
|
620
|
+
const lf = decodeFormula(l);
|
|
621
|
+
const rf = decodeFormula(r);
|
|
622
|
+
if (lf === null || rf === null)
|
|
623
|
+
return null;
|
|
624
|
+
return (0, exports.implies)(lf, rf);
|
|
625
|
+
}
|
|
626
|
+
if (tag === TAG.forall || tag === TAG.exists) {
|
|
627
|
+
const [bindN, bodyN] = unpair(payload);
|
|
628
|
+
const bind = decodeString(bindN);
|
|
629
|
+
const body = decodeFormula(bodyN);
|
|
630
|
+
if (body === null)
|
|
631
|
+
return null;
|
|
632
|
+
return tag === TAG.forall ? (0, exports.forall)(bind, body) : (0, exports.exists)(bind, body);
|
|
633
|
+
}
|
|
634
|
+
return null;
|
|
635
|
+
}
|
|
636
|
+
// Helper: lt() del export está sombreado en este scope local.
|
|
637
|
+
function lt2lt(l, r) {
|
|
638
|
+
return { kind: 'lt', left: l, right: r };
|
|
639
|
+
}
|
|
640
|
+
function fromGodel(n) {
|
|
641
|
+
if (n < 0n)
|
|
642
|
+
return null;
|
|
643
|
+
try {
|
|
644
|
+
return decodeFormula(n);
|
|
645
|
+
}
|
|
646
|
+
catch {
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
//# sourceMappingURL=index.js.map
|