@proposit/proposit-core 0.12.3 → 1.0.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 (125) hide show
  1. package/README.md +104 -93
  2. package/dist/cli/commands/premises.d.ts.map +1 -1
  3. package/dist/cli/commands/premises.js +28 -24
  4. package/dist/cli/commands/premises.js.map +1 -1
  5. package/dist/cli/commands/repair.d.ts.map +1 -1
  6. package/dist/cli/commands/repair.js +4 -2
  7. package/dist/cli/commands/repair.js.map +1 -1
  8. package/dist/cli/commands/validate.d.ts.map +1 -1
  9. package/dist/cli/commands/validate.js +7 -1
  10. package/dist/cli/commands/validate.js.map +1 -1
  11. package/dist/cli/engine.d.ts.map +1 -1
  12. package/dist/cli/engine.js +7 -25
  13. package/dist/cli/engine.js.map +1 -1
  14. package/dist/cli/import.d.ts.map +1 -1
  15. package/dist/cli/import.js +66 -28
  16. package/dist/cli/import.js.map +1 -1
  17. package/dist/lib/core/argument-engine.d.ts +275 -10
  18. package/dist/lib/core/argument-engine.d.ts.map +1 -1
  19. package/dist/lib/core/argument-engine.js +442 -82
  20. package/dist/lib/core/argument-engine.js.map +1 -1
  21. package/dist/lib/core/argument-library.d.ts +5 -1
  22. package/dist/lib/core/argument-library.d.ts.map +1 -1
  23. package/dist/lib/core/argument-library.js +7 -3
  24. package/dist/lib/core/argument-library.js.map +1 -1
  25. package/dist/lib/core/expression-manager.d.ts +68 -73
  26. package/dist/lib/core/expression-manager.d.ts.map +1 -1
  27. package/dist/lib/core/expression-manager.js +272 -771
  28. package/dist/lib/core/expression-manager.js.map +1 -1
  29. package/dist/lib/core/fork.d.ts +5 -1
  30. package/dist/lib/core/fork.d.ts.map +1 -1
  31. package/dist/lib/core/fork.js +16 -6
  32. package/dist/lib/core/fork.js.map +1 -1
  33. package/dist/lib/core/interfaces/argument-engine.interfaces.d.ts +68 -7
  34. package/dist/lib/core/interfaces/argument-engine.interfaces.d.ts.map +1 -1
  35. package/dist/lib/core/interfaces/library.interfaces.d.ts +8 -3
  36. package/dist/lib/core/interfaces/library.interfaces.d.ts.map +1 -1
  37. package/dist/lib/core/interfaces/premise-engine.interfaces.d.ts +50 -47
  38. package/dist/lib/core/interfaces/premise-engine.interfaces.d.ts.map +1 -1
  39. package/dist/lib/core/premise-engine.d.ts +80 -11
  40. package/dist/lib/core/premise-engine.d.ts.map +1 -1
  41. package/dist/lib/core/premise-engine.js +245 -83
  42. package/dist/lib/core/premise-engine.js.map +1 -1
  43. package/dist/lib/core/proposit-core.d.ts.map +1 -1
  44. package/dist/lib/core/proposit-core.js +13 -3
  45. package/dist/lib/core/proposit-core.js.map +1 -1
  46. package/dist/lib/grammar/an-rules.d.ts +158 -0
  47. package/dist/lib/grammar/an-rules.d.ts.map +1 -0
  48. package/dist/lib/grammar/an-rules.js +778 -0
  49. package/dist/lib/grammar/an-rules.js.map +1 -0
  50. package/dist/lib/grammar/auto-normalize.d.ts +14 -0
  51. package/dist/lib/grammar/auto-normalize.d.ts.map +1 -0
  52. package/dist/lib/grammar/auto-normalize.js +35 -0
  53. package/dist/lib/grammar/auto-normalize.js.map +1 -0
  54. package/dist/lib/grammar/bounded-subtree.d.ts +30 -0
  55. package/dist/lib/grammar/bounded-subtree.d.ts.map +1 -0
  56. package/dist/lib/grammar/bounded-subtree.js +74 -0
  57. package/dist/lib/grammar/bounded-subtree.js.map +1 -0
  58. package/dist/lib/grammar/naked-q.d.ts +20 -0
  59. package/dist/lib/grammar/naked-q.d.ts.map +1 -0
  60. package/dist/lib/grammar/naked-q.js +58 -0
  61. package/dist/lib/grammar/naked-q.js.map +1 -0
  62. package/dist/lib/grammar/normalize.d.ts +12 -0
  63. package/dist/lib/grammar/normalize.d.ts.map +1 -0
  64. package/dist/lib/grammar/normalize.js +45 -0
  65. package/dist/lib/grammar/normalize.js.map +1 -0
  66. package/dist/lib/grammar/populate-from.d.ts +25 -0
  67. package/dist/lib/grammar/populate-from.d.ts.map +1 -0
  68. package/dist/lib/grammar/populate-from.js +252 -0
  69. package/dist/lib/grammar/populate-from.js.map +1 -0
  70. package/dist/lib/grammar/repair.d.ts +65 -0
  71. package/dist/lib/grammar/repair.d.ts.map +1 -0
  72. package/dist/lib/grammar/repair.js +251 -0
  73. package/dist/lib/grammar/repair.js.map +1 -0
  74. package/dist/lib/grammar/types.d.ts +17 -0
  75. package/dist/lib/grammar/types.d.ts.map +1 -0
  76. package/dist/lib/grammar/types.js +82 -0
  77. package/dist/lib/grammar/types.js.map +1 -0
  78. package/dist/lib/grammar/validate.d.ts +4 -0
  79. package/dist/lib/grammar/validate.d.ts.map +1 -0
  80. package/dist/lib/grammar/validate.js +28 -0
  81. package/dist/lib/grammar/validate.js.map +1 -0
  82. package/dist/lib/grammar/validators/context.d.ts +11 -0
  83. package/dist/lib/grammar/validators/context.d.ts.map +1 -0
  84. package/dist/lib/grammar/validators/context.js +5 -0
  85. package/dist/lib/grammar/validators/context.js.map +1 -0
  86. package/dist/lib/grammar/validators/derivable.d.ts +63 -0
  87. package/dist/lib/grammar/validators/derivable.d.ts.map +1 -0
  88. package/dist/lib/grammar/validators/derivable.js +502 -0
  89. package/dist/lib/grammar/validators/derivable.js.map +1 -0
  90. package/dist/lib/grammar/validators/evaluable.d.ts +48 -0
  91. package/dist/lib/grammar/validators/evaluable.d.ts.map +1 -0
  92. package/dist/lib/grammar/validators/evaluable.js +226 -0
  93. package/dist/lib/grammar/validators/evaluable.js.map +1 -0
  94. package/dist/lib/grammar/validators/presentable.d.ts +45 -0
  95. package/dist/lib/grammar/validators/presentable.d.ts.map +1 -0
  96. package/dist/lib/grammar/validators/presentable.js +231 -0
  97. package/dist/lib/grammar/validators/presentable.js.map +1 -0
  98. package/dist/lib/grammar/validators/structural.d.ts +103 -0
  99. package/dist/lib/grammar/validators/structural.d.ts.map +1 -0
  100. package/dist/lib/grammar/validators/structural.js +602 -0
  101. package/dist/lib/grammar/validators/structural.js.map +1 -0
  102. package/dist/lib/index.d.ts +4 -3
  103. package/dist/lib/index.d.ts.map +1 -1
  104. package/dist/lib/index.js +2 -2
  105. package/dist/lib/index.js.map +1 -1
  106. package/dist/lib/parsing/argument-parser.d.ts.map +1 -1
  107. package/dist/lib/parsing/argument-parser.js +52 -10
  108. package/dist/lib/parsing/argument-parser.js.map +1 -1
  109. package/dist/lib/types/evaluation.d.ts +1 -1
  110. package/dist/lib/types/evaluation.d.ts.map +1 -1
  111. package/dist/lib/types/fork.d.ts +12 -3
  112. package/dist/lib/types/fork.d.ts.map +1 -1
  113. package/dist/lib/types/validation.d.ts +0 -6
  114. package/dist/lib/types/validation.d.ts.map +1 -1
  115. package/dist/lib/types/validation.js +23 -6
  116. package/dist/lib/types/validation.js.map +1 -1
  117. package/package.json +1 -1
  118. package/dist/lib/core/managed-derivation-premise-engine.d.ts +0 -172
  119. package/dist/lib/core/managed-derivation-premise-engine.d.ts.map +0 -1
  120. package/dist/lib/core/managed-derivation-premise-engine.js +0 -550
  121. package/dist/lib/core/managed-derivation-premise-engine.js.map +0 -1
  122. package/dist/lib/types/grammar.d.ts +0 -83
  123. package/dist/lib/types/grammar.d.ts.map +0 -1
  124. package/dist/lib/types/grammar.js +0 -24
  125. package/dist/lib/types/grammar.js.map +0 -1
@@ -0,0 +1,502 @@
1
+ // Derivable-tier validators (D-1..D-6). Code 'D-7' is reserved — see spec
2
+ // §4.3 (derivation premise cardinality was restated as Evaluable E-6).
3
+ //
4
+ // D-1 derivation premise canonical shape (naked-Q or populated)
5
+ // D-2 single-citation derivation form (IMPLIES(c, Q), no surrounding OR)
6
+ // D-3 no mixing axioms and citations in one derivation
7
+ // D-4 axiomatic claim placement (only in derivation antecedent)
8
+ // D-5 citation claim placement (only in derivation antecedent)
9
+ // D-6 derivation premise role (supporting, not conclusion)
10
+ import { isClaimBound } from "../../schemata/propositional.js";
11
+ /**
12
+ * Build a Map<parentId, children-sorted-by-position> view of the expression
13
+ * tree.
14
+ */
15
+ function buildTChildMap(expressions) {
16
+ const out = new Map();
17
+ for (const e of expressions) {
18
+ if (e.parentId === null)
19
+ continue;
20
+ const list = out.get(e.parentId) ?? [];
21
+ list.push(e);
22
+ out.set(e.parentId, list);
23
+ }
24
+ for (const list of out.values()) {
25
+ list.sort((a, b) => a.position - b.position);
26
+ }
27
+ return out;
28
+ }
29
+ /**
30
+ * Walks down through transparent `formula` nodes, returning the first
31
+ * descendant that is not a formula. Per spec §4.3 D-1: the Presentable
32
+ * tier wraps `OR` in a formula buffer; validators must treat the buffer
33
+ * as transparent when matching the populated-form skeleton.
34
+ *
35
+ * Returns the input expression itself if it is not a formula. Returns
36
+ * undefined if a malformed formula (0 or >1 children) breaks the walk —
37
+ * higher-level callers can treat that as a shape-mismatch.
38
+ */
39
+ function peelFormulas(expr, children) {
40
+ let cursor = expr;
41
+ while (cursor?.type === "formula") {
42
+ const kids = children.get(cursor.id) ?? [];
43
+ if (kids.length !== 1)
44
+ return undefined;
45
+ cursor = kids[0];
46
+ }
47
+ return cursor;
48
+ }
49
+ /**
50
+ * Group expressions by premise.
51
+ */
52
+ function groupExpressionsByPremise(expressions) {
53
+ const out = new Map();
54
+ for (const e of expressions) {
55
+ const list = out.get(e.premiseId) ?? [];
56
+ list.push(e);
57
+ out.set(e.premiseId, list);
58
+ }
59
+ return out;
60
+ }
61
+ /**
62
+ * Map variableId → its claim record (claim-bound variables only).
63
+ */
64
+ function buildVarToClaim(ctx) {
65
+ const claimById = new Map();
66
+ for (const c of ctx.claims)
67
+ claimById.set(c.id, c);
68
+ const out = new Map();
69
+ for (const v of ctx.variables) {
70
+ if (!isClaimBound(v))
71
+ continue;
72
+ const claim = claimById.get(v.claimId);
73
+ if (claim !== undefined)
74
+ out.set(v.id, claim);
75
+ }
76
+ return out;
77
+ }
78
+ /**
79
+ * Collect every variable expression in the subtree rooted at `start`,
80
+ * walking through all descendants. Used by D-3 (collect antecedent
81
+ * variables) and D-4/D-5 placement scans.
82
+ */
83
+ function collectVariableExpressionsInSubtree(start, children) {
84
+ const out = [];
85
+ const stack = [start];
86
+ while (stack.length > 0) {
87
+ const cursor = stack.pop();
88
+ if (cursor.type === "variable")
89
+ out.push(cursor);
90
+ const kids = children.get(cursor.id) ?? [];
91
+ stack.push(...kids);
92
+ }
93
+ return out;
94
+ }
95
+ /**
96
+ * For a `type='derivation'` premise, find the root expression
97
+ * (parentId === null) within that premise. Returns undefined if no root
98
+ * exists or multiple roots exist (other validators flag those).
99
+ */
100
+ function findPremiseRoot(premiseId, grouped) {
101
+ const exprs = grouped.get(premiseId) ?? [];
102
+ const roots = exprs.filter((e) => e.parentId === null);
103
+ if (roots.length !== 1)
104
+ return undefined;
105
+ return roots[0];
106
+ }
107
+ // ---- Validators -------------------------------------------------------
108
+ /**
109
+ * D-1 — Derivation premise canonical shape. Every `type='derivation'`
110
+ * premise's tree matches one of two canonical forms:
111
+ *
112
+ * - **Naked-Q**: a single `variable` expression at the root, bound to
113
+ * `derivedClaimId`.
114
+ * - **Populated**: root `IMPLIES` with consequent at position 1 (variable
115
+ * bound to `derivedClaimId`); antecedent at position 0, after peeling
116
+ * formula buffers, is either a single claim-bound variable
117
+ * (citation/axiomatic) — see D-2 — or an `OR` whose children (each
118
+ * peeled of formulas) are all claim-bound variables of the same
119
+ * grounding type. IFF at root fails D-1 (Structurally allowed per
120
+ * S-14; D-1 narrows derivation premise root to IMPLIES).
121
+ *
122
+ * Wrong-root-operator cases (and/or/not/formula at root) are already
123
+ * caught by Structural S-14; D-1 silently skips them.
124
+ */
125
+ export function validateD1(ctx) {
126
+ const violations = [];
127
+ const children = buildTChildMap(ctx.expressions);
128
+ const grouped = groupExpressionsByPremise(ctx.expressions);
129
+ const varToClaim = buildVarToClaim(ctx);
130
+ for (const p of ctx.premises) {
131
+ if (p.type !== "derivation")
132
+ continue;
133
+ const root = findPremiseRoot(p.id, grouped);
134
+ if (root === undefined)
135
+ continue;
136
+ // Naked-Q: single variable at root bound to derivedClaimId.
137
+ if (root.type === "variable") {
138
+ const claim = varToClaim.get(root.variableId);
139
+ if (claim?.id !== p.derivedClaimId) {
140
+ violations.push({
141
+ tier: "derivable",
142
+ code: "D-1",
143
+ message: `derivation premise ${p.id} naked-Q root variable is not bound to derivedClaimId ${p.derivedClaimId}`,
144
+ argumentId: ctx.argument.id,
145
+ premiseId: p.id,
146
+ expressionId: root.id,
147
+ });
148
+ }
149
+ continue;
150
+ }
151
+ // Populated form requires root='implies'. IFF at root is a D-1
152
+ // violation. Any other operator type (and/or/not/formula) is
153
+ // caught by S-14; D-1 skips silently.
154
+ if (root.type !== "operator")
155
+ continue;
156
+ if (root.operator === "iff") {
157
+ violations.push({
158
+ tier: "derivable",
159
+ code: "D-1",
160
+ message: `derivation premise ${p.id} has IFF at root; populated form must be IMPLIES`,
161
+ argumentId: ctx.argument.id,
162
+ premiseId: p.id,
163
+ expressionId: root.id,
164
+ });
165
+ continue;
166
+ }
167
+ if (root.operator !== "implies")
168
+ continue;
169
+ // Populated form: check consequent at position 1.
170
+ const kids = children.get(root.id) ?? [];
171
+ if (kids.length !== 2) {
172
+ violations.push({
173
+ tier: "derivable",
174
+ code: "D-1",
175
+ message: `derivation premise ${p.id} populated form has ${kids.length} root children (expected 2)`,
176
+ argumentId: ctx.argument.id,
177
+ premiseId: p.id,
178
+ expressionId: root.id,
179
+ });
180
+ continue;
181
+ }
182
+ const consequent = kids[1];
183
+ if (consequent.type !== "variable") {
184
+ violations.push({
185
+ tier: "derivable",
186
+ code: "D-1",
187
+ message: `derivation premise ${p.id} consequent slot must be a variable expression`,
188
+ argumentId: ctx.argument.id,
189
+ premiseId: p.id,
190
+ expressionId: consequent.id,
191
+ });
192
+ continue;
193
+ }
194
+ const consequentClaim = varToClaim.get(consequent.variableId);
195
+ if (consequentClaim?.id !== p.derivedClaimId) {
196
+ violations.push({
197
+ tier: "derivable",
198
+ code: "D-1",
199
+ message: `derivation premise ${p.id} consequent variable is not bound to derivedClaimId ${p.derivedClaimId}`,
200
+ argumentId: ctx.argument.id,
201
+ premiseId: p.id,
202
+ expressionId: consequent.id,
203
+ });
204
+ continue;
205
+ }
206
+ // Antecedent at position 0, peeled of formula buffers.
207
+ const antecedent = peelFormulas(kids[0], children);
208
+ if (antecedent === undefined) {
209
+ violations.push({
210
+ tier: "derivable",
211
+ code: "D-1",
212
+ message: `derivation premise ${p.id} antecedent has malformed formula buffer`,
213
+ argumentId: ctx.argument.id,
214
+ premiseId: p.id,
215
+ expressionId: kids[0].id,
216
+ });
217
+ continue;
218
+ }
219
+ const valid = antecedentMatchesPopulatedForm(antecedent, children, varToClaim);
220
+ if (!valid) {
221
+ violations.push({
222
+ tier: "derivable",
223
+ code: "D-1",
224
+ message: `derivation premise ${p.id} antecedent shape does not match populated form (single claim variable or OR of same-grounding claim variables)`,
225
+ argumentId: ctx.argument.id,
226
+ premiseId: p.id,
227
+ expressionId: antecedent.id,
228
+ });
229
+ }
230
+ }
231
+ return violations;
232
+ }
233
+ /**
234
+ * Returns true when `antecedent` is one of:
235
+ * - A variable expression bound to a citation or axiomatic claim.
236
+ * - An `or` operator whose children (each peeled of formulas) are all
237
+ * variable expressions bound to citation or axiomatic claims of the
238
+ * same grounding type.
239
+ *
240
+ * D-2 (single-citation form) and D-3 (no mixing) are separate validators
241
+ * that emit their own codes; this helper only answers the D-1 question.
242
+ */
243
+ function antecedentMatchesPopulatedForm(antecedent, children, varToClaim) {
244
+ if (antecedent.type === "variable") {
245
+ const claim = varToClaim.get(antecedent.variableId);
246
+ if (claim === undefined)
247
+ return false;
248
+ return claim.type === "citation" || claim.type === "axiomatic";
249
+ }
250
+ if (antecedent.type !== "operator" || antecedent.operator !== "or") {
251
+ return false;
252
+ }
253
+ const orChildren = children.get(antecedent.id) ?? [];
254
+ // Multi-citation populated form requires ≥ 2 children. A 1-child OR
255
+ // is not valid populated form — the single-grounding case is
256
+ // `IMPLIES(claim-var, Q)` without an OR wrapper (D-2). Without this
257
+ // ≥-2 floor, `IMPLIES(OR(single-citation), Q)` would pass D-1
258
+ // silently and only D-2 would fire; consumers gating on a clean D-1
259
+ // would accept invalid shape.
260
+ if (orChildren.length < 2)
261
+ return false;
262
+ for (const child of orChildren) {
263
+ const peeled = peelFormulas(child, children);
264
+ if (peeled === undefined)
265
+ return false;
266
+ if (peeled.type !== "variable")
267
+ return false;
268
+ const claim = varToClaim.get(peeled.variableId);
269
+ if (claim === undefined)
270
+ return false;
271
+ if (claim.type !== "citation" && claim.type !== "axiomatic") {
272
+ return false;
273
+ }
274
+ }
275
+ return true;
276
+ }
277
+ /**
278
+ * D-2 — Single-citation derivation form. If a derivation premise has a
279
+ * populated form whose antecedent (peeled of formula buffers) is an `OR`
280
+ * with exactly one child (also peeled of formulas), that's wrong — the
281
+ * canonical single-grounding form is `IMPLIES(claim-var, Q)` without the
282
+ * `OR` wrapper.
283
+ *
284
+ * Note: a 1-child `OR` also fails E-1 (variadic ≥ 2) and P-4
285
+ * (single-child binary). D-2 is the Derivable-tier UI hint specifically
286
+ * naming the "drop the OR wrapper" remediation.
287
+ */
288
+ export function validateD2(ctx) {
289
+ const violations = [];
290
+ const children = buildTChildMap(ctx.expressions);
291
+ const grouped = groupExpressionsByPremise(ctx.expressions);
292
+ for (const p of ctx.premises) {
293
+ if (p.type !== "derivation")
294
+ continue;
295
+ const root = findPremiseRoot(p.id, grouped);
296
+ if (root === undefined)
297
+ continue;
298
+ if (root.type !== "operator" || root.operator !== "implies")
299
+ continue;
300
+ const kids = children.get(root.id) ?? [];
301
+ if (kids.length < 1)
302
+ continue;
303
+ const antecedent = peelFormulas(kids[0], children);
304
+ if (antecedent === undefined)
305
+ continue;
306
+ if (antecedent.type !== "operator" || antecedent.operator !== "or") {
307
+ continue;
308
+ }
309
+ const orChildren = children.get(antecedent.id) ?? [];
310
+ if (orChildren.length === 1) {
311
+ violations.push({
312
+ tier: "derivable",
313
+ code: "D-2",
314
+ message: `derivation premise ${p.id} antecedent is OR with a single child; drop the OR wrapper`,
315
+ argumentId: ctx.argument.id,
316
+ premiseId: p.id,
317
+ expressionId: antecedent.id,
318
+ });
319
+ }
320
+ }
321
+ return violations;
322
+ }
323
+ /**
324
+ * D-3 — No mixing axioms and citations in one derivation. For each
325
+ * derivation premise's populated form, collect all claim-bound variables
326
+ * in the antecedent subtree. If they bind to claims of more than one
327
+ * grounding type (citation vs axiomatic), emit D-3.
328
+ *
329
+ * Formula nodes are traversed transparently by
330
+ * `collectVariableExpressionsInSubtree`'s plain DFS descent — no
331
+ * explicit `peelFormulas` call needed for D-3, since the DFS visits
332
+ * formula descendants like any other node and the variable collector
333
+ * picks up the claim-bound variables regardless of nesting depth.
334
+ */
335
+ export function validateD3(ctx) {
336
+ const violations = [];
337
+ const children = buildTChildMap(ctx.expressions);
338
+ const grouped = groupExpressionsByPremise(ctx.expressions);
339
+ const varToClaim = buildVarToClaim(ctx);
340
+ for (const p of ctx.premises) {
341
+ if (p.type !== "derivation")
342
+ continue;
343
+ const root = findPremiseRoot(p.id, grouped);
344
+ if (root === undefined)
345
+ continue;
346
+ if (root.type !== "operator" || root.operator !== "implies")
347
+ continue;
348
+ const kids = children.get(root.id) ?? [];
349
+ if (kids.length < 1)
350
+ continue;
351
+ const antecedent = kids[0];
352
+ const varExprs = collectVariableExpressionsInSubtree(antecedent, children);
353
+ const groundingTypes = new Set();
354
+ for (const ve of varExprs) {
355
+ const claim = varToClaim.get(ve.variableId);
356
+ if (claim === undefined)
357
+ continue;
358
+ if (claim.type === "citation" || claim.type === "axiomatic") {
359
+ groundingTypes.add(claim.type);
360
+ }
361
+ }
362
+ if (groundingTypes.size > 1) {
363
+ violations.push({
364
+ tier: "derivable",
365
+ code: "D-3",
366
+ message: `derivation premise ${p.id} antecedent mixes axiom and citation grounding`,
367
+ argumentId: ctx.argument.id,
368
+ premiseId: p.id,
369
+ expressionId: antecedent.id,
370
+ });
371
+ }
372
+ }
373
+ return violations;
374
+ }
375
+ /**
376
+ * Returns true when `expr` is in the antecedent subtree (position-0
377
+ * descendants of root IMPLIES) of a derivation premise. Used by D-4/D-5
378
+ * to determine whether a typed-claim variable expression is in a
379
+ * permissible location.
380
+ *
381
+ * Returns false for variables in freeform premises, variables at the
382
+ * consequent slot of a derivation premise's IMPLIES, and variables at the
383
+ * naked-Q root of a derivation premise.
384
+ */
385
+ function isInDerivationAntecedent(expr, premiseType, children, expressionsById, grouped) {
386
+ if (premiseType !== "derivation")
387
+ return false;
388
+ const root = findPremiseRoot(expr.premiseId, grouped);
389
+ if (root === undefined)
390
+ return false;
391
+ // Naked-Q: the root variable is the consequent, not the antecedent.
392
+ if (root.type === "variable")
393
+ return false;
394
+ if (root.type !== "operator" || root.operator !== "implies")
395
+ return false;
396
+ const kids = children.get(root.id) ?? [];
397
+ if (kids.length < 1)
398
+ return false;
399
+ const antecedentRoot = kids[0];
400
+ // Walk up from expr's parent until we either reach the antecedent root
401
+ // (in scope) or reach the IMPLIES root via the consequent path (out of scope).
402
+ let cursor = expr.id;
403
+ while (cursor !== null) {
404
+ if (cursor === antecedentRoot.id)
405
+ return true;
406
+ if (cursor === root.id)
407
+ return false;
408
+ const node = expressionsById.get(cursor);
409
+ if (node === undefined)
410
+ return false;
411
+ cursor = node.parentId;
412
+ }
413
+ return false;
414
+ }
415
+ /**
416
+ * Common implementation for D-4 / D-5: variables bound to a particular
417
+ * claim type appear only in derivation premise antecedents.
418
+ */
419
+ function validateClaimPlacement(ctx, claimType, code) {
420
+ const violations = [];
421
+ const children = buildTChildMap(ctx.expressions);
422
+ const grouped = groupExpressionsByPremise(ctx.expressions);
423
+ const varToClaim = buildVarToClaim(ctx);
424
+ const premiseTypeById = new Map();
425
+ for (const p of ctx.premises)
426
+ premiseTypeById.set(p.id, p.type);
427
+ const expressionsById = new Map();
428
+ for (const e of ctx.expressions)
429
+ expressionsById.set(e.id, e);
430
+ for (const e of ctx.expressions) {
431
+ if (e.type !== "variable")
432
+ continue;
433
+ const claim = varToClaim.get(e.variableId);
434
+ if (claim?.type !== claimType)
435
+ continue;
436
+ const premiseType = premiseTypeById.get(e.premiseId);
437
+ if (premiseType === undefined)
438
+ continue;
439
+ const allowed = isInDerivationAntecedent(e, premiseType, children, expressionsById, grouped);
440
+ if (!allowed) {
441
+ violations.push({
442
+ tier: "derivable",
443
+ code,
444
+ message: `${claimType}-bound variable expression ${e.id} appears outside a derivation premise antecedent`,
445
+ argumentId: ctx.argument.id,
446
+ premiseId: e.premiseId,
447
+ expressionId: e.id,
448
+ claimId: claim.id,
449
+ variableId: e.variableId,
450
+ });
451
+ }
452
+ }
453
+ return violations;
454
+ }
455
+ /**
456
+ * D-4 — Axiomatic claim placement. Variables bound to `type='axiomatic'`
457
+ * claims appear only in the antecedent of a derivation premise, never in
458
+ * freeform premises and never in a derivation premise's consequent slot.
459
+ */
460
+ export function validateD4(ctx) {
461
+ return validateClaimPlacement(ctx, "axiomatic", "D-4");
462
+ }
463
+ /**
464
+ * D-5 — Citation claim placement. Mirror of D-4 for citation claims.
465
+ */
466
+ export function validateD5(ctx) {
467
+ return validateClaimPlacement(ctx, "citation", "D-5");
468
+ }
469
+ /**
470
+ * D-6 — Derivation premise role. Every `type='derivation'` premise has
471
+ * `role='supporting'` — concretely, `roleState.conclusionPremiseId !==
472
+ * premise.id`.
473
+ */
474
+ export function validateD6(ctx) {
475
+ const violations = [];
476
+ for (const p of ctx.premises) {
477
+ if (p.type !== "derivation")
478
+ continue;
479
+ if (ctx.roleState.conclusionPremiseId === p.id) {
480
+ violations.push({
481
+ tier: "derivable",
482
+ code: "D-6",
483
+ message: `derivation premise ${p.id} is designated as conclusion; derivation premises must be supporting`,
484
+ argumentId: ctx.argument.id,
485
+ premiseId: p.id,
486
+ });
487
+ }
488
+ }
489
+ return violations;
490
+ }
491
+ // 'D-7' reserved — not used.
492
+ export function validateDerivable(ctx) {
493
+ return [
494
+ ...validateD1(ctx),
495
+ ...validateD2(ctx),
496
+ ...validateD3(ctx),
497
+ ...validateD4(ctx),
498
+ ...validateD5(ctx),
499
+ ...validateD6(ctx),
500
+ ];
501
+ }
502
+ //# sourceMappingURL=derivable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derivable.js","sourceR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AC,mBAAmB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;YAC7C,UAAU,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,sBAAsB,CAAC,CAAC,EAAE,sEAAsE;gBACzG,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE;gBAC3B,SAAS,EAAE,CAAC,CAAC,EAAE;aAClB,CAAC,CAAA;QACN,CAAC;IACL,CAAC;IACD,OAAO,UAAU,CAAA;AACrB,CAAC;AAED,6BAA6B;AAE7B,MAAM,UAAU,iBAAiB,CAC7B,GAAsB;IAEtB,OAAO;QACH,GAAG,UAAU,CAAC,GAAG,CAAC;QAClB,GAAG,UAAU,CAAC,GAAG,CAAC;QAClB,GAAG,UAAU,CAAC,GAAG,CAAC;QAClB,GAAG,UAAU,CAAC,GAAG,CAAC;QAClB,GAAG,UAAU,CAAC,GAAG,CAAC;QAClB,GAAG,UAAU,CAAC,GAAG,CAAC;KACrB,CAAA;AACL,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { TViolation } from "../types.js";
2
+ import type { TValidatorContext } from "./context.js";
3
+ /**
4
+ * E-1 — Variadic operator arity floor. `and` and `or` each have at least
5
+ * two children. (Unary `not`/`formula` are constrained Structurally per
6
+ * S-12/S-13; binary `implies`/`iff` per S-8.)
7
+ */
8
+ export declare function validateE1(ctx: TValidatorContext): readonly TViolation[];
9
+ /**
10
+ * E-3 — Variable binding resolves. Every variable's claim or premise
11
+ * reference points at an existing target. External premise bindings
12
+ * (`boundArgumentId !== argument.id`) resolve in a different argument
13
+ * and are out of scope here — those targets aren't in this context.
14
+ */
15
+ export declare function validateE3(ctx: TValidatorContext): readonly TViolation[];
16
+ /**
17
+ * E-4 — Axiomatic-binding constraint. Axiomatic-bound variables must not
18
+ * be assigned in the caller's evaluation input. This is a **runtime
19
+ * guard** on caller-supplied input, not an AST invariant — the check
20
+ * runs inside `ArgumentEngine.evaluate` / `.checkValidity` and rejects
21
+ * pre-flight with the engine-error code `AXIOM_VARIABLE_ASSIGNMENT_FORBIDDEN`.
22
+ * The AST-level validator cannot detect E-4 from the argument tree alone
23
+ * and intentionally returns an empty array.
24
+ */
25
+ export declare function validateE4(_ctx: TValidatorContext): readonly TViolation[];
26
+ /**
27
+ * E-5 — Derivation premise consequent present. Every `type='derivation'`
28
+ * premise's expression tree includes a variable bound to its
29
+ * `derivedClaimId`. Naked-Q satisfies this (the lone variable at the
30
+ * root *is* the consequent).
31
+ */
32
+ export declare function validateE5(ctx: TValidatorContext): readonly TViolation[];
33
+ /**
34
+ * E-6 — Claim-derivation pairing. For every `type='normal'` claim
35
+ * referenced in the argument, at most one `type='derivation'` premise
36
+ * exists with `derivedClaimId` matching that claim. Zero is valid (the
37
+ * post-publish-pruning state); two or more is the violation.
38
+ */
39
+ export declare function validateE6(ctx: TValidatorContext): readonly TViolation[];
40
+ /**
41
+ * E-7 — Argument has conclusion premise. An argument that has at least
42
+ * one premise has exactly one premise designated as the conclusion via
43
+ * `roleState.conclusionPremiseId`. A brand-new argument with zero
44
+ * premises is exempt.
45
+ */
46
+ export declare function validateE7(ctx: TValidatorContext): readonly TViolation[];
47
+ export declare function validateEvaluable(ctx: TValidatorContext): readonly TViolation[];
48
+ //# sourceMappingURL=evaluable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluable.d.ts","sourceRoot":"","sources":["../../../../src/lib/grammar/validators/evaluable.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAkBrD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,UAAU,EAAE,CAmBxE;AAID;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,UAAU,EAAE,CAkCxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,UAAU,EAAE,CAEzE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,UAAU,EAAE,CAkCxE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,UAAU,EAAE,CA6BxE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,UAAU,EAAE,CA0BxE;AAED,wBAAgB,iBAAiB,CAC7B,GAAG,EAAE,iBAAiB,GACvB,SAAS,UAAU,EAAE,CASvB"}