@stevenvo780/st-lang 4.10.0 → 4.12.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/proof-systems/distributed-exchange/index.d.ts +101 -0
- package/dist/proof-systems/distributed-exchange/index.d.ts.map +1 -0
- package/dist/proof-systems/distributed-exchange/index.js +408 -0
- package/dist/proof-systems/distributed-exchange/index.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/index.d.ts +7 -0
- package/dist/proof-systems/fol-prover-advanced/index.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/index.js +34 -0
- package/dist/proof-systems/fol-prover-advanced/index.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/ordering.d.ts +34 -0
- package/dist/proof-systems/fol-prover-advanced/ordering.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/ordering.js +197 -0
- package/dist/proof-systems/fol-prover-advanced/ordering.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/prover.d.ts +22 -0
- package/dist/proof-systems/fol-prover-advanced/prover.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/prover.js +219 -0
- package/dist/proof-systems/fol-prover-advanced/prover.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/resolve.d.ts +43 -0
- package/dist/proof-systems/fol-prover-advanced/resolve.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/resolve.js +297 -0
- package/dist/proof-systems/fol-prover-advanced/resolve.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/subsumption.d.ts +28 -0
- package/dist/proof-systems/fol-prover-advanced/subsumption.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/subsumption.js +172 -0
- package/dist/proof-systems/fol-prover-advanced/subsumption.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/types.d.ts +68 -0
- package/dist/proof-systems/fol-prover-advanced/types.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/types.js +12 -0
- package/dist/proof-systems/fol-prover-advanced/types.js.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/unify.d.ts +15 -0
- package/dist/proof-systems/fol-prover-advanced/unify.d.ts.map +1 -0
- package/dist/proof-systems/fol-prover-advanced/unify.js +144 -0
- package/dist/proof-systems/fol-prover-advanced/unify.js.map +1 -0
- package/dist/reasoning/combinatorics/basic-counts.d.ts +6 -0
- package/dist/reasoning/combinatorics/basic-counts.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/basic-counts.js +82 -0
- package/dist/reasoning/combinatorics/basic-counts.js.map +1 -0
- package/dist/reasoning/combinatorics/bigint-helpers.d.ts +5 -0
- package/dist/reasoning/combinatorics/bigint-helpers.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/bigint-helpers.js +8 -0
- package/dist/reasoning/combinatorics/bigint-helpers.js.map +1 -0
- package/dist/reasoning/combinatorics/burnside.d.ts +15 -0
- package/dist/reasoning/combinatorics/burnside.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/burnside.js +91 -0
- package/dist/reasoning/combinatorics/burnside.js.map +1 -0
- package/dist/reasoning/combinatorics/generating-functions.d.ts +12 -0
- package/dist/reasoning/combinatorics/generating-functions.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/generating-functions.js +67 -0
- package/dist/reasoning/combinatorics/generating-functions.js.map +1 -0
- package/dist/reasoning/combinatorics/generators.d.ts +5 -0
- package/dist/reasoning/combinatorics/generators.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/generators.js +111 -0
- package/dist/reasoning/combinatorics/generators.js.map +1 -0
- package/dist/reasoning/combinatorics/inclusion-exclusion.d.ts +8 -0
- package/dist/reasoning/combinatorics/inclusion-exclusion.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/inclusion-exclusion.js +45 -0
- package/dist/reasoning/combinatorics/inclusion-exclusion.js.map +1 -0
- package/dist/reasoning/combinatorics/index.d.ts +10 -0
- package/dist/reasoning/combinatorics/index.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/index.js +44 -0
- package/dist/reasoning/combinatorics/index.js.map +1 -0
- package/dist/reasoning/combinatorics/partitions.d.ts +4 -0
- package/dist/reasoning/combinatorics/partitions.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/partitions.js +90 -0
- package/dist/reasoning/combinatorics/partitions.js.map +1 -0
- package/dist/reasoning/combinatorics/permutations.d.ts +6 -0
- package/dist/reasoning/combinatorics/permutations.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/permutations.js +124 -0
- package/dist/reasoning/combinatorics/permutations.js.map +1 -0
- package/dist/reasoning/combinatorics/set-partitions.d.ts +3 -0
- package/dist/reasoning/combinatorics/set-partitions.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/set-partitions.js +46 -0
- package/dist/reasoning/combinatorics/set-partitions.js.map +1 -0
- package/dist/reasoning/combinatorics/special-numbers.d.ts +7 -0
- package/dist/reasoning/combinatorics/special-numbers.d.ts.map +1 -0
- package/dist/reasoning/combinatorics/special-numbers.js +128 -0
- package/dist/reasoning/combinatorics/special-numbers.js.map +1 -0
- package/dist/reasoning/constructive-analysis/cauchy.d.ts +51 -0
- package/dist/reasoning/constructive-analysis/cauchy.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/cauchy.js +77 -0
- package/dist/reasoning/constructive-analysis/cauchy.js.map +1 -0
- package/dist/reasoning/constructive-analysis/compact.d.ts +35 -0
- package/dist/reasoning/constructive-analysis/compact.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/compact.js +61 -0
- package/dist/reasoning/constructive-analysis/compact.js.map +1 -0
- package/dist/reasoning/constructive-analysis/continuity.d.ts +62 -0
- package/dist/reasoning/constructive-analysis/continuity.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/continuity.js +112 -0
- package/dist/reasoning/constructive-analysis/continuity.js.map +1 -0
- package/dist/reasoning/constructive-analysis/index.d.ts +24 -0
- package/dist/reasoning/constructive-analysis/index.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/index.js +36 -0
- package/dist/reasoning/constructive-analysis/index.js.map +1 -0
- package/dist/reasoning/constructive-analysis/integral.d.ts +31 -0
- package/dist/reasoning/constructive-analysis/integral.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/integral.js +59 -0
- package/dist/reasoning/constructive-analysis/integral.js.map +1 -0
- package/dist/reasoning/constructive-analysis/ivt.d.ts +41 -0
- package/dist/reasoning/constructive-analysis/ivt.d.ts.map +1 -0
- package/dist/reasoning/constructive-analysis/ivt.js +115 -0
- package/dist/reasoning/constructive-analysis/ivt.js.map +1 -0
- package/dist/reasoning/constructive-reals/index.d.ts +23 -0
- package/dist/reasoning/constructive-reals/index.d.ts.map +1 -1
- package/dist/reasoning/constructive-reals/index.js +52 -1
- package/dist/reasoning/constructive-reals/index.js.map +1 -1
- package/dist/reasoning/graph-theory/index.d.ts +63 -0
- package/dist/reasoning/graph-theory/index.d.ts.map +1 -0
- package/dist/reasoning/graph-theory/index.js +1043 -0
- package/dist/reasoning/graph-theory/index.js.map +1 -0
- package/dist/reasoning/group-presentation/cayley.d.ts +8 -0
- package/dist/reasoning/group-presentation/cayley.d.ts.map +1 -0
- package/dist/reasoning/group-presentation/cayley.js +38 -0
- package/dist/reasoning/group-presentation/cayley.js.map +1 -0
- package/dist/reasoning/group-presentation/index.d.ts +8 -0
- package/dist/reasoning/group-presentation/index.d.ts.map +1 -0
- package/dist/reasoning/group-presentation/index.js +36 -0
- package/dist/reasoning/group-presentation/index.js.map +1 -0
- package/dist/reasoning/group-presentation/standard-groups.d.ts +6 -0
- package/dist/reasoning/group-presentation/standard-groups.d.ts.map +1 -0
- package/dist/reasoning/group-presentation/standard-groups.js +93 -0
- package/dist/reasoning/group-presentation/standard-groups.js.map +1 -0
- package/dist/reasoning/group-presentation/todd-coxeter.d.ts +10 -0
- package/dist/reasoning/group-presentation/todd-coxeter.d.ts.map +1 -0
- package/dist/reasoning/group-presentation/todd-coxeter.js +362 -0
- package/dist/reasoning/group-presentation/todd-coxeter.js.map +1 -0
- package/dist/reasoning/group-presentation/types.d.ts +7 -0
- package/dist/reasoning/group-presentation/types.d.ts.map +1 -0
- package/dist/reasoning/group-presentation/types.js +22 -0
- package/dist/reasoning/group-presentation/types.js.map +1 -0
- package/dist/reasoning/group-presentation/words.d.ts +10 -0
- package/dist/reasoning/group-presentation/words.d.ts.map +1 -0
- package/dist/reasoning/group-presentation/words.js +109 -0
- package/dist/reasoning/group-presentation/words.js.map +1 -0
- package/dist/reasoning/linear-algebra/index.d.ts +69 -0
- package/dist/reasoning/linear-algebra/index.d.ts.map +1 -0
- package/dist/reasoning/linear-algebra/index.js +859 -0
- package/dist/reasoning/linear-algebra/index.js.map +1 -0
- package/dist/reasoning/set-theory/hf-functions.d.ts +35 -0
- package/dist/reasoning/set-theory/hf-functions.d.ts.map +1 -0
- package/dist/reasoning/set-theory/hf-functions.js +147 -0
- package/dist/reasoning/set-theory/hf-functions.js.map +1 -0
- package/dist/reasoning/set-theory/hf-sets.d.ts +79 -0
- package/dist/reasoning/set-theory/hf-sets.d.ts.map +1 -0
- package/dist/reasoning/set-theory/hf-sets.js +338 -0
- package/dist/reasoning/set-theory/hf-sets.js.map +1 -0
- package/dist/reasoning/set-theory/index.d.ts +7 -0
- package/dist/reasoning/set-theory/index.d.ts.map +1 -0
- package/dist/reasoning/set-theory/index.js +44 -0
- package/dist/reasoning/set-theory/index.js.map +1 -0
- package/dist/reasoning/set-theory/zfc-axioms.d.ts +59 -0
- package/dist/reasoning/set-theory/zfc-axioms.d.ts.map +1 -0
- package/dist/reasoning/set-theory/zfc-axioms.js +245 -0
- package/dist/reasoning/set-theory/zfc-axioms.js.map +1 -0
- package/dist/tests/proof-systems/distributed-exchange/distributed-exchange.test.d.ts +2 -0
- package/dist/tests/proof-systems/distributed-exchange/distributed-exchange.test.d.ts.map +1 -0
- package/dist/tests/proof-systems/distributed-exchange/distributed-exchange.test.js +328 -0
- package/dist/tests/proof-systems/distributed-exchange/distributed-exchange.test.js.map +1 -0
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.d.ts +2 -0
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.d.ts.map +1 -0
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.js +253 -0
- package/dist/tests/proof-systems/fol-prover-advanced/prover.test.js.map +1 -0
- package/dist/tests/reasoning/combinatorics/combinatorics.test.d.ts +2 -0
- package/dist/tests/reasoning/combinatorics/combinatorics.test.d.ts.map +1 -0
- package/dist/tests/reasoning/combinatorics/combinatorics.test.js +256 -0
- package/dist/tests/reasoning/combinatorics/combinatorics.test.js.map +1 -0
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.d.ts +2 -0
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.d.ts.map +1 -0
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.js +174 -0
- package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.js.map +1 -0
- package/dist/tests/reasoning/graph-theory/graph-theory.test.d.ts +2 -0
- package/dist/tests/reasoning/graph-theory/graph-theory.test.d.ts.map +1 -0
- package/dist/tests/reasoning/graph-theory/graph-theory.test.js +363 -0
- package/dist/tests/reasoning/graph-theory/graph-theory.test.js.map +1 -0
- package/dist/tests/reasoning/group-presentation/group-presentation.test.d.ts +2 -0
- package/dist/tests/reasoning/group-presentation/group-presentation.test.d.ts.map +1 -0
- package/dist/tests/reasoning/group-presentation/group-presentation.test.js +229 -0
- package/dist/tests/reasoning/group-presentation/group-presentation.test.js.map +1 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.d.ts +2 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.d.ts.map +1 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.js +369 -0
- package/dist/tests/reasoning/linear-algebra/linear-algebra.test.js.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.d.ts +2 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.d.ts.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.js +122 -0
- package/dist/tests/reasoning/set-theory/hf-functions.test.js.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-sets.test.d.ts +2 -0
- package/dist/tests/reasoning/set-theory/hf-sets.test.d.ts.map +1 -0
- package/dist/tests/reasoning/set-theory/hf-sets.test.js +177 -0
- package/dist/tests/reasoning/set-theory/hf-sets.test.js.map +1 -0
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.d.ts +2 -0
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.d.ts.map +1 -0
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.js +56 -0
- package/dist/tests/reasoning/set-theory/zfc-axioms.test.js.map +1 -0
- package/dist/tests/tooling/doc-gen/doc-gen.test.d.ts +2 -0
- package/dist/tests/tooling/doc-gen/doc-gen.test.d.ts.map +1 -0
- package/dist/tests/tooling/doc-gen/doc-gen.test.js +350 -0
- package/dist/tests/tooling/doc-gen/doc-gen.test.js.map +1 -0
- package/dist/tests/tooling/exporters/coq-v2/coq-v2-exporter.test.d.ts +2 -0
- package/dist/tests/tooling/exporters/coq-v2/coq-v2-exporter.test.d.ts.map +1 -0
- package/dist/tests/tooling/exporters/coq-v2/coq-v2-exporter.test.js +411 -0
- package/dist/tests/tooling/exporters/coq-v2/coq-v2-exporter.test.js.map +1 -0
- package/dist/tests/tooling/lemma-library/lemma-library.test.d.ts +2 -0
- package/dist/tests/tooling/lemma-library/lemma-library.test.d.ts.map +1 -0
- package/dist/tests/tooling/lemma-library/lemma-library.test.js +197 -0
- package/dist/tests/tooling/lemma-library/lemma-library.test.js.map +1 -0
- package/dist/tests/tooling/provenance/ledger.test.d.ts +2 -0
- package/dist/tests/tooling/provenance/ledger.test.d.ts.map +1 -0
- package/dist/tests/tooling/provenance/ledger.test.js +545 -0
- package/dist/tests/tooling/provenance/ledger.test.js.map +1 -0
- package/dist/tests/tooling/test-harness/test-harness.test.d.ts +2 -0
- package/dist/tests/tooling/test-harness/test-harness.test.d.ts.map +1 -0
- package/dist/tests/tooling/test-harness/test-harness.test.js +208 -0
- package/dist/tests/tooling/test-harness/test-harness.test.js.map +1 -0
- package/dist/tooling/doc-gen/extract.d.ts +13 -0
- package/dist/tooling/doc-gen/extract.d.ts.map +1 -0
- package/dist/tooling/doc-gen/extract.js +379 -0
- package/dist/tooling/doc-gen/extract.js.map +1 -0
- package/dist/tooling/doc-gen/generate.d.ts +9 -0
- package/dist/tooling/doc-gen/generate.d.ts.map +1 -0
- package/dist/tooling/doc-gen/generate.js +116 -0
- package/dist/tooling/doc-gen/generate.js.map +1 -0
- package/dist/tooling/doc-gen/index.d.ts +7 -0
- package/dist/tooling/doc-gen/index.d.ts.map +1 -0
- package/dist/tooling/doc-gen/index.js +39 -0
- package/dist/tooling/doc-gen/index.js.map +1 -0
- package/dist/tooling/doc-gen/jsdoc.d.ts +31 -0
- package/dist/tooling/doc-gen/jsdoc.d.ts.map +1 -0
- package/dist/tooling/doc-gen/jsdoc.js +140 -0
- package/dist/tooling/doc-gen/jsdoc.js.map +1 -0
- package/dist/tooling/doc-gen/render.d.ts +29 -0
- package/dist/tooling/doc-gen/render.d.ts.map +1 -0
- package/dist/tooling/doc-gen/render.js +206 -0
- package/dist/tooling/doc-gen/render.js.map +1 -0
- package/dist/tooling/doc-gen/types.d.ts +51 -0
- package/dist/tooling/doc-gen/types.d.ts.map +1 -0
- package/dist/tooling/doc-gen/types.js +10 -0
- package/dist/tooling/doc-gen/types.js.map +1 -0
- package/dist/tooling/exporters/coq-v2/index.d.ts +68 -0
- package/dist/tooling/exporters/coq-v2/index.d.ts.map +1 -0
- package/dist/tooling/exporters/coq-v2/index.js +692 -0
- package/dist/tooling/exporters/coq-v2/index.js.map +1 -0
- package/dist/tooling/lemma-library/apply.d.ts +9 -0
- package/dist/tooling/lemma-library/apply.d.ts.map +1 -0
- package/dist/tooling/lemma-library/apply.js +94 -0
- package/dist/tooling/lemma-library/apply.js.map +1 -0
- package/dist/tooling/lemma-library/arithmetic.d.ts +3 -0
- package/dist/tooling/lemma-library/arithmetic.d.ts.map +1 -0
- package/dist/tooling/lemma-library/arithmetic.js +176 -0
- package/dist/tooling/lemma-library/arithmetic.js.map +1 -0
- package/dist/tooling/lemma-library/firstorder.d.ts +3 -0
- package/dist/tooling/lemma-library/firstorder.d.ts.map +1 -0
- package/dist/tooling/lemma-library/firstorder.js +136 -0
- package/dist/tooling/lemma-library/firstorder.js.map +1 -0
- package/dist/tooling/lemma-library/index.d.ts +13 -0
- package/dist/tooling/lemma-library/index.d.ts.map +1 -0
- package/dist/tooling/lemma-library/index.js +32 -0
- package/dist/tooling/lemma-library/index.js.map +1 -0
- package/dist/tooling/lemma-library/library.d.ts +34 -0
- package/dist/tooling/lemma-library/library.d.ts.map +1 -0
- package/dist/tooling/lemma-library/library.js +126 -0
- package/dist/tooling/lemma-library/library.js.map +1 -0
- package/dist/tooling/lemma-library/modal.d.ts +3 -0
- package/dist/tooling/lemma-library/modal.d.ts.map +1 -0
- package/dist/tooling/lemma-library/modal.js +138 -0
- package/dist/tooling/lemma-library/modal.js.map +1 -0
- package/dist/tooling/lemma-library/propositional.d.ts +3 -0
- package/dist/tooling/lemma-library/propositional.d.ts.map +1 -0
- package/dist/tooling/lemma-library/propositional.js +265 -0
- package/dist/tooling/lemma-library/propositional.js.map +1 -0
- package/dist/tooling/lemma-library/set-theory.d.ts +3 -0
- package/dist/tooling/lemma-library/set-theory.d.ts.map +1 -0
- package/dist/tooling/lemma-library/set-theory.js +134 -0
- package/dist/tooling/lemma-library/set-theory.js.map +1 -0
- package/dist/tooling/lemma-library/standard.d.ts +3 -0
- package/dist/tooling/lemma-library/standard.d.ts.map +1 -0
- package/dist/tooling/lemma-library/standard.js +27 -0
- package/dist/tooling/lemma-library/standard.js.map +1 -0
- package/dist/tooling/lemma-library/tfidf.d.ts +5 -0
- package/dist/tooling/lemma-library/tfidf.d.ts.map +1 -0
- package/dist/tooling/lemma-library/tfidf.js +100 -0
- package/dist/tooling/lemma-library/tfidf.js.map +1 -0
- package/dist/tooling/lemma-library/tokenize.d.ts +2 -0
- package/dist/tooling/lemma-library/tokenize.d.ts.map +1 -0
- package/dist/tooling/lemma-library/tokenize.js +74 -0
- package/dist/tooling/lemma-library/tokenize.js.map +1 -0
- package/dist/tooling/lemma-library/types.d.ts +53 -0
- package/dist/tooling/lemma-library/types.d.ts.map +1 -0
- package/dist/tooling/lemma-library/types.js +10 -0
- package/dist/tooling/lemma-library/types.js.map +1 -0
- package/dist/tooling/provenance/index.d.ts +3 -0
- package/dist/tooling/provenance/index.d.ts.map +1 -0
- package/dist/tooling/provenance/index.js +16 -0
- package/dist/tooling/provenance/index.js.map +1 -0
- package/dist/tooling/provenance/ledger.d.ts +89 -0
- package/dist/tooling/provenance/ledger.d.ts.map +1 -0
- package/dist/tooling/provenance/ledger.js +439 -0
- package/dist/tooling/provenance/ledger.js.map +1 -0
- package/dist/tooling/provenance/types.d.ts +70 -0
- package/dist/tooling/provenance/types.d.ts.map +1 -0
- package/dist/tooling/provenance/types.js +14 -0
- package/dist/tooling/provenance/types.js.map +1 -0
- package/dist/tooling/test-harness/combinators.d.ts +14 -0
- package/dist/tooling/test-harness/combinators.d.ts.map +1 -0
- package/dist/tooling/test-harness/combinators.js +122 -0
- package/dist/tooling/test-harness/combinators.js.map +1 -0
- package/dist/tooling/test-harness/coverage.d.ts +3 -0
- package/dist/tooling/test-harness/coverage.d.ts.map +1 -0
- package/dist/tooling/test-harness/coverage.js +32 -0
- package/dist/tooling/test-harness/coverage.js.map +1 -0
- package/dist/tooling/test-harness/generators.d.ts +6 -0
- package/dist/tooling/test-harness/generators.d.ts.map +1 -0
- package/dist/tooling/test-harness/generators.js +66 -0
- package/dist/tooling/test-harness/generators.js.map +1 -0
- package/dist/tooling/test-harness/index.d.ts +7 -0
- package/dist/tooling/test-harness/index.d.ts.map +1 -0
- package/dist/tooling/test-harness/index.js +27 -0
- package/dist/tooling/test-harness/index.js.map +1 -0
- package/dist/tooling/test-harness/mutation.d.ts +4 -0
- package/dist/tooling/test-harness/mutation.d.ts.map +1 -0
- package/dist/tooling/test-harness/mutation.js +28 -0
- package/dist/tooling/test-harness/mutation.js.map +1 -0
- package/dist/tooling/test-harness/snapshot.d.ts +5 -0
- package/dist/tooling/test-harness/snapshot.d.ts.map +1 -0
- package/dist/tooling/test-harness/snapshot.js +86 -0
- package/dist/tooling/test-harness/snapshot.js.map +1 -0
- package/dist/tooling/test-harness/types.d.ts +32 -0
- package/dist/tooling/test-harness/types.d.ts.map +1 -0
- package/dist/tooling/test-harness/types.js +3 -0
- package/dist/tooling/test-harness/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inclusionExclusion = inclusionExclusion;
|
|
4
|
+
/**
|
|
5
|
+
* Calcula |A_1 ∪ A_2 ∪ ... ∪ A_n| usando el principio de inclusión-exclusión
|
|
6
|
+
* a fuerza bruta sobre el reticulado de subconjuntos no vacíos de índices.
|
|
7
|
+
*
|
|
8
|
+
* |⋃ A_i| = Σ_{S≠∅} (-1)^(|S|+1) |⋂_{i∈S} A_i|
|
|
9
|
+
*/
|
|
10
|
+
function inclusionExclusion(sets) {
|
|
11
|
+
const n = sets.length;
|
|
12
|
+
if (n === 0)
|
|
13
|
+
return 0;
|
|
14
|
+
let total = 0;
|
|
15
|
+
const totalMasks = 1 << n;
|
|
16
|
+
for (let mask = 1; mask < totalMasks; mask++) {
|
|
17
|
+
let popcount = 0;
|
|
18
|
+
let intersection = null;
|
|
19
|
+
for (let i = 0; i < n; i++) {
|
|
20
|
+
if ((mask >> i) & 1) {
|
|
21
|
+
popcount++;
|
|
22
|
+
const si = sets[i];
|
|
23
|
+
if (si === undefined)
|
|
24
|
+
throw new Error('inclusionExclusion: set inválido');
|
|
25
|
+
if (intersection === null) {
|
|
26
|
+
intersection = new Set(si);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const next = new Set();
|
|
30
|
+
for (const v of intersection) {
|
|
31
|
+
if (si.has(v))
|
|
32
|
+
next.add(v);
|
|
33
|
+
}
|
|
34
|
+
intersection = next;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (intersection === null)
|
|
39
|
+
continue;
|
|
40
|
+
const sign = popcount % 2 === 1 ? 1 : -1;
|
|
41
|
+
total += sign * intersection.size;
|
|
42
|
+
}
|
|
43
|
+
return total;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=inclusion-exclusion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inclusion-exclusion.js","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/inclusion-exclusion.ts"],"names":[],"mappings":";;AAMA,gDA6BC;AAnCD;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,IAAwB;IACzD,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IACtB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC;QAC7C,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,YAAY,GAAuB,IAAI,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpB,QAAQ,EAAE,CAAC;gBACX,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;gBACnB,IAAI,EAAE,KAAK,SAAS;oBAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;gBAC1E,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;oBAC1B,YAAY,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC7B,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;oBAC/B,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;wBAC7B,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;4BAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAC7B,CAAC;oBACD,YAAY,GAAG,IAAI,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,YAAY,KAAK,IAAI;YAAE,SAAS;QACpC,MAAM,IAAI,GAAG,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,KAAK,IAAI,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;IACpC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { factorial, binomial, multinomial, permutations, combinations } from './basic-counts';
|
|
2
|
+
export { generatePermutations, generateCombinations, generatePowerSet, generateSubsetsOfSize } from './generators';
|
|
3
|
+
export { permutationParity, permutationCycles, permutationOrder, composePermutations, inversePermutation } from './permutations';
|
|
4
|
+
export { partitions, partitionsCount, partitionsIntoParts } from './partitions';
|
|
5
|
+
export { stirlingSecondKind, stirlingFirstKind, catalan, bellNumber, eulerNumber, eulerianNumber } from './special-numbers';
|
|
6
|
+
export { setPartitions, setPartitionsCount } from './set-partitions';
|
|
7
|
+
export { burnsideCount, cyclicRotations } from './burnside';
|
|
8
|
+
export { multiplyPolynomials, generatingFunction, binomialGF } from './generating-functions';
|
|
9
|
+
export { inclusionExclusion } from './inclusion-exclusion';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,YAAY,EACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,WAAW,EACX,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,aAAa,EACb,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACX,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,kBAAkB,EACnB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inclusionExclusion = exports.binomialGF = exports.generatingFunction = exports.multiplyPolynomials = exports.cyclicRotations = exports.burnsideCount = exports.setPartitionsCount = exports.setPartitions = exports.eulerianNumber = exports.eulerNumber = exports.bellNumber = exports.catalan = exports.stirlingFirstKind = exports.stirlingSecondKind = exports.partitionsIntoParts = exports.partitionsCount = exports.partitions = exports.inversePermutation = exports.composePermutations = exports.permutationOrder = exports.permutationCycles = exports.permutationParity = exports.generateSubsetsOfSize = exports.generatePowerSet = exports.generateCombinations = exports.generatePermutations = exports.combinations = exports.permutations = exports.multinomial = exports.binomial = exports.factorial = void 0;
|
|
4
|
+
var basic_counts_1 = require("./basic-counts");
|
|
5
|
+
Object.defineProperty(exports, "factorial", { enumerable: true, get: function () { return basic_counts_1.factorial; } });
|
|
6
|
+
Object.defineProperty(exports, "binomial", { enumerable: true, get: function () { return basic_counts_1.binomial; } });
|
|
7
|
+
Object.defineProperty(exports, "multinomial", { enumerable: true, get: function () { return basic_counts_1.multinomial; } });
|
|
8
|
+
Object.defineProperty(exports, "permutations", { enumerable: true, get: function () { return basic_counts_1.permutations; } });
|
|
9
|
+
Object.defineProperty(exports, "combinations", { enumerable: true, get: function () { return basic_counts_1.combinations; } });
|
|
10
|
+
var generators_1 = require("./generators");
|
|
11
|
+
Object.defineProperty(exports, "generatePermutations", { enumerable: true, get: function () { return generators_1.generatePermutations; } });
|
|
12
|
+
Object.defineProperty(exports, "generateCombinations", { enumerable: true, get: function () { return generators_1.generateCombinations; } });
|
|
13
|
+
Object.defineProperty(exports, "generatePowerSet", { enumerable: true, get: function () { return generators_1.generatePowerSet; } });
|
|
14
|
+
Object.defineProperty(exports, "generateSubsetsOfSize", { enumerable: true, get: function () { return generators_1.generateSubsetsOfSize; } });
|
|
15
|
+
var permutations_1 = require("./permutations");
|
|
16
|
+
Object.defineProperty(exports, "permutationParity", { enumerable: true, get: function () { return permutations_1.permutationParity; } });
|
|
17
|
+
Object.defineProperty(exports, "permutationCycles", { enumerable: true, get: function () { return permutations_1.permutationCycles; } });
|
|
18
|
+
Object.defineProperty(exports, "permutationOrder", { enumerable: true, get: function () { return permutations_1.permutationOrder; } });
|
|
19
|
+
Object.defineProperty(exports, "composePermutations", { enumerable: true, get: function () { return permutations_1.composePermutations; } });
|
|
20
|
+
Object.defineProperty(exports, "inversePermutation", { enumerable: true, get: function () { return permutations_1.inversePermutation; } });
|
|
21
|
+
var partitions_1 = require("./partitions");
|
|
22
|
+
Object.defineProperty(exports, "partitions", { enumerable: true, get: function () { return partitions_1.partitions; } });
|
|
23
|
+
Object.defineProperty(exports, "partitionsCount", { enumerable: true, get: function () { return partitions_1.partitionsCount; } });
|
|
24
|
+
Object.defineProperty(exports, "partitionsIntoParts", { enumerable: true, get: function () { return partitions_1.partitionsIntoParts; } });
|
|
25
|
+
var special_numbers_1 = require("./special-numbers");
|
|
26
|
+
Object.defineProperty(exports, "stirlingSecondKind", { enumerable: true, get: function () { return special_numbers_1.stirlingSecondKind; } });
|
|
27
|
+
Object.defineProperty(exports, "stirlingFirstKind", { enumerable: true, get: function () { return special_numbers_1.stirlingFirstKind; } });
|
|
28
|
+
Object.defineProperty(exports, "catalan", { enumerable: true, get: function () { return special_numbers_1.catalan; } });
|
|
29
|
+
Object.defineProperty(exports, "bellNumber", { enumerable: true, get: function () { return special_numbers_1.bellNumber; } });
|
|
30
|
+
Object.defineProperty(exports, "eulerNumber", { enumerable: true, get: function () { return special_numbers_1.eulerNumber; } });
|
|
31
|
+
Object.defineProperty(exports, "eulerianNumber", { enumerable: true, get: function () { return special_numbers_1.eulerianNumber; } });
|
|
32
|
+
var set_partitions_1 = require("./set-partitions");
|
|
33
|
+
Object.defineProperty(exports, "setPartitions", { enumerable: true, get: function () { return set_partitions_1.setPartitions; } });
|
|
34
|
+
Object.defineProperty(exports, "setPartitionsCount", { enumerable: true, get: function () { return set_partitions_1.setPartitionsCount; } });
|
|
35
|
+
var burnside_1 = require("./burnside");
|
|
36
|
+
Object.defineProperty(exports, "burnsideCount", { enumerable: true, get: function () { return burnside_1.burnsideCount; } });
|
|
37
|
+
Object.defineProperty(exports, "cyclicRotations", { enumerable: true, get: function () { return burnside_1.cyclicRotations; } });
|
|
38
|
+
var generating_functions_1 = require("./generating-functions");
|
|
39
|
+
Object.defineProperty(exports, "multiplyPolynomials", { enumerable: true, get: function () { return generating_functions_1.multiplyPolynomials; } });
|
|
40
|
+
Object.defineProperty(exports, "generatingFunction", { enumerable: true, get: function () { return generating_functions_1.generatingFunction; } });
|
|
41
|
+
Object.defineProperty(exports, "binomialGF", { enumerable: true, get: function () { return generating_functions_1.binomialGF; } });
|
|
42
|
+
var inclusion_exclusion_1 = require("./inclusion-exclusion");
|
|
43
|
+
Object.defineProperty(exports, "inclusionExclusion", { enumerable: true, get: function () { return inclusion_exclusion_1.inclusionExclusion; } });
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/index.ts"],"names":[],"mappings":";;;AAAA,+CAMwB;AALtB,yGAAA,SAAS,OAAA;AACT,wGAAA,QAAQ,OAAA;AACR,2GAAA,WAAW,OAAA;AACX,4GAAA,YAAY,OAAA;AACZ,4GAAA,YAAY,OAAA;AAGd,2CAKsB;AAJpB,kHAAA,oBAAoB,OAAA;AACpB,kHAAA,oBAAoB,OAAA;AACpB,8GAAA,gBAAgB,OAAA;AAChB,mHAAA,qBAAqB,OAAA;AAGvB,+CAMwB;AALtB,iHAAA,iBAAiB,OAAA;AACjB,iHAAA,iBAAiB,OAAA;AACjB,gHAAA,gBAAgB,OAAA;AAChB,mHAAA,mBAAmB,OAAA;AACnB,kHAAA,kBAAkB,OAAA;AAGpB,2CAIsB;AAHpB,wGAAA,UAAU,OAAA;AACV,6GAAA,eAAe,OAAA;AACf,iHAAA,mBAAmB,OAAA;AAGrB,qDAO2B;AANzB,qHAAA,kBAAkB,OAAA;AAClB,oHAAA,iBAAiB,OAAA;AACjB,0GAAA,OAAO,OAAA;AACP,6GAAA,UAAU,OAAA;AACV,8GAAA,WAAW,OAAA;AACX,iHAAA,cAAc,OAAA;AAGhB,mDAG0B;AAFxB,+GAAA,aAAa,OAAA;AACb,oHAAA,kBAAkB,OAAA;AAGpB,uCAGoB;AAFlB,yGAAA,aAAa,OAAA;AACb,2GAAA,eAAe,OAAA;AAGjB,+DAIgC;AAH9B,2HAAA,mBAAmB,OAAA;AACnB,0HAAA,kBAAkB,OAAA;AAClB,kHAAA,UAAU,OAAA;AAGZ,6DAE+B;AAD7B,yHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partitions.d.ts","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/partitions.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAoBhD;AAID,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CA6BjD;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAoBhE"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.partitions = partitions;
|
|
4
|
+
exports.partitionsCount = partitionsCount;
|
|
5
|
+
exports.partitionsIntoParts = partitionsIntoParts;
|
|
6
|
+
const bigint_helpers_1 = require("./bigint-helpers");
|
|
7
|
+
function partitions(n) {
|
|
8
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
9
|
+
throw new RangeError('partitions requiere entero no negativo');
|
|
10
|
+
}
|
|
11
|
+
if (n === 0)
|
|
12
|
+
return [[]];
|
|
13
|
+
const result = [];
|
|
14
|
+
function recurse(remaining, maxPart, current) {
|
|
15
|
+
if (remaining === 0) {
|
|
16
|
+
result.push(current.slice());
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const upper = Math.min(maxPart, remaining);
|
|
20
|
+
for (let i = upper; i >= 1; i--) {
|
|
21
|
+
current.push(i);
|
|
22
|
+
recurse(remaining - i, i, current);
|
|
23
|
+
current.pop();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
recurse(n, n, []);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
const PARTITION_COUNT_CACHE = [bigint_helpers_1.ONE];
|
|
30
|
+
function partitionsCount(n) {
|
|
31
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
32
|
+
throw new RangeError('partitionsCount requiere entero no negativo');
|
|
33
|
+
}
|
|
34
|
+
// Euler pentagonal number recurrence:
|
|
35
|
+
// p(n) = sum_{k!=0} (-1)^(k-1) [p(n - k(3k-1)/2) + p(n - k(3k+1)/2)]
|
|
36
|
+
for (let m = PARTITION_COUNT_CACHE.length; m <= n; m++) {
|
|
37
|
+
let total = bigint_helpers_1.ZERO;
|
|
38
|
+
for (let k = 1;; k++) {
|
|
39
|
+
const g1 = (k * (3 * k - 1)) / 2;
|
|
40
|
+
const g2 = (k * (3 * k + 1)) / 2;
|
|
41
|
+
if (g1 > m && g2 > m)
|
|
42
|
+
break;
|
|
43
|
+
const sign = k % 2 === 1 ? bigint_helpers_1.ONE : bigint_helpers_1.NEG_ONE;
|
|
44
|
+
if (g1 <= m) {
|
|
45
|
+
const v = PARTITION_COUNT_CACHE[m - g1];
|
|
46
|
+
if (v === undefined)
|
|
47
|
+
throw new Error('partitionsCount cache miss');
|
|
48
|
+
total += sign * v;
|
|
49
|
+
}
|
|
50
|
+
if (g2 <= m) {
|
|
51
|
+
const v = PARTITION_COUNT_CACHE[m - g2];
|
|
52
|
+
if (v === undefined)
|
|
53
|
+
throw new Error('partitionsCount cache miss');
|
|
54
|
+
total += sign * v;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
PARTITION_COUNT_CACHE[m] = total;
|
|
58
|
+
}
|
|
59
|
+
const v = PARTITION_COUNT_CACHE[n];
|
|
60
|
+
if (v === undefined)
|
|
61
|
+
throw new Error('partitionsCount cache miss inesperado');
|
|
62
|
+
return v;
|
|
63
|
+
}
|
|
64
|
+
function partitionsIntoParts(n, k) {
|
|
65
|
+
if (!Number.isInteger(n) || !Number.isInteger(k) || n < 0 || k < 0) {
|
|
66
|
+
throw new RangeError('partitionsIntoParts requiere n,k enteros no negativos');
|
|
67
|
+
}
|
|
68
|
+
if (k === 0)
|
|
69
|
+
return n === 0 ? bigint_helpers_1.ONE : bigint_helpers_1.ZERO;
|
|
70
|
+
if (k > n)
|
|
71
|
+
return bigint_helpers_1.ZERO;
|
|
72
|
+
// p_k(n) = p_k(n-k) + p_{k-1}(n-1)
|
|
73
|
+
// memoization 2D
|
|
74
|
+
const memo = new Map();
|
|
75
|
+
function pk(nn, kk) {
|
|
76
|
+
if (kk === 0)
|
|
77
|
+
return nn === 0 ? bigint_helpers_1.ONE : bigint_helpers_1.ZERO;
|
|
78
|
+
if (nn <= 0 || kk > nn)
|
|
79
|
+
return bigint_helpers_1.ZERO;
|
|
80
|
+
const key = `${nn}|${kk}`;
|
|
81
|
+
const cached = memo.get(key);
|
|
82
|
+
if (cached !== undefined)
|
|
83
|
+
return cached;
|
|
84
|
+
const v = pk(nn - kk, kk) + pk(nn - 1, kk - 1);
|
|
85
|
+
memo.set(key, v);
|
|
86
|
+
return v;
|
|
87
|
+
}
|
|
88
|
+
return pk(n, k);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=partitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partitions.js","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/partitions.ts"],"names":[],"mappings":";;AAEA,gCAoBC;AAID,0CA6BC;AAED,kDAoBC;AA7ED,qDAAsD;AAEtD,SAAgB,UAAU,CAAC,CAAS;IAClC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,UAAU,CAAC,wCAAwC,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACzB,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,SAAS,OAAO,CAAC,SAAiB,EAAE,OAAe,EAAE,OAAiB;QACpE,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CA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I,CAAC;IACzC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,qBAAI,CAAC;IACvB,mCAAmC;IACnC,iBAAiB;IACjB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,SAAS,EAAE,CAAC,EAAU,EAAE,EAAU;QAChC,IAAI,EAAE,KAAK,CAAC;YAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,oBAAG,CAAC,CAAC,CAAC,qBAAI,CAAC;QAC3C,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,qBAAI,CAAC;QACpC,MAAM,GAAG,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function permutationParity(perm: number[]): 1 | -1;
|
|
2
|
+
export declare function permutationCycles(perm: number[]): number[][];
|
|
3
|
+
export declare function permutationOrder(perm: number[]): number;
|
|
4
|
+
export declare function composePermutations(p: number[], q: number[]): number[];
|
|
5
|
+
export declare function inversePermutation(perm: number[]): number[];
|
|
6
|
+
//# sourceMappingURL=permutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permutations.d.ts","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/permutations.ts"],"names":[],"mappings":"AAcA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAqBxD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAqB5D;AAkBD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAOvD;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAoBtE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAY3D"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.permutationParity = permutationParity;
|
|
4
|
+
exports.permutationCycles = permutationCycles;
|
|
5
|
+
exports.permutationOrder = permutationOrder;
|
|
6
|
+
exports.composePermutations = composePermutations;
|
|
7
|
+
exports.inversePermutation = inversePermutation;
|
|
8
|
+
function assertValidPermutation(perm) {
|
|
9
|
+
const n = perm.length;
|
|
10
|
+
const seen = new Set();
|
|
11
|
+
for (const v of perm) {
|
|
12
|
+
if (!Number.isInteger(v) || v < 0 || v >= n) {
|
|
13
|
+
throw new RangeError(`permutación inválida: valor ${v} fuera de [0,${n})`);
|
|
14
|
+
}
|
|
15
|
+
if (seen.has(v)) {
|
|
16
|
+
throw new RangeError(`permutación inválida: valor repetido ${v}`);
|
|
17
|
+
}
|
|
18
|
+
seen.add(v);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function permutationParity(perm) {
|
|
22
|
+
assertValidPermutation(perm);
|
|
23
|
+
const n = perm.length;
|
|
24
|
+
const visited = new Array(n).fill(false);
|
|
25
|
+
let totalTranspositions = 0;
|
|
26
|
+
for (let i = 0; i < n; i++) {
|
|
27
|
+
if (visited[i])
|
|
28
|
+
continue;
|
|
29
|
+
let length = 0;
|
|
30
|
+
let j = i;
|
|
31
|
+
while (!visited[j]) {
|
|
32
|
+
visited[j] = true;
|
|
33
|
+
const next = perm[j];
|
|
34
|
+
if (next === undefined) {
|
|
35
|
+
throw new Error('permutationParity: índice inválido');
|
|
36
|
+
}
|
|
37
|
+
j = next;
|
|
38
|
+
length++;
|
|
39
|
+
}
|
|
40
|
+
totalTranspositions += length - 1;
|
|
41
|
+
}
|
|
42
|
+
return totalTranspositions % 2 === 0 ? 1 : -1;
|
|
43
|
+
}
|
|
44
|
+
function permutationCycles(perm) {
|
|
45
|
+
assertValidPermutation(perm);
|
|
46
|
+
const n = perm.length;
|
|
47
|
+
const visited = new Array(n).fill(false);
|
|
48
|
+
const cycles = [];
|
|
49
|
+
for (let i = 0; i < n; i++) {
|
|
50
|
+
if (visited[i])
|
|
51
|
+
continue;
|
|
52
|
+
const cycle = [];
|
|
53
|
+
let j = i;
|
|
54
|
+
while (!visited[j]) {
|
|
55
|
+
visited[j] = true;
|
|
56
|
+
cycle.push(j);
|
|
57
|
+
const next = perm[j];
|
|
58
|
+
if (next === undefined) {
|
|
59
|
+
throw new Error('permutationCycles: índice inválido');
|
|
60
|
+
}
|
|
61
|
+
j = next;
|
|
62
|
+
}
|
|
63
|
+
cycles.push(cycle);
|
|
64
|
+
}
|
|
65
|
+
return cycles;
|
|
66
|
+
}
|
|
67
|
+
function gcd(a, b) {
|
|
68
|
+
let x = Math.abs(a);
|
|
69
|
+
let y = Math.abs(b);
|
|
70
|
+
while (y !== 0) {
|
|
71
|
+
const t = y;
|
|
72
|
+
y = x % y;
|
|
73
|
+
x = t;
|
|
74
|
+
}
|
|
75
|
+
return x;
|
|
76
|
+
}
|
|
77
|
+
function lcm(a, b) {
|
|
78
|
+
if (a === 0 || b === 0)
|
|
79
|
+
return 0;
|
|
80
|
+
return Math.abs(a * b) / gcd(a, b);
|
|
81
|
+
}
|
|
82
|
+
function permutationOrder(perm) {
|
|
83
|
+
const cycles = permutationCycles(perm);
|
|
84
|
+
let order = 1;
|
|
85
|
+
for (const c of cycles) {
|
|
86
|
+
order = lcm(order, c.length);
|
|
87
|
+
}
|
|
88
|
+
return order;
|
|
89
|
+
}
|
|
90
|
+
function composePermutations(p, q) {
|
|
91
|
+
assertValidPermutation(p);
|
|
92
|
+
assertValidPermutation(q);
|
|
93
|
+
if (p.length !== q.length) {
|
|
94
|
+
throw new RangeError('composePermutations: longitudes diferentes');
|
|
95
|
+
}
|
|
96
|
+
const n = p.length;
|
|
97
|
+
const out = new Array(n);
|
|
98
|
+
for (let i = 0; i < n; i++) {
|
|
99
|
+
const qi = q[i];
|
|
100
|
+
if (qi === undefined) {
|
|
101
|
+
throw new Error('composePermutations: índice inválido en q');
|
|
102
|
+
}
|
|
103
|
+
const pqi = p[qi];
|
|
104
|
+
if (pqi === undefined) {
|
|
105
|
+
throw new Error('composePermutations: índice inválido en p');
|
|
106
|
+
}
|
|
107
|
+
out[i] = pqi;
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
function inversePermutation(perm) {
|
|
112
|
+
assertValidPermutation(perm);
|
|
113
|
+
const n = perm.length;
|
|
114
|
+
const inv = new Array(n);
|
|
115
|
+
for (let i = 0; i < n; i++) {
|
|
116
|
+
const pi = perm[i];
|
|
117
|
+
if (pi === undefined) {
|
|
118
|
+
throw new Error('inversePermutation: índice inválido');
|
|
119
|
+
}
|
|
120
|
+
inv[pi] = i;
|
|
121
|
+
}
|
|
122
|
+
return inv;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=permutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permutations.js","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/permutations.ts"],"names":[],"mappings":";;AAcA,8CAqBC;AAED,8CAqBC;AAkBD,4CAOC;AAED,kDAoBC;AAED,gDAYC;AAvHD,SAAS,sBAAsB,CAAC,IAAc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AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setPartitions = setPartitions;
|
|
4
|
+
exports.setPartitionsCount = setPartitionsCount;
|
|
5
|
+
const special_numbers_1 = require("./special-numbers");
|
|
6
|
+
function setPartitions(items) {
|
|
7
|
+
const n = items.length;
|
|
8
|
+
if (n === 0)
|
|
9
|
+
return [[]];
|
|
10
|
+
const result = [];
|
|
11
|
+
// restricted growth strings: a[i] indica el bloque de items[i].
|
|
12
|
+
const assignment = new Array(n).fill(0);
|
|
13
|
+
function recurse(i, maxUsed) {
|
|
14
|
+
if (i === n) {
|
|
15
|
+
const blocks = [];
|
|
16
|
+
for (let b = 0; b <= maxUsed; b++) {
|
|
17
|
+
blocks.push([]);
|
|
18
|
+
}
|
|
19
|
+
for (let idx = 0; idx < n; idx++) {
|
|
20
|
+
const bIdx = assignment[idx];
|
|
21
|
+
const item = items[idx];
|
|
22
|
+
if (bIdx === undefined)
|
|
23
|
+
throw new Error('setPartitions: assignment inválido');
|
|
24
|
+
if (item === undefined && !(idx in items)) {
|
|
25
|
+
throw new Error('setPartitions: ítem inválido');
|
|
26
|
+
}
|
|
27
|
+
const block = blocks[bIdx];
|
|
28
|
+
if (block === undefined)
|
|
29
|
+
throw new Error('setPartitions: bloque inválido');
|
|
30
|
+
block.push(item);
|
|
31
|
+
}
|
|
32
|
+
result.push(blocks);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
for (let b = 0; b <= maxUsed + 1; b++) {
|
|
36
|
+
assignment[i] = b;
|
|
37
|
+
recurse(i + 1, Math.max(maxUsed, b));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
recurse(0, -1);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
function setPartitionsCount(n) {
|
|
44
|
+
return (0, special_numbers_1.bellNumber)(n);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=set-partitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-partitions.js","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/set-partitions.ts"],"names":[],"mappings":";;AAEA,sCAiCC;AAED,gDAEC;AAvCD,uDAA+C;AAE/C,SAAgB,aAAa,CAAI,KAAU;IACzC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;IACvB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACzB,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,gEAAgE;IAChE,MAAM,UAAU,GAAG,IAAI,KAAK,CAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChD,SAAS,OAAO,CAAC,CAAS,EAAE,OAAe;QACzC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACZ,MAAM,MAAM,GAAU,EAAE,CAAC;YACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC;gBAClC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClB,CAAC;YACD,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC;gBACjC,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;gBAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;gBACxB,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;gBAC9E,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC;oBAC1C,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;gBAClD,CAAC;gBACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC3B,IAAI,KAAK,KAAK,SAAS;oBAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;gBAC3E,KAAK,CAAC,IAAI,CAAC,IAAS,CAAC,CAAC;YACxB,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpB,OAAO;QACT,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACf,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,kBAAkB,CAAC,CAAS;IAC1C,OAAO,IAAA,4BAAU,EAAC,CAAC,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function stirlingSecondKind(n: number, k: number): bigint;
|
|
2
|
+
export declare function stirlingFirstKind(n: number, k: number): bigint;
|
|
3
|
+
export declare function catalan(n: number): bigint;
|
|
4
|
+
export declare function bellNumber(n: number): bigint;
|
|
5
|
+
export declare function eulerNumber(n: number): bigint;
|
|
6
|
+
export declare function eulerianNumber(n: number, k: number): bigint;
|
|
7
|
+
//# sourceMappingURL=special-numbers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"special-numbers.d.ts","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/special-numbers.ts"],"names":[],"mappings":"AAKA,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAe/D;AAID,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAc9D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAMzC;AAID,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAgB5C;AAkBD,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAuB7C;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3D"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stirlingSecondKind = stirlingSecondKind;
|
|
4
|
+
exports.stirlingFirstKind = stirlingFirstKind;
|
|
5
|
+
exports.catalan = catalan;
|
|
6
|
+
exports.bellNumber = bellNumber;
|
|
7
|
+
exports.eulerNumber = eulerNumber;
|
|
8
|
+
exports.eulerianNumber = eulerianNumber;
|
|
9
|
+
const basic_counts_1 = require("./basic-counts");
|
|
10
|
+
const bigint_helpers_1 = require("./bigint-helpers");
|
|
11
|
+
const STIRLING2_CACHE = new Map();
|
|
12
|
+
function stirlingSecondKind(n, k) {
|
|
13
|
+
if (!Number.isInteger(n) || !Number.isInteger(k) || n < 0 || k < 0) {
|
|
14
|
+
throw new RangeError('stirlingSecondKind requiere enteros no negativos');
|
|
15
|
+
}
|
|
16
|
+
if (k === 0)
|
|
17
|
+
return n === 0 ? bigint_helpers_1.ONE : bigint_helpers_1.ZERO;
|
|
18
|
+
if (k > n)
|
|
19
|
+
return bigint_helpers_1.ZERO;
|
|
20
|
+
if (k === n)
|
|
21
|
+
return bigint_helpers_1.ONE;
|
|
22
|
+
if (k === 1)
|
|
23
|
+
return bigint_helpers_1.ONE;
|
|
24
|
+
const key = `${n}|${k}`;
|
|
25
|
+
const cached = STIRLING2_CACHE.get(key);
|
|
26
|
+
if (cached !== undefined)
|
|
27
|
+
return cached;
|
|
28
|
+
// S(n,k) = k*S(n-1,k) + S(n-1,k-1)
|
|
29
|
+
const v = BigInt(k) * stirlingSecondKind(n - 1, k) + stirlingSecondKind(n - 1, k - 1);
|
|
30
|
+
STIRLING2_CACHE.set(key, v);
|
|
31
|
+
return v;
|
|
32
|
+
}
|
|
33
|
+
const STIRLING1_CACHE = new Map();
|
|
34
|
+
function stirlingFirstKind(n, k) {
|
|
35
|
+
if (!Number.isInteger(n) || !Number.isInteger(k) || n < 0 || k < 0) {
|
|
36
|
+
throw new RangeError('stirlingFirstKind requiere enteros no negativos');
|
|
37
|
+
}
|
|
38
|
+
if (k === 0)
|
|
39
|
+
return n === 0 ? bigint_helpers_1.ONE : bigint_helpers_1.ZERO;
|
|
40
|
+
if (k > n)
|
|
41
|
+
return bigint_helpers_1.ZERO;
|
|
42
|
+
if (k === n)
|
|
43
|
+
return bigint_helpers_1.ONE;
|
|
44
|
+
const key = `${n}|${k}`;
|
|
45
|
+
const cached = STIRLING1_CACHE.get(key);
|
|
46
|
+
if (cached !== undefined)
|
|
47
|
+
return cached;
|
|
48
|
+
// c(n,k) = c(n-1,k-1) + (n-1)*c(n-1,k) (unsigned)
|
|
49
|
+
const v = stirlingFirstKind(n - 1, k - 1) + BigInt(n - 1) * stirlingFirstKind(n - 1, k);
|
|
50
|
+
STIRLING1_CACHE.set(key, v);
|
|
51
|
+
return v;
|
|
52
|
+
}
|
|
53
|
+
function catalan(n) {
|
|
54
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
55
|
+
throw new RangeError('catalan requiere entero no negativo');
|
|
56
|
+
}
|
|
57
|
+
// C_n = C(2n,n) / (n+1)
|
|
58
|
+
return (0, basic_counts_1.binomial)(2 * n, n) / BigInt(n + 1);
|
|
59
|
+
}
|
|
60
|
+
const BELL_CACHE = [bigint_helpers_1.ONE];
|
|
61
|
+
function bellNumber(n) {
|
|
62
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
63
|
+
throw new RangeError('bellNumber requiere entero no negativo');
|
|
64
|
+
}
|
|
65
|
+
for (let m = BELL_CACHE.length; m <= n; m++) {
|
|
66
|
+
let total = bigint_helpers_1.ZERO;
|
|
67
|
+
for (let k = 0; k < m; k++) {
|
|
68
|
+
const bk = BELL_CACHE[k];
|
|
69
|
+
if (bk === undefined)
|
|
70
|
+
throw new Error('bellNumber cache miss');
|
|
71
|
+
total += (0, basic_counts_1.binomial)(m - 1, k) * bk;
|
|
72
|
+
}
|
|
73
|
+
BELL_CACHE[m] = total;
|
|
74
|
+
}
|
|
75
|
+
const v = BELL_CACHE[n];
|
|
76
|
+
if (v === undefined)
|
|
77
|
+
throw new Error('bellNumber cache miss');
|
|
78
|
+
return v;
|
|
79
|
+
}
|
|
80
|
+
const EULER_CACHE = new Map();
|
|
81
|
+
function eulerianFirstOrder(n, k) {
|
|
82
|
+
if (k < 0 || k >= n)
|
|
83
|
+
return bigint_helpers_1.ZERO;
|
|
84
|
+
if (k === 0)
|
|
85
|
+
return bigint_helpers_1.ONE;
|
|
86
|
+
const key = `${n}|${k}`;
|
|
87
|
+
const cached = EULER_CACHE.get(key);
|
|
88
|
+
if (cached !== undefined)
|
|
89
|
+
return cached;
|
|
90
|
+
// <n,k> = (k+1) <n-1,k> + (n-k) <n-1,k-1>
|
|
91
|
+
const v = BigInt(k + 1) * eulerianFirstOrder(n - 1, k) + BigInt(n - k) * eulerianFirstOrder(n - 1, k - 1);
|
|
92
|
+
EULER_CACHE.set(key, v);
|
|
93
|
+
return v;
|
|
94
|
+
}
|
|
95
|
+
const ZIGZAG_CACHE = [bigint_helpers_1.ONE, bigint_helpers_1.ONE];
|
|
96
|
+
function eulerNumber(n) {
|
|
97
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
98
|
+
throw new RangeError('eulerNumber requiere entero no negativo');
|
|
99
|
+
}
|
|
100
|
+
// Número de permutaciones alternantes ("zigzag"): A(0)=1, A(1)=1,
|
|
101
|
+
// 2*A(n+1) = sum_{k=0..n} C(n,k) * A(k) * A(n-k).
|
|
102
|
+
for (let m = ZIGZAG_CACHE.length; m <= n; m++) {
|
|
103
|
+
const prev = m - 1;
|
|
104
|
+
let total = bigint_helpers_1.ZERO;
|
|
105
|
+
for (let k = 0; k <= prev; k++) {
|
|
106
|
+
const ak = ZIGZAG_CACHE[k];
|
|
107
|
+
const ank = ZIGZAG_CACHE[prev - k];
|
|
108
|
+
if (ak === undefined || ank === undefined)
|
|
109
|
+
throw new Error('eulerNumber cache miss');
|
|
110
|
+
total += (0, basic_counts_1.binomial)(prev, k) * ak * ank;
|
|
111
|
+
}
|
|
112
|
+
if (total % bigint_helpers_1.TWO !== bigint_helpers_1.ZERO) {
|
|
113
|
+
throw new Error('eulerNumber: total impar inesperado');
|
|
114
|
+
}
|
|
115
|
+
ZIGZAG_CACHE[m] = total / bigint_helpers_1.TWO;
|
|
116
|
+
}
|
|
117
|
+
const v = ZIGZAG_CACHE[n];
|
|
118
|
+
if (v === undefined)
|
|
119
|
+
throw new Error('eulerNumber cache miss');
|
|
120
|
+
return v;
|
|
121
|
+
}
|
|
122
|
+
function eulerianNumber(n, k) {
|
|
123
|
+
if (!Number.isInteger(n) || !Number.isInteger(k) || n < 0 || k < 0) {
|
|
124
|
+
throw new RangeError('eulerianNumber requiere enteros no negativos');
|
|
125
|
+
}
|
|
126
|
+
return eulerianFirstOrder(n, k);
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=special-numbers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"special-numbers.js","sourceRoot":"","sources":["../../../src/reasoning/combinatorics/special-numbers.ts"],"names":[],"mappings":";;AAKA,gDAeC;AAID,8CAcC;AAED,0BAMC;AAID,gCAgBC;AAkBD,kCAuBC;AAED,wCAKC;AAlHD,iDAA0C;AAC1C,qDAAkD;AAElD,MAAM,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;AAElD,SAAgB,kBAAk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ACxC,CAAC;QACD,IAAI,KAAK,GAAG,oBAAG,KAAK,qBAAI,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QACD,YAAY,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,oBAAG,CAAC;IAChC,CAAC;IACD,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,CAAC,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC/D,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAgB,cAAc,CAAC,CAAS,EAAE,CAAS;IACjD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,UAAU,CAAC,8CAA8C,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructive Cauchy sequences with explicit modulus of convergence.
|
|
3
|
+
*
|
|
4
|
+
* In Bishop's school, a "Cauchy sequence" without a modulus is not enough
|
|
5
|
+
* data to extract a limit constructively — one needs an explicit
|
|
6
|
+
* `modulus(eps)` returning an index N(eps) such that
|
|
7
|
+
* for all m, n >= N(eps), |x_m - x_n| < eps.
|
|
8
|
+
*/
|
|
9
|
+
import { type CReal } from '../constructive-reals';
|
|
10
|
+
export interface ConstructiveCauchySeq {
|
|
11
|
+
/** n-th term of the sequence (n >= 0). */
|
|
12
|
+
approx: (n: number) => CReal;
|
|
13
|
+
/**
|
|
14
|
+
* Modulus of convergence: returns N such that for all m, n >= N,
|
|
15
|
+
* |x_m - x_n| < 1/epsPrecision. `epsPrecision` is a positive integer
|
|
16
|
+
* (we work with rational 1/k thresholds to stay constructive).
|
|
17
|
+
*/
|
|
18
|
+
modulus: (epsPrecision: number) => number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sound (one-sided) check: returns true if the modulus genuinely
|
|
22
|
+
* witnesses Cauchy-ness at precision `eps` for the first few terms.
|
|
23
|
+
*
|
|
24
|
+
* Constructively we cannot inspect "all m, n >= N" — we sample a window
|
|
25
|
+
* and verify the bound holds. If the modulus is correct this will
|
|
26
|
+
* return true; if it is a counterexample for some sampled pair, false.
|
|
27
|
+
*
|
|
28
|
+
* `sampleWindow` controls how many terms past N we inspect. Default 8
|
|
29
|
+
* is enough to expose almost all wrong moduli.
|
|
30
|
+
*/
|
|
31
|
+
export declare const isCauchy: (seq: ConstructiveCauchySeq, epsPrecision: number, sampleWindow?: number) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Limit of a Cauchy sequence with modulus.
|
|
34
|
+
*
|
|
35
|
+
* `bits` (the CReal precision argument) is the number of binary fractional
|
|
36
|
+
* bits required. We need |limit - approx| < 2^{-bits}.
|
|
37
|
+
*
|
|
38
|
+
* Strategy: find index N such that the N-th term x_N is within 2^{-(bits+1)}
|
|
39
|
+
* of the true limit. By the triangle inequality, evaluating x_N at (bits+1)
|
|
40
|
+
* binary bits gives a result within 2^{-bits} of the limit.
|
|
41
|
+
*
|
|
42
|
+
* The modulus(eps) guarantees |x_m - x_n| < 1/eps for m,n >= N(eps).
|
|
43
|
+
* We need 1/eps <= 2^{-(bits+1)}, so eps >= 2^{bits+1}.
|
|
44
|
+
*/
|
|
45
|
+
export declare const limit: (seq: ConstructiveCauchySeq) => CReal;
|
|
46
|
+
/**
|
|
47
|
+
* Convenience: builds a Cauchy seq from a generator + a known rate `1/f(eps)`.
|
|
48
|
+
* `f(eps)` must return an integer N with |x_m - x_n| < 1/eps for m, n >= N.
|
|
49
|
+
*/
|
|
50
|
+
export declare const cauchyFrom: (term: (n: number) => CReal, modulus: (eps: number) => number) => ConstructiveCauchySeq;
|
|
51
|
+
//# sourceMappingURL=cauchy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cauchy.d.ts","sourceRoot":"","sources":["../../../src/reasoning/constructive-analysis/cauchy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,KAAK,EAAiC,MAAM,uBAAuB,CAAC;AAElF,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC;IAC7B;;;;OAIG;IACH,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,GACnB,KAAK,qBAAqB,EAC1B,cAAc,MAAM,EACpB,qBAAgB,KACf,OAiBF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,qBAAqB,KAAG,KASjD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,UAAU,GACrB,MAAM,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,EAC1B,SAAS,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,KAC/B,qBAGD,CAAC"}
|