@stevenvo780/st-lang 4.13.0 → 4.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/README.md +6 -6
  2. package/dist/ast/nodes.d.ts +50 -0
  3. package/dist/ast/nodes.d.ts.map +1 -1
  4. package/dist/format/stnb/parser.d.ts +14 -0
  5. package/dist/format/stnb/parser.d.ts.map +1 -0
  6. package/dist/format/stnb/parser.js +123 -0
  7. package/dist/format/stnb/parser.js.map +1 -0
  8. package/dist/format/stnb/types.d.ts +45 -0
  9. package/dist/format/stnb/types.d.ts.map +1 -0
  10. package/dist/format/stnb/types.js +7 -0
  11. package/dist/format/stnb/types.js.map +1 -0
  12. package/dist/logic/profile-bridge/index.d.ts.map +1 -1
  13. package/dist/logic/profile-bridge/index.js +20 -3
  14. package/dist/logic/profile-bridge/index.js.map +1 -1
  15. package/dist/logic/profiles/classical/propositional.d.ts.map +1 -1
  16. package/dist/logic/profiles/classical/propositional.js.map +1 -1
  17. package/dist/logic/profiles/ctl/check.d.ts.map +1 -1
  18. package/dist/logic/profiles/ctl/check.js +21 -11
  19. package/dist/logic/profiles/ctl/check.js.map +1 -1
  20. package/dist/logic/profiles/ctl/witness.d.ts.map +1 -1
  21. package/dist/logic/profiles/ctl/witness.js +2 -0
  22. package/dist/logic/profiles/ctl/witness.js.map +1 -1
  23. package/dist/logic/profiles/description-logic/types.d.ts +15 -0
  24. package/dist/logic/profiles/description-logic/types.d.ts.map +1 -1
  25. package/dist/logic/profiles/description-logic/types.js +13 -0
  26. package/dist/logic/profiles/description-logic/types.js.map +1 -1
  27. package/dist/logic/profiles/hybrid-logic/types.d.ts +17 -0
  28. package/dist/logic/profiles/hybrid-logic/types.d.ts.map +1 -1
  29. package/dist/logic/profiles/hybrid-logic/types.js +17 -0
  30. package/dist/logic/profiles/hybrid-logic/types.js.map +1 -1
  31. package/dist/logic/profiles/intuitionistic-nj/kripke.d.ts.map +1 -1
  32. package/dist/logic/profiles/intuitionistic-nj/kripke.js +8 -5
  33. package/dist/logic/profiles/intuitionistic-nj/kripke.js.map +1 -1
  34. package/dist/logic/profiles/ltl-sat/tableau.d.ts +31 -0
  35. package/dist/logic/profiles/ltl-sat/tableau.d.ts.map +1 -1
  36. package/dist/logic/profiles/ltl-sat/tableau.js +18 -0
  37. package/dist/logic/profiles/ltl-sat/tableau.js.map +1 -1
  38. package/dist/logic/profiles/ltl-sat/types.d.ts +15 -0
  39. package/dist/logic/profiles/ltl-sat/types.d.ts.map +1 -1
  40. package/dist/logic/profiles/ltl-sat/types.js +2 -1
  41. package/dist/logic/profiles/ltl-sat/types.js.map +1 -1
  42. package/dist/logic/profiles/modal-frame-axioms/formula.d.ts +10 -0
  43. package/dist/logic/profiles/modal-frame-axioms/formula.d.ts.map +1 -1
  44. package/dist/logic/profiles/modal-frame-axioms/formula.js +10 -0
  45. package/dist/logic/profiles/modal-frame-axioms/formula.js.map +1 -1
  46. package/dist/logic/profiles/mu-calculus/check.d.ts.map +1 -1
  47. package/dist/logic/profiles/mu-calculus/check.js +7 -4
  48. package/dist/logic/profiles/mu-calculus/check.js.map +1 -1
  49. package/dist/logic/profiles/natural-deduction-nk/formula.d.ts +8 -0
  50. package/dist/logic/profiles/natural-deduction-nk/formula.d.ts.map +1 -1
  51. package/dist/logic/profiles/natural-deduction-nk/formula.js +8 -0
  52. package/dist/logic/profiles/natural-deduction-nk/formula.js.map +1 -1
  53. package/dist/logic/profiles/quantum/index.d.ts.map +1 -1
  54. package/dist/logic/profiles/quantum/index.js +11 -8
  55. package/dist/logic/profiles/quantum/index.js.map +1 -1
  56. package/dist/logic/profiles/sequent-lj/index.d.ts +90 -0
  57. package/dist/logic/profiles/sequent-lj/index.d.ts.map +1 -0
  58. package/dist/logic/profiles/sequent-lj/index.js +903 -0
  59. package/dist/logic/profiles/sequent-lj/index.js.map +1 -0
  60. package/dist/logic/profiles/shared/tableau-engine.d.ts.map +1 -1
  61. package/dist/logic/profiles/shared/tableau-engine.js +0 -17
  62. package/dist/logic/profiles/shared/tableau-engine.js.map +1 -1
  63. package/dist/namespaces/proof-systems.d.ts +1 -1
  64. package/dist/namespaces/proof-systems.d.ts.map +1 -1
  65. package/dist/namespaces/proof-systems.js.map +1 -1
  66. package/dist/namespaces/semantics.d.ts +1 -1
  67. package/dist/namespaces/semantics.d.ts.map +1 -1
  68. package/dist/namespaces/semantics.js.map +1 -1
  69. package/dist/proof-systems/distributed-exchange/index.d.ts +29 -0
  70. package/dist/proof-systems/distributed-exchange/index.d.ts.map +1 -1
  71. package/dist/proof-systems/distributed-exchange/index.js +18 -0
  72. package/dist/proof-systems/distributed-exchange/index.js.map +1 -1
  73. package/dist/proof-systems/fol-prover/types.d.ts +16 -0
  74. package/dist/proof-systems/fol-prover/types.d.ts.map +1 -1
  75. package/dist/proof-systems/fol-prover/types.js +7 -0
  76. package/dist/proof-systems/fol-prover/types.js.map +1 -1
  77. package/dist/proof-systems/fol-prover-advanced/index.d.ts +3 -3
  78. package/dist/proof-systems/fol-prover-advanced/index.d.ts.map +1 -1
  79. package/dist/proof-systems/fol-prover-advanced/index.js.map +1 -1
  80. package/dist/proof-systems/fol-prover-advanced/ordering.js +1 -1
  81. package/dist/proof-systems/fol-prover-advanced/prover.d.ts.map +1 -1
  82. package/dist/proof-systems/fol-prover-advanced/prover.js +19 -12
  83. package/dist/proof-systems/fol-prover-advanced/prover.js.map +1 -1
  84. package/dist/proof-systems/fol-prover-advanced/resolve.d.ts.map +1 -1
  85. package/dist/proof-systems/fol-prover-advanced/resolve.js +7 -7
  86. package/dist/proof-systems/fol-prover-advanced/resolve.js.map +1 -1
  87. package/dist/proof-systems/fol-prover-advanced/subsumption.d.ts.map +1 -1
  88. package/dist/proof-systems/fol-prover-advanced/subsumption.js.map +1 -1
  89. package/dist/proof-systems/fol-prover-advanced/types.d.ts +12 -0
  90. package/dist/proof-systems/fol-prover-advanced/types.d.ts.map +1 -1
  91. package/dist/proof-systems/fol-prover-advanced/unify.js +2 -2
  92. package/dist/proof-systems/fol-prover-equality/term-utils.d.ts +46 -0
  93. package/dist/proof-systems/fol-prover-equality/term-utils.d.ts.map +1 -1
  94. package/dist/proof-systems/fol-prover-equality/term-utils.js +46 -0
  95. package/dist/proof-systems/fol-prover-equality/term-utils.js.map +1 -1
  96. package/dist/proof-systems/proof-nets/correctness.d.ts.map +1 -1
  97. package/dist/proof-systems/proof-nets/correctness.js +24 -12
  98. package/dist/proof-systems/proof-nets/correctness.js.map +1 -1
  99. package/dist/proof-systems/proof-nets/types.d.ts +18 -0
  100. package/dist/proof-systems/proof-nets/types.d.ts.map +1 -1
  101. package/dist/proof-systems/proof-nets/types.js +6 -0
  102. package/dist/proof-systems/proof-nets/types.js.map +1 -1
  103. package/dist/proof-systems/tableau-framework/TableauProver.d.ts.map +1 -1
  104. package/dist/proof-systems/tableau-framework/TableauProver.js +5 -5
  105. package/dist/proof-systems/tableau-framework/TableauProver.js.map +1 -1
  106. package/dist/proof-systems/tableau-framework/propositional.d.ts.map +1 -1
  107. package/dist/proof-systems/tableau-framework/propositional.js +21 -21
  108. package/dist/proof-systems/tableau-framework/propositional.js.map +1 -1
  109. package/dist/reasoning/ban-logic/terms.d.ts +24 -0
  110. package/dist/reasoning/ban-logic/terms.d.ts.map +1 -1
  111. package/dist/reasoning/ban-logic/terms.js +24 -0
  112. package/dist/reasoning/ban-logic/terms.js.map +1 -1
  113. package/dist/reasoning/bayesian/factor.js +8 -8
  114. package/dist/reasoning/bayesian/factor.js.map +1 -1
  115. package/dist/reasoning/bayesian/inference.d.ts.map +1 -1
  116. package/dist/reasoning/bayesian/inference.js +11 -5
  117. package/dist/reasoning/bayesian/inference.js.map +1 -1
  118. package/dist/reasoning/combinatorics/generators.js.map +1 -1
  119. package/dist/reasoning/combinatorics/index.d.ts +3 -3
  120. package/dist/reasoning/combinatorics/index.d.ts.map +1 -1
  121. package/dist/reasoning/combinatorics/index.js.map +1 -1
  122. package/dist/reasoning/combinatorics/set-partitions.js.map +1 -1
  123. package/dist/reasoning/combinatorics/special-numbers.d.ts.map +1 -1
  124. package/dist/reasoning/combinatorics/special-numbers.js.map +1 -1
  125. package/dist/reasoning/constructive-analysis/cauchy.js +2 -2
  126. package/dist/reasoning/constructive-analysis/compact.js +1 -1
  127. package/dist/reasoning/constructive-analysis/continuity.d.ts.map +1 -1
  128. package/dist/reasoning/constructive-analysis/continuity.js +4 -4
  129. package/dist/reasoning/constructive-analysis/continuity.js.map +1 -1
  130. package/dist/reasoning/constructive-analysis/index.d.ts.map +1 -1
  131. package/dist/reasoning/constructive-analysis/index.js.map +1 -1
  132. package/dist/reasoning/constructive-analysis/ivt.d.ts.map +1 -1
  133. package/dist/reasoning/constructive-analysis/ivt.js +2 -2
  134. package/dist/reasoning/constructive-analysis/ivt.js.map +1 -1
  135. package/dist/reasoning/constructive-reals/index.d.ts.map +1 -1
  136. package/dist/reasoning/constructive-reals/index.js +4 -8
  137. package/dist/reasoning/constructive-reals/index.js.map +1 -1
  138. package/dist/reasoning/galois-fields/index.d.ts +64 -0
  139. package/dist/reasoning/galois-fields/index.d.ts.map +1 -1
  140. package/dist/reasoning/galois-fields/index.js +56 -6
  141. package/dist/reasoning/galois-fields/index.js.map +1 -1
  142. package/dist/reasoning/graph-theory/index.d.ts +31 -0
  143. package/dist/reasoning/graph-theory/index.d.ts.map +1 -1
  144. package/dist/reasoning/graph-theory/index.js +28 -10
  145. package/dist/reasoning/graph-theory/index.js.map +1 -1
  146. package/dist/reasoning/hoare-logic/index.d.ts +164 -0
  147. package/dist/reasoning/hoare-logic/index.d.ts.map +1 -0
  148. package/dist/reasoning/hoare-logic/index.js +561 -0
  149. package/dist/reasoning/hoare-logic/index.js.map +1 -0
  150. package/dist/reasoning/hyperreal/index.d.ts +30 -0
  151. package/dist/reasoning/hyperreal/index.d.ts.map +1 -1
  152. package/dist/reasoning/hyperreal/index.js +25 -0
  153. package/dist/reasoning/hyperreal/index.js.map +1 -1
  154. package/dist/reasoning/information-theory/index.d.ts +34 -0
  155. package/dist/reasoning/information-theory/index.d.ts.map +1 -1
  156. package/dist/reasoning/information-theory/index.js +27 -44
  157. package/dist/reasoning/information-theory/index.js.map +1 -1
  158. package/dist/reasoning/lemma-synthesis/index.d.ts +36 -0
  159. package/dist/reasoning/lemma-synthesis/index.d.ts.map +1 -1
  160. package/dist/reasoning/lemma-synthesis/index.js +12 -0
  161. package/dist/reasoning/lemma-synthesis/index.js.map +1 -1
  162. package/dist/reasoning/linear-algebra/index.d.ts +38 -0
  163. package/dist/reasoning/linear-algebra/index.d.ts.map +1 -1
  164. package/dist/reasoning/linear-algebra/index.js +34 -5
  165. package/dist/reasoning/linear-algebra/index.js.map +1 -1
  166. package/dist/reasoning/markov-logic/grounding.js +1 -1
  167. package/dist/reasoning/markov-logic/grounding.js.map +1 -1
  168. package/dist/reasoning/markov-logic/inference.js +1 -1
  169. package/dist/reasoning/markov-logic/inference.js.map +1 -1
  170. package/dist/reasoning/model-checking/index.d.ts +113 -0
  171. package/dist/reasoning/model-checking/index.d.ts.map +1 -0
  172. package/dist/reasoning/model-checking/index.js +786 -0
  173. package/dist/reasoning/model-checking/index.js.map +1 -0
  174. package/dist/reasoning/order-theory/index.d.ts +121 -0
  175. package/dist/reasoning/order-theory/index.d.ts.map +1 -0
  176. package/dist/reasoning/order-theory/index.js +562 -0
  177. package/dist/reasoning/order-theory/index.js.map +1 -0
  178. package/dist/reasoning/peano-arithmetic/index.d.ts +114 -0
  179. package/dist/reasoning/peano-arithmetic/index.d.ts.map +1 -0
  180. package/dist/reasoning/peano-arithmetic/index.js +650 -0
  181. package/dist/reasoning/peano-arithmetic/index.js.map +1 -0
  182. package/dist/reasoning/polynomial-ring/index.d.ts +80 -0
  183. package/dist/reasoning/polynomial-ring/index.d.ts.map +1 -1
  184. package/dist/reasoning/polynomial-ring/index.js +75 -0
  185. package/dist/reasoning/polynomial-ring/index.js.map +1 -1
  186. package/dist/reasoning/separation-logic/index.d.ts +220 -0
  187. package/dist/reasoning/separation-logic/index.d.ts.map +1 -0
  188. package/dist/reasoning/separation-logic/index.js +779 -0
  189. package/dist/reasoning/separation-logic/index.js.map +1 -0
  190. package/dist/reasoning/set-theory/hf-functions.js +3 -3
  191. package/dist/reasoning/set-theory/hf-sets.js +1 -1
  192. package/dist/reasoning/set-theory/index.d.ts +3 -3
  193. package/dist/reasoning/set-theory/index.d.ts.map +1 -1
  194. package/dist/reasoning/set-theory/zfc-axioms.js +4 -4
  195. package/dist/reasoning/tactic-dsl/tactics.d.ts +87 -0
  196. package/dist/reasoning/tactic-dsl/tactics.d.ts.map +1 -1
  197. package/dist/reasoning/tactic-dsl/tactics.js +86 -36
  198. package/dist/reasoning/tactic-dsl/tactics.js.map +1 -1
  199. package/dist/reasoning/topology/index.d.ts +81 -0
  200. package/dist/reasoning/topology/index.d.ts.map +1 -1
  201. package/dist/reasoning/topology/index.js +69 -45
  202. package/dist/reasoning/topology/index.js.map +1 -1
  203. package/dist/reasoning/universal-algebra/index.d.ts +196 -0
  204. package/dist/reasoning/universal-algebra/index.d.ts.map +1 -0
  205. package/dist/reasoning/universal-algebra/index.js +865 -0
  206. package/dist/reasoning/universal-algebra/index.js.map +1 -0
  207. package/dist/runtime/countermodel-min/minimize.js +0 -0
  208. package/dist/runtime/countermodel-min/minimize.js.map +1 -1
  209. package/dist/runtime/csp-hoare/semantics.d.ts +12 -0
  210. package/dist/runtime/csp-hoare/semantics.d.ts.map +1 -1
  211. package/dist/runtime/csp-hoare/semantics.js +12 -0
  212. package/dist/runtime/csp-hoare/semantics.js.map +1 -1
  213. package/dist/runtime/symbolic-diff/constructors.d.ts +20 -0
  214. package/dist/runtime/symbolic-diff/constructors.d.ts.map +1 -1
  215. package/dist/runtime/symbolic-diff/constructors.js +20 -0
  216. package/dist/runtime/symbolic-diff/constructors.js.map +1 -1
  217. package/dist/runtime/term-rewriting/term-utils.d.ts.map +1 -1
  218. package/dist/runtime/term-rewriting/term-utils.js +33 -2
  219. package/dist/runtime/term-rewriting/term-utils.js.map +1 -1
  220. package/dist/runtime/typecheck/checker.js +2 -2
  221. package/dist/runtime/typecheck/checker.js.map +1 -1
  222. package/dist/runtime/typecheck/levenshtein.js +1 -1
  223. package/dist/runtime/typecheck/levenshtein.js.map +1 -1
  224. package/dist/semantics/categorical/fin-set.d.ts.map +1 -1
  225. package/dist/semantics/categorical/fin-set.js +8 -1
  226. package/dist/semantics/categorical/fin-set.js.map +1 -1
  227. package/dist/semantics/categorical/free.d.ts.map +1 -1
  228. package/dist/semantics/categorical/free.js +8 -2
  229. package/dist/semantics/categorical/free.js.map +1 -1
  230. package/dist/semantics/categorical/limits.d.ts.map +1 -1
  231. package/dist/semantics/categorical/limits.js +13 -4
  232. package/dist/semantics/categorical/limits.js.map +1 -1
  233. package/dist/semantics/categorical/monoidal.d.ts.map +1 -1
  234. package/dist/semantics/categorical/monoidal.js +3 -1
  235. package/dist/semantics/categorical/monoidal.js.map +1 -1
  236. package/dist/semantics/text-layer/compiler.d.ts +46 -0
  237. package/dist/semantics/text-layer/compiler.d.ts.map +1 -1
  238. package/dist/semantics/text-layer/compiler.js +46 -11
  239. package/dist/semantics/text-layer/compiler.js.map +1 -1
  240. package/dist/solver/cdcl-v2/index.d.ts +8 -0
  241. package/dist/solver/cdcl-v2/index.d.ts.map +1 -1
  242. package/dist/solver/cdcl-v2/index.js +8 -0
  243. package/dist/solver/cdcl-v2/index.js.map +1 -1
  244. package/dist/solver/smt-z3/z3-wasm-backend.d.ts +0 -1
  245. package/dist/solver/smt-z3/z3-wasm-backend.d.ts.map +1 -1
  246. package/dist/solver/smt-z3/z3-wasm-backend.js +2 -3
  247. package/dist/solver/smt-z3/z3-wasm-backend.js.map +1 -1
  248. package/dist/tests/agora-integration-fixtures.test.js +7 -2
  249. package/dist/tests/agora-integration-fixtures.test.js.map +1 -1
  250. package/dist/tests/coverage-90/coverage-90-cdcl-v2-deep.test.d.ts +2 -0
  251. package/dist/tests/coverage-90/coverage-90-cdcl-v2-deep.test.d.ts.map +1 -0
  252. package/dist/tests/coverage-90/coverage-90-cdcl-v2-deep.test.js +123 -0
  253. package/dist/tests/coverage-90/coverage-90-cdcl-v2-deep.test.js.map +1 -0
  254. package/dist/tests/coverage-90/coverage-90-certificate-rules.test.d.ts +2 -0
  255. package/dist/tests/coverage-90/coverage-90-certificate-rules.test.d.ts.map +1 -0
  256. package/dist/tests/coverage-90/coverage-90-certificate-rules.test.js +172 -0
  257. package/dist/tests/coverage-90/coverage-90-certificate-rules.test.js.map +1 -0
  258. package/dist/tests/coverage-90/coverage-90-interpreter-extra.test.d.ts +2 -0
  259. package/dist/tests/coverage-90/coverage-90-interpreter-extra.test.d.ts.map +1 -0
  260. package/dist/tests/coverage-90/coverage-90-interpreter-extra.test.js +326 -0
  261. package/dist/tests/coverage-90/coverage-90-interpreter-extra.test.js.map +1 -0
  262. package/dist/tests/coverage-90/coverage-90-interpreter-features.test.d.ts +2 -0
  263. package/dist/tests/coverage-90/coverage-90-interpreter-features.test.d.ts.map +1 -0
  264. package/dist/tests/coverage-90/coverage-90-interpreter-features.test.js +418 -0
  265. package/dist/tests/coverage-90/coverage-90-interpreter-features.test.js.map +1 -0
  266. package/dist/tests/coverage-90/coverage-90-modal-temporal.test.d.ts +2 -0
  267. package/dist/tests/coverage-90/coverage-90-modal-temporal.test.d.ts.map +1 -0
  268. package/dist/tests/coverage-90/coverage-90-modal-temporal.test.js +162 -0
  269. package/dist/tests/coverage-90/coverage-90-modal-temporal.test.js.map +1 -0
  270. package/dist/tests/coverage-90/coverage-90-nk-prover.test.d.ts +2 -0
  271. package/dist/tests/coverage-90/coverage-90-nk-prover.test.d.ts.map +1 -0
  272. package/dist/tests/coverage-90/coverage-90-nk-prover.test.js +104 -0
  273. package/dist/tests/coverage-90/coverage-90-nk-prover.test.js.map +1 -0
  274. package/dist/tests/coverage-90/coverage-90-parser-deep.test.d.ts +2 -0
  275. package/dist/tests/coverage-90/coverage-90-parser-deep.test.d.ts.map +1 -0
  276. package/dist/tests/coverage-90/coverage-90-parser-deep.test.js +262 -0
  277. package/dist/tests/coverage-90/coverage-90-parser-deep.test.js.map +1 -0
  278. package/dist/tests/coverage-90/coverage-90-sat-engines.test.d.ts +2 -0
  279. package/dist/tests/coverage-90/coverage-90-sat-engines.test.d.ts.map +1 -0
  280. package/dist/tests/coverage-90/coverage-90-sat-engines.test.js +101 -0
  281. package/dist/tests/coverage-90/coverage-90-sat-engines.test.js.map +1 -0
  282. package/dist/tests/coverage-90/coverage-90-sequent-lk.test.d.ts +2 -0
  283. package/dist/tests/coverage-90/coverage-90-sequent-lk.test.d.ts.map +1 -0
  284. package/dist/tests/coverage-90/coverage-90-sequent-lk.test.js +219 -0
  285. package/dist/tests/coverage-90/coverage-90-sequent-lk.test.js.map +1 -0
  286. package/dist/tests/coverage-90/coverage-90-smt-lib-parser.test.d.ts +2 -0
  287. package/dist/tests/coverage-90/coverage-90-smt-lib-parser.test.d.ts.map +1 -0
  288. package/dist/tests/coverage-90/coverage-90-smt-lib-parser.test.js +154 -0
  289. package/dist/tests/coverage-90/coverage-90-smt-lib-parser.test.js.map +1 -0
  290. package/dist/tests/coverage-95/first-order.test.js.map +1 -1
  291. package/dist/tests/coverage-95/fol-prover.test.js.map +1 -1
  292. package/dist/tests/integration/cross-modules.test.js +43 -19
  293. package/dist/tests/integration/cross-modules.test.js.map +1 -1
  294. package/dist/tests/logic/ctl/check.test.js.map +1 -1
  295. package/dist/tests/logic/profile-bridge/translations.test.js +3 -3
  296. package/dist/tests/logic/profile-bridge/translations.test.js.map +1 -1
  297. package/dist/tests/logic/profiles/sequent-lj/lj.test.d.ts +2 -0
  298. package/dist/tests/logic/profiles/sequent-lj/lj.test.d.ts.map +1 -0
  299. package/dist/tests/logic/profiles/sequent-lj/lj.test.js +400 -0
  300. package/dist/tests/logic/profiles/sequent-lj/lj.test.js.map +1 -0
  301. package/dist/tests/logic/sequent-g3/prover.test.js.map +1 -1
  302. package/dist/tests/logic/substructural/prover.test.js.map +1 -1
  303. package/dist/tests/proof-systems/fol-prover-advanced/prover.test.js +40 -13
  304. package/dist/tests/proof-systems/fol-prover-advanced/prover.test.js.map +1 -1
  305. package/dist/tests/proof-systems/higher-order-unify/ho-unify.test.js.map +1 -1
  306. package/dist/tests/proof-systems/tableau-framework/tableau.test.js +8 -8
  307. package/dist/tests/proof-systems/tableau-framework/tableau.test.js.map +1 -1
  308. package/dist/tests/properties/agm.property.test.js +1 -1
  309. package/dist/tests/properties/agm.property.test.js.map +1 -1
  310. package/dist/tests/properties/anti-unification.property.test.js.map +1 -1
  311. package/dist/tests/properties/argumentation.property.test.js.map +1 -1
  312. package/dist/tests/properties/bisimulation.property.test.js.map +1 -1
  313. package/dist/tests/properties/cdcl.property.test.js.map +1 -1
  314. package/dist/tests/properties/coinduction.property.test.js.map +1 -1
  315. package/dist/tests/properties/constructive-reals.property.test.js.map +1 -1
  316. package/dist/tests/properties/csp.property.test.js +1 -3
  317. package/dist/tests/properties/csp.property.test.js.map +1 -1
  318. package/dist/tests/properties/generators.d.ts +1 -1
  319. package/dist/tests/properties/generators.d.ts.map +1 -1
  320. package/dist/tests/properties/generators.js +22 -30
  321. package/dist/tests/properties/generators.js.map +1 -1
  322. package/dist/tests/properties/intuit-nj.property.test.js +3 -1
  323. package/dist/tests/properties/intuit-nj.property.test.js.map +1 -1
  324. package/dist/tests/properties/lambda-calc.property.test.js.map +1 -1
  325. package/dist/tests/properties/mln.property.test.js +1 -3
  326. package/dist/tests/properties/mln.property.test.js.map +1 -1
  327. package/dist/tests/properties/planning.property.test.js.map +1 -1
  328. package/dist/tests/properties/profile-bridge.property.test.js.map +1 -1
  329. package/dist/tests/properties/theorem-cache.property.test.js.map +1 -1
  330. package/dist/tests/protocol-text-layer.test.js.map +1 -1
  331. package/dist/tests/reasoning/combinatorics/combinatorics.test.js +1 -1
  332. package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.js +9 -9
  333. package/dist/tests/reasoning/constructive-analysis/constructive-analysis.test.js.map +1 -1
  334. package/dist/tests/reasoning/hoare-logic/hoare-logic.test.d.ts +2 -0
  335. package/dist/tests/reasoning/hoare-logic/hoare-logic.test.d.ts.map +1 -0
  336. package/dist/tests/reasoning/hoare-logic/hoare-logic.test.js +340 -0
  337. package/dist/tests/reasoning/hoare-logic/hoare-logic.test.js.map +1 -0
  338. package/dist/tests/reasoning/linear-algebra/linear-algebra.test.js +80 -38
  339. package/dist/tests/reasoning/linear-algebra/linear-algebra.test.js.map +1 -1
  340. package/dist/tests/reasoning/model-checking/model-checking.test.d.ts +2 -0
  341. package/dist/tests/reasoning/model-checking/model-checking.test.d.ts.map +1 -0
  342. package/dist/tests/reasoning/model-checking/model-checking.test.js +222 -0
  343. package/dist/tests/reasoning/model-checking/model-checking.test.js.map +1 -0
  344. package/dist/tests/reasoning/order-theory/order-theory.test.d.ts +2 -0
  345. package/dist/tests/reasoning/order-theory/order-theory.test.d.ts.map +1 -0
  346. package/dist/tests/reasoning/order-theory/order-theory.test.js +211 -0
  347. package/dist/tests/reasoning/order-theory/order-theory.test.js.map +1 -0
  348. package/dist/tests/reasoning/peano-arithmetic/peano.test.d.ts +2 -0
  349. package/dist/tests/reasoning/peano-arithmetic/peano.test.d.ts.map +1 -0
  350. package/dist/tests/reasoning/peano-arithmetic/peano.test.js +159 -0
  351. package/dist/tests/reasoning/peano-arithmetic/peano.test.js.map +1 -0
  352. package/dist/tests/reasoning/separation-logic/separation-logic.test.d.ts +2 -0
  353. package/dist/tests/reasoning/separation-logic/separation-logic.test.d.ts.map +1 -0
  354. package/dist/tests/reasoning/separation-logic/separation-logic.test.js +311 -0
  355. package/dist/tests/reasoning/separation-logic/separation-logic.test.js.map +1 -0
  356. package/dist/tests/reasoning/set-theory/hf-functions.test.js +11 -11
  357. package/dist/tests/reasoning/set-theory/zfc-axioms.test.js +1 -1
  358. package/dist/tests/reasoning/universal-algebra/universal-algebra.test.d.ts +2 -0
  359. package/dist/tests/reasoning/universal-algebra/universal-algebra.test.d.ts.map +1 -0
  360. package/dist/tests/reasoning/universal-algebra/universal-algebra.test.js +289 -0
  361. package/dist/tests/reasoning/universal-algebra/universal-algebra.test.js.map +1 -0
  362. package/dist/tests/semantics/text-layer-v2/claim-graph.test.js.map +1 -1
  363. package/dist/tests/solver/smt-lib/emitter.test.js.map +1 -1
  364. package/dist/tests/solver/smt-z3/z3-wasm-backend.test.js.map +1 -1
  365. package/dist/tests/tooling/test-harness/test-harness.test.js +9 -6
  366. package/dist/tests/tooling/test-harness/test-harness.test.js.map +1 -1
  367. package/dist/tooling/lsp/types.d.ts +13 -0
  368. package/dist/tooling/lsp/types.d.ts.map +1 -1
  369. package/dist/tooling/lsp/types.js +1 -0
  370. package/dist/tooling/lsp/types.js.map +1 -1
  371. package/dist/tooling/test-harness/combinators.d.ts.map +1 -1
  372. package/dist/tooling/test-harness/combinators.js +4 -4
  373. package/dist/tooling/test-harness/combinators.js.map +1 -1
  374. package/dist/tooling/test-harness/coverage.js +1 -1
  375. package/dist/tooling/test-harness/generators.d.ts.map +1 -1
  376. package/dist/tooling/test-harness/generators.js.map +1 -1
  377. package/dist/tooling/test-harness/index.d.ts +1 -1
  378. package/dist/tooling/test-harness/index.d.ts.map +1 -1
  379. package/dist/tooling/test-harness/index.js.map +1 -1
  380. package/dist/tooling/test-harness/snapshot.d.ts.map +1 -1
  381. package/dist/tooling/test-harness/snapshot.js +2 -2
  382. package/dist/tooling/test-harness/snapshot.js.map +1 -1
  383. package/dist/type-theory/cubical/types.d.ts +25 -0
  384. package/dist/type-theory/cubical/types.d.ts.map +1 -1
  385. package/dist/type-theory/cubical/types.js +20 -0
  386. package/dist/type-theory/cubical/types.js.map +1 -1
  387. package/dist/type-theory/curry-howard/types.d.ts +27 -0
  388. package/dist/type-theory/curry-howard/types.d.ts.map +1 -1
  389. package/dist/type-theory/curry-howard/types.js +18 -0
  390. package/dist/type-theory/curry-howard/types.js.map +1 -1
  391. package/dist/type-theory/hindley-milner/substitution.d.ts +39 -0
  392. package/dist/type-theory/hindley-milner/substitution.d.ts.map +1 -1
  393. package/dist/type-theory/hindley-milner/substitution.js +37 -0
  394. package/dist/type-theory/hindley-milner/substitution.js.map +1 -1
  395. package/dist/type-theory/hindley-milner/types.d.ts +25 -0
  396. package/dist/type-theory/hindley-milner/types.d.ts.map +1 -1
  397. package/dist/type-theory/hindley-milner/types.js +22 -2
  398. package/dist/type-theory/hindley-milner/types.js.map +1 -1
  399. package/dist/type-theory/hol/rules.d.ts +36 -0
  400. package/dist/type-theory/hol/rules.d.ts.map +1 -1
  401. package/dist/type-theory/hol/rules.js +36 -0
  402. package/dist/type-theory/hol/rules.js.map +1 -1
  403. package/dist/type-theory/hott/types.d.ts +32 -0
  404. package/dist/type-theory/hott/types.d.ts.map +1 -1
  405. package/dist/type-theory/hott/types.js +31 -1
  406. package/dist/type-theory/hott/types.js.map +1 -1
  407. package/dist/type-theory/lambda-cube/types.d.ts +17 -0
  408. package/dist/type-theory/lambda-cube/types.d.ts.map +1 -1
  409. package/dist/type-theory/lambda-cube/types.js +13 -0
  410. package/dist/type-theory/lambda-cube/types.js.map +1 -1
  411. package/dist/type-theory/mltt/types.d.ts +19 -0
  412. package/dist/type-theory/mltt/types.d.ts.map +1 -1
  413. package/dist/type-theory/mltt/types.js +15 -1
  414. package/dist/type-theory/mltt/types.js.map +1 -1
  415. package/dist/type-theory/nbe/types.d.ts +21 -0
  416. package/dist/type-theory/nbe/types.d.ts.map +1 -1
  417. package/dist/type-theory/nbe/types.js +13 -1
  418. package/dist/type-theory/nbe/types.js.map +1 -1
  419. package/dist/type-theory/refinement-types/types.d.ts +38 -0
  420. package/dist/type-theory/refinement-types/types.d.ts.map +1 -1
  421. package/dist/type-theory/refinement-types/types.js +35 -0
  422. package/dist/type-theory/refinement-types/types.js.map +1 -1
  423. package/dist/type-theory/system-f/types.d.ts +30 -0
  424. package/dist/type-theory/system-f/types.d.ts.map +1 -1
  425. package/dist/type-theory/system-f/types.js +24 -3
  426. package/dist/type-theory/system-f/types.js.map +1 -1
  427. package/dist/types/index.d.ts +42 -0
  428. package/dist/types/index.d.ts.map +1 -1
  429. package/dist/types/index.js.map +1 -1
  430. package/package.json +1 -1
@@ -0,0 +1,903 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // LJ Sequent Calculus — Calculo de secuentes intuicionista
4
+ // ============================================================
5
+ //
6
+ // LJ de Gentzen (1934) para logica intuicionista proposicional.
7
+ // A diferencia de LK clasico, LJ admite a lo sumo UNA formula
8
+ // en el succedente: secuentes de la forma Γ ⊢ φ (con succedente
9
+ // no vacio) o Γ ⊢ (succedente vacio). Esta restriccion es lo
10
+ // que hace que LJ NO derive ¬¬P → P ni P ∨ ¬P (LEM/DNE
11
+ // clasicas).
12
+ //
13
+ // Reglas (proposicionales):
14
+ // axiom : A, Γ ⊢ A
15
+ // cut : Γ ⊢ A A, Σ ⊢ C ⟹ Γ, Σ ⊢ C
16
+ // weakL : Γ ⊢ C ⟹ A, Γ ⊢ C
17
+ // contrL : A, A, Γ ⊢ C ⟹ A, Γ ⊢ C
18
+ // exL : permuta a la izquierda
19
+ // notL : Γ ⊢ A ⟹ ¬A, Γ ⊢ C
20
+ // notR : A, Γ ⊢ ⟹ Γ ⊢ ¬A (succedente vacio)
21
+ // andL : A, B, Γ ⊢ C ⟹ A∧B, Γ ⊢ C
22
+ // andR : Γ ⊢ A y Γ ⊢ B ⟹ Γ ⊢ A∧B
23
+ // orL : A, Γ ⊢ C y B, Γ ⊢ C ⟹ A∨B, Γ ⊢ C
24
+ // orR-l : Γ ⊢ A ⟹ Γ ⊢ A∨B
25
+ // orR-r : Γ ⊢ B ⟹ Γ ⊢ A∨B
26
+ // impL : Γ ⊢ A y B, Γ ⊢ C ⟹ A→B, Γ ⊢ C
27
+ // impR : A, Γ ⊢ B ⟹ Γ ⊢ A→B
28
+ // bottomL : ⊥, Γ ⊢ C (ex falso quodlibet)
29
+ //
30
+ // Glivenko (1929): Γ ⊢_LK φ sii Γ ⊢_LJ ¬¬φ. La funcion
31
+ // `glivenkoEmbed` traduce una formula clasica a su lectura
32
+ // intuicionista doble-negada.
33
+ //
34
+ // import { proveLJ, hasCut, eliminateCut, isValid, ljToLk, lkToLj, glivenkoEmbed }
35
+ // from 'src/profiles/sequent-lj';
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.proveLJ = proveLJ;
38
+ exports.proveLJFormula = proveLJFormula;
39
+ exports.isValid = isValid;
40
+ exports.hasCut = hasCut;
41
+ exports.eliminateCut = eliminateCut;
42
+ exports.ljToLk = ljToLk;
43
+ exports.lkToLj = lkToLj;
44
+ exports.glivenkoEmbed = glivenkoEmbed;
45
+ exports.ljKey = ljKey;
46
+ exports.ljEq = eqF;
47
+ exports.ljDepth = depth;
48
+ // ============================================================
49
+ // Utilidades sintacticas
50
+ // ============================================================
51
+ function ljKey(f) {
52
+ switch (f.kind) {
53
+ case 'atom':
54
+ return `a:${f.name}`;
55
+ case 'not':
56
+ return `n(${ljKey(f.arg)})`;
57
+ case 'and':
58
+ return `&(${ljKey(f.left)},${ljKey(f.right)})`;
59
+ case 'or':
60
+ return `|(${ljKey(f.left)},${ljKey(f.right)})`;
61
+ case 'implies':
62
+ return `>(${ljKey(f.left)},${ljKey(f.right)})`;
63
+ case 'bottom':
64
+ return '_';
65
+ }
66
+ }
67
+ function eqF(a, b) {
68
+ return ljKey(a) === ljKey(b);
69
+ }
70
+ function eqSide(a, b) {
71
+ if (a === null && b === null)
72
+ return true;
73
+ if (a === null || b === null)
74
+ return false;
75
+ return eqF(a, b);
76
+ }
77
+ function removeAt(xs, idx) {
78
+ const copy = xs.slice();
79
+ copy.splice(idx, 1);
80
+ return copy;
81
+ }
82
+ function removeFirstByKey(xs, key) {
83
+ const idx = xs.findIndex((f) => ljKey(f) === key);
84
+ if (idx === -1)
85
+ return xs.slice();
86
+ return removeAt(xs, idx);
87
+ }
88
+ function containsKey(xs, key) {
89
+ return xs.some((f) => ljKey(f) === key);
90
+ }
91
+ function multisetIncludes(haystack, needle) {
92
+ const counts = new Map();
93
+ for (const f of haystack)
94
+ counts.set(ljKey(f), (counts.get(ljKey(f)) ?? 0) + 1);
95
+ for (const f of needle) {
96
+ const k = ljKey(f);
97
+ const c = counts.get(k) ?? 0;
98
+ if (c <= 0)
99
+ return false;
100
+ counts.set(k, c - 1);
101
+ }
102
+ return true;
103
+ }
104
+ function sameMultiset(a, b) {
105
+ if (a.length !== b.length)
106
+ return false;
107
+ return multisetIncludes(a, b) && multisetIncludes(b, a);
108
+ }
109
+ function depth(f) {
110
+ switch (f.kind) {
111
+ case 'atom':
112
+ case 'bottom':
113
+ return 0;
114
+ case 'not':
115
+ return depth(f.arg) + 1;
116
+ case 'and':
117
+ case 'or':
118
+ case 'implies':
119
+ return Math.max(depth(f.left), depth(f.right)) + 1;
120
+ }
121
+ }
122
+ function exhausted(ctx) {
123
+ return ctx.used >= ctx.budget || ctx.depth >= ctx.maxDepth;
124
+ }
125
+ function seqKey(left, right) {
126
+ const lkeys = left.map(ljKey).sort().join(',');
127
+ const rkey = right ? ljKey(right) : '_';
128
+ return `${lkeys}|${rkey}`;
129
+ }
130
+ function isAtomic(f) {
131
+ return f.kind === 'atom' || f.kind === 'bottom';
132
+ }
133
+ function prove(left, right, ctx) {
134
+ ctx.used++;
135
+ if (exhausted(ctx))
136
+ return undefined;
137
+ const key = seqKey(left, right);
138
+ if (ctx.failed.has(key))
139
+ return undefined;
140
+ if (ctx.active.has(key))
141
+ return undefined;
142
+ ctx.active.add(key);
143
+ ctx.depth++;
144
+ const result = proveInner(left, right, ctx);
145
+ ctx.depth--;
146
+ ctx.active.delete(key);
147
+ if (!result)
148
+ ctx.failed.add(key);
149
+ return result;
150
+ }
151
+ function proveInner(left, right, ctx) {
152
+ // 1. Axioma: A ∈ Γ y right = A
153
+ if (right) {
154
+ const rkey = ljKey(right);
155
+ if (containsKey(left, rkey)) {
156
+ return {
157
+ goal: { left: left.slice(), right },
158
+ rule: 'axiom',
159
+ premises: [],
160
+ principalFormula: right,
161
+ };
162
+ }
163
+ }
164
+ // 2. bottomL: ⊥ ∈ Γ → cualquier conclusion (incluyendo right=null)
165
+ const bottomIdx = left.findIndex((f) => f.kind === 'bottom');
166
+ if (bottomIdx !== -1) {
167
+ const bf = left[bottomIdx];
168
+ if (bf) {
169
+ return {
170
+ goal: { left: left.slice(), right },
171
+ rule: 'bottomL',
172
+ premises: [],
173
+ principalFormula: bf,
174
+ };
175
+ }
176
+ }
177
+ // 3. Reglas invertibles a la izquierda (no ramificantes salvo orL/andL)
178
+ for (let i = 0; i < left.length; i++) {
179
+ const f = left[i];
180
+ if (!f)
181
+ continue;
182
+ if (f.kind === 'and') {
183
+ // A∧B, Γ ⊢ C ↦ A, B, Γ ⊢ C
184
+ const newL = [f.left, f.right, ...removeAt(left, i)];
185
+ const sub = prove(newL, right, ctx);
186
+ if (!sub)
187
+ return undefined;
188
+ return {
189
+ goal: { left: left.slice(), right },
190
+ rule: 'andL',
191
+ premises: [sub],
192
+ principalFormula: f,
193
+ };
194
+ }
195
+ }
196
+ // 4. Reglas invertibles a la derecha (no ramificantes)
197
+ if (right) {
198
+ if (right.kind === 'and') {
199
+ // Γ ⊢ A∧B ↦ Γ ⊢ A y Γ ⊢ B
200
+ const subA = prove(left, right.left, ctx);
201
+ if (!subA)
202
+ return undefined;
203
+ const subB = prove(left, right.right, ctx);
204
+ if (!subB)
205
+ return undefined;
206
+ return {
207
+ goal: { left: left.slice(), right },
208
+ rule: 'andR',
209
+ premises: [subA, subB],
210
+ principalFormula: right,
211
+ };
212
+ }
213
+ if (right.kind === 'implies') {
214
+ // Γ ⊢ A→B ↦ A, Γ ⊢ B
215
+ const newL = [right.left, ...left];
216
+ const sub = prove(newL, right.right, ctx);
217
+ if (!sub)
218
+ return undefined;
219
+ return {
220
+ goal: { left: left.slice(), right },
221
+ rule: 'impR',
222
+ premises: [sub],
223
+ principalFormula: right,
224
+ };
225
+ }
226
+ if (right.kind === 'not') {
227
+ // Γ ⊢ ¬A ↦ A, Γ ⊢ (succedente vacio)
228
+ const newL = [right.arg, ...left];
229
+ const sub = prove(newL, null, ctx);
230
+ if (!sub)
231
+ return undefined;
232
+ return {
233
+ goal: { left: left.slice(), right },
234
+ rule: 'notR',
235
+ premises: [sub],
236
+ principalFormula: right,
237
+ };
238
+ }
239
+ }
240
+ // 5. Reglas invertibles ramificantes a la izquierda (orL)
241
+ for (let i = 0; i < left.length; i++) {
242
+ const f = left[i];
243
+ if (!f)
244
+ continue;
245
+ if (f.kind === 'or') {
246
+ const rest = removeAt(left, i);
247
+ const subL = prove([f.left, ...rest], right, ctx);
248
+ if (!subL)
249
+ continue; // tratar como fallida la rama → no es orL; sigue intentando
250
+ const subR = prove([f.right, ...rest], right, ctx);
251
+ if (!subR)
252
+ continue;
253
+ return {
254
+ goal: { left: left.slice(), right },
255
+ rule: 'orL',
256
+ premises: [subL, subR],
257
+ principalFormula: f,
258
+ };
259
+ }
260
+ }
261
+ // 6. Regla no invertible a la izquierda: impL (Dyckhoff G3i, contraction-free)
262
+ // A→B, Γ ⊢ C via Γ' ⊢ A y B, Γ' ⊢ C (Γ' = Γ \ {A→B})
263
+ for (let i = 0; i < left.length; i++) {
264
+ const f = left[i];
265
+ if (!f)
266
+ continue;
267
+ if (f.kind === 'implies') {
268
+ const rest = removeAt(left, i);
269
+ // Sub-meta 1: Γ' ⊢ A (sin re-añadir A→B → contraction-free)
270
+ const subA = prove(rest, f.left, ctx);
271
+ if (!subA)
272
+ continue;
273
+ // Sub-meta 2: B, Γ' ⊢ C
274
+ const subB = prove([f.right, ...rest], right, ctx);
275
+ if (!subB)
276
+ continue;
277
+ return {
278
+ goal: { left: left.slice(), right },
279
+ rule: 'impL',
280
+ premises: [subA, subB],
281
+ principalFormula: f,
282
+ };
283
+ }
284
+ }
285
+ // 7. Regla no invertible a la izquierda: notL
286
+ // ¬A, Γ ⊢ C via Γ' ⊢ A
287
+ // Por defecto contraction-free (Γ' = Γ \ {¬A}). Pero cuando el
288
+ // succedente esta vacio (busqueda de contradiccion para Glivenko)
289
+ // o cuando esa rama no cierra, intentamos tambien con contraccion
290
+ // (Γ' = Γ, manteniendo ¬A para usos multiples).
291
+ for (let i = 0; i < left.length; i++) {
292
+ const f = left[i];
293
+ if (!f)
294
+ continue;
295
+ if (f.kind === 'not') {
296
+ const rest = removeAt(left, i);
297
+ const subA = prove(rest, f.arg, ctx);
298
+ if (subA) {
299
+ return {
300
+ goal: { left: left.slice(), right },
301
+ rule: 'notL',
302
+ premises: [subA],
303
+ principalFormula: f,
304
+ };
305
+ }
306
+ // Variante con contraccion (¬A se mantiene): util para derivar
307
+ // contradicciones donde ¬A se usa multiples veces.
308
+ const subAcontr = prove(left.slice(), f.arg, ctx);
309
+ if (subAcontr) {
310
+ return {
311
+ goal: { left: left.slice(), right },
312
+ rule: 'notL',
313
+ premises: [subAcontr],
314
+ principalFormula: f,
315
+ };
316
+ }
317
+ }
318
+ }
319
+ // 8. Reglas no invertibles a la derecha: orR-l y orR-r
320
+ if (right && right.kind === 'or') {
321
+ const subL = prove(left, right.left, ctx);
322
+ if (subL) {
323
+ return {
324
+ goal: { left: left.slice(), right },
325
+ rule: 'orR-l',
326
+ premises: [subL],
327
+ principalFormula: right,
328
+ };
329
+ }
330
+ const subR = prove(left, right.right, ctx);
331
+ if (subR) {
332
+ return {
333
+ goal: { left: left.slice(), right },
334
+ rule: 'orR-r',
335
+ premises: [subR],
336
+ principalFormula: right,
337
+ };
338
+ }
339
+ }
340
+ // 9. Sin reglas aplicables → no derivable
341
+ if (right === null) {
342
+ // succedente vacio sin ⊥ a la izquierda y sin formulas descomponibles
343
+ const anyComplex = left.some((f) => !isAtomic(f));
344
+ if (!anyComplex)
345
+ return undefined;
346
+ }
347
+ return undefined;
348
+ }
349
+ /**
350
+ * Demuestra el secuente `seq` en LJ intuicionista (sin cortes).
351
+ * Devuelve `null` si no encuentra derivacion dentro del budget.
352
+ */
353
+ function proveLJ(seq, options = {}) {
354
+ const ctx = {
355
+ budget: options.budget ?? 10_000,
356
+ used: 0,
357
+ depth: 0,
358
+ maxDepth: 200,
359
+ failed: new Set(),
360
+ active: new Set(),
361
+ };
362
+ const tree = prove(seq.left.slice(), seq.right, ctx);
363
+ return tree ?? null;
364
+ }
365
+ /** Atajo: ⊢ φ en LJ. */
366
+ /** Atajo: intenta derivar ⊢ φ en LJ (secuente con antecedente vacío). */
367
+ function proveLJFormula(formula, options = {}) {
368
+ return proveLJ({ left: [], right: formula }, options);
369
+ }
370
+ // ============================================================
371
+ // Validacion estructural de derivaciones LJ
372
+ // ============================================================
373
+ /** Verifica estructuralmente que un árbol de derivación LJ es correcto. */
374
+ function isValid(proof) {
375
+ const { goal, rule, premises } = proof;
376
+ const L = goal.left;
377
+ const R = goal.right;
378
+ for (const p of premises) {
379
+ if (!isValid(p))
380
+ return false;
381
+ }
382
+ switch (rule) {
383
+ case 'axiom': {
384
+ if (premises.length !== 0)
385
+ return false;
386
+ if (R === null)
387
+ return false;
388
+ return containsKey(L, ljKey(R));
389
+ }
390
+ case 'bottomL': {
391
+ if (premises.length !== 0)
392
+ return false;
393
+ return L.some((f) => f.kind === 'bottom');
394
+ }
395
+ case 'cut': {
396
+ if (premises.length !== 2)
397
+ return false;
398
+ const cf = proof.cutFormula;
399
+ if (!cf)
400
+ return false;
401
+ const [p1, p2] = premises;
402
+ if (!p1 || !p2)
403
+ return false;
404
+ // p1: Γ ⊢ A p2: A, Σ ⊢ C ⟹ Γ, Σ ⊢ C
405
+ if (!eqSide(p1.goal.right, cf))
406
+ return false;
407
+ if (!containsKey(p2.goal.left, ljKey(cf)))
408
+ return false;
409
+ const gamma = p1.goal.left;
410
+ const sigma = removeFirstByKey(p2.goal.left, ljKey(cf));
411
+ if (!eqSide(p2.goal.right, R))
412
+ return false;
413
+ return sameMultiset(L, [...gamma, ...sigma]);
414
+ }
415
+ case 'weakL': {
416
+ if (premises.length !== 1)
417
+ return false;
418
+ const [p] = premises;
419
+ if (!p)
420
+ return false;
421
+ if (!eqSide(p.goal.right, R))
422
+ return false;
423
+ for (let i = 0; i < L.length; i++) {
424
+ const x = L[i];
425
+ if (!x)
426
+ continue;
427
+ if (sameMultiset(removeAt(L, i), p.goal.left))
428
+ return true;
429
+ }
430
+ return false;
431
+ }
432
+ case 'contrL': {
433
+ if (premises.length !== 1)
434
+ return false;
435
+ const [p] = premises;
436
+ if (!p)
437
+ return false;
438
+ if (!eqSide(p.goal.right, R))
439
+ return false;
440
+ // p.goal.left ≡ L con alguna formula duplicada
441
+ for (let i = 0; i < L.length; i++) {
442
+ const x = L[i];
443
+ if (!x)
444
+ continue;
445
+ const candidate = [x, ...L];
446
+ if (sameMultiset(p.goal.left, candidate))
447
+ return true;
448
+ }
449
+ return false;
450
+ }
451
+ case 'exL': {
452
+ if (premises.length !== 1)
453
+ return false;
454
+ const [p] = premises;
455
+ if (!p)
456
+ return false;
457
+ return sameMultiset(p.goal.left, L) && eqSide(p.goal.right, R);
458
+ }
459
+ case 'notL': {
460
+ if (premises.length !== 1)
461
+ return false;
462
+ const [p] = premises;
463
+ if (!p)
464
+ return false;
465
+ const pf = proof.principalFormula;
466
+ if (!pf || pf.kind !== 'not')
467
+ return false;
468
+ // ¬A, Γ ⊢ C ; premisa: Γ ⊢ A
469
+ // Aceptamos forma contraction-free (Γ' = Γ \ {¬A}) o con contraccion (Γ' = Γ).
470
+ if (!containsKey(L, ljKey(pf)))
471
+ return false;
472
+ const gamma = removeFirstByKey(L, ljKey(pf));
473
+ const okCtx = sameMultiset(p.goal.left, gamma) || sameMultiset(p.goal.left, L);
474
+ return okCtx && eqSide(p.goal.right, pf.arg);
475
+ }
476
+ case 'notR': {
477
+ if (premises.length !== 1)
478
+ return false;
479
+ const [p] = premises;
480
+ if (!p)
481
+ return false;
482
+ const pf = proof.principalFormula;
483
+ if (!pf || pf.kind !== 'not')
484
+ return false;
485
+ if (!eqSide(R, pf))
486
+ return false;
487
+ // premisa: A, Γ ⊢ (vacio)
488
+ if (p.goal.right !== null)
489
+ return false;
490
+ if (!containsKey(p.goal.left, ljKey(pf.arg)))
491
+ return false;
492
+ const gamma = removeFirstByKey(p.goal.left, ljKey(pf.arg));
493
+ return sameMultiset(gamma, L);
494
+ }
495
+ case 'andL': {
496
+ if (premises.length !== 1)
497
+ return false;
498
+ const [p] = premises;
499
+ if (!p)
500
+ return false;
501
+ const pf = proof.principalFormula;
502
+ if (!pf || pf.kind !== 'and')
503
+ return false;
504
+ if (!containsKey(L, ljKey(pf)))
505
+ return false;
506
+ const gamma = removeFirstByKey(L, ljKey(pf));
507
+ const expected = [pf.left, pf.right, ...gamma];
508
+ return sameMultiset(p.goal.left, expected) && eqSide(p.goal.right, R);
509
+ }
510
+ case 'andR': {
511
+ if (premises.length !== 2)
512
+ return false;
513
+ const [p1, p2] = premises;
514
+ if (!p1 || !p2)
515
+ return false;
516
+ if (!R || R.kind !== 'and')
517
+ return false;
518
+ const pf = proof.principalFormula ?? R;
519
+ if (pf.kind !== 'and')
520
+ return false;
521
+ return (sameMultiset(p1.goal.left, L) &&
522
+ eqSide(p1.goal.right, pf.left) &&
523
+ sameMultiset(p2.goal.left, L) &&
524
+ eqSide(p2.goal.right, pf.right));
525
+ }
526
+ case 'orL': {
527
+ if (premises.length !== 2)
528
+ return false;
529
+ const [p1, p2] = premises;
530
+ if (!p1 || !p2)
531
+ return false;
532
+ const pf = proof.principalFormula;
533
+ if (!pf || pf.kind !== 'or')
534
+ return false;
535
+ if (!containsKey(L, ljKey(pf)))
536
+ return false;
537
+ const gamma = removeFirstByKey(L, ljKey(pf));
538
+ const okL = containsKey(p1.goal.left, ljKey(pf.left)) &&
539
+ sameMultiset(removeFirstByKey(p1.goal.left, ljKey(pf.left)), gamma) &&
540
+ eqSide(p1.goal.right, R);
541
+ const okR = containsKey(p2.goal.left, ljKey(pf.right)) &&
542
+ sameMultiset(removeFirstByKey(p2.goal.left, ljKey(pf.right)), gamma) &&
543
+ eqSide(p2.goal.right, R);
544
+ return okL && okR;
545
+ }
546
+ case 'orR-l': {
547
+ if (premises.length !== 1)
548
+ return false;
549
+ const [p] = premises;
550
+ if (!p)
551
+ return false;
552
+ if (!R || R.kind !== 'or')
553
+ return false;
554
+ return sameMultiset(p.goal.left, L) && eqSide(p.goal.right, R.left);
555
+ }
556
+ case 'orR-r': {
557
+ if (premises.length !== 1)
558
+ return false;
559
+ const [p] = premises;
560
+ if (!p)
561
+ return false;
562
+ if (!R || R.kind !== 'or')
563
+ return false;
564
+ return sameMultiset(p.goal.left, L) && eqSide(p.goal.right, R.right);
565
+ }
566
+ case 'impL': {
567
+ if (premises.length !== 2)
568
+ return false;
569
+ const [p1, p2] = premises;
570
+ if (!p1 || !p2)
571
+ return false;
572
+ const pf = proof.principalFormula;
573
+ if (!pf || pf.kind !== 'implies')
574
+ return false;
575
+ if (!containsKey(L, ljKey(pf)))
576
+ return false;
577
+ const gamma = removeFirstByKey(L, ljKey(pf));
578
+ // p1: Γ' ⊢ A (contraction-free: sin re-añadir A→B)
579
+ const okL = sameMultiset(p1.goal.left, gamma) && eqSide(p1.goal.right, pf.left);
580
+ // p2: B, Γ' ⊢ C
581
+ const okR = containsKey(p2.goal.left, ljKey(pf.right)) &&
582
+ sameMultiset(removeFirstByKey(p2.goal.left, ljKey(pf.right)), gamma) &&
583
+ eqSide(p2.goal.right, R);
584
+ return okL && okR;
585
+ }
586
+ case 'impR': {
587
+ if (premises.length !== 1)
588
+ return false;
589
+ const [p] = premises;
590
+ if (!p)
591
+ return false;
592
+ if (!R || R.kind !== 'implies')
593
+ return false;
594
+ // A, Γ ⊢ B
595
+ if (!containsKey(p.goal.left, ljKey(R.left)))
596
+ return false;
597
+ const gamma = removeFirstByKey(p.goal.left, ljKey(R.left));
598
+ return sameMultiset(gamma, L) && eqSide(p.goal.right, R.right);
599
+ }
600
+ }
601
+ }
602
+ /** Devuelve `true` si el árbol de derivación contiene alguna aplicación de la regla cut. */
603
+ function hasCut(proof) {
604
+ if (proof.rule === 'cut')
605
+ return true;
606
+ return proof.premises.some(hasCut);
607
+ }
608
+ // ============================================================
609
+ // Eliminacion de cortes (Hauptsatz para LJ)
610
+ // ============================================================
611
+ //
612
+ // Gentzen (1934) prueba que LJ admite eliminacion de cortes. La
613
+ // estrategia aqui combina reducciones principales cuando el cut
614
+ // es sobre un conectivo principal en ambas premisas, y usa el
615
+ // prover cut-free como oraculo para los casos restantes (cuts
616
+ // permutativos / commutativos): si el secuente final es
617
+ // derivable, lo es sin cortes por el Hauptsatz.
618
+ function eliminateCutAtRoot(proof) {
619
+ if (proof.rule !== 'cut')
620
+ return proof;
621
+ const [p1, p2] = proof.premises;
622
+ if (!p1 || !p2 || !proof.cutFormula)
623
+ return proof;
624
+ const A = proof.cutFormula;
625
+ const ak = ljKey(A);
626
+ // Caso axioma: A ⊢ A cut A, Σ ⊢ C ⟹ A, Σ ⊢ C (= p2)
627
+ if (p1.rule === 'axiom' && p1.principalFormula && ljKey(p1.principalFormula) === ak) {
628
+ // p1 prueba (Γ con A) ⊢ A; el cut con p2: A, Σ ⊢ C resulta en p2 con Γ adicional.
629
+ // Si p1 es exactamente "A ⊢ A", la conclusion es Σ ⊢ C = p2.
630
+ return p2;
631
+ }
632
+ if (p2.rule === 'axiom' && p2.principalFormula && ljKey(p2.principalFormula) === ak) {
633
+ return p1;
634
+ }
635
+ const principalOnLeft = p1.principalFormula && ljKey(p1.principalFormula) === ak;
636
+ const principalOnRight = p2.principalFormula && ljKey(p2.principalFormula) === ak;
637
+ if (principalOnLeft && principalOnRight) {
638
+ switch (A.kind) {
639
+ case 'and': {
640
+ // p1 termina en andR: Γ ⊢ A∧B con premisas Γ ⊢ A y Γ ⊢ B
641
+ // p2 termina en andL: A∧B, Σ ⊢ C con premisa A, B, Σ ⊢ C
642
+ // Resultado: cut sobre A y luego sobre B.
643
+ const subA = p1.premises[0];
644
+ const subB = p1.premises[1];
645
+ const subAB = p2.premises[0];
646
+ if (!subA || !subB || !subAB)
647
+ break;
648
+ const innerCut = {
649
+ goal: {
650
+ left: [...subB.goal.left, ...subAB.goal.left.filter((f) => ljKey(f) !== ljKey(A.left))],
651
+ right: subAB.goal.right,
652
+ },
653
+ rule: 'cut',
654
+ cutFormula: A.right,
655
+ premises: [subB, subAB],
656
+ };
657
+ const outerCut = {
658
+ goal: proof.goal,
659
+ rule: 'cut',
660
+ cutFormula: A.left,
661
+ premises: [subA, innerCut],
662
+ };
663
+ return eliminateCut(outerCut);
664
+ }
665
+ case 'or': {
666
+ // p1 termina en orR-l (Γ ⊢ A) o orR-r (Γ ⊢ B); p2 termina en orL.
667
+ const subOrR = p1.premises[0];
668
+ const subOrL_left = p2.premises[0]; // A, Σ ⊢ C
669
+ const subOrL_right = p2.premises[1]; // B, Σ ⊢ C
670
+ if (!subOrR || !subOrL_left || !subOrL_right)
671
+ break;
672
+ if (p1.rule === 'orR-l') {
673
+ // cut sobre A
674
+ const newCut = {
675
+ goal: proof.goal,
676
+ rule: 'cut',
677
+ cutFormula: A.left,
678
+ premises: [subOrR, subOrL_left],
679
+ };
680
+ return eliminateCut(newCut);
681
+ }
682
+ if (p1.rule === 'orR-r') {
683
+ const newCut = {
684
+ goal: proof.goal,
685
+ rule: 'cut',
686
+ cutFormula: A.right,
687
+ premises: [subOrR, subOrL_right],
688
+ };
689
+ return eliminateCut(newCut);
690
+ }
691
+ break;
692
+ }
693
+ case 'implies': {
694
+ // p1 termina en impR: A, Γ ⊢ B → premisa A, Γ ⊢ B (objetivo Γ ⊢ A→B)
695
+ // p2 termina en impL: A→B, Σ ⊢ C, premisas Σ ⊢ A y B, Σ ⊢ C
696
+ const subAB = p1.premises[0];
697
+ const subA = p2.premises[0];
698
+ const subC = p2.premises[1];
699
+ if (!subAB || !subA || !subC)
700
+ break;
701
+ // Cut sobre A: Σ ⊢ A y A, Γ ⊢ B → Σ, Γ ⊢ B
702
+ const cutOnA = {
703
+ goal: {
704
+ left: [...subA.goal.left, ...subAB.goal.left.filter((f) => ljKey(f) !== ljKey(A.left))],
705
+ right: subAB.goal.right,
706
+ },
707
+ rule: 'cut',
708
+ cutFormula: A.left,
709
+ premises: [subA, subAB],
710
+ };
711
+ // Cut sobre B: Σ, Γ ⊢ B y B, Σ ⊢ C → Σ, Γ, Σ ⊢ C
712
+ const cutOnB = {
713
+ goal: proof.goal,
714
+ rule: 'cut',
715
+ cutFormula: A.right,
716
+ premises: [cutOnA, subC],
717
+ };
718
+ return eliminateCut(cutOnB);
719
+ }
720
+ case 'not': {
721
+ // p1 termina en notR: Γ ⊢ ¬B, premisa B, Γ ⊢ (vacio)
722
+ // p2 termina en notL: ¬B, Σ ⊢ C, premisa Σ ⊢ B
723
+ // Cut sobre B: Σ ⊢ B y B, Γ ⊢ → Σ, Γ ⊢ ... pero el succedente
724
+ // del nuevo cut es null (de p1.premises[0]). Si necesitamos derivar
725
+ // C, debemos primero matar la rama con bottom; mas simple: usar oracle.
726
+ break;
727
+ }
728
+ case 'atom':
729
+ case 'bottom':
730
+ break;
731
+ }
732
+ }
733
+ // Casos restantes: usar el prover cut-free como oraculo.
734
+ const cutFree = proveLJ(proof.goal);
735
+ if (cutFree)
736
+ return cutFree;
737
+ return proof;
738
+ }
739
+ /**
740
+ * Elimina cortes de una derivación LJ (Hauptsatz de Gentzen).
741
+ * Usa reducciones principales para los casos estructurales y el prover
742
+ * cut-free como oráculo para los casos permutativos restantes.
743
+ */
744
+ function eliminateCut(proof) {
745
+ const premises = proof.premises.map(eliminateCut);
746
+ const updated = { ...proof, premises };
747
+ if (updated.rule !== 'cut')
748
+ return updated;
749
+ const reduced = eliminateCutAtRoot(updated);
750
+ let cur = reduced;
751
+ for (let i = 0; i < 32 && hasCut(cur); i++) {
752
+ cur = { ...cur, premises: cur.premises.map(eliminateCut) };
753
+ if (cur.rule === 'cut')
754
+ cur = eliminateCutAtRoot(cur);
755
+ }
756
+ if (hasCut(cur)) {
757
+ const cutFree = proveLJ(cur.goal);
758
+ if (cutFree && isValid(cutFree))
759
+ return cutFree;
760
+ }
761
+ return cur;
762
+ }
763
+ function formulaToLKLike(f) {
764
+ // LK no tiene `bottom` en este perfil; lo modelamos como atomo dedicado.
765
+ if (f.kind === 'bottom')
766
+ return { kind: 'atom', name: '⊥' };
767
+ if (f.kind === 'atom')
768
+ return { kind: 'atom', name: f.name };
769
+ if (f.kind === 'not')
770
+ return { kind: 'not', arg: formulaToLKLike(f.arg) };
771
+ if (f.kind === 'and')
772
+ return { kind: 'and', left: formulaToLKLike(f.left), right: formulaToLKLike(f.right) };
773
+ if (f.kind === 'or')
774
+ return { kind: 'or', left: formulaToLKLike(f.left), right: formulaToLKLike(f.right) };
775
+ return { kind: 'implies', left: formulaToLKLike(f.left), right: formulaToLKLike(f.right) };
776
+ }
777
+ function mapRuleLJtoLK(r) {
778
+ switch (r) {
779
+ case 'orR-l':
780
+ case 'orR-r':
781
+ return 'orR';
782
+ default:
783
+ return r;
784
+ }
785
+ }
786
+ /**
787
+ * Toda derivacion LJ es tambien una derivacion LK (con succedente
788
+ * a lo sumo unitario). La conversion es estructural: copia el arbol,
789
+ * usa right = [φ] o [] segun el secuente intuicionista, y mapea
790
+ * orR-l/orR-r → orR.
791
+ */
792
+ function ljToLk(proof) {
793
+ const convert = (p) => ({
794
+ goal: {
795
+ left: p.goal.left.map(formulaToLKLike),
796
+ right: p.goal.right ? [formulaToLKLike(p.goal.right)] : [],
797
+ },
798
+ rule: mapRuleLJtoLK(p.rule),
799
+ premises: p.premises.map(convert),
800
+ ...(p.cutFormula ? { cutFormula: formulaToLKLike(p.cutFormula) } : {}),
801
+ ...(p.principalFormula ? { principalFormula: formulaToLKLike(p.principalFormula) } : {}),
802
+ });
803
+ return convert(proof);
804
+ }
805
+ /**
806
+ * Conversion LK → LJ. Falla cuando la derivacion LK usa
807
+ * multisuccedente esencial (ej. LEM, doble negacion clasica).
808
+ * Estrategia: validar que cada secuente del arbol LK tenga
809
+ * succedente |Δ| ≤ 1; si no, rechazar con motivo.
810
+ */
811
+ function lkToLj(lkProof) {
812
+ if (lkProof === null || typeof lkProof !== 'object') {
813
+ return { rejected: 'entrada no es un LKProof' };
814
+ }
815
+ const lk = lkProof;
816
+ if (!lk.goal || !Array.isArray(lk.goal.left) || !Array.isArray(lk.goal.right)) {
817
+ return { rejected: 'estructura LKProof invalida' };
818
+ }
819
+ return convertLKtoLJ(lk);
820
+ }
821
+ function convertLKtoLJ(lk) {
822
+ if (lk.goal.right.length > 1) {
823
+ return {
824
+ rejected: `secuente LK con multisuccedente |Δ|=${lk.goal.right.length}; no traducible a LJ`,
825
+ };
826
+ }
827
+ const premises = [];
828
+ for (const sub of lk.premises) {
829
+ const r = convertLKtoLJ(sub);
830
+ if ('rejected' in r)
831
+ return r;
832
+ premises.push(r);
833
+ }
834
+ // Mapear reglas LK → LJ. Reglas exclusivas de LK (weakR, contrR, exR)
835
+ // no tienen analogo intuicionista; las rechazamos.
836
+ const ruleMap = {
837
+ axiom: 'axiom',
838
+ cut: 'cut',
839
+ weakL: 'weakL',
840
+ weakR: null,
841
+ contrL: 'contrL',
842
+ contrR: null,
843
+ exL: 'exL',
844
+ exR: null,
845
+ notL: 'notL',
846
+ notR: 'notR',
847
+ andL: 'andL',
848
+ andR: 'andR',
849
+ orL: 'orL',
850
+ orR: 'orR-l', // ambiguo: elegimos la rama izquierda por defecto
851
+ impL: 'impL',
852
+ impR: 'impR',
853
+ bottomL: 'bottomL',
854
+ };
855
+ const ljRule = ruleMap[lk.rule];
856
+ if (ljRule === undefined) {
857
+ return { rejected: `regla LK desconocida: ${lk.rule}` };
858
+ }
859
+ if (ljRule === null) {
860
+ return { rejected: `regla ${lk.rule} es exclusiva de LK (multisuccedente)` };
861
+ }
862
+ return {
863
+ goal: {
864
+ left: lk.goal.left.map(lkFormulaToLJ),
865
+ right: lk.goal.right.length === 0 ? null : lkFormulaToLJ(lk.goal.right[0]),
866
+ },
867
+ rule: ljRule,
868
+ premises,
869
+ ...(lk.cutFormula ? { cutFormula: lkFormulaToLJ(lk.cutFormula) } : {}),
870
+ ...(lk.principalFormula ? { principalFormula: lkFormulaToLJ(lk.principalFormula) } : {}),
871
+ };
872
+ }
873
+ function lkFormulaToLJ(f) {
874
+ if (!f || typeof f !== 'object') {
875
+ return { kind: 'atom', name: '?' };
876
+ }
877
+ const o = f;
878
+ switch (o.kind) {
879
+ case 'atom':
880
+ return { kind: 'atom', name: typeof o.name === 'string' ? o.name : '?' };
881
+ case 'not':
882
+ return { kind: 'not', arg: lkFormulaToLJ(o.arg) };
883
+ case 'and':
884
+ return { kind: 'and', left: lkFormulaToLJ(o.left), right: lkFormulaToLJ(o.right) };
885
+ case 'or':
886
+ return { kind: 'or', left: lkFormulaToLJ(o.left), right: lkFormulaToLJ(o.right) };
887
+ case 'implies':
888
+ return { kind: 'implies', left: lkFormulaToLJ(o.left), right: lkFormulaToLJ(o.right) };
889
+ default:
890
+ return { kind: 'atom', name: '?' };
891
+ }
892
+ }
893
+ // ============================================================
894
+ // Glivenko: clasico ⊢ φ sii intuicionista ⊢ ¬¬φ
895
+ // ============================================================
896
+ //
897
+ // Glivenko (1929) demostro que el fragmento proposicional clasico
898
+ // se traduce al intuicionista mediante doble negacion (Glivenko
899
+ // embedding). La traduccion mas simple es φ ↦ ¬¬φ.
900
+ function glivenkoEmbed(formula) {
901
+ return { kind: 'not', arg: { kind: 'not', arg: formula } };
902
+ }
903
+ //# sourceMappingURL=index.js.map