@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,779 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // Separation Logic — Reynolds-style heap reasoning
4
+ // ============================================================
5
+ //
6
+ // Lógica de separación clásica (Reynolds / O'Hearn / Yang) para razonar
7
+ // sobre estructuras dinámicas (listas, árboles) y mutación con aliasing
8
+ // controlado.
9
+ //
10
+ // Núcleo:
11
+ // - Heap finito (Map<number, SLValue>) con dominio explícito.
12
+ // - Fórmulas: `emp`, `x ↦ v`, `P * Q`, `P -* Q`, `∃x. P`, conectivos
13
+ // clásicos sobre el fragmento puro.
14
+ // - Semántica `satisfies(P, h, valuation)` siguiendo el split de heap.
15
+ // - Triplas de Hoare con axiomas locales (alloc, free, load, store).
16
+ // - Predicados inductivos: `ls(x, y)` (list-segment) y `tree(x)`.
17
+ //
18
+ // El módulo es puro TypeScript, sin dependencias del resto del repo.
19
+ // Las estructuras Heap son inmutables hacia afuera: `write`, `delete` y
20
+ // `combine` devuelven instancias nuevas.
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Cmd = exports.forallF = exports.existsF = exports.notF = exports.impliesF = exports.orF = exports.andF = exports.pure = exports.magicWand = exports.star = exports.pointsTo = exports.emp = void 0;
23
+ exports.intVal = intVal;
24
+ exports.addrVal = addrVal;
25
+ exports.nullVal = nullVal;
26
+ exports.valueEquals = valueEquals;
27
+ exports.valueKey = valueKey;
28
+ exports.asLoc = asLoc;
29
+ exports.newHeap = newHeap;
30
+ exports.fromMap = fromMap;
31
+ exports.disjoint = disjoint;
32
+ exports.combine = combine;
33
+ exports.heapEquals = heapEquals;
34
+ exports.splits = splits;
35
+ exports.formulaToString = formulaToString;
36
+ exports.valueToString = valueToString;
37
+ exports.bind = bind;
38
+ exports.satisfies = satisfies;
39
+ exports.executeCommand = executeCommand;
40
+ exports.checkTriple = checkTriple;
41
+ exports.isListSegment = isListSegment;
42
+ exports.listSegment = listSegment;
43
+ exports.satisfiesShape = satisfiesShape;
44
+ exports.tree = tree;
45
+ exports.isTree = isTree;
46
+ exports.frame = frame;
47
+ /** Constructor de valor entero del heap de separación. */
48
+ function intVal(value) {
49
+ return { kind: 'int', value };
50
+ }
51
+ /** Constructor de valor dirección del heap de separación. */
52
+ function addrVal(loc) {
53
+ return { kind: 'addr', loc };
54
+ }
55
+ /** Singleton null del heap de separación (puntero nulo). */
56
+ function nullVal() {
57
+ return { kind: 'null' };
58
+ }
59
+ /** Igualdad estructural entre dos valores del heap de separación. */
60
+ function valueEquals(a, b) {
61
+ if (a.kind !== b.kind)
62
+ return false;
63
+ if (a.kind === 'int' && b.kind === 'int')
64
+ return a.value === b.value;
65
+ if (a.kind === 'addr' && b.kind === 'addr')
66
+ return a.loc === b.loc;
67
+ return a.kind === 'null' && b.kind === 'null';
68
+ }
69
+ /** Convierte un SLValue a una clave string estable para Maps. */
70
+ function valueKey(v) {
71
+ if (v.kind === 'int')
72
+ return `i:${v.value}`;
73
+ if (v.kind === 'addr')
74
+ return `a:${v.loc}`;
75
+ return 'null';
76
+ }
77
+ /** Devuelve la dirección de un SLValue si es addr, o null en cualquier
78
+ * otro caso. La null-location no se direcciona. */
79
+ function asLoc(v) {
80
+ return v.kind === 'addr' ? v.loc : null;
81
+ }
82
+ class HeapImpl {
83
+ map;
84
+ constructor(map) {
85
+ this.map = map;
86
+ }
87
+ domain() {
88
+ return [...this.map.keys()].sort((a, b) => a - b);
89
+ }
90
+ has(loc) {
91
+ return this.map.has(loc);
92
+ }
93
+ read(loc) {
94
+ return this.map.get(loc);
95
+ }
96
+ write(loc, val) {
97
+ const next = new Map(this.map);
98
+ next.set(loc, val);
99
+ return new HeapImpl(next);
100
+ }
101
+ delete(loc) {
102
+ if (!this.map.has(loc))
103
+ return this;
104
+ const next = new Map(this.map);
105
+ next.delete(loc);
106
+ return new HeapImpl(next);
107
+ }
108
+ size() {
109
+ return this.map.size;
110
+ }
111
+ clone() {
112
+ return new HeapImpl(new Map(this.map));
113
+ }
114
+ }
115
+ /** Crea un heap vacío. */
116
+ function newHeap() {
117
+ return new HeapImpl(new Map());
118
+ }
119
+ /** Crea un heap a partir de una lista de pares `[dirección, valor]`. */
120
+ function fromMap(entries) {
121
+ return new HeapImpl(new Map(entries));
122
+ }
123
+ /** Dos heaps son disjuntos sii sus dominios no se intersectan. */
124
+ function disjoint(h1, h2) {
125
+ if (h1.size() > h2.size())
126
+ return disjoint(h2, h1);
127
+ for (const loc of h1.domain()) {
128
+ if (h2.has(loc))
129
+ return false;
130
+ }
131
+ return true;
132
+ }
133
+ /** Unión disjunta `h1 ⊎ h2`. Devuelve null si los heaps comparten alguna
134
+ * dirección — la unión disjunta sólo está definida cuando son disjoint. */
135
+ function combine(h1, h2) {
136
+ if (!disjoint(h1, h2))
137
+ return null;
138
+ const merged = new Map(h1.map);
139
+ for (const [loc, v] of h2.map)
140
+ merged.set(loc, v);
141
+ return new HeapImpl(merged);
142
+ }
143
+ /** Igualdad estructural de heaps. */
144
+ function heapEquals(h1, h2) {
145
+ if (h1.size() !== h2.size())
146
+ return false;
147
+ for (const [loc, v] of h1.map) {
148
+ const other = h2.read(loc);
149
+ if (other === undefined)
150
+ return false;
151
+ if (!valueEquals(v, other))
152
+ return false;
153
+ }
154
+ return true;
155
+ }
156
+ // ── Sub-heaps (para semántica de `*` y `-*`) ────────────────
157
+ /** Enumera todas las particiones del heap en `(h1, h2)` con `h1 ⊎ h2 = h`. */
158
+ function splits(h) {
159
+ const dom = h.domain();
160
+ const n = dom.length;
161
+ const results = [];
162
+ // 2^n splits — sólo se invoca sobre heaps pequeños (testing/semántica).
163
+ const limit = 1 << n;
164
+ for (let mask = 0; mask < limit; mask++) {
165
+ const m1 = new Map();
166
+ const m2 = new Map();
167
+ for (let i = 0; i < n; i++) {
168
+ const loc = dom[i];
169
+ const v = h.read(loc);
170
+ if ((mask >> i) & 1)
171
+ m1.set(loc, v);
172
+ else
173
+ m2.set(loc, v);
174
+ }
175
+ results.push({ h1: new HeapImpl(m1), h2: new HeapImpl(m2) });
176
+ }
177
+ return results;
178
+ }
179
+ /** Heap vacío: `emp`. La fórmula que vale sobre el heap vacío. */
180
+ const emp = () => ({ kind: 'emp' });
181
+ exports.emp = emp;
182
+ /** `loc ↦ val` — `loc` apunta a `val` (heap de un solo celda). */
183
+ const pointsTo = (loc, val) => ({
184
+ kind: 'pointsTo',
185
+ loc,
186
+ val,
187
+ });
188
+ exports.pointsTo = pointsTo;
189
+ /** Conjunción separante `P * Q`: `P` y `Q` valen sobre sub-heaps disjuntos cuya unión es el heap total. */
190
+ const star = (left, right) => ({
191
+ kind: 'star',
192
+ left,
193
+ right,
194
+ });
195
+ exports.star = star;
196
+ /** Magic wand `P -* Q`: para cualquier heap disjunto que satisfaga `P`, la unión satisface `Q`. */
197
+ const magicWand = (left, right) => ({
198
+ kind: 'magicWand',
199
+ left,
200
+ right,
201
+ });
202
+ exports.magicWand = magicWand;
203
+ /** Fórmula pura `[expr]`: condición sin acceso al heap, evaluada por `predicate`. */
204
+ const pure = (expression, predicate) => ({
205
+ kind: 'pure',
206
+ expression,
207
+ predicate,
208
+ });
209
+ exports.pure = pure;
210
+ /** Conjunción clásica de dos fórmulas SL (no separante). */
211
+ const andF = (left, right) => ({
212
+ kind: 'and',
213
+ left,
214
+ right,
215
+ });
216
+ exports.andF = andF;
217
+ /** Disyunción de dos fórmulas SL. */
218
+ const orF = (left, right) => ({
219
+ kind: 'or',
220
+ left,
221
+ right,
222
+ });
223
+ exports.orF = orF;
224
+ /** Implicación clásica entre dos fórmulas SL. */
225
+ const impliesF = (left, right) => ({
226
+ kind: 'implies',
227
+ left,
228
+ right,
229
+ });
230
+ exports.impliesF = impliesF;
231
+ /** Negación de una fórmula SL. */
232
+ const notF = (body) => ({ kind: 'not', body });
233
+ exports.notF = notF;
234
+ /** Cuantificador existencial sobre una variable de valuación. */
235
+ const existsF = (bind, body) => ({
236
+ kind: 'exists',
237
+ bind,
238
+ body,
239
+ });
240
+ exports.existsF = existsF;
241
+ /** Cuantificador universal sobre una variable de valuación. */
242
+ const forallF = (bind, body) => ({
243
+ kind: 'forall',
244
+ bind,
245
+ body,
246
+ });
247
+ exports.forallF = forallF;
248
+ // ── Pretty printer ───────────────────────────────────────────
249
+ /** Serializa una fórmula SL a su representación textual estándar. */
250
+ function formulaToString(f) {
251
+ switch (f.kind) {
252
+ case 'emp':
253
+ return 'emp';
254
+ case 'pointsTo':
255
+ return `${valueToString(f.loc)} ↦ ${valueToString(f.val)}`;
256
+ case 'star':
257
+ return `(${formulaToString(f.left)} * ${formulaToString(f.right)})`;
258
+ case 'magicWand':
259
+ return `(${formulaToString(f.left)} -* ${formulaToString(f.right)})`;
260
+ case 'pure':
261
+ return `[${f.expression}]`;
262
+ case 'and':
263
+ return `(${formulaToString(f.left)} ∧ ${formulaToString(f.right)})`;
264
+ case 'or':
265
+ return `(${formulaToString(f.left)} ∨ ${formulaToString(f.right)})`;
266
+ case 'implies':
267
+ return `(${formulaToString(f.left)} → ${formulaToString(f.right)})`;
268
+ case 'not':
269
+ return `¬${formulaToString(f.body)}`;
270
+ case 'exists':
271
+ return `∃${f.bind}. ${formulaToString(f.body)}`;
272
+ case 'forall':
273
+ return `∀${f.bind}. ${formulaToString(f.body)}`;
274
+ }
275
+ }
276
+ /** Serializa un valor SL (int, addr, null) a texto legible. */
277
+ function valueToString(v) {
278
+ if (v.kind === 'int')
279
+ return `${v.value}`;
280
+ if (v.kind === 'addr')
281
+ return `&${v.loc}`;
282
+ return 'null';
283
+ }
284
+ /** Devuelve una copia del valuation con `name → v`. */
285
+ function bind(val, name, v) {
286
+ return { ...val, [name]: v };
287
+ }
288
+ // ── Semántica ────────────────────────────────────────────────
289
+ /** `satisfies(P, h, ν)` — el modelo `(h, ν)` satisface la fórmula P. */
290
+ function satisfies(formula, heap, val) {
291
+ switch (formula.kind) {
292
+ case 'emp':
293
+ return heap.size() === 0;
294
+ case 'pointsTo': {
295
+ const loc = asLoc(formula.loc);
296
+ if (loc === null)
297
+ return false;
298
+ if (heap.size() !== 1)
299
+ return false;
300
+ const stored = heap.read(loc);
301
+ if (stored === undefined)
302
+ return false;
303
+ return valueEquals(stored, formula.val);
304
+ }
305
+ case 'star': {
306
+ for (const { h1, h2 } of splits(heap)) {
307
+ if (satisfies(formula.left, h1, val) && satisfies(formula.right, h2, val)) {
308
+ return true;
309
+ }
310
+ }
311
+ return false;
312
+ }
313
+ case 'magicWand': {
314
+ // P -* Q : ∀ h'. (h ⊥ h' ∧ h' ⊨ P) → (h ⊎ h') ⊨ Q
315
+ // Acotado a sub-heaps relevantes vía un universo de direcciones.
316
+ const universe = collectAddresses(formula.left, heap, val);
317
+ for (const candidate of enumerateHeapsOver(universe, heap, formula.left, val)) {
318
+ if (!disjoint(heap, candidate))
319
+ continue;
320
+ if (!satisfies(formula.left, candidate, val))
321
+ continue;
322
+ const merged = combine(heap, candidate);
323
+ if (merged === null)
324
+ continue;
325
+ if (!satisfies(formula.right, merged, val))
326
+ return false;
327
+ }
328
+ return true;
329
+ }
330
+ case 'pure':
331
+ return formula.predicate(val);
332
+ case 'and':
333
+ return satisfies(formula.left, heap, val) && satisfies(formula.right, heap, val);
334
+ case 'or':
335
+ return satisfies(formula.left, heap, val) || satisfies(formula.right, heap, val);
336
+ case 'implies':
337
+ return !satisfies(formula.left, heap, val) || satisfies(formula.right, heap, val);
338
+ case 'not':
339
+ return !satisfies(formula.body, heap, val);
340
+ case 'exists': {
341
+ // Acotado al universo de valores presentes en el heap y la valuación
342
+ // más null. Para semántica computable necesitamos un dominio finito.
343
+ for (const v of finiteValueDomain(heap, val)) {
344
+ if (satisfies(formula.body, heap, bind(val, formula.bind, v)))
345
+ return true;
346
+ }
347
+ return false;
348
+ }
349
+ case 'forall': {
350
+ for (const v of finiteValueDomain(heap, val)) {
351
+ if (!satisfies(formula.body, heap, bind(val, formula.bind, v)))
352
+ return false;
353
+ }
354
+ return true;
355
+ }
356
+ }
357
+ }
358
+ /** Dominio finito de valores observables: direcciones del heap + valores
359
+ * en la valuación + null. Permite cuantificar de forma computable. */
360
+ function finiteValueDomain(heap, val) {
361
+ const seen = new Map();
362
+ const push = (v) => {
363
+ seen.set(valueKey(v), v);
364
+ };
365
+ push(nullVal());
366
+ for (const loc of heap.domain()) {
367
+ push(addrVal(loc));
368
+ const stored = heap.read(loc);
369
+ if (stored !== undefined)
370
+ push(stored);
371
+ }
372
+ for (const name of Object.keys(val)) {
373
+ const bound = val[name];
374
+ if (bound !== undefined)
375
+ push(bound);
376
+ }
377
+ return [...seen.values()];
378
+ }
379
+ /** Direcciones candidatas para extender el heap al evaluar `-*`. */
380
+ function collectAddresses(_left, heap, val) {
381
+ const seen = new Set();
382
+ for (const loc of heap.domain())
383
+ seen.add(loc);
384
+ for (const name of Object.keys(val)) {
385
+ const bound = val[name];
386
+ if (bound && bound.kind === 'addr')
387
+ seen.add(bound.loc);
388
+ }
389
+ // Sembramos algunas direcciones frescas para que `-*` pueda probar con
390
+ // un heap extensión no trivial sin explotar combinatoriamente.
391
+ const maxLoc = Math.max(0, ...seen);
392
+ for (let i = 1; i <= 2; i++)
393
+ seen.add(maxLoc + i);
394
+ return [...seen].sort((a, b) => a - b);
395
+ }
396
+ /** Enumera heaps pequeños sobre `universe` cuyas direcciones no estén ya
397
+ * en `existing`. Usa los valores observables como contenido. Cota dura
398
+ * para no estallar: máximo 3 ubicaciones nuevas. */
399
+ function* enumerateHeapsOver(universe, existing, leftFormula, val) {
400
+ const candidates = universe.filter((loc) => !existing.has(loc));
401
+ const maxExtra = Math.min(3, candidates.length);
402
+ const values = finiteValueDomain(existing, val);
403
+ // Recortar dominio: si la fórmula izquierda es `emp`, sólo importa el heap vacío.
404
+ if (leftFormula.kind === 'emp') {
405
+ yield newHeap();
406
+ return;
407
+ }
408
+ // 0 .. maxExtra direcciones, cada una con cualquier valor.
409
+ for (let size = 0; size <= maxExtra; size++) {
410
+ yield* enumerateSubset(candidates, 0, size, [], values);
411
+ }
412
+ }
413
+ function* enumerateSubset(pool, start, remaining, acc, values) {
414
+ if (remaining === 0) {
415
+ yield fromMap(acc);
416
+ return;
417
+ }
418
+ for (let i = start; i <= pool.length - remaining; i++) {
419
+ const loc = pool[i];
420
+ for (const v of values) {
421
+ acc.push([loc, v]);
422
+ yield* enumerateSubset(pool, i + 1, remaining - 1, acc, values);
423
+ acc.pop();
424
+ }
425
+ }
426
+ }
427
+ /** Ejecuta un único comando de forma small-step. */
428
+ function executeCommand(cmd, heap, val) {
429
+ switch (cmd.kind) {
430
+ case 'skip':
431
+ return { ok: true, heap, val, fault: false };
432
+ case 'assign': {
433
+ if (cmd.variable === undefined || cmd.value === undefined) {
434
+ return { ok: false, heap, val, fault: false, reason: 'assign sin variable/valor' };
435
+ }
436
+ return { ok: true, heap, val: bind(val, cmd.variable, cmd.value), fault: false };
437
+ }
438
+ case 'alloc': {
439
+ if (cmd.variable === undefined) {
440
+ return { ok: false, heap, val, fault: false, reason: 'alloc sin variable destino' };
441
+ }
442
+ const initial = cmd.value ?? intVal(0);
443
+ const freshLoc = freshAddress(heap);
444
+ const heap1 = heap.write(freshLoc, initial);
445
+ const val1 = bind(val, cmd.variable, addrVal(freshLoc));
446
+ return { ok: true, heap: heap1, val: val1, fault: false };
447
+ }
448
+ case 'free': {
449
+ const target = cmd.location === undefined ? undefined : val[cmd.location];
450
+ if (target === undefined) {
451
+ return { ok: false, heap, val, fault: false, reason: 'free sobre variable no ligada' };
452
+ }
453
+ const loc = asLoc(target);
454
+ if (loc === null || !heap.has(loc)) {
455
+ return { ok: false, heap, val, fault: true, reason: 'free: memory fault' };
456
+ }
457
+ return { ok: true, heap: heap.delete(loc), val, fault: false };
458
+ }
459
+ case 'load': {
460
+ if (cmd.variable === undefined || cmd.location === undefined) {
461
+ return { ok: false, heap, val, fault: false, reason: 'load sin variable/location' };
462
+ }
463
+ const target = val[cmd.location];
464
+ const loc = target === undefined ? null : asLoc(target);
465
+ if (loc === null || !heap.has(loc)) {
466
+ return { ok: false, heap, val, fault: true, reason: 'load: memory fault' };
467
+ }
468
+ const stored = heap.read(loc);
469
+ return { ok: true, heap, val: bind(val, cmd.variable, stored), fault: false };
470
+ }
471
+ case 'store': {
472
+ if (cmd.location === undefined || cmd.value === undefined) {
473
+ return { ok: false, heap, val, fault: false, reason: 'store sin location/valor' };
474
+ }
475
+ const target = val[cmd.location];
476
+ const loc = target === undefined ? null : asLoc(target);
477
+ if (loc === null || !heap.has(loc)) {
478
+ return { ok: false, heap, val, fault: true, reason: 'store: memory fault' };
479
+ }
480
+ return { ok: true, heap: heap.write(loc, cmd.value), val, fault: false };
481
+ }
482
+ }
483
+ }
484
+ /** Devuelve la primera dirección libre del heap (estrategia bumper). */
485
+ function freshAddress(heap) {
486
+ let loc = 1;
487
+ while (heap.has(loc))
488
+ loc++;
489
+ return loc;
490
+ }
491
+ /** Verifica una tripla `{P} c {Q}` por muestreo finito: enumera modelos
492
+ * (heap, val) que satisfagan P, los ejecuta y comprueba Q sobre el
493
+ * estado final. Devuelve `valid: false` con contraejemplo al primer
494
+ * fallo. No es completo — es una verificación de testing/random. */
495
+ function checkTriple(triple, options = {}) {
496
+ const samples = options.samples ?? 32;
497
+ const seed = options.seed ?? 0xc0ffee;
498
+ const rng = makeLcg(seed);
499
+ const pool = [];
500
+ if (options.candidates)
501
+ pool.push(...options.candidates);
502
+ for (let i = 0; i < samples; i++)
503
+ pool.push(randomModel(rng));
504
+ let checked = 0;
505
+ for (const { heap, val } of pool) {
506
+ if (!satisfies(triple.pre, heap, val))
507
+ continue;
508
+ checked++;
509
+ const result = executeCommand(triple.cmd, heap, val);
510
+ if (!result.ok) {
511
+ return {
512
+ valid: false,
513
+ counterexample: {
514
+ heap,
515
+ val,
516
+ reason: `comando inválido: ${result.reason ?? 'unknown'}`,
517
+ },
518
+ modelsChecked: checked,
519
+ };
520
+ }
521
+ if (result.fault) {
522
+ return {
523
+ valid: false,
524
+ counterexample: { heap, val, reason: 'memory fault al ejecutar' },
525
+ modelsChecked: checked,
526
+ };
527
+ }
528
+ if (!satisfies(triple.post, result.heap, result.val)) {
529
+ return {
530
+ valid: false,
531
+ counterexample: {
532
+ heap,
533
+ val,
534
+ reason: 'postcondición no satisfecha tras ejecución',
535
+ },
536
+ modelsChecked: checked,
537
+ };
538
+ }
539
+ }
540
+ return { valid: true, modelsChecked: checked };
541
+ }
542
+ function makeLcg(seed) {
543
+ let state = seed >>> 0;
544
+ return () => {
545
+ state = (state * 1664525 + 1013904223) >>> 0;
546
+ return state / 0x100000000;
547
+ };
548
+ }
549
+ function randomModel(rng) {
550
+ const size = Math.floor(rng() * 4); // 0..3 celdas
551
+ const entries = [];
552
+ const used = new Set();
553
+ for (let i = 0; i < size; i++) {
554
+ let loc = 1 + Math.floor(rng() * 5);
555
+ while (used.has(loc))
556
+ loc++;
557
+ used.add(loc);
558
+ entries.push([loc, randomValue(rng)]);
559
+ }
560
+ const heap = fromMap(entries);
561
+ const val = {};
562
+ // x apunta al primer slot si hay alguno
563
+ if (entries.length > 0) {
564
+ const first = entries[0];
565
+ if (first)
566
+ val.x = addrVal(first[0]);
567
+ }
568
+ else {
569
+ val.x = nullVal();
570
+ }
571
+ return { heap, val };
572
+ }
573
+ function randomValue(rng) {
574
+ const choice = Math.floor(rng() * 3);
575
+ if (choice === 0)
576
+ return intVal(Math.floor(rng() * 10));
577
+ if (choice === 1)
578
+ return nullVal();
579
+ return addrVal(1 + Math.floor(rng() * 5));
580
+ }
581
+ // ── Predicados inductivos ───────────────────────────────────
582
+ /** `ls(x, y)` — list-segment de x a y. Definido por:
583
+ * ls(x, y) ≡ (x = y ∧ emp) ∨ ∃z. (x ↦ z * ls(z, y))
584
+ *
585
+ * Para mantener semántica computable, se interpreta directamente sobre
586
+ * el heap: existe una cadena de celdas desde `start` a `end` cuyos
587
+ * contenidos son punteros, sin ciclos ni celdas extra. */
588
+ function isListSegment(start, end, heap) {
589
+ if (valueEquals(start, end))
590
+ return heap.size() === 0;
591
+ if (start.kind !== 'addr')
592
+ return false;
593
+ const visited = new Set();
594
+ const path = [];
595
+ let cur = start;
596
+ while (!valueEquals(cur, end)) {
597
+ if (cur.kind !== 'addr')
598
+ return false;
599
+ if (visited.has(cur.loc))
600
+ return false; // ciclo
601
+ if (!heap.has(cur.loc))
602
+ return false;
603
+ visited.add(cur.loc);
604
+ path.push(cur.loc);
605
+ const next = heap.read(cur.loc);
606
+ cur = next;
607
+ }
608
+ // El heap debe ser exactamente las celdas del path — nada más.
609
+ if (heap.size() !== path.length)
610
+ return false;
611
+ return true;
612
+ }
613
+ /** Predicado SL para list-segment `ls(start, end)`. Se evalúa como
614
+ * predicado puro sobre el heap (cumple `satisfies`). */
615
+ function listSegment(start, end) {
616
+ // Encapsulamos la semántica inductiva en un `pure` que internamente
617
+ // mira el heap mediante closure. Para ello expandimos a una fórmula
618
+ // compuesta con un truco: usamos una macro que, al evaluarse, hace la
619
+ // verificación directa. Construimos un nodo `pure` con expresión
620
+ // descriptiva pero la verdad real la calcula la función externa via
621
+ // `isListSegment` — exponemos por separado `satisfiesShape`.
622
+ // Para participar de la semántica `satisfies` declaramos un nodo
623
+ // estructural: ls(start, end).
624
+ return {
625
+ kind: 'pure',
626
+ expression: `ls(${valueToString(start)}, ${valueToString(end)})`,
627
+ predicate: () => {
628
+ // El predicado puro no conoce el heap. La forma correcta de usar
629
+ // `ls` es vía `satisfiesShape` o vía la combinación predicado +
630
+ // helper externo. Devolvemos true como placeholder para que
631
+ // `pure` no rechace por sí solo.
632
+ return true;
633
+ },
634
+ };
635
+ }
636
+ /** Evalúa una fórmula con soporte de predicados inductivos sobre forma de
637
+ * heap (ls, tree). Se usa cuando la fórmula contiene `listSegment` o
638
+ * `tree` — `satisfies` solo no basta porque su rama `pure` ignora el heap. */
639
+ function satisfiesShape(formula, heap, val) {
640
+ if (formula.kind === 'pure') {
641
+ const lsMatch = formula.expression.match(/^ls\((.+),\s*(.+)\)$/);
642
+ if (lsMatch) {
643
+ const start = parseValueLit(lsMatch[1], val);
644
+ const end = parseValueLit(lsMatch[2], val);
645
+ if (start === null || end === null)
646
+ return false;
647
+ return isListSegment(start, end, heap);
648
+ }
649
+ const treeMatch = formula.expression.match(/^tree\((.+)\)$/);
650
+ if (treeMatch) {
651
+ const root = parseValueLit(treeMatch[1], val);
652
+ if (root === null)
653
+ return false;
654
+ return isTree(root, heap);
655
+ }
656
+ return formula.predicate(val);
657
+ }
658
+ if (formula.kind === 'star') {
659
+ for (const { h1, h2 } of splits(heap)) {
660
+ if (satisfiesShape(formula.left, h1, val) && satisfiesShape(formula.right, h2, val)) {
661
+ return true;
662
+ }
663
+ }
664
+ return false;
665
+ }
666
+ if (formula.kind === 'and') {
667
+ return satisfiesShape(formula.left, heap, val) && satisfiesShape(formula.right, heap, val);
668
+ }
669
+ if (formula.kind === 'or') {
670
+ return satisfiesShape(formula.left, heap, val) || satisfiesShape(formula.right, heap, val);
671
+ }
672
+ if (formula.kind === 'not') {
673
+ return !satisfiesShape(formula.body, heap, val);
674
+ }
675
+ return satisfies(formula, heap, val);
676
+ }
677
+ function parseValueLit(s, val) {
678
+ const trimmed = s.trim();
679
+ if (trimmed === 'null')
680
+ return nullVal();
681
+ if (trimmed.startsWith('&')) {
682
+ const n = Number.parseInt(trimmed.slice(1), 10);
683
+ if (Number.isNaN(n))
684
+ return null;
685
+ return addrVal(n);
686
+ }
687
+ if (val[trimmed] !== undefined) {
688
+ return val[trimmed];
689
+ }
690
+ const asInt = Number.parseInt(trimmed, 10);
691
+ if (!Number.isNaN(asInt))
692
+ return intVal(asInt);
693
+ return null;
694
+ }
695
+ /** `tree(root)` — el heap representa un árbol binario con raíz `root`.
696
+ * tree(x) ≡ (x = null ∧ emp) ∨ ∃l, r. (x ↦ l * x.next ↦ r * tree(l) * tree(r))
697
+ *
698
+ * Modelo simplificado: cada nodo ocupa 2 celdas consecutivas
699
+ * (loc, loc+1) con los punteros izquierdo y derecho.
700
+ */
701
+ function tree(root) {
702
+ return {
703
+ kind: 'pure',
704
+ expression: `tree(${valueToString(root)})`,
705
+ predicate: () => true,
706
+ };
707
+ }
708
+ /** Comprueba si `heap` representa un árbol binario con raíz `root` (nodos de 2 celdas contiguas). */
709
+ function isTree(root, heap) {
710
+ if (root.kind === 'null')
711
+ return heap.size() === 0;
712
+ if (root.kind !== 'addr')
713
+ return false;
714
+ const visited = new Set();
715
+ function walk(node) {
716
+ if (node.kind === 'null')
717
+ return { ok: true, locs: [] };
718
+ if (node.kind !== 'addr')
719
+ return { ok: false, locs: [] };
720
+ if (visited.has(node.loc))
721
+ return { ok: false, locs: [] };
722
+ if (!heap.has(node.loc) || !heap.has(node.loc + 1)) {
723
+ return { ok: false, locs: [] };
724
+ }
725
+ visited.add(node.loc);
726
+ visited.add(node.loc + 1);
727
+ const left = heap.read(node.loc);
728
+ const right = heap.read(node.loc + 1);
729
+ const lr = walk(left);
730
+ if (!lr.ok)
731
+ return { ok: false, locs: [] };
732
+ const rr = walk(right);
733
+ if (!rr.ok)
734
+ return { ok: false, locs: [] };
735
+ return { ok: true, locs: [node.loc, node.loc + 1, ...lr.locs, ...rr.locs] };
736
+ }
737
+ const result = walk(root);
738
+ if (!result.ok)
739
+ return false;
740
+ return result.locs.length === heap.size();
741
+ }
742
+ // ── Frame rule (helper) ──────────────────────────────────────
743
+ /** Frame rule: si `{P} c {Q}` y `c` no modifica las variables libres de
744
+ * `R`, entonces `{P * R} c {Q * R}`. Esta función construye la tripla
745
+ * compuesta — la validación queda a cargo de `checkTriple`. */
746
+ function frame(triple, frameFormula) {
747
+ return {
748
+ pre: (0, exports.star)(triple.pre, frameFormula),
749
+ cmd: triple.cmd,
750
+ post: (0, exports.star)(triple.post, frameFormula),
751
+ };
752
+ }
753
+ // ── Re-exports y constructores convenientes ─────────────────
754
+ /** Constructores convenientes para `SLCommand` (skip, assign, alloc, free, load, store). */
755
+ exports.Cmd = {
756
+ skip: () => ({ kind: 'skip' }),
757
+ assign: (variable, value) => ({
758
+ kind: 'assign',
759
+ variable,
760
+ value,
761
+ }),
762
+ alloc: (variable, value) => ({
763
+ kind: 'alloc',
764
+ variable,
765
+ ...(value !== undefined ? { value } : {}),
766
+ }),
767
+ free: (location) => ({ kind: 'free', location }),
768
+ load: (variable, location) => ({
769
+ kind: 'load',
770
+ variable,
771
+ location,
772
+ }),
773
+ store: (location, value) => ({
774
+ kind: 'store',
775
+ location,
776
+ value,
777
+ }),
778
+ };
779
+ //# sourceMappingURL=index.js.map