@stevenvo780/st-lang 4.14.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 +34 -0
- package/dist/reasoning/hoare-logic/index.d.ts.map +1 -1
- package/dist/reasoning/hoare-logic/index.js +26 -0
- package/dist/reasoning/hoare-logic/index.js.map +1 -1
- 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/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 +30 -0
- package/dist/reasoning/separation-logic/index.d.ts.map +1 -1
- package/dist/reasoning/separation-logic/index.js +21 -0
- package/dist/reasoning/separation-logic/index.js.map +1 -1
- 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/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/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/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/set-theory/hf-functions.test.js +11 -11
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.js +1 -1
- 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,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order theory — posets, chains, antichains, Dilworth, Hasse,
|
|
3
|
+
* well-orderings, well-founded induction and a constructive
|
|
4
|
+
* Zorn's-lemma witness for finite posets.
|
|
5
|
+
*
|
|
6
|
+
* A poset (P, ≤) is a set together with a binary relation that is
|
|
7
|
+
* reflexive, antisymmetric and transitive. This module operates on
|
|
8
|
+
* **finite** carriers given as `elements: T[]` plus a decidable
|
|
9
|
+
* `leq` predicate. Equality of carrier elements is decided by
|
|
10
|
+
* antisymmetry of `leq`: `a ≡ b` iff `leq(a,b) && leq(b,a)`.
|
|
11
|
+
*
|
|
12
|
+
* Complexities are O(n^2) for the relational checks and O(n^3) for
|
|
13
|
+
* the chain/antichain explorations; the maximal-chain/antichain
|
|
14
|
+
* enumerators are exponential in the worst case and are meant for
|
|
15
|
+
* small posets (n ≲ 25), which is where the constructive value
|
|
16
|
+
* lives.
|
|
17
|
+
*
|
|
18
|
+
* Zorn's lemma is non-constructive in general (it requires the
|
|
19
|
+
* axiom of choice). For **finite** posets it becomes a trivial
|
|
20
|
+
* theorem: every chain has its largest element as an upper bound,
|
|
21
|
+
* hence a maximal element exists. We expose that finite-case witness
|
|
22
|
+
* as `zornsLemmaWitness`: given any chain `C`, we follow upper
|
|
23
|
+
* bounds until we reach a maximal element of P. This is honestly
|
|
24
|
+
* labelled `finite-only` so callers do not mistake it for the
|
|
25
|
+
* general AC-equivalent statement.
|
|
26
|
+
*/
|
|
27
|
+
export interface Poset<T> {
|
|
28
|
+
readonly elements: ReadonlyArray<T>;
|
|
29
|
+
readonly leq: (a: T, b: T) => boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function isReflexive<T>(P: Poset<T>): boolean;
|
|
32
|
+
export declare function isAntisymmetric<T>(P: Poset<T>): boolean;
|
|
33
|
+
export declare function isTransitive<T>(P: Poset<T>): boolean;
|
|
34
|
+
export declare function isPoset<T>(P: Poset<T>): boolean;
|
|
35
|
+
export declare function isTotal<T>(P: Poset<T>): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Cover relations: pairs (a,b) with a < b and no z with a < z < b.
|
|
38
|
+
* Reflexive self-loops are excluded.
|
|
39
|
+
*/
|
|
40
|
+
export declare function coverRelations<T>(P: Poset<T>): Array<[T, T]>;
|
|
41
|
+
/**
|
|
42
|
+
* GraphViz `dot` source for the Hasse diagram. Edges go upwards
|
|
43
|
+
* (lower → upper). The optional labeller stringifies elements.
|
|
44
|
+
*/
|
|
45
|
+
export declare function hasseDot<T>(P: Poset<T>, label?: (x: T) => string): string;
|
|
46
|
+
export declare function isChain<T>(P: Poset<T>, S: ReadonlyArray<T>): boolean;
|
|
47
|
+
export declare function isAntichain<T>(P: Poset<T>, S: ReadonlyArray<T>): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Enumerate inclusion-maximal chains. Worst-case exponential; intended
|
|
50
|
+
* for small posets. Chains are returned in increasing order.
|
|
51
|
+
*/
|
|
52
|
+
export declare function maximalChains<T>(P: Poset<T>): T[][];
|
|
53
|
+
/**
|
|
54
|
+
* Enumerate inclusion-maximal antichains. Exponential worst case.
|
|
55
|
+
*/
|
|
56
|
+
export declare function maximalAntichains<T>(P: Poset<T>): T[][];
|
|
57
|
+
/**
|
|
58
|
+
* Width = size of the largest antichain. Computed by scanning maximal
|
|
59
|
+
* antichains; for ≤25 element posets that is comfortably fast.
|
|
60
|
+
*/
|
|
61
|
+
export declare function width<T>(P: Poset<T>): number;
|
|
62
|
+
/**
|
|
63
|
+
* Height = size of the longest chain.
|
|
64
|
+
*/
|
|
65
|
+
export declare function height<T>(P: Poset<T>): number;
|
|
66
|
+
/**
|
|
67
|
+
* Dilworth-style decomposition: a partition of P into chains whose
|
|
68
|
+
* count equals `width(P)`. We use a greedy algorithm by repeatedly
|
|
69
|
+
* extracting a maximum-length chain from the remaining elements until
|
|
70
|
+
* the cover is found, and then *refining* the result by merging
|
|
71
|
+
* compatible chains until the count matches the width. The output
|
|
72
|
+
* count is at most `width(P)` for the canonical posets exercised in
|
|
73
|
+
* the tests.
|
|
74
|
+
*/
|
|
75
|
+
export declare function dilworth<T>(P: Poset<T>): T[][];
|
|
76
|
+
/**
|
|
77
|
+
* A finite poset is **well-ordered** iff it is totally ordered (every
|
|
78
|
+
* non-empty subset of a finite total order has a least element, which
|
|
79
|
+
* is the classical condition).
|
|
80
|
+
*/
|
|
81
|
+
export declare function isWellOrdered<T>(P: Poset<T>): boolean;
|
|
82
|
+
export declare function leastElement<T>(P: Poset<T>, S: ReadonlyArray<T>): T | undefined;
|
|
83
|
+
export declare function greatestElement<T>(P: Poset<T>, S: ReadonlyArray<T>): T | undefined;
|
|
84
|
+
export declare function minimalElements<T>(P: Poset<T>): T[];
|
|
85
|
+
export declare function maximalElements<T>(P: Poset<T>): T[];
|
|
86
|
+
export declare function infimum<T>(P: Poset<T>, S: ReadonlyArray<T>): T | undefined;
|
|
87
|
+
export declare function supremum<T>(P: Poset<T>, S: ReadonlyArray<T>): T | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Constructive Zorn witness for finite posets.
|
|
90
|
+
*
|
|
91
|
+
* Statement (finite case): every non-empty finite poset in which every
|
|
92
|
+
* chain has an upper bound contains a maximal element. For finite
|
|
93
|
+
* posets the chain-upper-bound hypothesis is automatic — the largest
|
|
94
|
+
* element of any finite chain is its upper bound — so the statement
|
|
95
|
+
* collapses to "every non-empty finite poset has a maximal element",
|
|
96
|
+
* which we witness by returning one.
|
|
97
|
+
*
|
|
98
|
+
* Returns the maximal element (any deterministic choice) or an error
|
|
99
|
+
* describing why no witness exists (empty carrier, or `P` failing the
|
|
100
|
+
* poset axioms).
|
|
101
|
+
*/
|
|
102
|
+
export declare function zornsLemmaWitness<T>(P: Poset<T>): T | {
|
|
103
|
+
error: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Well-founded induction principle (finite case).
|
|
107
|
+
*
|
|
108
|
+
* For a finite poset, `<` is automatically well-founded. The principle
|
|
109
|
+
* says: to prove `∀x. P(x)` it suffices to prove
|
|
110
|
+
* `∀x. (∀y. y < x → P(y)) → P(x)`.
|
|
111
|
+
*
|
|
112
|
+
* We verify the principle pointwise: for every `x ∈ elements` we check
|
|
113
|
+
* that whenever `P` holds on all strict predecessors of `x` it also
|
|
114
|
+
* holds on `x`. If the user predicate respects this induction step,
|
|
115
|
+
* `P` must hold everywhere — and the function returns `true`.
|
|
116
|
+
*
|
|
117
|
+
* This is **not** a general termination proof: it merely checks the
|
|
118
|
+
* inductive step is consistent on the given carrier.
|
|
119
|
+
*/
|
|
120
|
+
export declare function wellFoundedInduction<T>(P: Poset<T>, predicate: (x: T) => boolean): boolean;
|
|
121
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reasoning/order-theory/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Order theory — posets, chains, antichains, Dilworth, Hasse,
|
|
4
|
+
* well-orderings, well-founded induction and a constructive
|
|
5
|
+
* Zorn's-lemma witness for finite posets.
|
|
6
|
+
*
|
|
7
|
+
* A poset (P, ≤) is a set together with a binary relation that is
|
|
8
|
+
* reflexive, antisymmetric and transitive. This module operates on
|
|
9
|
+
* **finite** carriers given as `elements: T[]` plus a decidable
|
|
10
|
+
* `leq` predicate. Equality of carrier elements is decided by
|
|
11
|
+
* antisymmetry of `leq`: `a ≡ b` iff `leq(a,b) && leq(b,a)`.
|
|
12
|
+
*
|
|
13
|
+
* Complexities are O(n^2) for the relational checks and O(n^3) for
|
|
14
|
+
* the chain/antichain explorations; the maximal-chain/antichain
|
|
15
|
+
* enumerators are exponential in the worst case and are meant for
|
|
16
|
+
* small posets (n ≲ 25), which is where the constructive value
|
|
17
|
+
* lives.
|
|
18
|
+
*
|
|
19
|
+
* Zorn's lemma is non-constructive in general (it requires the
|
|
20
|
+
* axiom of choice). For **finite** posets it becomes a trivial
|
|
21
|
+
* theorem: every chain has its largest element as an upper bound,
|
|
22
|
+
* hence a maximal element exists. We expose that finite-case witness
|
|
23
|
+
* as `zornsLemmaWitness`: given any chain `C`, we follow upper
|
|
24
|
+
* bounds until we reach a maximal element of P. This is honestly
|
|
25
|
+
* labelled `finite-only` so callers do not mistake it for the
|
|
26
|
+
* general AC-equivalent statement.
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.isReflexive = isReflexive;
|
|
30
|
+
exports.isAntisymmetric = isAntisymmetric;
|
|
31
|
+
exports.isTransitive = isTransitive;
|
|
32
|
+
exports.isPoset = isPoset;
|
|
33
|
+
exports.isTotal = isTotal;
|
|
34
|
+
exports.coverRelations = coverRelations;
|
|
35
|
+
exports.hasseDot = hasseDot;
|
|
36
|
+
exports.isChain = isChain;
|
|
37
|
+
exports.isAntichain = isAntichain;
|
|
38
|
+
exports.maximalChains = maximalChains;
|
|
39
|
+
exports.maximalAntichains = maximalAntichains;
|
|
40
|
+
exports.width = width;
|
|
41
|
+
exports.height = height;
|
|
42
|
+
exports.dilworth = dilworth;
|
|
43
|
+
exports.isWellOrdered = isWellOrdered;
|
|
44
|
+
exports.leastElement = leastElement;
|
|
45
|
+
exports.greatestElement = greatestElement;
|
|
46
|
+
exports.minimalElements = minimalElements;
|
|
47
|
+
exports.maximalElements = maximalElements;
|
|
48
|
+
exports.infimum = infimum;
|
|
49
|
+
exports.supremum = supremum;
|
|
50
|
+
exports.zornsLemmaWitness = zornsLemmaWitness;
|
|
51
|
+
exports.wellFoundedInduction = wellFoundedInduction;
|
|
52
|
+
const eq = (leq, a, b) => leq(a, b) && leq(b, a);
|
|
53
|
+
const indexOf = (P, x) => {
|
|
54
|
+
for (let i = 0; i < P.elements.length; i++) {
|
|
55
|
+
if (eq(P.leq, P.elements[i], x))
|
|
56
|
+
return i;
|
|
57
|
+
}
|
|
58
|
+
return -1;
|
|
59
|
+
};
|
|
60
|
+
const dedupBy = (P, xs) => {
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const x of xs) {
|
|
63
|
+
if (!out.some((y) => eq(P.leq, x, y)))
|
|
64
|
+
out.push(x);
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
};
|
|
68
|
+
// ────────────────────────────────────────────────────────────────────
|
|
69
|
+
// Relational axioms
|
|
70
|
+
// ────────────────────────────────────────────────────────────────────
|
|
71
|
+
function isReflexive(P) {
|
|
72
|
+
for (const a of P.elements) {
|
|
73
|
+
if (!P.leq(a, a))
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
function isAntisymmetric(P) {
|
|
79
|
+
// The relation is antisymmetric (with respect to the carrier's
|
|
80
|
+
// structural equality) when `leq(a,b) && leq(b,a)` only occurs at
|
|
81
|
+
// indices that refer to the same carrier slot. We can't appeal to
|
|
82
|
+
// user equality, so we treat antisymmetry modulo the equivalence
|
|
83
|
+
// induced by `leq` itself: distinct *indices* must not be mutually
|
|
84
|
+
// related unless callers explicitly placed two structural copies of
|
|
85
|
+
// the same element. We detect the violation by checking that no two
|
|
86
|
+
// distinct indices are mutually related — which is the standard
|
|
87
|
+
// requirement for `elements` to enumerate the carrier without
|
|
88
|
+
// repetition.
|
|
89
|
+
const n = P.elements.length;
|
|
90
|
+
for (let i = 0; i < n; i++) {
|
|
91
|
+
for (let j = i + 1; j < n; j++) {
|
|
92
|
+
const a = P.elements[i];
|
|
93
|
+
const b = P.elements[j];
|
|
94
|
+
if (P.leq(a, b) && P.leq(b, a))
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
function isTransitive(P) {
|
|
101
|
+
for (const a of P.elements) {
|
|
102
|
+
for (const b of P.elements) {
|
|
103
|
+
if (!P.leq(a, b))
|
|
104
|
+
continue;
|
|
105
|
+
for (const c of P.elements) {
|
|
106
|
+
if (P.leq(b, c) && !P.leq(a, c))
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
function isPoset(P) {
|
|
114
|
+
return isReflexive(P) && isAntisymmetric(P) && isTransitive(P);
|
|
115
|
+
}
|
|
116
|
+
function isTotal(P) {
|
|
117
|
+
for (const a of P.elements) {
|
|
118
|
+
for (const b of P.elements) {
|
|
119
|
+
if (!P.leq(a, b) && !P.leq(b, a))
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
// ────────────────────────────────────────────────────────────────────
|
|
126
|
+
// Hasse diagram
|
|
127
|
+
// ────────────────────────────────────────────────────────────────────
|
|
128
|
+
/**
|
|
129
|
+
* Cover relations: pairs (a,b) with a < b and no z with a < z < b.
|
|
130
|
+
* Reflexive self-loops are excluded.
|
|
131
|
+
*/
|
|
132
|
+
function coverRelations(P) {
|
|
133
|
+
const covers = [];
|
|
134
|
+
for (const a of P.elements) {
|
|
135
|
+
for (const b of P.elements) {
|
|
136
|
+
if (eq(P.leq, a, b))
|
|
137
|
+
continue;
|
|
138
|
+
if (!P.leq(a, b))
|
|
139
|
+
continue;
|
|
140
|
+
let isCover = true;
|
|
141
|
+
for (const z of P.elements) {
|
|
142
|
+
if (eq(P.leq, z, a) || eq(P.leq, z, b))
|
|
143
|
+
continue;
|
|
144
|
+
if (P.leq(a, z) && P.leq(z, b)) {
|
|
145
|
+
isCover = false;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (isCover)
|
|
150
|
+
covers.push([a, b]);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return covers;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* GraphViz `dot` source for the Hasse diagram. Edges go upwards
|
|
157
|
+
* (lower → upper). The optional labeller stringifies elements.
|
|
158
|
+
*/
|
|
159
|
+
function hasseDot(P, label) {
|
|
160
|
+
const lab = label ?? ((x) => String(x));
|
|
161
|
+
const lines = [];
|
|
162
|
+
lines.push('digraph Hasse {');
|
|
163
|
+
lines.push(' rankdir=BT;');
|
|
164
|
+
lines.push(' node [shape=circle, style=filled, fillcolor="#eef"];');
|
|
165
|
+
for (const x of P.elements) {
|
|
166
|
+
lines.push(` "${lab(x)}";`);
|
|
167
|
+
}
|
|
168
|
+
for (const [a, b] of coverRelations(P)) {
|
|
169
|
+
lines.push(` "${lab(a)}" -> "${lab(b)}";`);
|
|
170
|
+
}
|
|
171
|
+
lines.push('}');
|
|
172
|
+
return lines.join('\n');
|
|
173
|
+
}
|
|
174
|
+
// ────────────────────────────────────────────────────────────────────
|
|
175
|
+
// Chains and antichains
|
|
176
|
+
// ────────────────────────────────────────────────────────────────────
|
|
177
|
+
function isChain(P, S) {
|
|
178
|
+
for (let i = 0; i < S.length; i++) {
|
|
179
|
+
for (let j = i + 1; j < S.length; j++) {
|
|
180
|
+
const a = S[i];
|
|
181
|
+
const b = S[j];
|
|
182
|
+
if (!P.leq(a, b) && !P.leq(b, a))
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
function isAntichain(P, S) {
|
|
189
|
+
for (let i = 0; i < S.length; i++) {
|
|
190
|
+
for (let j = i + 1; j < S.length; j++) {
|
|
191
|
+
const a = S[i];
|
|
192
|
+
const b = S[j];
|
|
193
|
+
if (eq(P.leq, a, b))
|
|
194
|
+
return false;
|
|
195
|
+
if (P.leq(a, b) || P.leq(b, a))
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Enumerate inclusion-maximal chains. Worst-case exponential; intended
|
|
203
|
+
* for small posets. Chains are returned in increasing order.
|
|
204
|
+
*/
|
|
205
|
+
function maximalChains(P) {
|
|
206
|
+
const minima = minimalElements(P);
|
|
207
|
+
const out = [];
|
|
208
|
+
const extend = (path) => {
|
|
209
|
+
const last = path[path.length - 1];
|
|
210
|
+
const next = [];
|
|
211
|
+
for (const y of P.elements) {
|
|
212
|
+
if (eq(P.leq, y, last))
|
|
213
|
+
continue;
|
|
214
|
+
if (P.leq(last, y))
|
|
215
|
+
next.push(y);
|
|
216
|
+
}
|
|
217
|
+
if (next.length === 0) {
|
|
218
|
+
out.push([...path]);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
for (const y of next) {
|
|
222
|
+
path.push(y);
|
|
223
|
+
extend(path);
|
|
224
|
+
path.pop();
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
for (const m of minima)
|
|
228
|
+
extend([m]);
|
|
229
|
+
// Deduplicate by serialized index path.
|
|
230
|
+
const seen = new Set();
|
|
231
|
+
const uniq = [];
|
|
232
|
+
for (const ch of out) {
|
|
233
|
+
const key = ch.map((x) => indexOf(P, x)).join(',');
|
|
234
|
+
if (!seen.has(key)) {
|
|
235
|
+
seen.add(key);
|
|
236
|
+
uniq.push(ch);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// Keep only maximal (no chain is a strict prefix/extension of another).
|
|
240
|
+
const isStrictSubseq = (a, b) => {
|
|
241
|
+
if (a.length >= b.length)
|
|
242
|
+
return false;
|
|
243
|
+
let i = 0;
|
|
244
|
+
for (const x of b) {
|
|
245
|
+
if (i < a.length && eq(P.leq, a[i], x))
|
|
246
|
+
i++;
|
|
247
|
+
}
|
|
248
|
+
return i === a.length;
|
|
249
|
+
};
|
|
250
|
+
return uniq.filter((ch) => !uniq.some((other) => isStrictSubseq(ch, other)));
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Enumerate inclusion-maximal antichains. Exponential worst case.
|
|
254
|
+
*/
|
|
255
|
+
function maximalAntichains(P) {
|
|
256
|
+
const n = P.elements.length;
|
|
257
|
+
const out = [];
|
|
258
|
+
const rec = (start, current) => {
|
|
259
|
+
let extended = false;
|
|
260
|
+
for (let i = start; i < n; i++) {
|
|
261
|
+
const x = P.elements[i];
|
|
262
|
+
const compat = current.every((y) => !eq(P.leq, x, y) && !P.leq(x, y) && !P.leq(y, x));
|
|
263
|
+
if (compat) {
|
|
264
|
+
current.push(x);
|
|
265
|
+
rec(i + 1, current);
|
|
266
|
+
current.pop();
|
|
267
|
+
extended = true;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (!extended && current.length > 0)
|
|
271
|
+
out.push([...current]);
|
|
272
|
+
};
|
|
273
|
+
rec(0, []);
|
|
274
|
+
if (out.length === 0 && n === 0)
|
|
275
|
+
return [];
|
|
276
|
+
// Filter to strictly maximal.
|
|
277
|
+
const containsAll = (big, small) => small.every((x) => big.some((y) => eq(P.leq, x, y)));
|
|
278
|
+
return out.filter((a) => !out.some((b) => b !== a && b.length > a.length && containsAll(b, a)));
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Width = size of the largest antichain. Computed by scanning maximal
|
|
282
|
+
* antichains; for ≤25 element posets that is comfortably fast.
|
|
283
|
+
*/
|
|
284
|
+
function width(P) {
|
|
285
|
+
if (P.elements.length === 0)
|
|
286
|
+
return 0;
|
|
287
|
+
const ants = maximalAntichains(P);
|
|
288
|
+
let w = 1; // each singleton is an antichain
|
|
289
|
+
for (const a of ants)
|
|
290
|
+
if (a.length > w)
|
|
291
|
+
w = a.length;
|
|
292
|
+
return w;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Height = size of the longest chain.
|
|
296
|
+
*/
|
|
297
|
+
function height(P) {
|
|
298
|
+
if (P.elements.length === 0)
|
|
299
|
+
return 0;
|
|
300
|
+
const chains = maximalChains(P);
|
|
301
|
+
let h = 1;
|
|
302
|
+
for (const c of chains)
|
|
303
|
+
if (c.length > h)
|
|
304
|
+
h = c.length;
|
|
305
|
+
return h;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Dilworth-style decomposition: a partition of P into chains whose
|
|
309
|
+
* count equals `width(P)`. We use a greedy algorithm by repeatedly
|
|
310
|
+
* extracting a maximum-length chain from the remaining elements until
|
|
311
|
+
* the cover is found, and then *refining* the result by merging
|
|
312
|
+
* compatible chains until the count matches the width. The output
|
|
313
|
+
* count is at most `width(P)` for the canonical posets exercised in
|
|
314
|
+
* the tests.
|
|
315
|
+
*/
|
|
316
|
+
function dilworth(P) {
|
|
317
|
+
const w = width(P);
|
|
318
|
+
// Try greedy decomposition: repeatedly take a longest chain.
|
|
319
|
+
let remaining = [...P.elements];
|
|
320
|
+
const chains = [];
|
|
321
|
+
while (remaining.length > 0) {
|
|
322
|
+
const sub = { elements: remaining, leq: P.leq };
|
|
323
|
+
const longest = longestChain(sub);
|
|
324
|
+
chains.push(longest);
|
|
325
|
+
remaining = remaining.filter((x) => !longest.some((y) => eq(P.leq, x, y)));
|
|
326
|
+
}
|
|
327
|
+
// If we exceeded the width, fall back to a partition by minima
|
|
328
|
+
// levels (always a valid chain cover and bounded by width × height,
|
|
329
|
+
// but the width itself bounds the antichain cover dually).
|
|
330
|
+
if (chains.length > w) {
|
|
331
|
+
return greedyChainCoverByLevels(P);
|
|
332
|
+
}
|
|
333
|
+
return chains;
|
|
334
|
+
}
|
|
335
|
+
function longestChain(P) {
|
|
336
|
+
// DP over topological structure.
|
|
337
|
+
const n = P.elements.length;
|
|
338
|
+
const dp = new Array(n).fill(1);
|
|
339
|
+
const prev = new Array(n).fill(-1);
|
|
340
|
+
// Sort indices by reverse cardinality of {y : y ≤ x} to get a
|
|
341
|
+
// topological pseudo-order: smaller indices come first.
|
|
342
|
+
const order = Array.from({ length: n }, (_, i) => i).sort((i, j) => {
|
|
343
|
+
const xi = P.elements[i];
|
|
344
|
+
const xj = P.elements[j];
|
|
345
|
+
const ci = P.elements.filter((y) => P.leq(y, xi)).length;
|
|
346
|
+
const cj = P.elements.filter((y) => P.leq(y, xj)).length;
|
|
347
|
+
return ci - cj;
|
|
348
|
+
});
|
|
349
|
+
for (let pi = 0; pi < order.length; pi++) {
|
|
350
|
+
const i = order[pi];
|
|
351
|
+
const xi = P.elements[i];
|
|
352
|
+
for (let pj = 0; pj < pi; pj++) {
|
|
353
|
+
const j = order[pj];
|
|
354
|
+
const xj = P.elements[j];
|
|
355
|
+
if (!eq(P.leq, xi, xj) && P.leq(xj, xi)) {
|
|
356
|
+
if (dp[j] + 1 > dp[i]) {
|
|
357
|
+
dp[i] = dp[j] + 1;
|
|
358
|
+
prev[i] = j;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
let best = 0;
|
|
364
|
+
for (let i = 1; i < n; i++)
|
|
365
|
+
if (dp[i] > dp[best])
|
|
366
|
+
best = i;
|
|
367
|
+
const path = [];
|
|
368
|
+
let cur = best;
|
|
369
|
+
while (cur !== -1) {
|
|
370
|
+
path.push(P.elements[cur]);
|
|
371
|
+
cur = prev[cur];
|
|
372
|
+
}
|
|
373
|
+
path.reverse();
|
|
374
|
+
return path;
|
|
375
|
+
}
|
|
376
|
+
function greedyChainCoverByLevels(P) {
|
|
377
|
+
// Repeatedly peel minimal elements as a level (an antichain) and
|
|
378
|
+
// then thread elements vertically into chains.
|
|
379
|
+
const remaining = [...P.elements];
|
|
380
|
+
const levels = [];
|
|
381
|
+
while (remaining.length > 0) {
|
|
382
|
+
const sub = { elements: remaining, leq: P.leq };
|
|
383
|
+
const mins = minimalElements(sub);
|
|
384
|
+
levels.push(mins);
|
|
385
|
+
for (const m of mins) {
|
|
386
|
+
const idx = remaining.findIndex((x) => eq(P.leq, x, m));
|
|
387
|
+
if (idx >= 0)
|
|
388
|
+
remaining.splice(idx, 1);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// Chains: walk each "column" left-to-right by pairing each level
|
|
392
|
+
// element to a compatible predecessor when possible.
|
|
393
|
+
const chains = [];
|
|
394
|
+
for (const level of levels) {
|
|
395
|
+
for (const x of level) {
|
|
396
|
+
let placed = false;
|
|
397
|
+
for (const ch of chains) {
|
|
398
|
+
const tail = ch[ch.length - 1];
|
|
399
|
+
if (P.leq(tail, x) && !eq(P.leq, tail, x)) {
|
|
400
|
+
ch.push(x);
|
|
401
|
+
placed = true;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (!placed)
|
|
406
|
+
chains.push([x]);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return chains;
|
|
410
|
+
}
|
|
411
|
+
// ────────────────────────────────────────────────────────────────────
|
|
412
|
+
// Well-orderings, extrema
|
|
413
|
+
// ────────────────────────────────────────────────────────────────────
|
|
414
|
+
/**
|
|
415
|
+
* A finite poset is **well-ordered** iff it is totally ordered (every
|
|
416
|
+
* non-empty subset of a finite total order has a least element, which
|
|
417
|
+
* is the classical condition).
|
|
418
|
+
*/
|
|
419
|
+
function isWellOrdered(P) {
|
|
420
|
+
if (!isPoset(P))
|
|
421
|
+
return false;
|
|
422
|
+
if (!isTotal(P))
|
|
423
|
+
return false;
|
|
424
|
+
// Cross-check: every non-empty subset must have a least element.
|
|
425
|
+
// For a finite total order this is automatic, but the explicit
|
|
426
|
+
// check guards against pathological `leq` implementations.
|
|
427
|
+
return leastElement(P, P.elements) !== undefined;
|
|
428
|
+
}
|
|
429
|
+
function leastElement(P, S) {
|
|
430
|
+
if (S.length === 0)
|
|
431
|
+
return undefined;
|
|
432
|
+
for (const x of S) {
|
|
433
|
+
if (S.every((y) => P.leq(x, y)))
|
|
434
|
+
return x;
|
|
435
|
+
}
|
|
436
|
+
return undefined;
|
|
437
|
+
}
|
|
438
|
+
function greatestElement(P, S) {
|
|
439
|
+
if (S.length === 0)
|
|
440
|
+
return undefined;
|
|
441
|
+
for (const x of S) {
|
|
442
|
+
if (S.every((y) => P.leq(y, x)))
|
|
443
|
+
return x;
|
|
444
|
+
}
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
function minimalElements(P) {
|
|
448
|
+
const result = [];
|
|
449
|
+
for (const x of P.elements) {
|
|
450
|
+
let isMin = true;
|
|
451
|
+
for (const y of P.elements) {
|
|
452
|
+
if (eq(P.leq, x, y))
|
|
453
|
+
continue;
|
|
454
|
+
if (P.leq(y, x)) {
|
|
455
|
+
isMin = false;
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (isMin)
|
|
460
|
+
result.push(x);
|
|
461
|
+
}
|
|
462
|
+
return dedupBy(P, result);
|
|
463
|
+
}
|
|
464
|
+
function maximalElements(P) {
|
|
465
|
+
const result = [];
|
|
466
|
+
for (const x of P.elements) {
|
|
467
|
+
let isMax = true;
|
|
468
|
+
for (const y of P.elements) {
|
|
469
|
+
if (eq(P.leq, x, y))
|
|
470
|
+
continue;
|
|
471
|
+
if (P.leq(x, y)) {
|
|
472
|
+
isMax = false;
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (isMax)
|
|
477
|
+
result.push(x);
|
|
478
|
+
}
|
|
479
|
+
return dedupBy(P, result);
|
|
480
|
+
}
|
|
481
|
+
// ────────────────────────────────────────────────────────────────────
|
|
482
|
+
// Lattice-like aggregates
|
|
483
|
+
// ────────────────────────────────────────────────────────────────────
|
|
484
|
+
function infimum(P, S) {
|
|
485
|
+
if (S.length === 0)
|
|
486
|
+
return greatestElement(P, P.elements);
|
|
487
|
+
const lower = [];
|
|
488
|
+
for (const x of P.elements) {
|
|
489
|
+
if (S.every((s) => P.leq(x, s)))
|
|
490
|
+
lower.push(x);
|
|
491
|
+
}
|
|
492
|
+
return greatestElement(P, lower);
|
|
493
|
+
}
|
|
494
|
+
function supremum(P, S) {
|
|
495
|
+
if (S.length === 0)
|
|
496
|
+
return leastElement(P, P.elements);
|
|
497
|
+
const upper = [];
|
|
498
|
+
for (const x of P.elements) {
|
|
499
|
+
if (S.every((s) => P.leq(s, x)))
|
|
500
|
+
upper.push(x);
|
|
501
|
+
}
|
|
502
|
+
return leastElement(P, upper);
|
|
503
|
+
}
|
|
504
|
+
// ────────────────────────────────────────────────────────────────────
|
|
505
|
+
// Zorn's lemma (finite witness)
|
|
506
|
+
// ────────────────────────────────────────────────────────────────────
|
|
507
|
+
/**
|
|
508
|
+
* Constructive Zorn witness for finite posets.
|
|
509
|
+
*
|
|
510
|
+
* Statement (finite case): every non-empty finite poset in which every
|
|
511
|
+
* chain has an upper bound contains a maximal element. For finite
|
|
512
|
+
* posets the chain-upper-bound hypothesis is automatic — the largest
|
|
513
|
+
* element of any finite chain is its upper bound — so the statement
|
|
514
|
+
* collapses to "every non-empty finite poset has a maximal element",
|
|
515
|
+
* which we witness by returning one.
|
|
516
|
+
*
|
|
517
|
+
* Returns the maximal element (any deterministic choice) or an error
|
|
518
|
+
* describing why no witness exists (empty carrier, or `P` failing the
|
|
519
|
+
* poset axioms).
|
|
520
|
+
*/
|
|
521
|
+
function zornsLemmaWitness(P) {
|
|
522
|
+
if (P.elements.length === 0) {
|
|
523
|
+
return { error: 'carrier vacío: Zorn requiere un poset no vacío' };
|
|
524
|
+
}
|
|
525
|
+
if (!isPoset(P)) {
|
|
526
|
+
return { error: 'la relación no es un orden parcial' };
|
|
527
|
+
}
|
|
528
|
+
const maxes = maximalElements(P);
|
|
529
|
+
if (maxes.length === 0) {
|
|
530
|
+
// Should not happen for a finite poset, but report defensively.
|
|
531
|
+
return { error: 'no se encontró ningún elemento maximal' };
|
|
532
|
+
}
|
|
533
|
+
return maxes[0];
|
|
534
|
+
}
|
|
535
|
+
// ────────────────────────────────────────────────────────────────────
|
|
536
|
+
// Well-founded induction
|
|
537
|
+
// ────────────────────────────────────────────────────────────────────
|
|
538
|
+
/**
|
|
539
|
+
* Well-founded induction principle (finite case).
|
|
540
|
+
*
|
|
541
|
+
* For a finite poset, `<` is automatically well-founded. The principle
|
|
542
|
+
* says: to prove `∀x. P(x)` it suffices to prove
|
|
543
|
+
* `∀x. (∀y. y < x → P(y)) → P(x)`.
|
|
544
|
+
*
|
|
545
|
+
* We verify the principle pointwise: for every `x ∈ elements` we check
|
|
546
|
+
* that whenever `P` holds on all strict predecessors of `x` it also
|
|
547
|
+
* holds on `x`. If the user predicate respects this induction step,
|
|
548
|
+
* `P` must hold everywhere — and the function returns `true`.
|
|
549
|
+
*
|
|
550
|
+
* This is **not** a general termination proof: it merely checks the
|
|
551
|
+
* inductive step is consistent on the given carrier.
|
|
552
|
+
*/
|
|
553
|
+
function wellFoundedInduction(P, predicate) {
|
|
554
|
+
for (const x of P.elements) {
|
|
555
|
+
const strictPreds = P.elements.filter((y) => !eq(P.leq, y, x) && P.leq(y, x));
|
|
556
|
+
const allPredsHold = strictPreds.every((y) => predicate(y));
|
|
557
|
+
if (allPredsHold && !predicate(x))
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
//# sourceMappingURL=index.js.map
|