@stevenvo780/st-lang 4.5.1 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/dist/bdd/index.d.ts +4 -0
  2. package/dist/bdd/index.d.ts.map +1 -0
  3. package/dist/bdd/index.js +29 -0
  4. package/dist/bdd/index.js.map +1 -0
  5. package/dist/bdd/manager.d.ts +122 -0
  6. package/dist/bdd/manager.d.ts.map +1 -0
  7. package/dist/bdd/manager.js +524 -0
  8. package/dist/bdd/manager.js.map +1 -0
  9. package/dist/bdd/types.d.ts +20 -0
  10. package/dist/bdd/types.d.ts.map +1 -0
  11. package/dist/bdd/types.js +28 -0
  12. package/dist/bdd/types.js.map +1 -0
  13. package/dist/categorical/fin-set.d.ts +39 -0
  14. package/dist/categorical/fin-set.d.ts.map +1 -0
  15. package/dist/categorical/fin-set.js +217 -0
  16. package/dist/categorical/fin-set.js.map +1 -0
  17. package/dist/categorical/free.d.ts +23 -0
  18. package/dist/categorical/free.d.ts.map +1 -0
  19. package/dist/categorical/free.js +168 -0
  20. package/dist/categorical/free.js.map +1 -0
  21. package/dist/categorical/functor.d.ts +40 -0
  22. package/dist/categorical/functor.d.ts.map +1 -0
  23. package/dist/categorical/functor.js +139 -0
  24. package/dist/categorical/functor.js.map +1 -0
  25. package/dist/categorical/index.d.ts +11 -0
  26. package/dist/categorical/index.d.ts.map +1 -0
  27. package/dist/categorical/index.js +33 -0
  28. package/dist/categorical/index.js.map +1 -0
  29. package/dist/categorical/limits.d.ts +64 -0
  30. package/dist/categorical/limits.d.ts.map +1 -0
  31. package/dist/categorical/limits.js +248 -0
  32. package/dist/categorical/limits.js.map +1 -0
  33. package/dist/categorical/monoidal.d.ts +14 -0
  34. package/dist/categorical/monoidal.d.ts.map +1 -0
  35. package/dist/categorical/monoidal.js +148 -0
  36. package/dist/categorical/monoidal.js.map +1 -0
  37. package/dist/categorical/poset.d.ts +14 -0
  38. package/dist/categorical/poset.d.ts.map +1 -0
  39. package/dist/categorical/poset.js +115 -0
  40. package/dist/categorical/poset.js.map +1 -0
  41. package/dist/categorical/types.d.ts +111 -0
  42. package/dist/categorical/types.d.ts.map +1 -0
  43. package/dist/categorical/types.js +15 -0
  44. package/dist/categorical/types.js.map +1 -0
  45. package/dist/csp-hoare/analysis.d.ts +51 -0
  46. package/dist/csp-hoare/analysis.d.ts.map +1 -0
  47. package/dist/csp-hoare/analysis.js +317 -0
  48. package/dist/csp-hoare/analysis.js.map +1 -0
  49. package/dist/csp-hoare/examples.d.ts +33 -0
  50. package/dist/csp-hoare/examples.d.ts.map +1 -0
  51. package/dist/csp-hoare/examples.js +108 -0
  52. package/dist/csp-hoare/examples.js.map +1 -0
  53. package/dist/csp-hoare/index.d.ts +6 -0
  54. package/dist/csp-hoare/index.d.ts.map +1 -0
  55. package/dist/csp-hoare/index.js +50 -0
  56. package/dist/csp-hoare/index.js.map +1 -0
  57. package/dist/csp-hoare/semantics.d.ts +49 -0
  58. package/dist/csp-hoare/semantics.d.ts.map +1 -0
  59. package/dist/csp-hoare/semantics.js +494 -0
  60. package/dist/csp-hoare/semantics.js.map +1 -0
  61. package/dist/csp-hoare/types.d.ts +60 -0
  62. package/dist/csp-hoare/types.d.ts.map +1 -0
  63. package/dist/csp-hoare/types.js +31 -0
  64. package/dist/csp-hoare/types.js.map +1 -0
  65. package/dist/game-theory/common-games.d.ts +50 -0
  66. package/dist/game-theory/common-games.d.ts.map +1 -0
  67. package/dist/game-theory/common-games.js +112 -0
  68. package/dist/game-theory/common-games.js.map +1 -0
  69. package/dist/game-theory/dominance.d.ts +26 -0
  70. package/dist/game-theory/dominance.d.ts.map +1 -0
  71. package/dist/game-theory/dominance.js +203 -0
  72. package/dist/game-theory/dominance.js.map +1 -0
  73. package/dist/game-theory/index.d.ts +8 -0
  74. package/dist/game-theory/index.d.ts.map +1 -0
  75. package/dist/game-theory/index.js +47 -0
  76. package/dist/game-theory/index.js.map +1 -0
  77. package/dist/game-theory/lemke-howson.d.ts +3 -0
  78. package/dist/game-theory/lemke-howson.d.ts.map +1 -0
  79. package/dist/game-theory/lemke-howson.js +269 -0
  80. package/dist/game-theory/lemke-howson.js.map +1 -0
  81. package/dist/game-theory/linalg.d.ts +7 -0
  82. package/dist/game-theory/linalg.d.ts.map +1 -0
  83. package/dist/game-theory/linalg.js +69 -0
  84. package/dist/game-theory/linalg.js.map +1 -0
  85. package/dist/game-theory/pure-nash.d.ts +3 -0
  86. package/dist/game-theory/pure-nash.d.ts.map +1 -0
  87. package/dist/game-theory/pure-nash.js +86 -0
  88. package/dist/game-theory/pure-nash.js.map +1 -0
  89. package/dist/game-theory/support-enumeration.d.ts +3 -0
  90. package/dist/game-theory/support-enumeration.d.ts.map +1 -0
  91. package/dist/game-theory/support-enumeration.js +214 -0
  92. package/dist/game-theory/support-enumeration.js.map +1 -0
  93. package/dist/game-theory/types.d.ts +57 -0
  94. package/dist/game-theory/types.d.ts.map +1 -0
  95. package/dist/game-theory/types.js +191 -0
  96. package/dist/game-theory/types.js.map +1 -0
  97. package/dist/hindley-milner/index.d.ts +7 -0
  98. package/dist/hindley-milner/index.d.ts.map +1 -0
  99. package/dist/hindley-milner/index.js +60 -0
  100. package/dist/hindley-milner/index.js.map +1 -0
  101. package/dist/hindley-milner/infer.d.ts +26 -0
  102. package/dist/hindley-milner/infer.d.ts.map +1 -0
  103. package/dist/hindley-milner/infer.js +278 -0
  104. package/dist/hindley-milner/infer.js.map +1 -0
  105. package/dist/hindley-milner/substitution.d.ts +21 -0
  106. package/dist/hindley-milner/substitution.d.ts.map +1 -0
  107. package/dist/hindley-milner/substitution.js +215 -0
  108. package/dist/hindley-milner/substitution.js.map +1 -0
  109. package/dist/hindley-milner/types.d.ts +84 -0
  110. package/dist/hindley-milner/types.d.ts.map +1 -0
  111. package/dist/hindley-milner/types.js +166 -0
  112. package/dist/hindley-milner/types.js.map +1 -0
  113. package/dist/hott/equality.d.ts +4 -0
  114. package/dist/hott/equality.d.ts.map +1 -0
  115. package/dist/hott/equality.js +108 -0
  116. package/dist/hott/equality.js.map +1 -0
  117. package/dist/hott/index.d.ts +13 -0
  118. package/dist/hott/index.d.ts.map +1 -0
  119. package/dist/hott/index.js +77 -0
  120. package/dist/hott/index.js.map +1 -0
  121. package/dist/hott/infer.d.ts +11 -0
  122. package/dist/hott/infer.d.ts.map +1 -0
  123. package/dist/hott/infer.js +465 -0
  124. package/dist/hott/infer.js.map +1 -0
  125. package/dist/hott/normalize.d.ts +5 -0
  126. package/dist/hott/normalize.d.ts.map +1 -0
  127. package/dist/hott/normalize.js +240 -0
  128. package/dist/hott/normalize.js.map +1 -0
  129. package/dist/hott/path-algebra.d.ts +25 -0
  130. package/dist/hott/path-algebra.d.ts.map +1 -0
  131. package/dist/hott/path-algebra.js +67 -0
  132. package/dist/hott/path-algebra.js.map +1 -0
  133. package/dist/hott/substitute.d.ts +3 -0
  134. package/dist/hott/substitute.d.ts.map +1 -0
  135. package/dist/hott/substitute.js +131 -0
  136. package/dist/hott/substitute.js.map +1 -0
  137. package/dist/hott/types.d.ts +126 -0
  138. package/dist/hott/types.d.ts.map +1 -0
  139. package/dist/hott/types.js +346 -0
  140. package/dist/hott/types.js.map +1 -0
  141. package/dist/index.d.ts +16 -1
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js +83 -3
  144. package/dist/index.js.map +1 -1
  145. package/dist/information-theory/index.d.ts +29 -0
  146. package/dist/information-theory/index.d.ts.map +1 -0
  147. package/dist/information-theory/index.js +323 -0
  148. package/dist/information-theory/index.js.map +1 -0
  149. package/dist/lemma-synthesis/index.d.ts +124 -0
  150. package/dist/lemma-synthesis/index.d.ts.map +1 -0
  151. package/dist/lemma-synthesis/index.js +640 -0
  152. package/dist/lemma-synthesis/index.js.map +1 -0
  153. package/dist/namespaces/logic.d.ts +42 -0
  154. package/dist/namespaces/logic.d.ts.map +1 -0
  155. package/dist/namespaces/logic.js +112 -0
  156. package/dist/namespaces/logic.js.map +1 -0
  157. package/dist/namespaces/proof-systems.d.ts +18 -0
  158. package/dist/namespaces/proof-systems.d.ts.map +1 -0
  159. package/dist/namespaces/proof-systems.js +59 -0
  160. package/dist/namespaces/proof-systems.js.map +1 -0
  161. package/dist/namespaces/reasoning.d.ts +26 -0
  162. package/dist/namespaces/reasoning.d.ts.map +1 -0
  163. package/dist/namespaces/reasoning.js +72 -0
  164. package/dist/namespaces/reasoning.js.map +1 -0
  165. package/dist/namespaces/semantics.d.ts +21 -0
  166. package/dist/namespaces/semantics.d.ts.map +1 -0
  167. package/dist/namespaces/semantics.js +64 -0
  168. package/dist/namespaces/semantics.js.map +1 -0
  169. package/dist/namespaces/solvers.d.ts +22 -0
  170. package/dist/namespaces/solvers.d.ts.map +1 -0
  171. package/dist/namespaces/solvers.js +66 -0
  172. package/dist/namespaces/solvers.js.map +1 -0
  173. package/dist/namespaces/type-theory.d.ts +22 -0
  174. package/dist/namespaces/type-theory.d.ts.map +1 -0
  175. package/dist/namespaces/type-theory.js +65 -0
  176. package/dist/namespaces/type-theory.js.map +1 -0
  177. package/dist/optimization/branch-and-bound.d.ts +11 -0
  178. package/dist/optimization/branch-and-bound.d.ts.map +1 -0
  179. package/dist/optimization/branch-and-bound.js +311 -0
  180. package/dist/optimization/branch-and-bound.js.map +1 -0
  181. package/dist/optimization/index.d.ts +5 -0
  182. package/dist/optimization/index.d.ts.map +1 -0
  183. package/dist/optimization/index.js +20 -0
  184. package/dist/optimization/index.js.map +1 -0
  185. package/dist/optimization/simplex.d.ts +8 -0
  186. package/dist/optimization/simplex.d.ts.map +1 -0
  187. package/dist/optimization/simplex.js +408 -0
  188. package/dist/optimization/simplex.js.map +1 -0
  189. package/dist/optimization/standard-form.d.ts +11 -0
  190. package/dist/optimization/standard-form.d.ts.map +1 -0
  191. package/dist/optimization/standard-form.js +112 -0
  192. package/dist/optimization/standard-form.js.map +1 -0
  193. package/dist/optimization/types.d.ts +44 -0
  194. package/dist/optimization/types.d.ts.map +1 -0
  195. package/dist/optimization/types.js +15 -0
  196. package/dist/optimization/types.js.map +1 -0
  197. package/dist/profiles/hol/connectives.d.ts +46 -0
  198. package/dist/profiles/hol/connectives.d.ts.map +1 -0
  199. package/dist/profiles/hol/connectives.js +104 -0
  200. package/dist/profiles/hol/connectives.js.map +1 -0
  201. package/dist/profiles/hol/index.d.ts +7 -0
  202. package/dist/profiles/hol/index.d.ts.map +1 -0
  203. package/dist/profiles/hol/index.js +77 -0
  204. package/dist/profiles/hol/index.js.map +1 -0
  205. package/dist/profiles/hol/rules.d.ts +31 -0
  206. package/dist/profiles/hol/rules.d.ts.map +1 -0
  207. package/dist/profiles/hol/rules.js +258 -0
  208. package/dist/profiles/hol/rules.js.map +1 -0
  209. package/dist/profiles/hol/term.d.ts +52 -0
  210. package/dist/profiles/hol/term.d.ts.map +1 -0
  211. package/dist/profiles/hol/term.js +345 -0
  212. package/dist/profiles/hol/term.js.map +1 -0
  213. package/dist/profiles/hol/type-system.d.ts +38 -0
  214. package/dist/profiles/hol/type-system.d.ts.map +1 -0
  215. package/dist/profiles/hol/type-system.js +133 -0
  216. package/dist/profiles/hol/type-system.js.map +1 -0
  217. package/dist/profiles/hol/types.d.ts +59 -0
  218. package/dist/profiles/hol/types.d.ts.map +1 -0
  219. package/dist/profiles/hol/types.js +26 -0
  220. package/dist/profiles/hol/types.js.map +1 -0
  221. package/dist/smt-lib/ast.d.ts +138 -0
  222. package/dist/smt-lib/ast.d.ts.map +1 -0
  223. package/dist/smt-lib/ast.js +73 -0
  224. package/dist/smt-lib/ast.js.map +1 -0
  225. package/dist/smt-lib/emitter.d.ts +12 -0
  226. package/dist/smt-lib/emitter.d.ts.map +1 -0
  227. package/dist/smt-lib/emitter.js +174 -0
  228. package/dist/smt-lib/emitter.js.map +1 -0
  229. package/dist/smt-lib/index.d.ts +6 -0
  230. package/dist/smt-lib/index.d.ts.map +1 -0
  231. package/dist/smt-lib/index.js +31 -0
  232. package/dist/smt-lib/index.js.map +1 -0
  233. package/dist/smt-lib/parser.d.ts +13 -0
  234. package/dist/smt-lib/parser.d.ts.map +1 -0
  235. package/dist/smt-lib/parser.js +614 -0
  236. package/dist/smt-lib/parser.js.map +1 -0
  237. package/dist/smt-lib/tokenizer.d.ts +16 -0
  238. package/dist/smt-lib/tokenizer.d.ts.map +1 -0
  239. package/dist/smt-lib/tokenizer.js +234 -0
  240. package/dist/smt-lib/tokenizer.js.map +1 -0
  241. package/dist/tactic-dsl/combinators.d.ts +6 -0
  242. package/dist/tactic-dsl/combinators.d.ts.map +1 -0
  243. package/dist/tactic-dsl/combinators.js +98 -0
  244. package/dist/tactic-dsl/combinators.js.map +1 -0
  245. package/dist/tactic-dsl/index.d.ts +39 -0
  246. package/dist/tactic-dsl/index.d.ts.map +1 -0
  247. package/dist/tactic-dsl/index.js +162 -0
  248. package/dist/tactic-dsl/index.js.map +1 -0
  249. package/dist/tactic-dsl/tactics.d.ts +21 -0
  250. package/dist/tactic-dsl/tactics.d.ts.map +1 -0
  251. package/dist/tactic-dsl/tactics.js +536 -0
  252. package/dist/tactic-dsl/tactics.js.map +1 -0
  253. package/dist/tactic-dsl/types.d.ts +54 -0
  254. package/dist/tactic-dsl/types.d.ts.map +1 -0
  255. package/dist/tactic-dsl/types.js +226 -0
  256. package/dist/tactic-dsl/types.js.map +1 -0
  257. package/dist/tests/api/namespaces.test.d.ts +9 -0
  258. package/dist/tests/api/namespaces.test.d.ts.map +1 -0
  259. package/dist/tests/api/namespaces.test.js +218 -0
  260. package/dist/tests/api/namespaces.test.js.map +1 -0
  261. package/dist/tests/bdd/manager.test.d.ts +2 -0
  262. package/dist/tests/bdd/manager.test.d.ts.map +1 -0
  263. package/dist/tests/bdd/manager.test.js +472 -0
  264. package/dist/tests/bdd/manager.test.js.map +1 -0
  265. package/dist/tests/categorical/categorical.test.d.ts +2 -0
  266. package/dist/tests/categorical/categorical.test.d.ts.map +1 -0
  267. package/dist/tests/categorical/categorical.test.js +300 -0
  268. package/dist/tests/categorical/categorical.test.js.map +1 -0
  269. package/dist/tests/csp-hoare/csp-hoare.test.d.ts +2 -0
  270. package/dist/tests/csp-hoare/csp-hoare.test.d.ts.map +1 -0
  271. package/dist/tests/csp-hoare/csp-hoare.test.js +313 -0
  272. package/dist/tests/csp-hoare/csp-hoare.test.js.map +1 -0
  273. package/dist/tests/game-theory/game-theory.test.d.ts +2 -0
  274. package/dist/tests/game-theory/game-theory.test.d.ts.map +1 -0
  275. package/dist/tests/game-theory/game-theory.test.js +252 -0
  276. package/dist/tests/game-theory/game-theory.test.js.map +1 -0
  277. package/dist/tests/hindley-milner/hindley-milner.test.d.ts +2 -0
  278. package/dist/tests/hindley-milner/hindley-milner.test.d.ts.map +1 -0
  279. package/dist/tests/hindley-milner/hindley-milner.test.js +327 -0
  280. package/dist/tests/hindley-milner/hindley-milner.test.js.map +1 -0
  281. package/dist/tests/hol/hol.test.d.ts +2 -0
  282. package/dist/tests/hol/hol.test.d.ts.map +1 -0
  283. package/dist/tests/hol/hol.test.js +340 -0
  284. package/dist/tests/hol/hol.test.js.map +1 -0
  285. package/dist/tests/hott/hott.test.d.ts +2 -0
  286. package/dist/tests/hott/hott.test.d.ts.map +1 -0
  287. package/dist/tests/hott/hott.test.js +271 -0
  288. package/dist/tests/hott/hott.test.js.map +1 -0
  289. package/dist/tests/information-theory/information-theory.test.d.ts +2 -0
  290. package/dist/tests/information-theory/information-theory.test.d.ts.map +1 -0
  291. package/dist/tests/information-theory/information-theory.test.js +291 -0
  292. package/dist/tests/information-theory/information-theory.test.js.map +1 -0
  293. package/dist/tests/lemma-synthesis/lemma-synthesis.test.d.ts +2 -0
  294. package/dist/tests/lemma-synthesis/lemma-synthesis.test.d.ts.map +1 -0
  295. package/dist/tests/lemma-synthesis/lemma-synthesis.test.js +460 -0
  296. package/dist/tests/lemma-synthesis/lemma-synthesis.test.js.map +1 -0
  297. package/dist/tests/optimization/ilp.test.d.ts +2 -0
  298. package/dist/tests/optimization/ilp.test.d.ts.map +1 -0
  299. package/dist/tests/optimization/ilp.test.js +204 -0
  300. package/dist/tests/optimization/ilp.test.js.map +1 -0
  301. package/dist/tests/optimization/lp.test.d.ts +2 -0
  302. package/dist/tests/optimization/lp.test.d.ts.map +1 -0
  303. package/dist/tests/optimization/lp.test.js +224 -0
  304. package/dist/tests/optimization/lp.test.js.map +1 -0
  305. package/dist/tests/properties/agm.property.test.d.ts +2 -0
  306. package/dist/tests/properties/agm.property.test.d.ts.map +1 -0
  307. package/dist/tests/properties/agm.property.test.js +75 -0
  308. package/dist/tests/properties/agm.property.test.js.map +1 -0
  309. package/dist/tests/properties/anti-unification.property.test.d.ts +2 -0
  310. package/dist/tests/properties/anti-unification.property.test.d.ts.map +1 -0
  311. package/dist/tests/properties/anti-unification.property.test.js +43 -0
  312. package/dist/tests/properties/anti-unification.property.test.js.map +1 -0
  313. package/dist/tests/properties/argumentation.property.test.d.ts +2 -0
  314. package/dist/tests/properties/argumentation.property.test.d.ts.map +1 -0
  315. package/dist/tests/properties/argumentation.property.test.js +51 -0
  316. package/dist/tests/properties/argumentation.property.test.js.map +1 -0
  317. package/dist/tests/properties/bayesian.property.test.d.ts +2 -0
  318. package/dist/tests/properties/bayesian.property.test.d.ts.map +1 -0
  319. package/dist/tests/properties/bayesian.property.test.js +32 -0
  320. package/dist/tests/properties/bayesian.property.test.js.map +1 -0
  321. package/dist/tests/properties/bisimulation.property.test.d.ts +2 -0
  322. package/dist/tests/properties/bisimulation.property.test.d.ts.map +1 -0
  323. package/dist/tests/properties/bisimulation.property.test.js +50 -0
  324. package/dist/tests/properties/bisimulation.property.test.js.map +1 -0
  325. package/dist/tests/properties/cdcl.property.test.d.ts +2 -0
  326. package/dist/tests/properties/cdcl.property.test.d.ts.map +1 -0
  327. package/dist/tests/properties/cdcl.property.test.js +70 -0
  328. package/dist/tests/properties/cdcl.property.test.js.map +1 -0
  329. package/dist/tests/properties/coinduction.property.test.d.ts +2 -0
  330. package/dist/tests/properties/coinduction.property.test.d.ts.map +1 -0
  331. package/dist/tests/properties/coinduction.property.test.js +34 -0
  332. package/dist/tests/properties/coinduction.property.test.js.map +1 -0
  333. package/dist/tests/properties/constructive-reals.property.test.d.ts +2 -0
  334. package/dist/tests/properties/constructive-reals.property.test.d.ts.map +1 -0
  335. package/dist/tests/properties/constructive-reals.property.test.js +59 -0
  336. package/dist/tests/properties/constructive-reals.property.test.js.map +1 -0
  337. package/dist/tests/properties/csp.property.test.d.ts +2 -0
  338. package/dist/tests/properties/csp.property.test.d.ts.map +1 -0
  339. package/dist/tests/properties/csp.property.test.js +58 -0
  340. package/dist/tests/properties/csp.property.test.js.map +1 -0
  341. package/dist/tests/properties/generators.d.ts +78 -0
  342. package/dist/tests/properties/generators.d.ts.map +1 -0
  343. package/dist/tests/properties/generators.js +348 -0
  344. package/dist/tests/properties/generators.js.map +1 -0
  345. package/dist/tests/properties/ho-unify.property.test.d.ts +2 -0
  346. package/dist/tests/properties/ho-unify.property.test.d.ts.map +1 -0
  347. package/dist/tests/properties/ho-unify.property.test.js +46 -0
  348. package/dist/tests/properties/ho-unify.property.test.js.map +1 -0
  349. package/dist/tests/properties/hyperreal.property.test.d.ts +2 -0
  350. package/dist/tests/properties/hyperreal.property.test.d.ts.map +1 -0
  351. package/dist/tests/properties/hyperreal.property.test.js +33 -0
  352. package/dist/tests/properties/hyperreal.property.test.js.map +1 -0
  353. package/dist/tests/properties/intuit-nj.property.test.d.ts +2 -0
  354. package/dist/tests/properties/intuit-nj.property.test.d.ts.map +1 -0
  355. package/dist/tests/properties/intuit-nj.property.test.js +57 -0
  356. package/dist/tests/properties/intuit-nj.property.test.js.map +1 -0
  357. package/dist/tests/properties/lambda-calc.property.test.d.ts +2 -0
  358. package/dist/tests/properties/lambda-calc.property.test.d.ts.map +1 -0
  359. package/dist/tests/properties/lambda-calc.property.test.js +35 -0
  360. package/dist/tests/properties/lambda-calc.property.test.js.map +1 -0
  361. package/dist/tests/properties/mln.property.test.d.ts +2 -0
  362. package/dist/tests/properties/mln.property.test.d.ts.map +1 -0
  363. package/dist/tests/properties/mln.property.test.js +41 -0
  364. package/dist/tests/properties/mln.property.test.js.map +1 -0
  365. package/dist/tests/properties/mltt.property.test.d.ts +2 -0
  366. package/dist/tests/properties/mltt.property.test.d.ts.map +1 -0
  367. package/dist/tests/properties/mltt.property.test.js +33 -0
  368. package/dist/tests/properties/mltt.property.test.js.map +1 -0
  369. package/dist/tests/properties/nbe.property.test.d.ts +2 -0
  370. package/dist/tests/properties/nbe.property.test.d.ts.map +1 -0
  371. package/dist/tests/properties/nbe.property.test.js +44 -0
  372. package/dist/tests/properties/nbe.property.test.js.map +1 -0
  373. package/dist/tests/properties/planning.property.test.d.ts +2 -0
  374. package/dist/tests/properties/planning.property.test.d.ts.map +1 -0
  375. package/dist/tests/properties/planning.property.test.js +51 -0
  376. package/dist/tests/properties/planning.property.test.js.map +1 -0
  377. package/dist/tests/properties/profile-bridge.property.test.d.ts +2 -0
  378. package/dist/tests/properties/profile-bridge.property.test.d.ts.map +1 -0
  379. package/dist/tests/properties/profile-bridge.property.test.js +71 -0
  380. package/dist/tests/properties/profile-bridge.property.test.js.map +1 -0
  381. package/dist/tests/properties/refinement-types.property.test.d.ts +2 -0
  382. package/dist/tests/properties/refinement-types.property.test.d.ts.map +1 -0
  383. package/dist/tests/properties/refinement-types.property.test.js +37 -0
  384. package/dist/tests/properties/refinement-types.property.test.js.map +1 -0
  385. package/dist/tests/properties/sequent-g3.property.test.d.ts +2 -0
  386. package/dist/tests/properties/sequent-g3.property.test.d.ts.map +1 -0
  387. package/dist/tests/properties/sequent-g3.property.test.js +34 -0
  388. package/dist/tests/properties/sequent-g3.property.test.js.map +1 -0
  389. package/dist/tests/properties/symbolic-diff.property.test.d.ts +2 -0
  390. package/dist/tests/properties/symbolic-diff.property.test.d.ts.map +1 -0
  391. package/dist/tests/properties/symbolic-diff.property.test.js +49 -0
  392. package/dist/tests/properties/symbolic-diff.property.test.js.map +1 -0
  393. package/dist/tests/properties/system-f.property.test.d.ts +2 -0
  394. package/dist/tests/properties/system-f.property.test.d.ts.map +1 -0
  395. package/dist/tests/properties/system-f.property.test.js +37 -0
  396. package/dist/tests/properties/system-f.property.test.js.map +1 -0
  397. package/dist/tests/properties/theorem-cache.property.test.d.ts +2 -0
  398. package/dist/tests/properties/theorem-cache.property.test.d.ts.map +1 -0
  399. package/dist/tests/properties/theorem-cache.property.test.js +38 -0
  400. package/dist/tests/properties/theorem-cache.property.test.js.map +1 -0
  401. package/dist/tests/properties/trs.property.test.d.ts +2 -0
  402. package/dist/tests/properties/trs.property.test.d.ts.map +1 -0
  403. package/dist/tests/properties/trs.property.test.js +34 -0
  404. package/dist/tests/properties/trs.property.test.js.map +1 -0
  405. package/dist/tests/properties/unification.property.test.d.ts +2 -0
  406. package/dist/tests/properties/unification.property.test.d.ts.map +1 -0
  407. package/dist/tests/properties/unification.property.test.js +42 -0
  408. package/dist/tests/properties/unification.property.test.js.map +1 -0
  409. package/dist/tests/smt-lib/emitter.test.d.ts +2 -0
  410. package/dist/tests/smt-lib/emitter.test.d.ts.map +1 -0
  411. package/dist/tests/smt-lib/emitter.test.js +155 -0
  412. package/dist/tests/smt-lib/emitter.test.js.map +1 -0
  413. package/dist/tests/smt-lib/parser.test.d.ts +2 -0
  414. package/dist/tests/smt-lib/parser.test.d.ts.map +1 -0
  415. package/dist/tests/smt-lib/parser.test.js +164 -0
  416. package/dist/tests/smt-lib/parser.test.js.map +1 -0
  417. package/dist/tests/smt-lib/tokenizer.test.d.ts +2 -0
  418. package/dist/tests/smt-lib/tokenizer.test.d.ts.map +1 -0
  419. package/dist/tests/smt-lib/tokenizer.test.js +59 -0
  420. package/dist/tests/smt-lib/tokenizer.test.js.map +1 -0
  421. package/dist/tests/tactic-dsl/tactic-dsl.test.d.ts +2 -0
  422. package/dist/tests/tactic-dsl/tactic-dsl.test.d.ts.map +1 -0
  423. package/dist/tests/tactic-dsl/tactic-dsl.test.js +259 -0
  424. package/dist/tests/tactic-dsl/tactic-dsl.test.js.map +1 -0
  425. package/dist/tests/tptp/bridge.test.d.ts +2 -0
  426. package/dist/tests/tptp/bridge.test.d.ts.map +1 -0
  427. package/dist/tests/tptp/bridge.test.js +154 -0
  428. package/dist/tests/tptp/bridge.test.js.map +1 -0
  429. package/dist/tests/tptp/emitter.test.d.ts +2 -0
  430. package/dist/tests/tptp/emitter.test.d.ts.map +1 -0
  431. package/dist/tests/tptp/emitter.test.js +128 -0
  432. package/dist/tests/tptp/emitter.test.js.map +1 -0
  433. package/dist/tests/tptp/parser.test.d.ts +2 -0
  434. package/dist/tests/tptp/parser.test.d.ts.map +1 -0
  435. package/dist/tests/tptp/parser.test.js +192 -0
  436. package/dist/tests/tptp/parser.test.js.map +1 -0
  437. package/dist/tests/tptp/tokenizer.test.d.ts +2 -0
  438. package/dist/tests/tptp/tokenizer.test.d.ts.map +1 -0
  439. package/dist/tests/tptp/tokenizer.test.js +60 -0
  440. package/dist/tests/tptp/tokenizer.test.js.map +1 -0
  441. package/dist/tptp/ast.d.ts +73 -0
  442. package/dist/tptp/ast.d.ts.map +1 -0
  443. package/dist/tptp/ast.js +35 -0
  444. package/dist/tptp/ast.js.map +1 -0
  445. package/dist/tptp/bridge.d.ts +14 -0
  446. package/dist/tptp/bridge.d.ts.map +1 -0
  447. package/dist/tptp/bridge.js +146 -0
  448. package/dist/tptp/bridge.js.map +1 -0
  449. package/dist/tptp/emitter.d.ts +5 -0
  450. package/dist/tptp/emitter.d.ts.map +1 -0
  451. package/dist/tptp/emitter.js +103 -0
  452. package/dist/tptp/emitter.js.map +1 -0
  453. package/dist/tptp/index.d.ts +7 -0
  454. package/dist/tptp/index.d.ts.map +1 -0
  455. package/dist/tptp/index.js +31 -0
  456. package/dist/tptp/index.js.map +1 -0
  457. package/dist/tptp/parser.d.ts +23 -0
  458. package/dist/tptp/parser.d.ts.map +1 -0
  459. package/dist/tptp/parser.js +440 -0
  460. package/dist/tptp/parser.js.map +1 -0
  461. package/dist/tptp/tokenizer.d.ts +14 -0
  462. package/dist/tptp/tokenizer.d.ts.map +1 -0
  463. package/dist/tptp/tokenizer.js +264 -0
  464. package/dist/tptp/tokenizer.js.map +1 -0
  465. package/package.json +5 -1
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // Support enumeration — algoritmo para enumerar TODOS los Nash
4
+ // equilibria de un juego 2-player.
5
+ // ============================================================
6
+ //
7
+ // Idea (Dickhaut–Kaplan, generalizado): un equilibrio mixto está
8
+ // soportado por dos subconjuntos S_1 ⊆ [n], S_2 ⊆ [m] de igual
9
+ // cardinalidad (por el Lemma de complementariedad).
10
+ //
11
+ // Para cada par (S_1, S_2) del mismo tamaño k:
12
+ // - jugador 1 mezcla solo en S_1 con probs p_i (i ∈ S_1)
13
+ // - jugador 2 mezcla solo en S_2 con probs q_j (j ∈ S_2)
14
+ // - p, q deben volver indiferente al rival en su soporte:
15
+ // sum_i p_i * a[i][j] = u_2 para todo j ∈ S_2
16
+ // sum_j q_j * a'[i][j] = u_1 para todo i ∈ S_1
17
+ // (donde a' = pagos de player 1, a = pagos de player 2)
18
+ // - p, q ≥ 0, suman 1
19
+ // - mejores fuera del soporte no deben superar el pago de equilibrio
20
+ //
21
+ // Resolvemos el sistema lineal y filtramos. Para juegos chicos
22
+ // (n*m ≤ ~10) la enumeración es trivial: 2^n * 2^m subsets.
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.enumerateAllNash = enumerateAllNash;
25
+ const types_1 = require("./types");
26
+ const linalg_1 = require("./linalg");
27
+ const TOL = 1e-9;
28
+ function enumerateAllNash(game, maxSize) {
29
+ if (game.players !== 2) {
30
+ throw new Error('enumerateAllNash currently supports 2-player games only');
31
+ }
32
+ const n = game.strategies[0];
33
+ const m = game.strategies[1];
34
+ const a1 = game.payoffs[0]; // a1[i*m+j] = u_1(i, j)
35
+ const a2 = game.payoffs[1]; // a2[i*m+j] = u_2(i, j)
36
+ const cap = maxSize ?? Math.min(n, m);
37
+ const results = [];
38
+ const seen = new Set();
39
+ // Enumerar subsets crecientes para que las equilibria puras
40
+ // aparezcan primero.
41
+ for (let k = 1; k <= cap; k++) {
42
+ const subsetsRow = subsetsOfSize(n, k);
43
+ const subsetsCol = subsetsOfSize(m, k);
44
+ for (const S1 of subsetsRow) {
45
+ for (const S2 of subsetsCol) {
46
+ const eq = solveSupport(n, m, a1, a2, S1, S2);
47
+ if (eq == null)
48
+ continue;
49
+ const key = canonicalKey(eq.strategies[0].distribution, eq.strategies[1].distribution);
50
+ if (seen.has(key))
51
+ continue;
52
+ seen.add(key);
53
+ results.push(eq);
54
+ }
55
+ }
56
+ }
57
+ return results;
58
+ }
59
+ function solveSupport(n, m, a1, a2, S1, S2) {
60
+ const k = S1.length;
61
+ if (S2.length !== k)
62
+ return null;
63
+ // Sistema para q (variable del jugador 2, |S2| = k):
64
+ // Para cada i ∈ S1: sum_{j ∈ S2} a1[i,j] * q_j = u_1
65
+ // sum_{j ∈ S2} q_j = 1
66
+ // Variables: q_j (k), u_1 (1). Ecuaciones: k + 1.
67
+ const A_q = [];
68
+ const b_q = [];
69
+ for (const i of S1) {
70
+ const row = new Array(k + 1).fill(0);
71
+ for (let idx = 0; idx < k; idx++) {
72
+ const j = S2[idx];
73
+ row[idx] = a1[i * m + j];
74
+ }
75
+ row[k] = -1; // -u_1
76
+ A_q.push(row);
77
+ b_q.push(0);
78
+ }
79
+ const last_q = new Array(k + 1).fill(0);
80
+ for (let idx = 0; idx < k; idx++)
81
+ last_q[idx] = 1;
82
+ A_q.push(last_q);
83
+ b_q.push(1);
84
+ const solQ = (0, linalg_1.solveLinear)(A_q, b_q);
85
+ if (solQ === null)
86
+ return null;
87
+ // Sistema para p (variable del jugador 1, |S1| = k):
88
+ // Para cada j ∈ S2: sum_{i ∈ S1} a2[i,j] * p_i = u_2
89
+ // sum_{i ∈ S1} p_i = 1
90
+ const A_p = [];
91
+ const b_p = [];
92
+ for (const j of S2) {
93
+ const row = new Array(k + 1).fill(0);
94
+ for (let idx = 0; idx < k; idx++) {
95
+ const i = S1[idx];
96
+ row[idx] = a2[i * m + j];
97
+ }
98
+ row[k] = -1; // -u_2
99
+ A_p.push(row);
100
+ b_p.push(0);
101
+ }
102
+ const last_p = new Array(k + 1).fill(0);
103
+ for (let idx = 0; idx < k; idx++)
104
+ last_p[idx] = 1;
105
+ A_p.push(last_p);
106
+ b_p.push(1);
107
+ const solP = (0, linalg_1.solveLinear)(A_p, b_p);
108
+ if (solP === null)
109
+ return null;
110
+ const q_support = solQ.slice(0, k);
111
+ const u1 = solQ[k];
112
+ const p_support = solP.slice(0, k);
113
+ const u2 = solP[k];
114
+ // Probabilidades dentro del soporte deben ser ≥ 0 (y >0 idealmente)
115
+ for (const v of q_support) {
116
+ if (v < -TOL)
117
+ return null;
118
+ if (v < TOL)
119
+ return null; // soporte = solo elementos con prob>0
120
+ }
121
+ for (const v of p_support) {
122
+ if (v < -TOL)
123
+ return null;
124
+ if (v < TOL)
125
+ return null;
126
+ }
127
+ // Reconstruir distribuciones completas
128
+ const p = new Array(n).fill(0);
129
+ for (let idx = 0; idx < k; idx++)
130
+ p[S1[idx]] = p_support[idx];
131
+ const q = new Array(m).fill(0);
132
+ for (let idx = 0; idx < k; idx++)
133
+ q[S2[idx]] = q_support[idx];
134
+ // Mejor respuesta fuera del soporte no debe superar u_1 / u_2
135
+ for (let i = 0; i < n; i++) {
136
+ if (S1.includes(i))
137
+ continue;
138
+ let u = 0;
139
+ for (let j = 0; j < m; j++)
140
+ u += q[j] * a1[i * m + j];
141
+ if (u > u1 + 1e-7)
142
+ return null;
143
+ }
144
+ for (let j = 0; j < m; j++) {
145
+ if (S2.includes(j))
146
+ continue;
147
+ let u = 0;
148
+ for (let i = 0; i < n; i++)
149
+ u += p[i] * a2[i * m + j];
150
+ if (u > u2 + 1e-7)
151
+ return null;
152
+ }
153
+ const game = {
154
+ players: 2,
155
+ strategies: [n, m],
156
+ payoffs: [a1, a2],
157
+ };
158
+ const dists = [p, q];
159
+ const payoffs = [
160
+ (0, types_1.expectedPayoffFromDistributions)(game, 0, dists),
161
+ (0, types_1.expectedPayoffFromDistributions)(game, 1, dists),
162
+ ];
163
+ const isPure = k === 1;
164
+ const isStrict = isPure && isStrictBR(n, m, a1, a2, S1[0], S2[0]);
165
+ return {
166
+ strategies: [
167
+ { player: 0, distribution: p },
168
+ { player: 1, distribution: q },
169
+ ],
170
+ payoffs,
171
+ isPure,
172
+ isStrict,
173
+ };
174
+ }
175
+ function isStrictBR(n, m, a1, a2, i, j) {
176
+ const cur1 = a1[i * m + j];
177
+ for (let ii = 0; ii < n; ii++) {
178
+ if (ii === i)
179
+ continue;
180
+ if (a1[ii * m + j] >= cur1 - TOL)
181
+ return false;
182
+ }
183
+ const cur2 = a2[i * m + j];
184
+ for (let jj = 0; jj < m; jj++) {
185
+ if (jj === j)
186
+ continue;
187
+ if (a2[i * m + jj] >= cur2 - TOL)
188
+ return false;
189
+ }
190
+ return true;
191
+ }
192
+ function subsetsOfSize(n, k) {
193
+ const result = [];
194
+ const cur = [];
195
+ function rec(start) {
196
+ if (cur.length === k) {
197
+ result.push(cur.slice());
198
+ return;
199
+ }
200
+ const need = k - cur.length;
201
+ for (let i = start; i <= n - need; i++) {
202
+ cur.push(i);
203
+ rec(i + 1);
204
+ cur.pop();
205
+ }
206
+ }
207
+ rec(0);
208
+ return result;
209
+ }
210
+ function canonicalKey(p, q) {
211
+ const round = (xs) => xs.map((x) => Math.round(x * 1e6) / 1e6).join(',');
212
+ return `${round(p)}|${round(q)}`;
213
+ }
214
+ //# sourceMappingURL=support-enumeration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"support-enumeration.js","sourceRoot":"","sources":["../../src/game-theory/support-enumeration.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,mCAAmC;AACnC,+DAA+D;AAC/D,EAAE;AACF,iEAAiE;AACjE,+DAA+D;AAC/D,oDAAoD;AACpD,EAAE;AACF,+CAA+C;AAC/C,2DAA2D;AAC3D,2DAA2D;AAC3D,4DAA4D;AAC5D,sDAAsD;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AAC,EAAY,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnF,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,57 @@
1
+ export interface NormalFormGame {
2
+ /** Cantidad de jugadores (≥ 2). */
3
+ players: number;
4
+ /** strategies[i] = número de estrategias puras del jugador i. */
5
+ strategies: number[];
6
+ /** payoffs[player][profileIndex] = utilidad del jugador en ese perfil. */
7
+ payoffs: number[][];
8
+ }
9
+ export interface MixedStrategy {
10
+ /** Índice del jugador (0-based). */
11
+ player: number;
12
+ /** Distribución sobre estrategias puras; debe sumar 1 y ser no-negativa. */
13
+ distribution: number[];
14
+ }
15
+ export interface NashEquilibrium {
16
+ /** Una distribución mixta por jugador (en orden de jugador). */
17
+ strategies: MixedStrategy[];
18
+ /** Pagos esperados por jugador en este equilibrio. */
19
+ payoffs: number[];
20
+ /** True si toda distribución pone masa 1 en alguna estrategia pura. */
21
+ isPure: boolean;
22
+ /** True si el equilibrio es estricto (best response única para cada jugador puro). */
23
+ isStrict: boolean;
24
+ }
25
+ /**
26
+ * Convierte un perfil `(s_0, ..., s_{n-1})` a su índice row-major
27
+ * en `payoffs[player]`. Lanza si el perfil no encaja en `sizes`.
28
+ */
29
+ export declare function profileToIndex(profile: number[], sizes: number[]): number;
30
+ /** Inversa de `profileToIndex`. */
31
+ export declare function indexToProfile(index: number, sizes: number[]): number[];
32
+ /** Producto cartesiano de tamaños — número total de perfiles. */
33
+ export declare function totalProfiles(sizes: number[]): number;
34
+ /**
35
+ * Construye un juego en forma normal validando dimensiones.
36
+ */
37
+ export declare function createGame(players: number, strategies: number[], payoffs: number[][]): NormalFormGame;
38
+ /**
39
+ * Construye un juego 2-player a partir de dos matrices NxM.
40
+ * `payoff1[i][j]` = utilidad del jugador 1 cuando juega i y el 2 juega j.
41
+ * `payoff2[i][j]` = utilidad del jugador 2.
42
+ */
43
+ export declare function createTwoPlayerGame(payoff1: number[][], payoff2: number[][]): NormalFormGame;
44
+ /** Lectura ergonómica del pago: u_player(profile). */
45
+ export declare function payoffOf(game: NormalFormGame, player: number, profile: number[]): number;
46
+ /** Suma de un vector — útil para chequeos de simplex. */
47
+ export declare function sumOf(xs: number[]): number;
48
+ /** Pago esperado del jugador en un perfil mixto. */
49
+ export declare function expectedPayoff(game: NormalFormGame, player: number, mixed: MixedStrategy[]): number;
50
+ export declare function expectedPayoffFromDistributions(game: NormalFormGame, player: number, dists: number[][]): number;
51
+ /** Distribución pura: masa 1 en `s`, 0 en el resto. */
52
+ export declare function pureDistribution(s: number, size: number): number[];
53
+ /** Dos números reales aproximadamente iguales. */
54
+ export declare function approxEqual(a: number, b: number, tol?: number): boolean;
55
+ /** Igualdad punto a punto bajo tolerancia. */
56
+ export declare function vectorsApproxEqual(a: number[], b: number[], tol?: number): boolean;
57
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/game-theory/types.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,sDAAsD;IACtD,OAAO,EAAE,MAAM,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,MAAM,GAAG,MAAM,EAAE,CAIlE;AAED,kDAAkD;AAClD,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,SAAO,GAAG,OAAO,CAErE;AAED,8CAA8C;AAC9C,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,SAAO,GAAG,OAAO,CAMhF"}
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // Game theory — Tipos y utilidades de juegos en forma normal
4
+ // ============================================================
5
+ //
6
+ // Modelo de juego en forma normal (también llamado matriz de
7
+ // pagos) para n jugadores con conjuntos finitos de estrategias
8
+ // puras. Los pagos se almacenan en un layout flat:
9
+ //
10
+ // payoffs[player][index] = u_player(s_1, ..., s_n)
11
+ //
12
+ // donde `index` es la codificación row-major (lexicográfica) del
13
+ // perfil de estrategias `(s_1, ..., s_n)` usando los tamaños en
14
+ // `strategies`. Esta forma permite manejar uniformemente juegos
15
+ // 2-player NxM y juegos n-player simétricos chicos.
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.profileToIndex = profileToIndex;
18
+ exports.indexToProfile = indexToProfile;
19
+ exports.totalProfiles = totalProfiles;
20
+ exports.createGame = createGame;
21
+ exports.createTwoPlayerGame = createTwoPlayerGame;
22
+ exports.payoffOf = payoffOf;
23
+ exports.sumOf = sumOf;
24
+ exports.expectedPayoff = expectedPayoff;
25
+ exports.expectedPayoffFromDistributions = expectedPayoffFromDistributions;
26
+ exports.pureDistribution = pureDistribution;
27
+ exports.approxEqual = approxEqual;
28
+ exports.vectorsApproxEqual = vectorsApproxEqual;
29
+ // ---------- helpers internos ----------
30
+ /**
31
+ * Convierte un perfil `(s_0, ..., s_{n-1})` a su índice row-major
32
+ * en `payoffs[player]`. Lanza si el perfil no encaja en `sizes`.
33
+ */
34
+ function profileToIndex(profile, sizes) {
35
+ if (profile.length !== sizes.length) {
36
+ throw new Error(`profile length ${profile.length} != strategies length ${sizes.length}`);
37
+ }
38
+ let idx = 0;
39
+ for (let i = 0; i < profile.length; i++) {
40
+ const s = profile[i];
41
+ const size = sizes[i];
42
+ if (s < 0 || s >= size) {
43
+ throw new Error(`strategy ${s} out of range [0, ${size}) for player ${i}`);
44
+ }
45
+ idx = idx * size + s;
46
+ }
47
+ return idx;
48
+ }
49
+ /** Inversa de `profileToIndex`. */
50
+ function indexToProfile(index, sizes) {
51
+ const profile = new Array(sizes.length);
52
+ let remaining = index;
53
+ for (let i = sizes.length - 1; i >= 0; i--) {
54
+ const size = sizes[i];
55
+ profile[i] = remaining % size;
56
+ remaining = Math.floor(remaining / size);
57
+ }
58
+ if (remaining !== 0) {
59
+ throw new Error(`index ${index} out of range for sizes ${sizes.join(',')}`);
60
+ }
61
+ return profile;
62
+ }
63
+ /** Producto cartesiano de tamaños — número total de perfiles. */
64
+ function totalProfiles(sizes) {
65
+ let n = 1;
66
+ for (const s of sizes)
67
+ n *= s;
68
+ return n;
69
+ }
70
+ /**
71
+ * Construye un juego en forma normal validando dimensiones.
72
+ */
73
+ function createGame(players, strategies, payoffs) {
74
+ if (players < 2)
75
+ throw new Error('a game needs at least 2 players');
76
+ if (strategies.length !== players) {
77
+ throw new Error(`strategies length ${strategies.length} != players ${players}`);
78
+ }
79
+ const total = totalProfiles(strategies);
80
+ if (payoffs.length !== players) {
81
+ throw new Error(`payoffs has ${payoffs.length} rows, expected ${players}`);
82
+ }
83
+ for (let i = 0; i < players; i++) {
84
+ const row = payoffs[i];
85
+ if (row.length !== total) {
86
+ throw new Error(`payoffs[${i}] has length ${row.length}, expected ${total}`);
87
+ }
88
+ }
89
+ return { players, strategies: strategies.slice(), payoffs: payoffs.map((r) => r.slice()) };
90
+ }
91
+ /**
92
+ * Construye un juego 2-player a partir de dos matrices NxM.
93
+ * `payoff1[i][j]` = utilidad del jugador 1 cuando juega i y el 2 juega j.
94
+ * `payoff2[i][j]` = utilidad del jugador 2.
95
+ */
96
+ function createTwoPlayerGame(payoff1, payoff2) {
97
+ const n = payoff1.length;
98
+ if (n === 0)
99
+ throw new Error('payoff1 must have at least one row');
100
+ const first = payoff1[0];
101
+ const m = first.length;
102
+ if (m === 0)
103
+ throw new Error('payoff1 must have at least one column');
104
+ if (payoff2.length !== n) {
105
+ throw new Error(`payoff2 has ${payoff2.length} rows, expected ${n}`);
106
+ }
107
+ for (let i = 0; i < n; i++) {
108
+ const r1 = payoff1[i];
109
+ const r2 = payoff2[i];
110
+ if (r1.length !== m)
111
+ throw new Error(`payoff1[${i}] has length ${r1.length}, expected ${m}`);
112
+ if (r2.length !== m)
113
+ throw new Error(`payoff2[${i}] has length ${r2.length}, expected ${m}`);
114
+ }
115
+ const flat1 = new Array(n * m);
116
+ const flat2 = new Array(n * m);
117
+ for (let i = 0; i < n; i++) {
118
+ for (let j = 0; j < m; j++) {
119
+ flat1[i * m + j] = payoff1[i][j];
120
+ flat2[i * m + j] = payoff2[i][j];
121
+ }
122
+ }
123
+ return { players: 2, strategies: [n, m], payoffs: [flat1, flat2] };
124
+ }
125
+ /** Lectura ergonómica del pago: u_player(profile). */
126
+ function payoffOf(game, player, profile) {
127
+ const idx = profileToIndex(profile, game.strategies);
128
+ const row = game.payoffs[player];
129
+ if (!row)
130
+ throw new Error(`player ${player} out of range`);
131
+ const v = row[idx];
132
+ if (v === undefined)
133
+ throw new Error('payoff missing at index');
134
+ return v;
135
+ }
136
+ /** Suma de un vector — útil para chequeos de simplex. */
137
+ function sumOf(xs) {
138
+ let s = 0;
139
+ for (const x of xs)
140
+ s += x;
141
+ return s;
142
+ }
143
+ /** Pago esperado del jugador en un perfil mixto. */
144
+ function expectedPayoff(game, player, mixed) {
145
+ const dists = mixed.map((m) => m.distribution);
146
+ return expectedPayoffFromDistributions(game, player, dists);
147
+ }
148
+ function expectedPayoffFromDistributions(game, player, dists) {
149
+ const sizes = game.strategies;
150
+ const total = totalProfiles(sizes);
151
+ const row = game.payoffs[player];
152
+ if (!row)
153
+ throw new Error(`player ${player} out of range`);
154
+ let total2 = 0;
155
+ for (let idx = 0; idx < total; idx++) {
156
+ const profile = indexToProfile(idx, sizes);
157
+ let prob = 1;
158
+ for (let p = 0; p < profile.length; p++) {
159
+ const d = dists[p];
160
+ if (!d)
161
+ throw new Error(`missing distribution for player ${p}`);
162
+ const sp = profile[p];
163
+ prob *= d[sp];
164
+ }
165
+ if (prob === 0)
166
+ continue;
167
+ total2 += prob * row[idx];
168
+ }
169
+ return total2;
170
+ }
171
+ /** Distribución pura: masa 1 en `s`, 0 en el resto. */
172
+ function pureDistribution(s, size) {
173
+ const d = new Array(size).fill(0);
174
+ d[s] = 1;
175
+ return d;
176
+ }
177
+ /** Dos números reales aproximadamente iguales. */
178
+ function approxEqual(a, b, tol = 1e-9) {
179
+ return Math.abs(a - b) < tol;
180
+ }
181
+ /** Igualdad punto a punto bajo tolerancia. */
182
+ function vectorsApproxEqual(a, b, tol = 1e-9) {
183
+ if (a.length !== b.length)
184
+ return false;
185
+ for (let i = 0; i < a.length; i++) {
186
+ if (!approxEqual(a[i], b[i], tol))
187
+ return false;
188
+ }
189
+ return true;
190
+ }
191
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/game-theory/types.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,6DAA6D;AAC7D,+DAA+D;AAC/D,EAAE;AACF,6DAA6D;AAC7D,+DAA+D;AAC/D,mDAAmD;AACnD,EAAE;AACF,qDAAqD;AACrD,EAAE;AACF,iEAAiE;AACjE,gEAAgE;AAChE,gEAAgE;AAChE,oDAAoD;;AAmCpD,wCAcC;AAGD,wCAYC;AAGD,sCAIC;AAKD,gCAoBC;AAOD,kDAwBC;AAGD,4BAOC;AAGD,sBAIC;AAGD,wCAOC;AAED,0EAuBC;AAGD,4CAIC;AAGD,kCAEC;AAGD,gDAMC;AA3KD,yCAAyC;AAEzC;;;GAGG;AACH,SAA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QAChB,CAAC;QACD,IAAI,IAAI,KAAK,CAAC;YAAE,SAAS;QACzB,MAAM,IAAI,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,uDAAuD;AACvD,SAAgB,gBAAgB,CAAC,CAAS,EAAE,IAAY;IACtD,MAAM,CAAC,GAAG,IAAI,KAAK,CAAS,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACT,OAAO,CAAC,CAAC;AACX,CAAC;AAED,kDAAkD;AAClD,SAAgB,WAAW,CAAC,CAAS,EAAE,CAAS,EAAE,GAAG,GAAG,IAAI;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;AAC/B,CAAC;AAED,8CAA8C;AAC9C,SAAgB,kBAAkB,CAAC,CAAW,EAAE,CAAW,EAAE,GAAG,GAAG,IAAI;IACrE,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,7 @@
1
+ export type { Type, TypeScheme, Expr } from './types';
2
+ export type { Substitution, UnifyResult } from './substitution';
3
+ export type { InferResult, InferOutcome, InferSchemeResult } from './infer';
4
+ export { TypeEnv, tVar, tConst, tArrow, tApp, scheme, mono, eVar, eLit, eApp, eAppN, eLam, eLet, eLetRec, eIf, TInt, TBool, TStr, typeFreeVars, schemeFreeVars, typeToString, schemeToString, } from './types';
5
+ export { emptySubst, applySubst, applySubstScheme, composeSubsts, freshTypeVar, resetFreshSupply, occursIn, unify, isUnifyError, generalize, instantiate, } from './substitution';
6
+ export { algorithmW, infer, inferScheme, isInferError, initialEnv, normalizeScheme } from './infer';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hindley-milner/index.ts"],"names":[],"mappings":"AAeA,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5E,OAAO,EACL,OAAO,EACP,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,GAAG,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,UAAU,EACV,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // Hindley-Milner — Punto de entrada público
4
+ // ============================================================
5
+ //
6
+ // Sistema de tipos let-polimórfico (Damas-Milner). Provee:
7
+ // - Sintaxis: Type, TypeScheme, Expr, TypeEnv.
8
+ // - Constructores breves: tVar, tConst, tArrow, tApp, eLam, eApp,
9
+ // eLet, eLetRec, eIf, eLit, eVar.
10
+ // - Algoritmo W: algorithmW / infer / inferScheme.
11
+ // - Unificación y sustituciones: unify, applySubst, composeSubsts,
12
+ // freshTypeVar, generalize, instantiate.
13
+ // - Entorno inicial con primitivos (+, ==, pair, cons, ...).
14
+ // - normalizeScheme: renombra tvars ligadas a a, b, c, ... para
15
+ // comparación estable en tests.
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.normalizeScheme = exports.initialEnv = exports.isInferError = exports.inferScheme = exports.infer = exports.algorithmW = exports.instantiate = exports.generalize = exports.isUnifyError = exports.unify = exports.occursIn = exports.resetFreshSupply = exports.freshTypeVar = exports.composeSubsts = exports.applySubstScheme = exports.applySubst = exports.emptySubst = exports.schemeToString = exports.typeToString = exports.schemeFreeVars = exports.typeFreeVars = exports.TStr = exports.TBool = exports.TInt = exports.eIf = exports.eLetRec = exports.eLet = exports.eLam = exports.eAppN = exports.eApp = exports.eLit = exports.eVar = exports.mono = exports.scheme = exports.tApp = exports.tArrow = exports.tConst = exports.tVar = exports.TypeEnv = void 0;
18
+ var types_1 = require("./types");
19
+ Object.defineProperty(exports, "TypeEnv", { enumerable: true, get: function () { return types_1.TypeEnv; } });
20
+ Object.defineProperty(exports, "tVar", { enumerable: true, get: function () { return types_1.tVar; } });
21
+ Object.defineProperty(exports, "tConst", { enumerable: true, get: function () { return types_1.tConst; } });
22
+ Object.defineProperty(exports, "tArrow", { enumerable: true, get: function () { return types_1.tArrow; } });
23
+ Object.defineProperty(exports, "tApp", { enumerable: true, get: function () { return types_1.tApp; } });
24
+ Object.defineProperty(exports, "scheme", { enumerable: true, get: function () { return types_1.scheme; } });
25
+ Object.defineProperty(exports, "mono", { enumerable: true, get: function () { return types_1.mono; } });
26
+ Object.defineProperty(exports, "eVar", { enumerable: true, get: function () { return types_1.eVar; } });
27
+ Object.defineProperty(exports, "eLit", { enumerable: true, get: function () { return types_1.eLit; } });
28
+ Object.defineProperty(exports, "eApp", { enumerable: true, get: function () { return types_1.eApp; } });
29
+ Object.defineProperty(exports, "eAppN", { enumerable: true, get: function () { return types_1.eAppN; } });
30
+ Object.defineProperty(exports, "eLam", { enumerable: true, get: function () { return types_1.eLam; } });
31
+ Object.defineProperty(exports, "eLet", { enumerable: true, get: function () { return types_1.eLet; } });
32
+ Object.defineProperty(exports, "eLetRec", { enumerable: true, get: function () { return types_1.eLetRec; } });
33
+ Object.defineProperty(exports, "eIf", { enumerable: true, get: function () { return types_1.eIf; } });
34
+ Object.defineProperty(exports, "TInt", { enumerable: true, get: function () { return types_1.TInt; } });
35
+ Object.defineProperty(exports, "TBool", { enumerable: true, get: function () { return types_1.TBool; } });
36
+ Object.defineProperty(exports, "TStr", { enumerable: true, get: function () { return types_1.TStr; } });
37
+ Object.defineProperty(exports, "typeFreeVars", { enumerable: true, get: function () { return types_1.typeFreeVars; } });
38
+ Object.defineProperty(exports, "schemeFreeVars", { enumerable: true, get: function () { return types_1.schemeFreeVars; } });
39
+ Object.defineProperty(exports, "typeToString", { enumerable: true, get: function () { return types_1.typeToString; } });
40
+ Object.defineProperty(exports, "schemeToString", { enumerable: true, get: function () { return types_1.schemeToString; } });
41
+ var substitution_1 = require("./substitution");
42
+ Object.defineProperty(exports, "emptySubst", { enumerable: true, get: function () { return substitution_1.emptySubst; } });
43
+ Object.defineProperty(exports, "applySubst", { enumerable: true, get: function () { return substitution_1.applySubst; } });
44
+ Object.defineProperty(exports, "applySubstScheme", { enumerable: true, get: function () { return substitution_1.applySubstScheme; } });
45
+ Object.defineProperty(exports, "composeSubsts", { enumerable: true, get: function () { return substitution_1.composeSubsts; } });
46
+ Object.defineProperty(exports, "freshTypeVar", { enumerable: true, get: function () { return substitution_1.freshTypeVar; } });
47
+ Object.defineProperty(exports, "resetFreshSupply", { enumerable: true, get: function () { return substitution_1.resetFreshSupply; } });
48
+ Object.defineProperty(exports, "occursIn", { enumerable: true, get: function () { return substitution_1.occursIn; } });
49
+ Object.defineProperty(exports, "unify", { enumerable: true, get: function () { return substitution_1.unify; } });
50
+ Object.defineProperty(exports, "isUnifyError", { enumerable: true, get: function () { return substitution_1.isUnifyError; } });
51
+ Object.defineProperty(exports, "generalize", { enumerable: true, get: function () { return substitution_1.generalize; } });
52
+ Object.defineProperty(exports, "instantiate", { enumerable: true, get: function () { return substitution_1.instantiate; } });
53
+ var infer_1 = require("./infer");
54
+ Object.defineProperty(exports, "algorithmW", { enumerable: true, get: function () { return infer_1.algorithmW; } });
55
+ Object.defineProperty(exports, "infer", { enumerable: true, get: function () { return infer_1.infer; } });
56
+ Object.defineProperty(exports, "inferScheme", { enumerable: true, get: function () { return infer_1.inferScheme; } });
57
+ Object.defineProperty(exports, "isInferError", { enumerable: true, get: function () { return infer_1.isInferError; } });
58
+ Object.defineProperty(exports, "initialEnv", { enumerable: true, get: function () { return infer_1.initialEnv; } });
59
+ Object.defineProperty(exports, "normalizeScheme", { enumerable: true, get: function () { return infer_1.normalizeScheme; } });
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hindley-milner/index.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,4CAA4C;AAC5C,+DAA+D;AAC/D,EAAE;AACF,2DAA2D;AAC3D,iDAAiD;AACjD,oEAAoE;AACpE,sCAAsC;AACtC,qDAAqD;AACrD,qEAAqE;AACrE,6CAA6C;AAC7C,+DAA+D;AAC/D,kEAAkE;AAClE,oCAAoC;;;AAMpC,iCAuBiB;AAtBf,gGAAA,OAAO,OAAA;AACP,6FAAA,IAAI,OAAA;AACJ,+FAAA,MAAM,OAAA;AACN,+FAAA,MAAM,OAAA;AACN,6FAAA,IAAI,OAAA;AACJ,+FAAA,MAAM,OAAA;AACN,6FAAA,IAAI,OAAA;AACJ,6FAAA,IAAI,OAAA;AACJ,6FAAA,IAAI,OAAA;AACJ,6FAAA,IAAI,OAAA;AACJ,8FAAA,KAAK,OAAA;AACL,6FAAA,IAAI,OAAA;AACJ,6FAAA,IAAI,OAAA;AACJ,gGAAA,OAAO,OAAA;AACP,4FAAA,GAAG,OAAA;AACH,6FAAA,IAAI,OAAA;AACJ,8FAAA,KAAK,OAAA;AACL,6FAAA,IAAI,OAAA;AACJ,qGAAA,YAAY,OAAA;AACZ,uGAAA,cAAc,OAAA;AACd,qGAAA,YAAY,OAAA;AACZ,uGAAA,cAAc,OAAA;AAGhB,+CAYwB;AAXtB,0GAAA,UAAU,OAAA;AACV,0GAAA,UAAU,OAAA;AACV,gHAAA,gBAAgB,OAAA;AAChB,6GAAA,aAAa,OAAA;AACb,4GAAA,YAAY,OAAA;AACZ,gHAAA,gBAAgB,OAAA;AAChB,wGAAA,QAAQ,OAAA;AACR,qGAAA,KAAK,OAAA;AACL,4GAAA,YAAY,OAAA;AACZ,0GAAA,UAAU,OAAA;AACV,2GAAA,WAAW,OAAA;AAGb,iCAAoG;AAA3F,mGAAA,UAAU,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,mGAAA,UAAU,OAAA;AAAE,wGAAA,eAAe,OAAA"}
@@ -0,0 +1,26 @@
1
+ import type { Expr, Type, TypeScheme } from './types';
2
+ import { TypeEnv } from './types';
3
+ import type { Substitution } from './substitution';
4
+ export interface InferResult {
5
+ type: Type;
6
+ subst: Substitution;
7
+ }
8
+ export type InferOutcome = InferResult | {
9
+ error: string;
10
+ };
11
+ export declare function isInferError(r: InferOutcome): r is {
12
+ error: string;
13
+ };
14
+ export declare function initialEnv(): TypeEnv;
15
+ export declare function algorithmW(expr: Expr, env: TypeEnv): InferOutcome;
16
+ export declare function infer(expr: Expr, env?: TypeEnv): InferOutcome;
17
+ export interface InferSchemeResult {
18
+ scheme: TypeScheme;
19
+ subst: Substitution;
20
+ type: Type;
21
+ }
22
+ export declare function inferScheme(expr: Expr, env?: TypeEnv): InferSchemeResult | {
23
+ error: string;
24
+ };
25
+ export declare function normalizeScheme(sc: TypeScheme): TypeScheme;
26
+ //# sourceMappingURL=infer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer.d.ts","sourceRoot":"","sources":["../../src/hindley-milner/infer.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAqB,OAAO,EAA4C,MAAM,SAAS,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAanD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3D,wBAAgB,YAAY,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,IAAI;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAEpE;AAOD,wBAAgB,UAAU,IAAI,OAAO,CA+CpC;AAGD,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAG,YAAY,CAsHjE;AAQD,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,GAAE,OAAsB,GAAG,YAAY,CAE3E;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,EACV,GAAG,GAAE,OAAsB,GAC1B,iBAAiB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAMvC;AAeD,wBAAgB,eAAe,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,CAyB1D"}