@stevenvo780/st-lang 4.3.0 → 4.5.0
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/dist/coinduction/index.d.ts +136 -0
- package/dist/coinduction/index.d.ts.map +1 -0
- package/dist/coinduction/index.js +318 -0
- package/dist/coinduction/index.js.map +1 -0
- package/dist/combinators-ski/abstract.d.ts +5 -0
- package/dist/combinators-ski/abstract.d.ts.map +1 -0
- package/dist/combinators-ski/abstract.js +88 -0
- package/dist/combinators-ski/abstract.js.map +1 -0
- package/dist/combinators-ski/index.d.ts +6 -0
- package/dist/combinators-ski/index.d.ts.map +1 -0
- package/dist/combinators-ski/index.js +30 -0
- package/dist/combinators-ski/index.js.map +1 -0
- package/dist/combinators-ski/reduce.d.ts +10 -0
- package/dist/combinators-ski/reduce.d.ts.map +1 -0
- package/dist/combinators-ski/reduce.js +118 -0
- package/dist/combinators-ski/reduce.js.map +1 -0
- package/dist/combinators-ski/types.d.ts +23 -0
- package/dist/combinators-ski/types.d.ts.map +1 -0
- package/dist/combinators-ski/types.js +102 -0
- package/dist/combinators-ski/types.js.map +1 -0
- package/dist/constructive-reals/index.d.ts +132 -0
- package/dist/constructive-reals/index.d.ts.map +1 -0
- package/dist/constructive-reals/index.js +723 -0
- package/dist/constructive-reals/index.js.map +1 -0
- package/dist/game-semantics/convert.d.ts +4 -0
- package/dist/game-semantics/convert.d.ts.map +1 -0
- package/dist/game-semantics/convert.js +28 -0
- package/dist/game-semantics/convert.js.map +1 -0
- package/dist/game-semantics/index.d.ts +6 -0
- package/dist/game-semantics/index.d.ts.map +1 -0
- package/dist/game-semantics/index.js +28 -0
- package/dist/game-semantics/index.js.map +1 -0
- package/dist/game-semantics/strategy.d.ts +34 -0
- package/dist/game-semantics/strategy.d.ts.map +1 -0
- package/dist/game-semantics/strategy.js +336 -0
- package/dist/game-semantics/strategy.js.map +1 -0
- package/dist/game-semantics/types.d.ts +64 -0
- package/dist/game-semantics/types.d.ts.map +1 -0
- package/dist/game-semantics/types.js +78 -0
- package/dist/game-semantics/types.js.map +1 -0
- package/dist/higher-order-unify/index.d.ts +5 -0
- package/dist/higher-order-unify/index.d.ts.map +1 -0
- package/dist/higher-order-unify/index.js +27 -0
- package/dist/higher-order-unify/index.js.map +1 -0
- package/dist/higher-order-unify/normalize.d.ts +14 -0
- package/dist/higher-order-unify/normalize.d.ts.map +1 -0
- package/dist/higher-order-unify/normalize.js +191 -0
- package/dist/higher-order-unify/normalize.js.map +1 -0
- package/dist/higher-order-unify/pattern.d.ts +4 -0
- package/dist/higher-order-unify/pattern.d.ts.map +1 -0
- package/dist/higher-order-unify/pattern.js +70 -0
- package/dist/higher-order-unify/pattern.js.map +1 -0
- package/dist/higher-order-unify/types.d.ts +19 -0
- package/dist/higher-order-unify/types.d.ts.map +1 -0
- package/dist/higher-order-unify/types.js +14 -0
- package/dist/higher-order-unify/types.js.map +1 -0
- package/dist/higher-order-unify/unify.d.ts +5 -0
- package/dist/higher-order-unify/unify.d.ts.map +1 -0
- package/dist/higher-order-unify/unify.js +306 -0
- package/dist/higher-order-unify/unify.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/dist/lambda-calc/church.d.ts.map +1 -1
- package/dist/lambda-calc/church.js.map +1 -1
- package/dist/lambda-calc/combinators.d.ts.map +1 -1
- package/dist/lambda-calc/combinators.js.map +1 -1
- package/dist/lambda-calc/index.d.ts +1 -1
- package/dist/lambda-calc/index.d.ts.map +1 -1
- package/dist/lambda-calc/index.js.map +1 -1
- package/dist/mltt/equality.d.ts +9 -0
- package/dist/mltt/equality.d.ts.map +1 -0
- package/dist/mltt/equality.js +79 -0
- package/dist/mltt/equality.js.map +1 -0
- package/dist/mltt/index.d.ts +8 -0
- package/dist/mltt/index.d.ts.map +1 -0
- package/dist/mltt/index.js +49 -0
- package/dist/mltt/index.js.map +1 -0
- package/dist/mltt/infer.d.ts +17 -0
- package/dist/mltt/infer.d.ts.map +1 -0
- package/dist/mltt/infer.js +269 -0
- package/dist/mltt/infer.js.map +1 -0
- package/dist/mltt/normalize.d.ts +7 -0
- package/dist/mltt/normalize.d.ts.map +1 -0
- package/dist/mltt/normalize.js +131 -0
- package/dist/mltt/normalize.js.map +1 -0
- package/dist/mltt/substitute.d.ts +4 -0
- package/dist/mltt/substitute.d.ts.map +1 -0
- package/dist/mltt/substitute.js +94 -0
- package/dist/mltt/substitute.js.map +1 -0
- package/dist/mltt/types.d.ts +72 -0
- package/dist/mltt/types.d.ts.map +1 -0
- package/dist/mltt/types.js +211 -0
- package/dist/mltt/types.js.map +1 -0
- package/dist/nbe/index.d.ts +3 -0
- package/dist/nbe/index.d.ts.map +1 -0
- package/dist/nbe/index.js +25 -0
- package/dist/nbe/index.js.map +1 -0
- package/dist/nbe/nbe.d.ts +7 -0
- package/dist/nbe/nbe.d.ts.map +1 -0
- package/dist/nbe/nbe.js +118 -0
- package/dist/nbe/nbe.js.map +1 -0
- package/dist/nbe/types.d.ts +54 -0
- package/dist/nbe/types.d.ts.map +1 -0
- package/dist/nbe/types.js +117 -0
- package/dist/nbe/types.js.map +1 -0
- package/dist/profile-bridge/index.d.ts +64 -0
- package/dist/profile-bridge/index.d.ts.map +1 -0
- package/dist/profile-bridge/index.js +328 -0
- package/dist/profile-bridge/index.js.map +1 -0
- package/dist/profiles/many-valued/index.d.ts.map +1 -1
- package/dist/profiles/many-valued/index.js.map +1 -1
- package/dist/profiles/mu-calculus/check.d.ts +15 -0
- package/dist/profiles/mu-calculus/check.d.ts.map +1 -0
- package/dist/profiles/mu-calculus/check.js +172 -0
- package/dist/profiles/mu-calculus/check.js.map +1 -0
- package/dist/profiles/mu-calculus/ctl-translate.d.ts +61 -0
- package/dist/profiles/mu-calculus/ctl-translate.d.ts.map +1 -0
- package/dist/profiles/mu-calculus/ctl-translate.js +181 -0
- package/dist/profiles/mu-calculus/ctl-translate.js.map +1 -0
- package/dist/profiles/mu-calculus/index.d.ts +7 -0
- package/dist/profiles/mu-calculus/index.d.ts.map +1 -0
- package/dist/profiles/mu-calculus/index.js +33 -0
- package/dist/profiles/mu-calculus/index.js.map +1 -0
- package/dist/profiles/mu-calculus/types.d.ts +51 -0
- package/dist/profiles/mu-calculus/types.d.ts.map +1 -0
- package/dist/profiles/mu-calculus/types.js +42 -0
- package/dist/profiles/mu-calculus/types.js.map +1 -0
- package/dist/profiles/mu-calculus/wellformed.d.ts +40 -0
- package/dist/profiles/mu-calculus/wellformed.d.ts.map +1 -0
- package/dist/profiles/mu-calculus/wellformed.js +160 -0
- package/dist/profiles/mu-calculus/wellformed.js.map +1 -0
- package/dist/profiles/sequent-lk/cut-elimination.d.ts +11 -0
- package/dist/profiles/sequent-lk/cut-elimination.d.ts.map +1 -0
- package/dist/profiles/sequent-lk/cut-elimination.js +216 -0
- package/dist/profiles/sequent-lk/cut-elimination.js.map +1 -0
- package/dist/profiles/sequent-lk/index.d.ts +5 -0
- package/dist/profiles/sequent-lk/index.d.ts.map +1 -0
- package/dist/profiles/sequent-lk/index.js +24 -0
- package/dist/profiles/sequent-lk/index.js.map +1 -0
- package/dist/profiles/sequent-lk/prover.d.ts +25 -0
- package/dist/profiles/sequent-lk/prover.d.ts.map +1 -0
- package/dist/profiles/sequent-lk/prover.js +532 -0
- package/dist/profiles/sequent-lk/prover.js.map +1 -0
- package/dist/profiles/sequent-lk/types.d.ts +55 -0
- package/dist/profiles/sequent-lk/types.d.ts.map +1 -0
- package/dist/profiles/sequent-lk/types.js +18 -0
- package/dist/profiles/sequent-lk/types.js.map +1 -0
- package/dist/profiles/sequent-lk/util.d.ts +18 -0
- package/dist/profiles/sequent-lk/util.d.ts.map +1 -0
- package/dist/profiles/sequent-lk/util.js +71 -0
- package/dist/profiles/sequent-lk/util.js.map +1 -0
- package/dist/proof-nets/construct.d.ts +3 -0
- package/dist/proof-nets/construct.d.ts.map +1 -0
- package/dist/proof-nets/construct.js +85 -0
- package/dist/proof-nets/construct.js.map +1 -0
- package/dist/proof-nets/correctness.d.ts +3 -0
- package/dist/proof-nets/correctness.d.ts.map +1 -0
- package/dist/proof-nets/correctness.js +213 -0
- package/dist/proof-nets/correctness.js.map +1 -0
- package/dist/proof-nets/cut-elim.d.ts +9 -0
- package/dist/proof-nets/cut-elim.d.ts.map +1 -0
- package/dist/proof-nets/cut-elim.js +149 -0
- package/dist/proof-nets/cut-elim.js.map +1 -0
- package/dist/proof-nets/index.d.ts +6 -0
- package/dist/proof-nets/index.d.ts.map +1 -0
- package/dist/proof-nets/index.js +33 -0
- package/dist/proof-nets/index.js.map +1 -0
- package/dist/proof-nets/types.d.ts +36 -0
- package/dist/proof-nets/types.d.ts.map +1 -0
- package/dist/proof-nets/types.js +89 -0
- package/dist/proof-nets/types.js.map +1 -0
- package/dist/refinement-types/checker.d.ts +19 -0
- package/dist/refinement-types/checker.d.ts.map +1 -0
- package/dist/refinement-types/checker.js +248 -0
- package/dist/refinement-types/checker.js.map +1 -0
- package/dist/refinement-types/index.d.ts +11 -0
- package/dist/refinement-types/index.d.ts.map +1 -0
- package/dist/refinement-types/index.js +51 -0
- package/dist/refinement-types/index.js.map +1 -0
- package/dist/refinement-types/predicate.d.ts +31 -0
- package/dist/refinement-types/predicate.d.ts.map +1 -0
- package/dist/refinement-types/predicate.js +369 -0
- package/dist/refinement-types/predicate.js.map +1 -0
- package/dist/refinement-types/solver.d.ts +24 -0
- package/dist/refinement-types/solver.d.ts.map +1 -0
- package/dist/refinement-types/solver.js +207 -0
- package/dist/refinement-types/solver.js.map +1 -0
- package/dist/refinement-types/subtype.d.ts +14 -0
- package/dist/refinement-types/subtype.d.ts.map +1 -0
- package/dist/refinement-types/subtype.js +39 -0
- package/dist/refinement-types/subtype.js.map +1 -0
- package/dist/refinement-types/types.d.ts +64 -0
- package/dist/refinement-types/types.d.ts.map +1 -0
- package/dist/refinement-types/types.js +130 -0
- package/dist/refinement-types/types.js.map +1 -0
- package/dist/runtime/anti-unification/anti-unify.d.ts +22 -0
- package/dist/runtime/anti-unification/anti-unify.d.ts.map +1 -0
- package/dist/runtime/anti-unification/anti-unify.js +154 -0
- package/dist/runtime/anti-unification/anti-unify.js.map +1 -0
- package/dist/runtime/anti-unification/index.d.ts +6 -0
- package/dist/runtime/anti-unification/index.d.ts.map +1 -0
- package/dist/runtime/anti-unification/index.js +23 -0
- package/dist/runtime/anti-unification/index.js.map +1 -0
- package/dist/runtime/anti-unification/many.d.ts +49 -0
- package/dist/runtime/anti-unification/many.d.ts.map +1 -0
- package/dist/runtime/anti-unification/many.js +185 -0
- package/dist/runtime/anti-unification/many.js.map +1 -0
- package/dist/runtime/anti-unification/term-utils.d.ts +40 -0
- package/dist/runtime/anti-unification/term-utils.d.ts.map +1 -0
- package/dist/runtime/anti-unification/term-utils.js +173 -0
- package/dist/runtime/anti-unification/term-utils.js.map +1 -0
- package/dist/runtime/anti-unification/types.d.ts +41 -0
- package/dist/runtime/anti-unification/types.d.ts.map +1 -0
- package/dist/runtime/anti-unification/types.js +26 -0
- package/dist/runtime/anti-unification/types.js.map +1 -0
- package/dist/runtime/csp/ac3.d.ts +20 -0
- package/dist/runtime/csp/ac3.d.ts.map +1 -0
- package/dist/runtime/csp/ac3.js +165 -0
- package/dist/runtime/csp/ac3.js.map +1 -0
- package/dist/runtime/csp/backtrack.d.ts +15 -0
- package/dist/runtime/csp/backtrack.d.ts.map +1 -0
- package/dist/runtime/csp/backtrack.js +233 -0
- package/dist/runtime/csp/backtrack.js.map +1 -0
- package/dist/runtime/csp/builtins.d.ts +27 -0
- package/dist/runtime/csp/builtins.d.ts.map +1 -0
- package/dist/runtime/csp/builtins.js +109 -0
- package/dist/runtime/csp/builtins.js.map +1 -0
- package/dist/runtime/csp/index.d.ts +5 -0
- package/dist/runtime/csp/index.d.ts.map +1 -0
- package/dist/runtime/csp/index.js +23 -0
- package/dist/runtime/csp/index.js.map +1 -0
- package/dist/runtime/csp/types.d.ts +54 -0
- package/dist/runtime/csp/types.d.ts.map +1 -0
- package/dist/runtime/csp/types.js +14 -0
- package/dist/runtime/csp/types.js.map +1 -0
- package/dist/runtime/markov-logic/grounding.d.ts +19 -0
- package/dist/runtime/markov-logic/grounding.d.ts.map +1 -0
- package/dist/runtime/markov-logic/grounding.js +252 -0
- package/dist/runtime/markov-logic/grounding.js.map +1 -0
- package/dist/runtime/markov-logic/index.d.ts +6 -0
- package/dist/runtime/markov-logic/index.d.ts.map +1 -0
- package/dist/runtime/markov-logic/index.js +47 -0
- package/dist/runtime/markov-logic/index.js.map +1 -0
- package/dist/runtime/markov-logic/inference.d.ts +77 -0
- package/dist/runtime/markov-logic/inference.d.ts.map +1 -0
- package/dist/runtime/markov-logic/inference.js +382 -0
- package/dist/runtime/markov-logic/inference.js.map +1 -0
- package/dist/runtime/markov-logic/parser.d.ts +25 -0
- package/dist/runtime/markov-logic/parser.d.ts.map +1 -0
- package/dist/runtime/markov-logic/parser.js +264 -0
- package/dist/runtime/markov-logic/parser.js.map +1 -0
- package/dist/runtime/markov-logic/types.d.ts +64 -0
- package/dist/runtime/markov-logic/types.d.ts.map +1 -0
- package/dist/runtime/markov-logic/types.js +17 -0
- package/dist/runtime/markov-logic/types.js.map +1 -0
- package/dist/runtime/pi-calculus/congruence.d.ts +15 -0
- package/dist/runtime/pi-calculus/congruence.d.ts.map +1 -0
- package/dist/runtime/pi-calculus/congruence.js +271 -0
- package/dist/runtime/pi-calculus/congruence.js.map +1 -0
- package/dist/runtime/pi-calculus/index.d.ts +6 -0
- package/dist/runtime/pi-calculus/index.d.ts.map +1 -0
- package/dist/runtime/pi-calculus/index.js +30 -0
- package/dist/runtime/pi-calculus/index.js.map +1 -0
- package/dist/runtime/pi-calculus/names.d.ts +28 -0
- package/dist/runtime/pi-calculus/names.d.ts.map +1 -0
- package/dist/runtime/pi-calculus/names.js +182 -0
- package/dist/runtime/pi-calculus/names.js.map +1 -0
- package/dist/runtime/pi-calculus/reduction.d.ts +25 -0
- package/dist/runtime/pi-calculus/reduction.d.ts.map +1 -0
- package/dist/runtime/pi-calculus/reduction.js +338 -0
- package/dist/runtime/pi-calculus/reduction.js.map +1 -0
- package/dist/runtime/pi-calculus/substitution.d.ts +11 -0
- package/dist/runtime/pi-calculus/substitution.d.ts.map +1 -0
- package/dist/runtime/pi-calculus/substitution.js +109 -0
- package/dist/runtime/pi-calculus/substitution.js.map +1 -0
- package/dist/runtime/pi-calculus/types.d.ts +38 -0
- package/dist/runtime/pi-calculus/types.d.ts.map +1 -0
- package/dist/runtime/pi-calculus/types.js +22 -0
- package/dist/runtime/pi-calculus/types.js.map +1 -0
- package/dist/runtime/planning/astar.d.ts +10 -0
- package/dist/runtime/planning/astar.d.ts.map +1 -0
- package/dist/runtime/planning/astar.js +155 -0
- package/dist/runtime/planning/astar.js.map +1 -0
- package/dist/runtime/planning/bfs.d.ts +17 -0
- package/dist/runtime/planning/bfs.d.ts.map +1 -0
- package/dist/runtime/planning/bfs.js +87 -0
- package/dist/runtime/planning/bfs.js.map +1 -0
- package/dist/runtime/planning/ground.d.ts +55 -0
- package/dist/runtime/planning/ground.d.ts.map +1 -0
- package/dist/runtime/planning/ground.js +154 -0
- package/dist/runtime/planning/ground.js.map +1 -0
- package/dist/runtime/planning/heuristic.d.ts +29 -0
- package/dist/runtime/planning/heuristic.d.ts.map +1 -0
- package/dist/runtime/planning/heuristic.js +172 -0
- package/dist/runtime/planning/heuristic.js.map +1 -0
- package/dist/runtime/planning/index.d.ts +6 -0
- package/dist/runtime/planning/index.d.ts.map +1 -0
- package/dist/runtime/planning/index.js +38 -0
- package/dist/runtime/planning/index.js.map +1 -0
- package/dist/runtime/planning/types.d.ts +100 -0
- package/dist/runtime/planning/types.d.ts.map +1 -0
- package/dist/runtime/planning/types.js +22 -0
- package/dist/runtime/planning/types.js.map +1 -0
- package/dist/runtime/symbolic-diff/differentiate.d.ts.map +1 -1
- package/dist/runtime/symbolic-diff/differentiate.js.map +1 -1
- package/dist/runtime/symbolic-diff/index.d.ts +1 -1
- package/dist/runtime/symbolic-diff/index.d.ts.map +1 -1
- package/dist/runtime/symbolic-diff/index.js.map +1 -1
- package/dist/runtime/symbolic-diff/parse.d.ts.map +1 -1
- package/dist/runtime/symbolic-diff/parse.js +7 -1
- package/dist/runtime/symbolic-diff/parse.js.map +1 -1
- package/dist/runtime/theorem-cache/cache.d.ts +100 -0
- package/dist/runtime/theorem-cache/cache.d.ts.map +1 -0
- package/dist/runtime/theorem-cache/cache.js +213 -0
- package/dist/runtime/theorem-cache/cache.js.map +1 -0
- package/dist/runtime/theorem-cache/canonical.d.ts +59 -0
- package/dist/runtime/theorem-cache/canonical.d.ts.map +1 -0
- package/dist/runtime/theorem-cache/canonical.js +105 -0
- package/dist/runtime/theorem-cache/canonical.js.map +1 -0
- package/dist/runtime/theorem-cache/index.d.ts +6 -0
- package/dist/runtime/theorem-cache/index.d.ts.map +1 -0
- package/dist/runtime/theorem-cache/index.js +16 -0
- package/dist/runtime/theorem-cache/index.js.map +1 -0
- package/dist/runtime/theorem-cache/pattern.d.ts +24 -0
- package/dist/runtime/theorem-cache/pattern.d.ts.map +1 -0
- package/dist/runtime/theorem-cache/pattern.js +80 -0
- package/dist/runtime/theorem-cache/pattern.js.map +1 -0
- package/dist/system-f/index.d.ts +7 -0
- package/dist/system-f/index.d.ts.map +1 -0
- package/dist/system-f/index.js +48 -0
- package/dist/system-f/index.js.map +1 -0
- package/dist/system-f/infer.d.ts +9 -0
- package/dist/system-f/infer.d.ts.map +1 -0
- package/dist/system-f/infer.js +94 -0
- package/dist/system-f/infer.js.map +1 -0
- package/dist/system-f/reduce.d.ts +15 -0
- package/dist/system-f/reduce.d.ts.map +1 -0
- package/dist/system-f/reduce.js +259 -0
- package/dist/system-f/reduce.js.map +1 -0
- package/dist/system-f/types.d.ts +53 -0
- package/dist/system-f/types.d.ts.map +1 -0
- package/dist/system-f/types.js +157 -0
- package/dist/system-f/types.js.map +1 -0
- package/dist/tableau-framework/TableauProver.d.ts +10 -0
- package/dist/tableau-framework/TableauProver.d.ts.map +1 -0
- package/dist/tableau-framework/TableauProver.js +118 -0
- package/dist/tableau-framework/TableauProver.js.map +1 -0
- package/dist/tableau-framework/index.d.ts +5 -0
- package/dist/tableau-framework/index.d.ts.map +1 -0
- package/dist/tableau-framework/index.js +11 -0
- package/dist/tableau-framework/index.js.map +1 -0
- package/dist/tableau-framework/propositional.d.ts +11 -0
- package/dist/tableau-framework/propositional.d.ts.map +1 -0
- package/dist/tableau-framework/propositional.js +143 -0
- package/dist/tableau-framework/propositional.js.map +1 -0
- package/dist/tableau-framework/types.d.ts +32 -0
- package/dist/tableau-framework/types.d.ts.map +1 -0
- package/dist/tableau-framework/types.js +6 -0
- package/dist/tableau-framework/types.js.map +1 -0
- package/dist/tests/anti-unification/anti-unify.test.d.ts +2 -0
- package/dist/tests/anti-unification/anti-unify.test.d.ts.map +1 -0
- package/dist/tests/anti-unification/anti-unify.test.js +219 -0
- package/dist/tests/anti-unification/anti-unify.test.js.map +1 -0
- package/dist/tests/coinduction/coinduction.test.d.ts +2 -0
- package/dist/tests/coinduction/coinduction.test.d.ts.map +1 -0
- package/dist/tests/coinduction/coinduction.test.js +217 -0
- package/dist/tests/coinduction/coinduction.test.js.map +1 -0
- package/dist/tests/combinators-ski/combinators-ski.test.d.ts +2 -0
- package/dist/tests/combinators-ski/combinators-ski.test.d.ts.map +1 -0
- package/dist/tests/combinators-ski/combinators-ski.test.js +211 -0
- package/dist/tests/combinators-ski/combinators-ski.test.js.map +1 -0
- package/dist/tests/constructive-reals/constructive-reals.test.d.ts +2 -0
- package/dist/tests/constructive-reals/constructive-reals.test.d.ts.map +1 -0
- package/dist/tests/constructive-reals/constructive-reals.test.js +357 -0
- package/dist/tests/constructive-reals/constructive-reals.test.js.map +1 -0
- package/dist/tests/coverage-fill-aristotelian.test.js +1 -1
- package/dist/tests/coverage-fill-aristotelian.test.js.map +1 -1
- package/dist/tests/coverage-fill-fallacies.test.js +1 -1
- package/dist/tests/coverage-fill-fallacies.test.js.map +1 -1
- package/dist/tests/coverage-fill-format.test.js +1 -1
- package/dist/tests/coverage-fill-format.test.js.map +1 -1
- package/dist/tests/coverage-fill-intuitionistic.test.js +1 -1
- package/dist/tests/coverage-fill-intuitionistic.test.js.map +1 -1
- package/dist/tests/coverage-fill-probabilistic.test.js +1 -1
- package/dist/tests/coverage-fill-probabilistic.test.js.map +1 -1
- package/dist/tests/csp/csp.test.d.ts +2 -0
- package/dist/tests/csp/csp.test.d.ts.map +1 -0
- package/dist/tests/csp/csp.test.js +292 -0
- package/dist/tests/csp/csp.test.js.map +1 -0
- package/dist/tests/game-semantics/game-semantics.test.d.ts +2 -0
- package/dist/tests/game-semantics/game-semantics.test.d.ts.map +1 -0
- package/dist/tests/game-semantics/game-semantics.test.js +143 -0
- package/dist/tests/game-semantics/game-semantics.test.js.map +1 -0
- package/dist/tests/higher-order-unify/ho-unify.test.d.ts +2 -0
- package/dist/tests/higher-order-unify/ho-unify.test.d.ts.map +1 -0
- package/dist/tests/higher-order-unify/ho-unify.test.js +264 -0
- package/dist/tests/higher-order-unify/ho-unify.test.js.map +1 -0
- package/dist/tests/integration/cross-modules.test.d.ts +8 -0
- package/dist/tests/integration/cross-modules.test.d.ts.map +1 -0
- package/dist/tests/integration/cross-modules.test.js +668 -0
- package/dist/tests/integration/cross-modules.test.js.map +1 -0
- package/dist/tests/lambda-calc/lambda-calc.test.js.map +1 -1
- package/dist/tests/many-valued/many-valued.test.js.map +1 -1
- package/dist/tests/markov-logic/markov-logic.test.d.ts +2 -0
- package/dist/tests/markov-logic/markov-logic.test.d.ts.map +1 -0
- package/dist/tests/markov-logic/markov-logic.test.js +349 -0
- package/dist/tests/markov-logic/markov-logic.test.js.map +1 -0
- package/dist/tests/mltt/mltt.test.d.ts +2 -0
- package/dist/tests/mltt/mltt.test.d.ts.map +1 -0
- package/dist/tests/mltt/mltt.test.js +181 -0
- package/dist/tests/mltt/mltt.test.js.map +1 -0
- package/dist/tests/mu-calculus/check.test.d.ts +2 -0
- package/dist/tests/mu-calculus/check.test.d.ts.map +1 -0
- package/dist/tests/mu-calculus/check.test.js +234 -0
- package/dist/tests/mu-calculus/check.test.js.map +1 -0
- package/dist/tests/nbe/nbe.test.d.ts +2 -0
- package/dist/tests/nbe/nbe.test.d.ts.map +1 -0
- package/dist/tests/nbe/nbe.test.js +121 -0
- package/dist/tests/nbe/nbe.test.js.map +1 -0
- package/dist/tests/pi-calculus/pi-calculus.test.d.ts +2 -0
- package/dist/tests/pi-calculus/pi-calculus.test.d.ts.map +1 -0
- package/dist/tests/pi-calculus/pi-calculus.test.js +273 -0
- package/dist/tests/pi-calculus/pi-calculus.test.js.map +1 -0
- package/dist/tests/planning/planning.test.d.ts +2 -0
- package/dist/tests/planning/planning.test.d.ts.map +1 -0
- package/dist/tests/planning/planning.test.js +397 -0
- package/dist/tests/planning/planning.test.js.map +1 -0
- package/dist/tests/profile-bridge/translations.test.d.ts +2 -0
- package/dist/tests/profile-bridge/translations.test.d.ts.map +1 -0
- package/dist/tests/profile-bridge/translations.test.js +266 -0
- package/dist/tests/profile-bridge/translations.test.js.map +1 -0
- package/dist/tests/proof-nets/proof-nets.test.d.ts +2 -0
- package/dist/tests/proof-nets/proof-nets.test.d.ts.map +1 -0
- package/dist/tests/proof-nets/proof-nets.test.js +263 -0
- package/dist/tests/proof-nets/proof-nets.test.js.map +1 -0
- package/dist/tests/refinement-types/refinement-types.test.d.ts +2 -0
- package/dist/tests/refinement-types/refinement-types.test.d.ts.map +1 -0
- package/dist/tests/refinement-types/refinement-types.test.js +174 -0
- package/dist/tests/refinement-types/refinement-types.test.js.map +1 -0
- package/dist/tests/sequent-lk/prover.test.d.ts +2 -0
- package/dist/tests/sequent-lk/prover.test.d.ts.map +1 -0
- package/dist/tests/sequent-lk/prover.test.js +317 -0
- package/dist/tests/sequent-lk/prover.test.js.map +1 -0
- package/dist/tests/symbolic-diff/symbolic-diff.test.js.map +1 -1
- package/dist/tests/system-f/system-f.test.d.ts +2 -0
- package/dist/tests/system-f/system-f.test.d.ts.map +1 -0
- package/dist/tests/system-f/system-f.test.js +217 -0
- package/dist/tests/system-f/system-f.test.js.map +1 -0
- package/dist/tests/tableau-framework/tableau.test.d.ts +2 -0
- package/dist/tests/tableau-framework/tableau.test.d.ts.map +1 -0
- package/dist/tests/tableau-framework/tableau.test.js +196 -0
- package/dist/tests/tableau-framework/tableau.test.js.map +1 -0
- package/dist/tests/theorem-cache/cache.test.d.ts +2 -0
- package/dist/tests/theorem-cache/cache.test.d.ts.map +1 -0
- package/dist/tests/theorem-cache/cache.test.js +510 -0
- package/dist/tests/theorem-cache/cache.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const combinators_ski_1 = require("../../combinators-ski");
|
|
5
|
+
const lambda_calc_1 = require("../../lambda-calc");
|
|
6
|
+
(0, vitest_1.describe)('combinators-ski / reducción básica', () => {
|
|
7
|
+
(0, vitest_1.it)('I x reduce a x en un paso', () => {
|
|
8
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.I)(), (0, combinators_ski_1.cvar)('x'));
|
|
9
|
+
const r = (0, combinators_ski_1.reduceStep)(t);
|
|
10
|
+
(0, vitest_1.expect)(r).not.toBeNull();
|
|
11
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(r, (0, combinators_ski_1.cvar)('x'))).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.it)('K x y reduce a x en un paso', () => {
|
|
14
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.K)(), (0, combinators_ski_1.cvar)('x'), (0, combinators_ski_1.cvar)('y'));
|
|
15
|
+
const r = (0, combinators_ski_1.reduceStep)(t);
|
|
16
|
+
(0, vitest_1.expect)(r).not.toBeNull();
|
|
17
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(r, (0, combinators_ski_1.cvar)('x'))).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
(0, vitest_1.it)('K x y descarta y aunque y tenga redex', () => {
|
|
20
|
+
// y = I z; tras K x (I z) debe quedar x — sin reducir el segundo arg.
|
|
21
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.K)(), (0, combinators_ski_1.cvar)('x'), (0, combinators_ski_1.app)((0, combinators_ski_1.I)(), (0, combinators_ski_1.cvar)('z')));
|
|
22
|
+
const norm = (0, combinators_ski_1.normalize)(t);
|
|
23
|
+
(0, vitest_1.expect)(norm.terminated).toBe(true);
|
|
24
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(norm.result, (0, combinators_ski_1.cvar)('x'))).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.it)('S x y z reduce a x z (y z)', () => {
|
|
27
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.S)(), (0, combinators_ski_1.cvar)('x'), (0, combinators_ski_1.cvar)('y'), (0, combinators_ski_1.cvar)('z'));
|
|
28
|
+
const r = (0, combinators_ski_1.reduceStep)(t);
|
|
29
|
+
(0, vitest_1.expect)(r).not.toBeNull();
|
|
30
|
+
const expected = (0, combinators_ski_1.app)((0, combinators_ski_1.app)((0, combinators_ski_1.cvar)('x'), (0, combinators_ski_1.cvar)('z')), (0, combinators_ski_1.app)((0, combinators_ski_1.cvar)('y'), (0, combinators_ski_1.cvar)('z')));
|
|
31
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(r, expected)).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
(0, vitest_1.it)('S K K x reduce a x (= I)', () => {
|
|
34
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.S)(), (0, combinators_ski_1.K)(), (0, combinators_ski_1.K)(), (0, combinators_ski_1.cvar)('x'));
|
|
35
|
+
const norm = (0, combinators_ski_1.normalize)(t);
|
|
36
|
+
(0, vitest_1.expect)(norm.terminated).toBe(true);
|
|
37
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(norm.result, (0, combinators_ski_1.cvar)('x'))).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)('isNormalForm: variable libre sola es forma normal', () => {
|
|
40
|
+
(0, vitest_1.expect)((0, combinators_ski_1.isNormalForm)((0, combinators_ski_1.cvar)('x'))).toBe(true);
|
|
41
|
+
(0, vitest_1.expect)((0, combinators_ski_1.isNormalForm)((0, combinators_ski_1.I)())).toBe(true);
|
|
42
|
+
(0, vitest_1.expect)((0, combinators_ski_1.isNormalForm)((0, combinators_ski_1.K)())).toBe(true);
|
|
43
|
+
(0, vitest_1.expect)((0, combinators_ski_1.isNormalForm)((0, combinators_ski_1.S)())).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.it)('isNormalForm: K x sin segundo arg también es FN (under-applied)', () => {
|
|
46
|
+
// K x todavía no tiene los 2 args que necesita.
|
|
47
|
+
(0, vitest_1.expect)((0, combinators_ski_1.isNormalForm)((0, combinators_ski_1.app)((0, combinators_ski_1.K)(), (0, combinators_ski_1.cvar)('x')))).toBe(true);
|
|
48
|
+
(0, vitest_1.expect)((0, combinators_ski_1.isNormalForm)((0, combinators_ski_1.app)((0, combinators_ski_1.S)(), (0, combinators_ski_1.cvar)('x'), (0, combinators_ski_1.cvar)('y')))).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
(0, vitest_1.it)('reduceStep baja por las ramas si no hay redex en cabeza', () => {
|
|
51
|
+
// (K x) (I y) — la cabeza está under-applied a 1 arg; igual baja
|
|
52
|
+
// al subtérmino (I y) para reducirlo.
|
|
53
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.app)((0, combinators_ski_1.K)(), (0, combinators_ski_1.cvar)('x')), (0, combinators_ski_1.app)((0, combinators_ski_1.I)(), (0, combinators_ski_1.cvar)('y')));
|
|
54
|
+
// Primer paso ahora reduce K x (I y) → x (atomic head, well-applied).
|
|
55
|
+
const r = (0, combinators_ski_1.reduceStep)(t);
|
|
56
|
+
(0, vitest_1.expect)(r).not.toBeNull();
|
|
57
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(r, (0, combinators_ski_1.cvar)('x'))).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
(0, vitest_1.describe)('combinators-ski / divergencia y maxSteps', () => {
|
|
61
|
+
(0, vitest_1.it)('un término divergente respeta maxSteps con terminated=false', () => {
|
|
62
|
+
// Omega-equivalente en SKI: SII(SII) — clásico divergente.
|
|
63
|
+
// x = SII; x x = (SII)(SII) → I(SII)(I(SII)) → SII (SII) ...
|
|
64
|
+
const SII = (0, combinators_ski_1.app)((0, combinators_ski_1.S)(), (0, combinators_ski_1.I)(), (0, combinators_ski_1.I)());
|
|
65
|
+
const omega = (0, combinators_ski_1.app)(SII, SII);
|
|
66
|
+
const r = (0, combinators_ski_1.normalize)(omega, 50);
|
|
67
|
+
(0, vitest_1.expect)(r.terminated).toBe(false);
|
|
68
|
+
(0, vitest_1.expect)(r.steps).toBe(50);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
(0, vitest_1.describe)('combinators-ski / bracket abstraction (λ → SKI)', () => {
|
|
72
|
+
(0, vitest_1.it)('abstractFromLambda(λx.x) = I', () => {
|
|
73
|
+
const t = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.v)('x'));
|
|
74
|
+
const c = (0, combinators_ski_1.abstractFromLambda)(t);
|
|
75
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(c, (0, combinators_ski_1.I)())).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
(0, vitest_1.it)('abstractFromLambda(λx.λy.x) es equivalente a K', () => {
|
|
78
|
+
// [y] x = K x (x ∉ FV(x)... pero x ≠ y, sí es K x)
|
|
79
|
+
// [x] (K x) = S (K K) I (forma canónica, no sintácticamente K)
|
|
80
|
+
// Aplicado a dos args debe colapsar a x.
|
|
81
|
+
const t = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.lam)('y', (0, lambda_calc_1.v)('x')));
|
|
82
|
+
const c = (0, combinators_ski_1.abstractFromLambda)(t);
|
|
83
|
+
// Test semántico: aplicado a (a, b) debe normalizar a `a`.
|
|
84
|
+
const applied = (0, combinators_ski_1.app)(c, (0, combinators_ski_1.cvar)('a'), (0, combinators_ski_1.cvar)('b'));
|
|
85
|
+
const norm = (0, combinators_ski_1.normalize)(applied);
|
|
86
|
+
(0, vitest_1.expect)(norm.terminated).toBe(true);
|
|
87
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(norm.result, (0, combinators_ski_1.cvar)('a'))).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
(0, vitest_1.it)('abstractFromLambda(λx.λy.λz. x z (y z)) es equivalente a S', () => {
|
|
90
|
+
// S = λx.λy.λz. x z (y z)
|
|
91
|
+
const t = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.lam)('y', (0, lambda_calc_1.lam)('z', (0, lambda_calc_1.apN)((0, lambda_calc_1.v)('x'), (0, lambda_calc_1.v)('z'), (0, lambda_calc_1.ap)((0, lambda_calc_1.v)('y'), (0, lambda_calc_1.v)('z'))))));
|
|
92
|
+
const c = (0, combinators_ski_1.abstractFromLambda)(t);
|
|
93
|
+
// Aplicado a (f, g, h) debe normalizar a f h (g h).
|
|
94
|
+
const applied = (0, combinators_ski_1.app)(c, (0, combinators_ski_1.cvar)('f'), (0, combinators_ski_1.cvar)('g'), (0, combinators_ski_1.cvar)('h'));
|
|
95
|
+
const norm = (0, combinators_ski_1.normalize)(applied);
|
|
96
|
+
(0, vitest_1.expect)(norm.terminated).toBe(true);
|
|
97
|
+
const expected = (0, combinators_ski_1.app)((0, combinators_ski_1.app)((0, combinators_ski_1.cvar)('f'), (0, combinators_ski_1.cvar)('h')), (0, combinators_ski_1.app)((0, combinators_ski_1.cvar)('g'), (0, combinators_ski_1.cvar)('h')));
|
|
98
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(norm.result, expected)).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
(0, vitest_1.it)('abstractFromLambda(λx.y) = K y (constante respecto a x)', () => {
|
|
101
|
+
const t = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.v)('y'));
|
|
102
|
+
const c = (0, combinators_ski_1.abstractFromLambda)(t);
|
|
103
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(c, (0, combinators_ski_1.app)((0, combinators_ski_1.K)(), (0, combinators_ski_1.cvar)('y')))).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
(0, vitest_1.it)('abstractFromLambda(λx.λy. x y) es equivalente a I aplicado', () => {
|
|
106
|
+
// λx.λy. x y ≡ λx. x bajo η (en λ-cálculo).
|
|
107
|
+
// SKI bracket genera algo más grande; lo probamos vía aplicación.
|
|
108
|
+
const t = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.lam)('y', (0, lambda_calc_1.ap)((0, lambda_calc_1.v)('x'), (0, lambda_calc_1.v)('y'))));
|
|
109
|
+
const c = (0, combinators_ski_1.abstractFromLambda)(t);
|
|
110
|
+
const applied = (0, combinators_ski_1.app)(c, (0, combinators_ski_1.cvar)('f'), (0, combinators_ski_1.cvar)('a'));
|
|
111
|
+
const norm = (0, combinators_ski_1.normalize)(applied);
|
|
112
|
+
(0, vitest_1.expect)(norm.terminated).toBe(true);
|
|
113
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(norm.result, (0, combinators_ski_1.app)((0, combinators_ski_1.cvar)('f'), (0, combinators_ski_1.cvar)('a')))).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
(0, vitest_1.it)('abstractFromLambda no contiene abstracciones (sólo S/K/I/var/app)', () => {
|
|
116
|
+
// Cualquier λ-término debe traducirse a una expresión de combinadores pura.
|
|
117
|
+
const t = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.lam)('y', (0, lambda_calc_1.lam)('z', (0, lambda_calc_1.apN)((0, lambda_calc_1.v)('x'), (0, lambda_calc_1.v)('z'), (0, lambda_calc_1.ap)((0, lambda_calc_1.v)('y'), (0, lambda_calc_1.v)('z'))))));
|
|
118
|
+
const c = (0, combinators_ski_1.abstractFromLambda)(t);
|
|
119
|
+
assertNoBinders(c);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
(0, vitest_1.describe)('combinators-ski / round-trip semántico', () => {
|
|
123
|
+
(0, vitest_1.it)('toLambda(I), toLambda(K), toLambda(S) son las definiciones λ canónicas', () => {
|
|
124
|
+
(0, vitest_1.expect)((0, lambda_calc_1.alphaEq)((0, combinators_ski_1.toLambda)((0, combinators_ski_1.I)()), (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.v)('x')))).toBe(true);
|
|
125
|
+
(0, vitest_1.expect)((0, lambda_calc_1.alphaEq)((0, combinators_ski_1.toLambda)((0, combinators_ski_1.K)()), (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.lam)('y', (0, lambda_calc_1.v)('x'))))).toBe(true);
|
|
126
|
+
const Slam = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.lam)('y', (0, lambda_calc_1.lam)('z', (0, lambda_calc_1.apN)((0, lambda_calc_1.v)('x'), (0, lambda_calc_1.v)('z'), (0, lambda_calc_1.ap)((0, lambda_calc_1.v)('y'), (0, lambda_calc_1.v)('z'))))));
|
|
127
|
+
(0, vitest_1.expect)((0, lambda_calc_1.alphaEq)((0, combinators_ski_1.toLambda)((0, combinators_ski_1.S)()), Slam)).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
(0, vitest_1.it)('round-trip λ → SKI → λ preserva la semántica aplicada (identidad)', () => {
|
|
130
|
+
// Aplicamos `(λx.x) a` y `(toLambda(abstract(λx.x))) a` y comparamos formas normales.
|
|
131
|
+
const idLam = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.v)('x'));
|
|
132
|
+
const skis = (0, combinators_ski_1.abstractFromLambda)(idLam);
|
|
133
|
+
const lamBack = (0, combinators_ski_1.toLambda)(skis);
|
|
134
|
+
const lhs = (0, lambda_calc_1.normalize)((0, lambda_calc_1.ap)(idLam, (0, lambda_calc_1.v)('a')));
|
|
135
|
+
const rhs = (0, lambda_calc_1.normalize)((0, lambda_calc_1.ap)(lamBack, (0, lambda_calc_1.v)('a')));
|
|
136
|
+
(0, vitest_1.expect)(lhs.terminated).toBe(true);
|
|
137
|
+
(0, vitest_1.expect)(rhs.terminated).toBe(true);
|
|
138
|
+
(0, vitest_1.expect)((0, lambda_calc_1.alphaEq)(lhs.result, rhs.result)).toBe(true);
|
|
139
|
+
});
|
|
140
|
+
(0, vitest_1.it)('round-trip preserva semántica de K aplicado a (a, b)', () => {
|
|
141
|
+
const Klam = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.lam)('y', (0, lambda_calc_1.v)('x')));
|
|
142
|
+
const skis = (0, combinators_ski_1.abstractFromLambda)(Klam);
|
|
143
|
+
const lamBack = (0, combinators_ski_1.toLambda)(skis);
|
|
144
|
+
const applied = (0, lambda_calc_1.apN)(lamBack, (0, lambda_calc_1.v)('a'), (0, lambda_calc_1.v)('b'));
|
|
145
|
+
const norm = (0, lambda_calc_1.normalize)(applied);
|
|
146
|
+
(0, vitest_1.expect)(norm.terminated).toBe(true);
|
|
147
|
+
(0, vitest_1.expect)((0, lambda_calc_1.alphaEq)(norm.result, (0, lambda_calc_1.v)('a'))).toBe(true);
|
|
148
|
+
});
|
|
149
|
+
(0, vitest_1.it)('round-trip preserva semántica de S aplicado a (f, g, h)', () => {
|
|
150
|
+
const Slam = (0, lambda_calc_1.lam)('x', (0, lambda_calc_1.lam)('y', (0, lambda_calc_1.lam)('z', (0, lambda_calc_1.apN)((0, lambda_calc_1.v)('x'), (0, lambda_calc_1.v)('z'), (0, lambda_calc_1.ap)((0, lambda_calc_1.v)('y'), (0, lambda_calc_1.v)('z'))))));
|
|
151
|
+
const skis = (0, combinators_ski_1.abstractFromLambda)(Slam);
|
|
152
|
+
const lamBack = (0, combinators_ski_1.toLambda)(skis);
|
|
153
|
+
const applied = (0, lambda_calc_1.apN)(lamBack, (0, lambda_calc_1.v)('f'), (0, lambda_calc_1.v)('g'), (0, lambda_calc_1.v)('h'));
|
|
154
|
+
const norm = (0, lambda_calc_1.normalize)(applied);
|
|
155
|
+
(0, vitest_1.expect)(norm.terminated).toBe(true);
|
|
156
|
+
// Forma normal: f h (g h).
|
|
157
|
+
const expected = (0, lambda_calc_1.apN)((0, lambda_calc_1.v)('f'), (0, lambda_calc_1.v)('h'), (0, lambda_calc_1.ap)((0, lambda_calc_1.v)('g'), (0, lambda_calc_1.v)('h')));
|
|
158
|
+
(0, vitest_1.expect)((0, lambda_calc_1.alphaEq)(norm.result, expected)).toBe(true);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
(0, vitest_1.describe)('combinators-ski / utilidades', () => {
|
|
162
|
+
(0, vitest_1.it)('termToString imprime aplicaciones asociativas a la izquierda', () => {
|
|
163
|
+
// S K K x → "S K K x" (sin paréntesis: todo es app-izquierda)
|
|
164
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.S)(), (0, combinators_ski_1.K)(), (0, combinators_ski_1.K)(), (0, combinators_ski_1.cvar)('x'));
|
|
165
|
+
(0, vitest_1.expect)((0, combinators_ski_1.termToString)(t)).toBe('S K K x');
|
|
166
|
+
});
|
|
167
|
+
(0, vitest_1.it)('termToString agrupa con paréntesis los args que son aplicaciones', () => {
|
|
168
|
+
// f (g x)
|
|
169
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.cvar)('f'), (0, combinators_ski_1.app)((0, combinators_ski_1.cvar)('g'), (0, combinators_ski_1.cvar)('x')));
|
|
170
|
+
(0, vitest_1.expect)((0, combinators_ski_1.termToString)(t)).toBe('f (g x)');
|
|
171
|
+
});
|
|
172
|
+
(0, vitest_1.it)('freeVars enumera variables libres', () => {
|
|
173
|
+
// S (K x) y → libres: {x, y}
|
|
174
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.S)(), (0, combinators_ski_1.app)((0, combinators_ski_1.K)(), (0, combinators_ski_1.cvar)('x')), (0, combinators_ski_1.cvar)('y'));
|
|
175
|
+
const fv = (0, combinators_ski_1.freeVars)(t);
|
|
176
|
+
(0, vitest_1.expect)(fv.has('x')).toBe(true);
|
|
177
|
+
(0, vitest_1.expect)(fv.has('y')).toBe(true);
|
|
178
|
+
(0, vitest_1.expect)(fv.size).toBe(2);
|
|
179
|
+
});
|
|
180
|
+
(0, vitest_1.it)('app con un solo argumento devuelve el término tal cual', () => {
|
|
181
|
+
const t = (0, combinators_ski_1.app)((0, combinators_ski_1.cvar)('x'));
|
|
182
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)(t, (0, combinators_ski_1.cvar)('x'))).toBe(true);
|
|
183
|
+
});
|
|
184
|
+
(0, vitest_1.it)('app() sin argumentos lanza', () => {
|
|
185
|
+
(0, vitest_1.expect)(() => (0, combinators_ski_1.app)()).toThrow();
|
|
186
|
+
});
|
|
187
|
+
(0, vitest_1.it)('ctermEq distingue por estructura', () => {
|
|
188
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)((0, combinators_ski_1.I)(), (0, combinators_ski_1.I)())).toBe(true);
|
|
189
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)((0, combinators_ski_1.K)(), (0, combinators_ski_1.S)())).toBe(false);
|
|
190
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)((0, combinators_ski_1.cvar)('x'), (0, combinators_ski_1.cvar)('y'))).toBe(false);
|
|
191
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)((0, combinators_ski_1.app)((0, combinators_ski_1.I)(), (0, combinators_ski_1.cvar)('x')), (0, combinators_ski_1.app)((0, combinators_ski_1.I)(), (0, combinators_ski_1.cvar)('x')))).toBe(true);
|
|
192
|
+
(0, vitest_1.expect)((0, combinators_ski_1.ctermEq)((0, combinators_ski_1.app)((0, combinators_ski_1.I)(), (0, combinators_ski_1.cvar)('x')), (0, combinators_ski_1.app)((0, combinators_ski_1.I)(), (0, combinators_ski_1.cvar)('y')))).toBe(false);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
// Helper de test: confirma que un CTerm no contiene nodos de tipo 'abs'
|
|
196
|
+
// (sería estructuralmente imposible en SKI, pero comprueba que el tipo
|
|
197
|
+
// generado por bracket abstraction es realmente puro).
|
|
198
|
+
function assertNoBinders(t) {
|
|
199
|
+
switch (t.kind) {
|
|
200
|
+
case 'S':
|
|
201
|
+
case 'K':
|
|
202
|
+
case 'I':
|
|
203
|
+
case 'var':
|
|
204
|
+
return;
|
|
205
|
+
case 'app':
|
|
206
|
+
assertNoBinders(t.fn);
|
|
207
|
+
assertNoBinders(t.arg);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=combinators-ski.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinators-ski.test.js","sourceRoot":"","sources":["../../../src/tests/combinators-ski/combinators-ski.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,2DAc+B;AAE/B,mDAO2B;AAG3B,IAAA,iBAAQ,EAAC,oCAAoC,EAAE,GAAG,EAAE;IAClD,IAAA,WAAE,EAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,CAAC,GAAG,IAAA,qBAAG,EAAC,IAAA,mBAAC,GAAE,EAAE,IAAA,sBAAI,EAAC,GAAG,CAAC,CAAC,CAAC;QAC9B,MAAM,CAAC,GAAG,IAAA,4BAAU,EAAC,CAAC,CAAC,CAAC;QACxB,IAAA,eAAM,EAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QACzB,IAAA,eAAM,EAAC,IAAA,yBAAO,EAAC,CAAE,EAAE,IAAA,sBAAI,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,6BA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0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constructive-reals.test.d.ts","sourceRoot":"","sources":["../../../src/tests/constructive-reals/constructive-reals.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Constructive Reals — Tests
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Verificamos que cada operación cumple su contrato:
|
|
6
|
+
// |x - approx(p).numerator / approx(p).denominator| < 2^{-p}
|
|
7
|
+
// y que los resultados coinciden numéricamente con cálculos
|
|
8
|
+
// en `number` (con tolerancia floating-point) donde aplica.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const vitest_1 = require("vitest");
|
|
11
|
+
const constructive_reals_1 = require("../../constructive-reals");
|
|
12
|
+
/** Convierte una aproximación a `number` para comparar con float math. */
|
|
13
|
+
function asNumber(r, prec = 60) {
|
|
14
|
+
const { numerator, denominator } = r.approx(prec);
|
|
15
|
+
// Para que no perdamos por desbordar Number, dividimos en bigint primero
|
|
16
|
+
// si los bits son demasiados.
|
|
17
|
+
const numBits = numerator.toString(2).length;
|
|
18
|
+
if (numBits > 80) {
|
|
19
|
+
const shift = numBits - 60;
|
|
20
|
+
const small = numerator >> BigInt(shift);
|
|
21
|
+
const denomShifted = denominator >> BigInt(shift);
|
|
22
|
+
return Number(small) / Number(denomShifted);
|
|
23
|
+
}
|
|
24
|
+
return Number(numerator) / Number(denominator);
|
|
25
|
+
}
|
|
26
|
+
(0, vitest_1.describe)('constructive-reals — fundamentos', () => {
|
|
27
|
+
(0, vitest_1.it)('fromInt(2).approx(20) representa exactamente 2', () => {
|
|
28
|
+
const r = (0, constructive_reals_1.fromInt)(2);
|
|
29
|
+
const { numerator, denominator } = r.approx(20);
|
|
30
|
+
(0, vitest_1.expect)(denominator).toBe(1n << 20n);
|
|
31
|
+
// 2 · 2^20 = 2097152.
|
|
32
|
+
(0, vitest_1.expect)(numerator).toBe(2n << 20n);
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.it)('fromInt(-5).approx(10) representa exactamente -5', () => {
|
|
35
|
+
const r = (0, constructive_reals_1.fromInt)(-5);
|
|
36
|
+
const { numerator, denominator } = r.approx(10);
|
|
37
|
+
(0, vitest_1.expect)(numerator).toBe(-5n * (1n << 10n));
|
|
38
|
+
(0, vitest_1.expect)(denominator).toBe(1n << 10n);
|
|
39
|
+
});
|
|
40
|
+
(0, vitest_1.it)('fromRational(1, 3) tiene error < 2^{-p} en cada precisión', () => {
|
|
41
|
+
const oneThird = (0, constructive_reals_1.fromRational)(1, 3);
|
|
42
|
+
for (const p of [10, 30, 60, 100, 200]) {
|
|
43
|
+
const { numerator, denominator } = oneThird.approx(p);
|
|
44
|
+
// Error: |1/3 - num/2^p|. Multiplicamos por 3·2^p para enteros:
|
|
45
|
+
// |2^p - 3·num| < 3 (es decir, error < 1 en escala 2^p ⇒ < 2^{-p}).
|
|
46
|
+
const diff3 = (1n << BigInt(p)) - 3n * numerator;
|
|
47
|
+
const absDiff = diff3 < 0n ? -diff3 : diff3;
|
|
48
|
+
// |diff3| < 3, lo cual implica |1/3 - num/denom| < 1/2^p < 2^{-p}.
|
|
49
|
+
(0, vitest_1.expect)(absDiff).toBeLessThan(3n);
|
|
50
|
+
(0, vitest_1.expect)(denominator).toBe(1n << BigInt(p));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
(0, vitest_1.describe)('constructive-reals — aritmética', () => {
|
|
55
|
+
(0, vitest_1.it)('add(1, 1) ≈ 2 a alta precisión', () => {
|
|
56
|
+
const two = (0, constructive_reals_1.add)((0, constructive_reals_1.fromInt)(1), (0, constructive_reals_1.fromInt)(1));
|
|
57
|
+
(0, vitest_1.expect)(asNumber(two)).toBeCloseTo(2, 14);
|
|
58
|
+
// Verificamos también que la cota está cerca de 2 a precisión 100.
|
|
59
|
+
const { numerator, denominator } = two.approx(100);
|
|
60
|
+
// |2 - num/denom| < 2^{-100}, equivalente a |2·denom - num| < 1.
|
|
61
|
+
const diff = 2n * denominator - numerator;
|
|
62
|
+
const absDiff = diff < 0n ? -diff : diff;
|
|
63
|
+
(0, vitest_1.expect)(absDiff).toBeLessThanOrEqual(1n);
|
|
64
|
+
});
|
|
65
|
+
(0, vitest_1.it)('sub(5, 3) ≈ 2', () => {
|
|
66
|
+
const r = (0, constructive_reals_1.sub)((0, constructive_reals_1.fromInt)(5), (0, constructive_reals_1.fromInt)(3));
|
|
67
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(2, 14);
|
|
68
|
+
});
|
|
69
|
+
(0, vitest_1.it)('mul(7, 6) ≈ 42', () => {
|
|
70
|
+
const r = (0, constructive_reals_1.mul)((0, constructive_reals_1.fromInt)(7), (0, constructive_reals_1.fromInt)(6));
|
|
71
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(42, 12);
|
|
72
|
+
});
|
|
73
|
+
(0, vitest_1.it)('neg(neg(x)) = x', () => {
|
|
74
|
+
const seven = (0, constructive_reals_1.fromInt)(7);
|
|
75
|
+
const r = (0, constructive_reals_1.neg)((0, constructive_reals_1.neg)(seven));
|
|
76
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(7, 14);
|
|
77
|
+
});
|
|
78
|
+
(0, vitest_1.it)('abs(-3.5) ≈ 3.5', () => {
|
|
79
|
+
const r = (0, constructive_reals_1.abs)((0, constructive_reals_1.fromRational)(-7, 2));
|
|
80
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(3.5, 14);
|
|
81
|
+
});
|
|
82
|
+
(0, vitest_1.it)('div(22, 7) ≈ 3.142857… (aprox π)', () => {
|
|
83
|
+
const r = (0, constructive_reals_1.div)((0, constructive_reals_1.fromInt)(22), (0, constructive_reals_1.fromInt)(7));
|
|
84
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(22 / 7, 12);
|
|
85
|
+
});
|
|
86
|
+
(0, vitest_1.it)('div(1, 3) coincide con fromRational(1, 3)', () => {
|
|
87
|
+
const a = (0, constructive_reals_1.div)((0, constructive_reals_1.fromInt)(1), (0, constructive_reals_1.fromInt)(3));
|
|
88
|
+
const b = (0, constructive_reals_1.fromRational)(1, 3);
|
|
89
|
+
// |a - b| debe ser ≤ 2 ulps a precisión 60.
|
|
90
|
+
const av = a.approx(60).numerator;
|
|
91
|
+
const bv = b.approx(60).numerator;
|
|
92
|
+
const diff = av - bv;
|
|
93
|
+
const absDiff = diff < 0n ? -diff : diff;
|
|
94
|
+
(0, vitest_1.expect)(absDiff).toBeLessThanOrEqual(2n);
|
|
95
|
+
});
|
|
96
|
+
(0, vitest_1.it)('asociatividad aproximada: (a+b)+c ≈ a+(b+c)', () => {
|
|
97
|
+
const a = (0, constructive_reals_1.fromRational)(7, 11);
|
|
98
|
+
const b = (0, constructive_reals_1.fromRational)(13, 17);
|
|
99
|
+
const c = (0, constructive_reals_1.fromRational)(19, 23);
|
|
100
|
+
const left = (0, constructive_reals_1.add)((0, constructive_reals_1.add)(a, b), c);
|
|
101
|
+
const right = (0, constructive_reals_1.add)(a, (0, constructive_reals_1.add)(b, c));
|
|
102
|
+
// A precisión 50, la diferencia debe ser ≤ pocas ulps.
|
|
103
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(left, right, 40)).toBe(0);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
(0, vitest_1.describe)('constructive-reals — sqrt', () => {
|
|
107
|
+
(0, vitest_1.it)('sqrt(fromInt(4)) ≈ 2', () => {
|
|
108
|
+
const r = (0, constructive_reals_1.sqrt)((0, constructive_reals_1.fromInt)(4));
|
|
109
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(2, 14);
|
|
110
|
+
// Verificación más fuerte: (sqrt(4))² ≈ 4.
|
|
111
|
+
const sq = (0, constructive_reals_1.mul)(r, r);
|
|
112
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(sq, (0, constructive_reals_1.fromInt)(4), 30)).toBe(0);
|
|
113
|
+
});
|
|
114
|
+
(0, vitest_1.it)('sqrt(fromInt(2))² ≈ 2 a alta precisión', () => {
|
|
115
|
+
const r = (0, constructive_reals_1.sqrt)((0, constructive_reals_1.fromInt)(2));
|
|
116
|
+
const sq = (0, constructive_reals_1.mul)(r, r);
|
|
117
|
+
// Comparamos con fromInt(2) usando epsilon 40.
|
|
118
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(sq, (0, constructive_reals_1.fromInt)(2), 40)).toBe(0);
|
|
119
|
+
});
|
|
120
|
+
(0, vitest_1.it)('SQRT2.approx(50) elevado al cuadrado ≈ 2', () => {
|
|
121
|
+
const { numerator, denominator } = constructive_reals_1.SQRT2.approx(50);
|
|
122
|
+
// (num/denom)² ≈ 2 ⇔ |num² - 2·denom²| pequeño.
|
|
123
|
+
// Con error en num < 1, |num² - 2·denom²| < 2·num ≈ 2·√2·2^50 ≈ 2^51.5
|
|
124
|
+
const lhs = numerator * numerator;
|
|
125
|
+
const rhs = 2n * denominator * denominator;
|
|
126
|
+
const diff = lhs - rhs;
|
|
127
|
+
const absDiff = diff < 0n ? -diff : diff;
|
|
128
|
+
// En escala denom² = 2^100, la diferencia debe ser ≤ ~2^52 (margen amplio).
|
|
129
|
+
(0, vitest_1.expect)(absDiff).toBeLessThan(1n << 55n);
|
|
130
|
+
});
|
|
131
|
+
(0, vitest_1.it)('sqrt(fromInt(9)) ≈ 3', () => {
|
|
132
|
+
const r = (0, constructive_reals_1.sqrt)((0, constructive_reals_1.fromInt)(9));
|
|
133
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(3, 14);
|
|
134
|
+
});
|
|
135
|
+
(0, vitest_1.it)('sqrt(2) coincide con SQRT2', () => {
|
|
136
|
+
const a = (0, constructive_reals_1.sqrt)((0, constructive_reals_1.fromInt)(2));
|
|
137
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(a, constructive_reals_1.SQRT2, 40)).toBe(0);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
(0, vitest_1.describe)('constructive-reals — constantes', () => {
|
|
141
|
+
(0, vitest_1.it)('PI.approx(50) coincide con Math.PI', () => {
|
|
142
|
+
const piApprox = asNumber(constructive_reals_1.PI, 60);
|
|
143
|
+
(0, vitest_1.expect)(piApprox).toBeCloseTo(Math.PI, 13);
|
|
144
|
+
});
|
|
145
|
+
(0, vitest_1.it)('PI primeros 15 dígitos correctos vía toString', () => {
|
|
146
|
+
// π = 3.14159265358979323846…
|
|
147
|
+
const s = (0, constructive_reals_1.toString)(constructive_reals_1.PI, 20);
|
|
148
|
+
(0, vitest_1.expect)(s.startsWith('3.14159265358979323846')).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
(0, vitest_1.it)('E.approx(50) coincide con Math.E', () => {
|
|
151
|
+
const eApprox = asNumber(constructive_reals_1.E, 60);
|
|
152
|
+
(0, vitest_1.expect)(eApprox).toBeCloseTo(Math.E, 13);
|
|
153
|
+
});
|
|
154
|
+
(0, vitest_1.it)('E primeros 15 dígitos correctos', () => {
|
|
155
|
+
// e = 2.71828182845904523536…
|
|
156
|
+
const s = (0, constructive_reals_1.toString)(constructive_reals_1.E, 20);
|
|
157
|
+
(0, vitest_1.expect)(s.startsWith('2.71828182845904523536')).toBe(true);
|
|
158
|
+
});
|
|
159
|
+
(0, vitest_1.it)('SQRT2 coincide con Math.SQRT2', () => {
|
|
160
|
+
(0, vitest_1.expect)(asNumber(constructive_reals_1.SQRT2, 60)).toBeCloseTo(Math.SQRT2, 13);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
(0, vitest_1.describe)('constructive-reals — compareWithEpsilon', () => {
|
|
164
|
+
(0, vitest_1.it)('compareWithEpsilon(PI, fromInt(3), 10) = 1', () => {
|
|
165
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(constructive_reals_1.PI, (0, constructive_reals_1.fromInt)(3), 10)).toBe(1);
|
|
166
|
+
});
|
|
167
|
+
(0, vitest_1.it)('compareWithEpsilon(fromInt(3), PI, 10) = -1', () => {
|
|
168
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)((0, constructive_reals_1.fromInt)(3), constructive_reals_1.PI, 10)).toBe(-1);
|
|
169
|
+
});
|
|
170
|
+
(0, vitest_1.it)('compareWithEpsilon(x, x, p) = 0 (reflexivo)', () => {
|
|
171
|
+
const x = (0, constructive_reals_1.fromRational)(355, 113);
|
|
172
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(x, x, 30)).toBe(0);
|
|
173
|
+
});
|
|
174
|
+
(0, vitest_1.it)('compareWithEpsilon distingue valores cercanos a precisión adecuada', () => {
|
|
175
|
+
// 1/3 vs 1/3 + 2^{-20}: a precisión 30 deben diferir.
|
|
176
|
+
const a = (0, constructive_reals_1.fromRational)(1, 3);
|
|
177
|
+
const b = (0, constructive_reals_1.add)(a, (0, constructive_reals_1.fromRational)(1, 1 << 20));
|
|
178
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(a, b, 30)).toBe(-1);
|
|
179
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(b, a, 30)).toBe(1);
|
|
180
|
+
});
|
|
181
|
+
(0, vitest_1.it)('compareWithEpsilon trata como iguales valores dentro de epsilon', () => {
|
|
182
|
+
// 1/3 vs 1/3 + 2^{-30}: a precisión 10 deben verse iguales.
|
|
183
|
+
const a = (0, constructive_reals_1.fromRational)(1, 3);
|
|
184
|
+
const b = (0, constructive_reals_1.add)(a, (0, constructive_reals_1.fromRational)(1, 1 << 30));
|
|
185
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(a, b, 10)).toBe(0);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
(0, vitest_1.describe)('constructive-reals — toString', () => {
|
|
189
|
+
(0, vitest_1.it)('toString(fromInt(7), 5) = "7.00000"', () => {
|
|
190
|
+
(0, vitest_1.expect)((0, constructive_reals_1.toString)((0, constructive_reals_1.fromInt)(7), 5)).toBe('7.00000');
|
|
191
|
+
});
|
|
192
|
+
(0, vitest_1.it)('toString(fromInt(-3), 0) = "-3"', () => {
|
|
193
|
+
(0, vitest_1.expect)((0, constructive_reals_1.toString)((0, constructive_reals_1.fromInt)(-3), 0)).toBe('-3');
|
|
194
|
+
});
|
|
195
|
+
(0, vitest_1.it)('toString(fromRational(1, 4), 5) = "0.25000"', () => {
|
|
196
|
+
(0, vitest_1.expect)((0, constructive_reals_1.toString)((0, constructive_reals_1.fromRational)(1, 4), 5)).toBe('0.25000');
|
|
197
|
+
});
|
|
198
|
+
(0, vitest_1.it)('toString(SQRT2, 10) coincide con √2 redondeado', () => {
|
|
199
|
+
// √2 = 1.4142135623730950… → 1.4142135624 redondeado a 10 dígitos
|
|
200
|
+
// (el 11º dígito es 7, así que redondea hacia arriba).
|
|
201
|
+
const s = (0, constructive_reals_1.toString)(constructive_reals_1.SQRT2, 10);
|
|
202
|
+
(0, vitest_1.expect)(s).toBe('1.4142135624');
|
|
203
|
+
});
|
|
204
|
+
(0, vitest_1.it)('toString(SQRT2, 15) coincide con √2 a 15 dígitos', () => {
|
|
205
|
+
// √2 = 1.414213562373095048…
|
|
206
|
+
const s = (0, constructive_reals_1.toString)(constructive_reals_1.SQRT2, 15);
|
|
207
|
+
(0, vitest_1.expect)(s.startsWith('1.41421356237309')).toBe(true);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
(0, vitest_1.describe)('constructive-reals — propiedades algebraicas', () => {
|
|
211
|
+
(0, vitest_1.it)('(a + b) - b ≈ a', () => {
|
|
212
|
+
const a = (0, constructive_reals_1.fromRational)(7, 13);
|
|
213
|
+
const b = constructive_reals_1.SQRT2;
|
|
214
|
+
const r = (0, constructive_reals_1.sub)((0, constructive_reals_1.add)(a, b), b);
|
|
215
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(r, a, 30)).toBe(0);
|
|
216
|
+
});
|
|
217
|
+
(0, vitest_1.it)('a · (1/a) ≈ 1 para a = π', () => {
|
|
218
|
+
const inv = (0, constructive_reals_1.div)((0, constructive_reals_1.fromInt)(1), constructive_reals_1.PI);
|
|
219
|
+
const product = (0, constructive_reals_1.mul)(constructive_reals_1.PI, inv);
|
|
220
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(product, (0, constructive_reals_1.fromInt)(1), 30)).toBe(0);
|
|
221
|
+
});
|
|
222
|
+
(0, vitest_1.it)('mul distribuye sobre add: a·(b+c) ≈ a·b + a·c', () => {
|
|
223
|
+
const a = (0, constructive_reals_1.fromRational)(3, 7);
|
|
224
|
+
const b = (0, constructive_reals_1.fromRational)(11, 13);
|
|
225
|
+
const c = (0, constructive_reals_1.fromRational)(17, 19);
|
|
226
|
+
const lhs = (0, constructive_reals_1.mul)(a, (0, constructive_reals_1.add)(b, c));
|
|
227
|
+
const rhs = (0, constructive_reals_1.add)((0, constructive_reals_1.mul)(a, b), (0, constructive_reals_1.mul)(a, c));
|
|
228
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(lhs, rhs, 30)).toBe(0);
|
|
229
|
+
});
|
|
230
|
+
(0, vitest_1.it)('sqrt(x)² ≈ x para varios x positivos', () => {
|
|
231
|
+
for (const k of [2, 3, 5, 7, 16, 100, 1000]) {
|
|
232
|
+
const x = (0, constructive_reals_1.fromInt)(k);
|
|
233
|
+
const sq = (0, constructive_reals_1.mul)((0, constructive_reals_1.sqrt)(x), (0, constructive_reals_1.sqrt)(x));
|
|
234
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(sq, x, 20)).toBe(0);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
(0, vitest_1.it)('error de aproximación está acotado para mul de irracionales', () => {
|
|
238
|
+
// π · √2 ≈ 4.44288293…
|
|
239
|
+
const r = (0, constructive_reals_1.mul)(constructive_reals_1.PI, constructive_reals_1.SQRT2);
|
|
240
|
+
(0, vitest_1.expect)(asNumber(r, 60)).toBeCloseTo(Math.PI * Math.SQRT2, 12);
|
|
241
|
+
});
|
|
242
|
+
(0, vitest_1.it)('div maneja divisores negativos', () => {
|
|
243
|
+
// -10 / -5 = 2.
|
|
244
|
+
const r = (0, constructive_reals_1.div)((0, constructive_reals_1.fromInt)(-10), (0, constructive_reals_1.fromInt)(-5));
|
|
245
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(2, 14);
|
|
246
|
+
// 10 / -5 = -2.
|
|
247
|
+
const r2 = (0, constructive_reals_1.div)((0, constructive_reals_1.fromInt)(10), (0, constructive_reals_1.fromInt)(-5));
|
|
248
|
+
(0, vitest_1.expect)(asNumber(r2)).toBeCloseTo(-2, 14);
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
(0, vitest_1.describe)('constructive-reals — error handling', () => {
|
|
252
|
+
(0, vitest_1.it)('fromRational(_, 0) lanza', () => {
|
|
253
|
+
(0, vitest_1.expect)(() => (0, constructive_reals_1.fromRational)(1, 0)).toThrow();
|
|
254
|
+
});
|
|
255
|
+
(0, vitest_1.it)('sqrt(-1) lanza', () => {
|
|
256
|
+
(0, vitest_1.expect)(() => (0, constructive_reals_1.sqrt)((0, constructive_reals_1.fromInt)(-1)).approx(10)).toThrow();
|
|
257
|
+
});
|
|
258
|
+
(0, vitest_1.it)('fromInt(NaN) lanza', () => {
|
|
259
|
+
(0, vitest_1.expect)(() => (0, constructive_reals_1.fromInt)(NaN)).toThrow();
|
|
260
|
+
});
|
|
261
|
+
(0, vitest_1.it)('fromInt(3.14) lanza (no es entero)', () => {
|
|
262
|
+
(0, vitest_1.expect)(() => (0, constructive_reals_1.fromInt)(3.14)).toThrow();
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
(0, vitest_1.describe)('constructive-reals — transcendentales', () => {
|
|
266
|
+
(0, vitest_1.it)('exp(0) = 1', () => {
|
|
267
|
+
(0, vitest_1.expect)(asNumber((0, constructive_reals_1.exp)((0, constructive_reals_1.fromInt)(0)))).toBeCloseTo(1, 12);
|
|
268
|
+
});
|
|
269
|
+
(0, vitest_1.it)('exp(1) ≈ E', () => {
|
|
270
|
+
const r = (0, constructive_reals_1.exp)((0, constructive_reals_1.fromInt)(1));
|
|
271
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(r, constructive_reals_1.E, 30)).toBe(0);
|
|
272
|
+
});
|
|
273
|
+
(0, vitest_1.it)('exp(2) ≈ e²', () => {
|
|
274
|
+
(0, vitest_1.expect)(asNumber((0, constructive_reals_1.exp)((0, constructive_reals_1.fromInt)(2)))).toBeCloseTo(Math.E * Math.E, 10);
|
|
275
|
+
});
|
|
276
|
+
(0, vitest_1.it)('log(E) ≈ 1', () => {
|
|
277
|
+
const r = (0, constructive_reals_1.log)(constructive_reals_1.E);
|
|
278
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(1, 10);
|
|
279
|
+
});
|
|
280
|
+
(0, vitest_1.it)('log(exp(x)) ≈ x para x = 2', () => {
|
|
281
|
+
const x = (0, constructive_reals_1.fromInt)(2);
|
|
282
|
+
const r = (0, constructive_reals_1.log)((0, constructive_reals_1.exp)(x));
|
|
283
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(r, x, 20)).toBe(0);
|
|
284
|
+
});
|
|
285
|
+
(0, vitest_1.it)('exp(log(x)) ≈ x para x = 5', () => {
|
|
286
|
+
const x = (0, constructive_reals_1.fromInt)(5);
|
|
287
|
+
const r = (0, constructive_reals_1.exp)((0, constructive_reals_1.log)(x));
|
|
288
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(r, x, 20)).toBe(0);
|
|
289
|
+
});
|
|
290
|
+
(0, vitest_1.it)('sin(0) ≈ 0', () => {
|
|
291
|
+
(0, vitest_1.expect)(asNumber((0, constructive_reals_1.sin)((0, constructive_reals_1.fromInt)(0)))).toBeCloseTo(0, 12);
|
|
292
|
+
});
|
|
293
|
+
(0, vitest_1.it)('cos(0) = 1', () => {
|
|
294
|
+
(0, vitest_1.expect)(asNumber((0, constructive_reals_1.cos)((0, constructive_reals_1.fromInt)(0)))).toBeCloseTo(1, 12);
|
|
295
|
+
});
|
|
296
|
+
(0, vitest_1.it)('sin(PI) ≈ 0', () => {
|
|
297
|
+
const r = (0, constructive_reals_1.sin)(constructive_reals_1.PI);
|
|
298
|
+
// |sin(π)| < 2^{-20} debería ser cierto a precisión razonable.
|
|
299
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(r, (0, constructive_reals_1.fromInt)(0), 20)).toBe(0);
|
|
300
|
+
});
|
|
301
|
+
(0, vitest_1.it)('cos(PI) ≈ -1', () => {
|
|
302
|
+
const r = (0, constructive_reals_1.cos)(constructive_reals_1.PI);
|
|
303
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(r, (0, constructive_reals_1.fromInt)(-1), 20)).toBe(0);
|
|
304
|
+
});
|
|
305
|
+
(0, vitest_1.it)('sin²(x) + cos²(x) ≈ 1', () => {
|
|
306
|
+
const x = (0, constructive_reals_1.fromRational)(7, 5); // arbitrario, dentro de [-π, π].
|
|
307
|
+
const s = (0, constructive_reals_1.sin)(x);
|
|
308
|
+
const c = (0, constructive_reals_1.cos)(x);
|
|
309
|
+
const sum = (0, constructive_reals_1.add)((0, constructive_reals_1.mul)(s, s), (0, constructive_reals_1.mul)(c, c));
|
|
310
|
+
(0, vitest_1.expect)((0, constructive_reals_1.compareWithEpsilon)(sum, (0, constructive_reals_1.fromInt)(1), 20)).toBe(0);
|
|
311
|
+
});
|
|
312
|
+
(0, vitest_1.it)('pow(2, 10) = 1024 (entero rápido)', () => {
|
|
313
|
+
const r = (0, constructive_reals_1.pow)((0, constructive_reals_1.fromInt)(2), 10);
|
|
314
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(1024, 10);
|
|
315
|
+
});
|
|
316
|
+
(0, vitest_1.it)('pow(2, -3) = 1/8', () => {
|
|
317
|
+
const r = (0, constructive_reals_1.pow)((0, constructive_reals_1.fromInt)(2), -3);
|
|
318
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(0.125, 12);
|
|
319
|
+
});
|
|
320
|
+
(0, vitest_1.it)('pow(E, fromInt(2)) ≈ e²', () => {
|
|
321
|
+
const r = (0, constructive_reals_1.pow)(constructive_reals_1.E, (0, constructive_reals_1.fromInt)(2));
|
|
322
|
+
(0, vitest_1.expect)(asNumber(r)).toBeCloseTo(Math.E * Math.E, 8);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
(0, vitest_1.describe)('constructive-reals — internals', () => {
|
|
326
|
+
(0, vitest_1.it)('isqrt redondea correctamente', () => {
|
|
327
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(0n)).toBe(0n);
|
|
328
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(1n)).toBe(1n);
|
|
329
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(2n)).toBe(1n);
|
|
330
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(3n)).toBe(1n);
|
|
331
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(4n)).toBe(2n);
|
|
332
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(15n)).toBe(3n);
|
|
333
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(16n)).toBe(4n);
|
|
334
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(10000n)).toBe(100n);
|
|
335
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.isqrt(1n << 100n)).toBe(1n << 50n);
|
|
336
|
+
});
|
|
337
|
+
(0, vitest_1.it)('shiftRight redondea half-away-from-zero', () => {
|
|
338
|
+
// 5 / 2 = 2.5 → round half away = 3.
|
|
339
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.shiftRight(5n, 1)).toBe(3n);
|
|
340
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.shiftRight(-5n, 1)).toBe(-3n);
|
|
341
|
+
// 4 / 2 = 2.
|
|
342
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.shiftRight(4n, 1)).toBe(2n);
|
|
343
|
+
// shift por 0 = identidad.
|
|
344
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.shiftRight(7n, 0)).toBe(7n);
|
|
345
|
+
// shift negativo = shift left.
|
|
346
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.shiftRight(3n, -2)).toBe(12n);
|
|
347
|
+
});
|
|
348
|
+
(0, vitest_1.it)('bitLength funciona en bordes', () => {
|
|
349
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.bitLength(0n)).toBe(0);
|
|
350
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.bitLength(1n)).toBe(1);
|
|
351
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.bitLength(2n)).toBe(2);
|
|
352
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.bitLength(255n)).toBe(8);
|
|
353
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.bitLength(256n)).toBe(9);
|
|
354
|
+
(0, vitest_1.expect)(constructive_reals_1.__internals.bitLength(-256n)).toBe(9);
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
//# sourceMappingURL=constructive-reals.test.js.map
|