@polintpro/proposit-core 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/core/relationships.d.ts +15 -0
- package/dist/lib/core/relationships.d.ts.map +1 -0
- package/dist/lib/core/relationships.js +319 -0
- package/dist/lib/core/relationships.js.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/types/relationships.d.ts +36 -0
- package/dist/lib/types/relationships.d.ts.map +1 -0
- package/dist/lib/types/relationships.js +2 -0
- package/dist/lib/types/relationships.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,8 +178,13 @@ eng.setConclusionPremise(conclusion.getId())
|
|
|
178
178
|
|
|
179
179
|
### Evaluating an argument
|
|
180
180
|
|
|
181
|
+
Assignments use `TCoreExpressionAssignment`, which carries both variable truth values (three-valued: `true`, `false`, or `null` for unknown) and a list of rejected expression IDs:
|
|
182
|
+
|
|
181
183
|
```typescript
|
|
182
|
-
const result = eng.evaluate({
|
|
184
|
+
const result = eng.evaluate({
|
|
185
|
+
variables: { "var-p": true, "var-q": true },
|
|
186
|
+
rejectedExpressionIds: [],
|
|
187
|
+
})
|
|
183
188
|
if (result.ok) {
|
|
184
189
|
console.log(result.conclusionTrue) // true
|
|
185
190
|
console.log(result.allSupportingPremisesTrue) // true
|
|
@@ -354,7 +359,7 @@ Checks whether the argument is structurally ready to evaluate. Returns `{ ok, is
|
|
|
354
359
|
|
|
355
360
|
#### `evaluate(assignment, options?)` → `TArgumentEvaluationResult`
|
|
356
361
|
|
|
357
|
-
Evaluates all relevant premises under the given
|
|
362
|
+
Evaluates all relevant premises under the given expression assignment (`TCoreExpressionAssignment`). The assignment contains `variables` (a `Record<string, boolean | null>`) and `rejectedExpressionIds` (expression IDs that evaluate to `false` with children skipped). Returns per-premise truth values, counterexample status, and an admissibility flag.
|
|
358
363
|
|
|
359
364
|
Options:
|
|
360
365
|
|
|
@@ -495,6 +500,73 @@ Returns a serialisable snapshot of this premise (`{ id, title, type, rootExpress
|
|
|
495
500
|
|
|
496
501
|
---
|
|
497
502
|
|
|
503
|
+
### Standalone Functions
|
|
504
|
+
|
|
505
|
+
#### `diffArguments(engineA, engineB, options?)` → `TCoreArgumentDiff`
|
|
506
|
+
|
|
507
|
+
Compares two `ArgumentEngine` instances and returns a structured diff covering argument metadata, variables, premises (with nested expression diffs), and role changes. Each entity category reports added, removed, and modified items with field-level change details.
|
|
508
|
+
|
|
509
|
+
Options allow plugging custom comparators per entity type via `TCoreDiffOptions`:
|
|
510
|
+
|
|
511
|
+
```typescript
|
|
512
|
+
import { diffArguments, defaultCompareVariable } from "@polintpro/proposit-core"
|
|
513
|
+
|
|
514
|
+
const diff = diffArguments(engineA, engineB, {
|
|
515
|
+
compareVariable: (before, after) => {
|
|
516
|
+
// Wrap the default comparator with custom logic
|
|
517
|
+
return defaultCompareVariable(before, after)
|
|
518
|
+
},
|
|
519
|
+
})
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
Default comparators are also exported: `defaultCompareArgument`, `defaultCompareVariable`, `defaultComparePremise`, `defaultCompareExpression`.
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
#### `analyzePremiseRelationships(engine, focusedPremiseId)` → `TCorePremiseRelationshipAnalysis`
|
|
527
|
+
|
|
528
|
+
Analyzes how every other premise in the argument relates to a focused premise, classifying each as:
|
|
529
|
+
|
|
530
|
+
| Category | Meaning |
|
|
531
|
+
| --------------- | ------------------------------------------------------------------------ |
|
|
532
|
+
| `supporting` | Consequent feeds into the focused premise's antecedent (helps it fire) |
|
|
533
|
+
| `contradicting` | Infers values that negate the focused premise's antecedent or consequent |
|
|
534
|
+
| `restricting` | Constrains shared variables without clear support or contradiction |
|
|
535
|
+
| `downstream` | Takes the focused premise's consequent as input (inference flows away) |
|
|
536
|
+
| `unrelated` | No variable overlap, even transitively |
|
|
537
|
+
|
|
538
|
+
Each result includes per-variable relationship details and a `transitive` flag.
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
import { analyzePremiseRelationships } from "@polintpro/proposit-core"
|
|
542
|
+
|
|
543
|
+
const analysis = analyzePremiseRelationships(engine, conclusionPremiseId)
|
|
544
|
+
for (const r of analysis.premises) {
|
|
545
|
+
console.log(`${r.premiseId}: ${r.relationship}`)
|
|
546
|
+
}
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
#### `buildPremiseProfile(premise)` → `TCorePremiseProfile`
|
|
552
|
+
|
|
553
|
+
Builds a profile of a premise's variable appearances, recording each variable's side (`antecedent` or `consequent`) and polarity (`positive` or `negative`, determined by negation depth). Used internally by `analyzePremiseRelationships` but also exported for direct use.
|
|
554
|
+
|
|
555
|
+
---
|
|
556
|
+
|
|
557
|
+
#### `parseFormula(input)` → `FormulaAST`
|
|
558
|
+
|
|
559
|
+
Parses a logical formula string into an AST. Supports standard logical notation with operators `not`/`¬`, `and`/`∧`, `or`/`∨`, `implies`/`→`, `iff`/`↔`, and parentheses for grouping.
|
|
560
|
+
|
|
561
|
+
```typescript
|
|
562
|
+
import { parseFormula } from "@polintpro/proposit-core"
|
|
563
|
+
import type { FormulaAST } from "@polintpro/proposit-core"
|
|
564
|
+
|
|
565
|
+
const ast: FormulaAST = parseFormula("(P and Q) implies R")
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
498
570
|
## CLI
|
|
499
571
|
|
|
500
572
|
The package ships a command-line interface for managing arguments stored on disk.
|
|
@@ -657,6 +729,8 @@ proposit-core <id> <ver> analysis list [--json]
|
|
|
657
729
|
proposit-core <id> <ver> analysis show [--file <filename>] [--json]
|
|
658
730
|
proposit-core <id> <ver> analysis set <symbol> <true|false> [--file <filename>]
|
|
659
731
|
proposit-core <id> <ver> analysis reset [--file <filename>] [--value <true|false>]
|
|
732
|
+
proposit-core <id> <ver> analysis reject <expression_id> [--file <filename>]
|
|
733
|
+
proposit-core <id> <ver> analysis accept <expression_id> [--file <filename>]
|
|
660
734
|
proposit-core <id> <ver> analysis validate-assignments [--file <filename>] [--json]
|
|
661
735
|
proposit-core <id> <ver> analysis delete [--file <filename>] [--confirm]
|
|
662
736
|
proposit-core <id> <ver> analysis evaluate [--file <filename>] [options]
|
|
@@ -668,6 +742,8 @@ proposit-core <id> <ver> analysis export [--json]
|
|
|
668
742
|
|
|
669
743
|
`--file` defaults to `analysis.json` throughout. Key subcommands:
|
|
670
744
|
|
|
745
|
+
- **`reject`** — marks an expression as rejected (it will evaluate to `false` and its children are skipped).
|
|
746
|
+
- **`accept`** — removes an expression from the rejected list (restores normal computation).
|
|
671
747
|
- **`evaluate`** — resolves symbol→ID, evaluates the argument, reports admissibility, counterexample status, and whether the conclusion is true.
|
|
672
748
|
- **`check-validity`** — runs the full truth-table search (`--mode first-counterexample|exhaustive`).
|
|
673
749
|
- **`validate-argument`** — checks structural readiness (conclusion set, inference premises, etc.).
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export { ArgumentEngine, PremiseManager } from "./lib/index.js";
|
|
|
10
10
|
export * from "./lib/schemata/index.js";
|
|
11
11
|
export * from "./lib/types/diff.js";
|
|
12
12
|
export { diffArguments, defaultCompareArgument, defaultCompareVariable, defaultComparePremise, defaultCompareExpression, } from "./lib/core/diff.js";
|
|
13
|
+
export * from "./lib/types/relationships.js";
|
|
14
|
+
export { analyzePremiseRelationships, buildPremiseProfile, } from "./lib/core/relationships.js";
|
|
13
15
|
export { parseFormula } from "./lib/core/parser/formula.js";
|
|
14
16
|
export type { FormulaAST } from "./lib/core/parser/formula.js";
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,YAAY,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,oBAAoB,CAAA;AAC3B,cAAc,8BAA8B,CAAA;AAC5C,OAAO,EACH,2BAA2B,EAC3B,mBAAmB,GACtB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,YAAY,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -10,5 +10,7 @@ export { ArgumentEngine, PremiseManager } from "./lib/index.js";
|
|
|
10
10
|
export * from "./lib/schemata/index.js";
|
|
11
11
|
export * from "./lib/types/diff.js";
|
|
12
12
|
export { diffArguments, defaultCompareArgument, defaultCompareVariable, defaultComparePremise, defaultCompareExpression, } from "./lib/core/diff.js";
|
|
13
|
+
export * from "./lib/types/relationships.js";
|
|
14
|
+
export { analyzePremiseRelationships, buildPremiseProfile, } from "./lib/core/relationships.js";
|
|
13
15
|
export { parseFormula } from "./lib/core/parser/formula.js";
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,oBAAoB,CAAA;AAC3B,cAAc,8BAA8B,CAAA;AAC5C,OAAO,EACH,2BAA2B,EAC3B,mBAAmB,GACtB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ArgumentEngine } from "./ArgumentEngine.js";
|
|
2
|
+
import type { PremiseManager } from "./PremiseManager.js";
|
|
3
|
+
import type { TCorePremiseProfile, TCorePremiseRelationshipAnalysis } from "../types/relationships.js";
|
|
4
|
+
/**
|
|
5
|
+
* Builds a profile of a premise's variable appearances, recording each
|
|
6
|
+
* variable's side (antecedent/consequent) and polarity (positive/negative).
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildPremiseProfile(premise: PremiseManager): TCorePremiseProfile;
|
|
9
|
+
/**
|
|
10
|
+
* Analyzes how every other premise in the argument relates to the focused
|
|
11
|
+
* premise, classifying each as supporting, contradicting, restricting,
|
|
12
|
+
* downstream, or unrelated.
|
|
13
|
+
*/
|
|
14
|
+
export declare function analyzePremiseRelationships(engine: ArgumentEngine, focusedPremiseId: string): TCorePremiseRelationshipAnalysis;
|
|
15
|
+
//# sourceMappingURL=relationships.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../../src/lib/core/relationships.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAER,mBAAmB,EAGnB,gCAAgC,EAEnC,MAAM,2BAA2B,CAAA;AAuClC;;;GAGG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,cAAc,GACxB,mBAAmB,CAyBrB;AAwPD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACvC,MAAM,EAAE,cAAc,EACtB,gBAAgB,EAAE,MAAM,GACzB,gCAAgC,CA2HlC"}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// ── Variable profiling ──────────────────────────────────────────────────
|
|
2
|
+
function collectVariableAppearances(premise, expressionId, side) {
|
|
3
|
+
const appearances = [];
|
|
4
|
+
const stack = [
|
|
5
|
+
{ id: expressionId, negationDepth: 0 },
|
|
6
|
+
];
|
|
7
|
+
while (stack.length > 0) {
|
|
8
|
+
const { id, negationDepth } = stack.pop();
|
|
9
|
+
const expr = premise.getExpression(id);
|
|
10
|
+
if (!expr)
|
|
11
|
+
continue;
|
|
12
|
+
if (expr.type === "variable") {
|
|
13
|
+
appearances.push({
|
|
14
|
+
variableId: expr.variableId,
|
|
15
|
+
side,
|
|
16
|
+
polarity: negationDepth % 2 === 0 ? "positive" : "negative",
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const nextDepth = expr.type === "operator" && expr.operator === "not"
|
|
21
|
+
? negationDepth + 1
|
|
22
|
+
: negationDepth;
|
|
23
|
+
for (const child of premise.getChildExpressions(id)) {
|
|
24
|
+
stack.push({ id: child.id, negationDepth: nextDepth });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return appearances;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Builds a profile of a premise's variable appearances, recording each
|
|
32
|
+
* variable's side (antecedent/consequent) and polarity (positive/negative).
|
|
33
|
+
*/
|
|
34
|
+
export function buildPremiseProfile(premise) {
|
|
35
|
+
const premiseId = premise.getId();
|
|
36
|
+
if (!premise.isInference()) {
|
|
37
|
+
return { premiseId, isInference: false, appearances: [] };
|
|
38
|
+
}
|
|
39
|
+
const root = premise.getRootExpression();
|
|
40
|
+
const children = premise.getChildExpressions(root.id);
|
|
41
|
+
const leftChild = children.find((c) => c.position === 0);
|
|
42
|
+
const rightChild = children.find((c) => c.position === 1);
|
|
43
|
+
const appearances = [];
|
|
44
|
+
if (leftChild) {
|
|
45
|
+
appearances.push(...collectVariableAppearances(premise, leftChild.id, "antecedent"));
|
|
46
|
+
}
|
|
47
|
+
if (rightChild) {
|
|
48
|
+
appearances.push(...collectVariableAppearances(premise, rightChild.id, "consequent"));
|
|
49
|
+
}
|
|
50
|
+
return { premiseId, isInference: true, appearances };
|
|
51
|
+
}
|
|
52
|
+
// ── Graph construction ──────────────────────────────────────────────────
|
|
53
|
+
function buildVariableFlowGraph(profiles) {
|
|
54
|
+
const graph = new Map();
|
|
55
|
+
for (const [sourceId, sourceProfile] of profiles) {
|
|
56
|
+
if (!sourceProfile.isInference)
|
|
57
|
+
continue;
|
|
58
|
+
const edges = [];
|
|
59
|
+
const conseqVars = sourceProfile.appearances.filter((a) => a.side === "consequent");
|
|
60
|
+
for (const [targetId, targetProfile] of profiles) {
|
|
61
|
+
if (targetId === sourceId || !targetProfile.isInference)
|
|
62
|
+
continue;
|
|
63
|
+
const anteVars = targetProfile.appearances.filter((a) => a.side === "antecedent");
|
|
64
|
+
const variables = [];
|
|
65
|
+
for (const cv of conseqVars) {
|
|
66
|
+
for (const av of anteVars) {
|
|
67
|
+
if (cv.variableId === av.variableId) {
|
|
68
|
+
variables.push({
|
|
69
|
+
variableId: cv.variableId,
|
|
70
|
+
polarityMatch: cv.polarity === av.polarity,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (variables.length > 0) {
|
|
76
|
+
edges.push({ targetPremiseId: targetId, variables });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
graph.set(sourceId, edges);
|
|
80
|
+
}
|
|
81
|
+
return graph;
|
|
82
|
+
}
|
|
83
|
+
function bfsToTarget(graph, sourceId, targetId) {
|
|
84
|
+
const visited = new Set();
|
|
85
|
+
visited.add(sourceId);
|
|
86
|
+
const queue = [];
|
|
87
|
+
// Seed with direct edges from source
|
|
88
|
+
const sourceEdges = graph.get(sourceId) ?? [];
|
|
89
|
+
for (const edge of sourceEdges) {
|
|
90
|
+
const allMatch = edge.variables.every((v) => v.polarityMatch);
|
|
91
|
+
if (edge.targetPremiseId === targetId) {
|
|
92
|
+
return {
|
|
93
|
+
reachable: true,
|
|
94
|
+
polarityMatch: allMatch,
|
|
95
|
+
variableDetails: edge.variables.map((v) => ({
|
|
96
|
+
variableId: v.variableId,
|
|
97
|
+
relationship: v.polarityMatch
|
|
98
|
+
? "supporting"
|
|
99
|
+
: "contradicting",
|
|
100
|
+
})),
|
|
101
|
+
transitive: false,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (!visited.has(edge.targetPremiseId)) {
|
|
105
|
+
visited.add(edge.targetPremiseId);
|
|
106
|
+
queue.push({
|
|
107
|
+
premiseId: edge.targetPremiseId,
|
|
108
|
+
polarityMatch: allMatch,
|
|
109
|
+
entryVariables: edge.variables,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
while (queue.length > 0) {
|
|
114
|
+
const { premiseId, polarityMatch, entryVariables } = queue.shift();
|
|
115
|
+
const edges = graph.get(premiseId) ?? [];
|
|
116
|
+
for (const edge of edges) {
|
|
117
|
+
if (edge.targetPremiseId === targetId) {
|
|
118
|
+
const stepMatch = edge.variables.every((v) => v.polarityMatch);
|
|
119
|
+
// XOR logic: both match or both mismatch = overall match
|
|
120
|
+
const finalMatch = (polarityMatch && stepMatch) ||
|
|
121
|
+
(!polarityMatch && !stepMatch);
|
|
122
|
+
return {
|
|
123
|
+
reachable: true,
|
|
124
|
+
polarityMatch: finalMatch,
|
|
125
|
+
variableDetails: entryVariables.map((v) => ({
|
|
126
|
+
variableId: v.variableId,
|
|
127
|
+
relationship: finalMatch
|
|
128
|
+
? "supporting"
|
|
129
|
+
: "contradicting",
|
|
130
|
+
})),
|
|
131
|
+
transitive: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (!visited.has(edge.targetPremiseId)) {
|
|
135
|
+
visited.add(edge.targetPremiseId);
|
|
136
|
+
const stepMatch = edge.variables.every((v) => v.polarityMatch);
|
|
137
|
+
const nextMatch = (polarityMatch && stepMatch) ||
|
|
138
|
+
(!polarityMatch && !stepMatch);
|
|
139
|
+
queue.push({
|
|
140
|
+
premiseId: edge.targetPremiseId,
|
|
141
|
+
polarityMatch: nextMatch,
|
|
142
|
+
entryVariables,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
reachable: false,
|
|
149
|
+
polarityMatch: true,
|
|
150
|
+
variableDetails: [],
|
|
151
|
+
transitive: false,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// ── Restricting check ───────────────────────────────────────────────────
|
|
155
|
+
function hasVariableOnBothSides(profile, focusedProfile) {
|
|
156
|
+
const antecedentVarIds = new Set(profile.appearances
|
|
157
|
+
.filter((a) => a.side === "antecedent")
|
|
158
|
+
.map((a) => a.variableId));
|
|
159
|
+
const consequentVarIds = new Set(profile.appearances
|
|
160
|
+
.filter((a) => a.side === "consequent")
|
|
161
|
+
.map((a) => a.variableId));
|
|
162
|
+
const bothSideVarIds = new Set([...antecedentVarIds].filter((id) => consequentVarIds.has(id)));
|
|
163
|
+
const focusedVarIds = new Set(focusedProfile.appearances.map((a) => a.variableId));
|
|
164
|
+
const restricting = [];
|
|
165
|
+
for (const varId of bothSideVarIds) {
|
|
166
|
+
if (focusedVarIds.has(varId)) {
|
|
167
|
+
restricting.push({
|
|
168
|
+
variableId: varId,
|
|
169
|
+
relationship: "restricting",
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return restricting;
|
|
174
|
+
}
|
|
175
|
+
// ── Constraint premise classification ───────────────────────────────────
|
|
176
|
+
function classifyConstraintPremise(premise, focusedProfile, connectedVarIds) {
|
|
177
|
+
const premiseVarIds = new Set(premise.getVariables().map((v) => v.id));
|
|
178
|
+
const focusedVarIds = new Set(focusedProfile.appearances.map((a) => a.variableId));
|
|
179
|
+
const directOverlap = [...premiseVarIds].some((id) => focusedVarIds.has(id));
|
|
180
|
+
const transitiveOverlap = [...premiseVarIds].some((id) => connectedVarIds.has(id));
|
|
181
|
+
if (directOverlap || transitiveOverlap) {
|
|
182
|
+
return {
|
|
183
|
+
premiseId: premise.getId(),
|
|
184
|
+
relationship: "restricting",
|
|
185
|
+
variableDetails: [],
|
|
186
|
+
transitive: !directOverlap && transitiveOverlap,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
premiseId: premise.getId(),
|
|
191
|
+
relationship: "unrelated",
|
|
192
|
+
variableDetails: [],
|
|
193
|
+
transitive: false,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
// ── Precedence ──────────────────────────────────────────────────────────
|
|
197
|
+
const PRECEDENCE = {
|
|
198
|
+
contradicting: 3,
|
|
199
|
+
restricting: 2,
|
|
200
|
+
supporting: 1,
|
|
201
|
+
};
|
|
202
|
+
function applyPrecedence(details) {
|
|
203
|
+
let highest = "supporting";
|
|
204
|
+
for (const d of details) {
|
|
205
|
+
if (PRECEDENCE[d.relationship] > PRECEDENCE[highest]) {
|
|
206
|
+
highest = d.relationship;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return highest;
|
|
210
|
+
}
|
|
211
|
+
// ── Main function ───────────────────────────────────────────────────────
|
|
212
|
+
/**
|
|
213
|
+
* Analyzes how every other premise in the argument relates to the focused
|
|
214
|
+
* premise, classifying each as supporting, contradicting, restricting,
|
|
215
|
+
* downstream, or unrelated.
|
|
216
|
+
*/
|
|
217
|
+
export function analyzePremiseRelationships(engine, focusedPremiseId) {
|
|
218
|
+
const focusedPremise = engine.getPremise(focusedPremiseId);
|
|
219
|
+
if (!focusedPremise) {
|
|
220
|
+
throw new Error(`Premise "${focusedPremiseId}" does not exist in the argument.`);
|
|
221
|
+
}
|
|
222
|
+
const allPremises = engine.listPremises();
|
|
223
|
+
const otherPremises = allPremises.filter((pm) => pm.getId() !== focusedPremiseId);
|
|
224
|
+
if (otherPremises.length === 0) {
|
|
225
|
+
return { focusedPremiseId, premises: [] };
|
|
226
|
+
}
|
|
227
|
+
// Build profiles for all premises
|
|
228
|
+
const profiles = new Map();
|
|
229
|
+
for (const pm of allPremises) {
|
|
230
|
+
profiles.set(pm.getId(), buildPremiseProfile(pm));
|
|
231
|
+
}
|
|
232
|
+
const focusedProfile = profiles.get(focusedPremiseId);
|
|
233
|
+
// Build variable flow graph (inference premises only)
|
|
234
|
+
const graph = buildVariableFlowGraph(profiles);
|
|
235
|
+
// Collect all variable IDs connected to the focused premise
|
|
236
|
+
// (for constraint classification)
|
|
237
|
+
const connectedVarIds = new Set();
|
|
238
|
+
for (const pm of allPremises) {
|
|
239
|
+
const pmId = pm.getId();
|
|
240
|
+
if (pmId === focusedPremiseId)
|
|
241
|
+
continue;
|
|
242
|
+
const profile = profiles.get(pmId);
|
|
243
|
+
if (!profile.isInference)
|
|
244
|
+
continue;
|
|
245
|
+
const toFocused = bfsToTarget(graph, pmId, focusedPremiseId);
|
|
246
|
+
const fromFocused = bfsToTarget(graph, focusedPremiseId, pmId);
|
|
247
|
+
if (toFocused.reachable || fromFocused.reachable) {
|
|
248
|
+
for (const v of pm.getVariables()) {
|
|
249
|
+
connectedVarIds.add(v.id);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
for (const a of focusedProfile.appearances) {
|
|
254
|
+
connectedVarIds.add(a.variableId);
|
|
255
|
+
}
|
|
256
|
+
// Classify each premise
|
|
257
|
+
const results = [];
|
|
258
|
+
for (const pm of otherPremises) {
|
|
259
|
+
const pmId = pm.getId();
|
|
260
|
+
const profile = profiles.get(pmId);
|
|
261
|
+
// Constraint premises get special handling
|
|
262
|
+
if (!profile.isInference) {
|
|
263
|
+
results.push(classifyConstraintPremise(pm, focusedProfile, connectedVarIds));
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
// If focused premise is a constraint, all sharing premises are
|
|
267
|
+
// restricting
|
|
268
|
+
if (!focusedProfile.isInference) {
|
|
269
|
+
const focusedVarIds = new Set(focusedPremise.getVariables().map((v) => v.id));
|
|
270
|
+
const pmVarIds = new Set(pm.getVariables().map((v) => v.id));
|
|
271
|
+
const shares = [...pmVarIds].some((id) => focusedVarIds.has(id));
|
|
272
|
+
results.push({
|
|
273
|
+
premiseId: pmId,
|
|
274
|
+
relationship: shares ? "restricting" : "unrelated",
|
|
275
|
+
variableDetails: [],
|
|
276
|
+
transitive: false,
|
|
277
|
+
});
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
// Check restricting (variable on both sides of source, appearing
|
|
281
|
+
// in focused)
|
|
282
|
+
const restrictingDetails = hasVariableOnBothSides(profile, focusedProfile);
|
|
283
|
+
// Check forward path (source → focused)
|
|
284
|
+
const toFocused = bfsToTarget(graph, pmId, focusedPremiseId);
|
|
285
|
+
// Check reverse path (focused → source) for downstream
|
|
286
|
+
const fromFocused = bfsToTarget(graph, focusedPremiseId, pmId);
|
|
287
|
+
if (restrictingDetails.length > 0 || toFocused.reachable) {
|
|
288
|
+
const allDetails = [
|
|
289
|
+
...restrictingDetails,
|
|
290
|
+
...toFocused.variableDetails,
|
|
291
|
+
];
|
|
292
|
+
const relationship = applyPrecedence(allDetails);
|
|
293
|
+
results.push({
|
|
294
|
+
premiseId: pmId,
|
|
295
|
+
relationship,
|
|
296
|
+
variableDetails: allDetails,
|
|
297
|
+
transitive: toFocused.transitive,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
else if (fromFocused.reachable) {
|
|
301
|
+
results.push({
|
|
302
|
+
premiseId: pmId,
|
|
303
|
+
relationship: "downstream",
|
|
304
|
+
variableDetails: [],
|
|
305
|
+
transitive: fromFocused.transitive,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
results.push({
|
|
310
|
+
premiseId: pmId,
|
|
311
|
+
relationship: "unrelated",
|
|
312
|
+
variableDetails: [],
|
|
313
|
+
transitive: false,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return { focusedPremiseId, premises: results };
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=relationships.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationships.js","sourceRoot":"","sources":["../../../src/lib/core/relationships.ts"],"names":[],"mappings":"AAWA,2EAA2E;AAE3E,SAAS,0BAA0B,CAC/B,OAAuB,EACvB,YAAoB,EACpB,IAAsB;IAEtB,MAAM,WAAW,GAA8B,EAAE,CAAA;IACjD,MAAM,KAAK,GAA4C;QACnD,EAAE,EAAE,EAAE,YAAY,EAAE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QACN,CAAC;aAAM,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC;gBACT,SAAS,EAAE,IAAI;gBACf,YAAY,EAAE,YAAY;gBAC1B,eAAe,EAAE,EAAE;gBACnB,UAAU,EAAE,WAAW,CAAC,UAAU;aACrC,CAAC,CAAA;QACN,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,IAAI,CAAC;gBACT,SAAS,EAAE,IAAI;gBACf,YAAY,EAAE,WAAW;gBACzB,eAAe,EAAE,EAAE;gBACnB,UAAU,EAAE,KAAK;aACpB,CAAC,CAAA;QACN,CAAC;IACL,CAAC;IAED,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;AAClD,CAAC"}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export { PremiseManager } from "./core/PremiseManager.js";
|
|
|
7
7
|
export * from "./types/evaluation.js";
|
|
8
8
|
export * from "./types/diff.js";
|
|
9
9
|
export { diffArguments, defaultCompareArgument, defaultCompareVariable, defaultComparePremise, defaultCompareExpression, } from "./core/diff.js";
|
|
10
|
+
export * from "./types/relationships.js";
|
|
11
|
+
export { analyzePremiseRelationships, buildPremiseProfile, } from "./core/relationships.js";
|
|
10
12
|
export { parseFormula } from "./core/parser/formula.js";
|
|
11
13
|
export type { FormulaAST } from "./core/parser/formula.js";
|
|
12
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,gBAAgB,CAAA;AACvB,cAAc,0BAA0B,CAAA;AACxC,OAAO,EACH,2BAA2B,EAC3B,mBAAmB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA"}
|
package/dist/lib/index.js
CHANGED
|
@@ -7,5 +7,7 @@ export { PremiseManager } from "./core/PremiseManager.js";
|
|
|
7
7
|
export * from "./types/evaluation.js";
|
|
8
8
|
export * from "./types/diff.js";
|
|
9
9
|
export { diffArguments, defaultCompareArgument, defaultCompareVariable, defaultComparePremise, defaultCompareExpression, } from "./core/diff.js";
|
|
10
|
+
export * from "./types/relationships.js";
|
|
11
|
+
export { analyzePremiseRelationships, buildPremiseProfile, } from "./core/relationships.js";
|
|
10
12
|
export { parseFormula } from "./core/parser/formula.js";
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EACH,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,GAC3B,MAAM,gBAAgB,CAAA;AACvB,cAAc,0BAA0B,CAAA;AACxC,OAAO,EACH,2BAA2B,EAC3B,mBAAmB,GACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Polarity of a variable within an expression subtree. */
|
|
2
|
+
export type TCoreVariablePolarity = "positive" | "negative";
|
|
3
|
+
/** Which side of an inference premise a variable appears on. */
|
|
4
|
+
export type TCorePremiseSide = "antecedent" | "consequent";
|
|
5
|
+
/** A single variable appearance within a premise, recording its side and polarity. */
|
|
6
|
+
export interface TCoreVariableAppearance {
|
|
7
|
+
variableId: string;
|
|
8
|
+
side: TCorePremiseSide;
|
|
9
|
+
polarity: TCoreVariablePolarity;
|
|
10
|
+
}
|
|
11
|
+
/** Profile of a premise's variable appearances, split by antecedent/consequent. */
|
|
12
|
+
export interface TCorePremiseProfile {
|
|
13
|
+
premiseId: string;
|
|
14
|
+
isInference: boolean;
|
|
15
|
+
appearances: TCoreVariableAppearance[];
|
|
16
|
+
}
|
|
17
|
+
/** The five relationship categories a premise can have relative to a focused premise. */
|
|
18
|
+
export type TCorePremiseRelationshipType = "supporting" | "contradicting" | "restricting" | "downstream" | "unrelated";
|
|
19
|
+
/** Per-variable relationship detail explaining why a variable contributes to the classification. */
|
|
20
|
+
export interface TCoreVariableRelationship {
|
|
21
|
+
variableId: string;
|
|
22
|
+
relationship: "supporting" | "contradicting" | "restricting";
|
|
23
|
+
}
|
|
24
|
+
/** Classification result for a single premise relative to the focused premise. */
|
|
25
|
+
export interface TCorePremiseRelationResult {
|
|
26
|
+
premiseId: string;
|
|
27
|
+
relationship: TCorePremiseRelationshipType;
|
|
28
|
+
variableDetails: TCoreVariableRelationship[];
|
|
29
|
+
transitive: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Top-level result from `analyzePremiseRelationships`. */
|
|
32
|
+
export interface TCorePremiseRelationshipAnalysis {
|
|
33
|
+
focusedPremiseId: string;
|
|
34
|
+
premises: TCorePremiseRelationResult[];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=relationships.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../../src/lib/types/relationships.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,UAAU,CAAA;AAE3D,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,YAAY,CAAA;AAE1D,sFAAsF;AACtF,MAAM,WAAW,uBAAuB;IACpC,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,CAAA;IACtB,QAAQ,EAAE,qBAAqB,CAAA;CAClC;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,OAAO,CAAA;IACpB,WAAW,EAAE,uBAAuB,EAAE,CAAA;CACzC;AAED,yFAAyF;AACzF,MAAM,MAAM,4BAA4B,GAClC,YAAY,GACZ,eAAe,GACf,aAAa,GACb,YAAY,GACZ,WAAW,CAAA;AAEjB,oGAAoG;AACpG,MAAM,WAAW,yBAAyB;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,YAAY,GAAG,eAAe,GAAG,aAAa,CAAA;CAC/D;AAED,kFAAkF;AAClF,MAAM,WAAW,0BAA0B;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,4BAA4B,CAAA;IAC1C,eAAe,EAAE,yBAAyB,EAAE,CAAA;IAC5C,UAAU,EAAE,OAAO,CAAA;CACtB;AAED,2DAA2D;AAC3D,MAAM,WAAW,gCAAgC;IAC7C,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,EAAE,0BAA0B,EAAE,CAAA;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationships.js","sourceRoot":"","sources":["../../../src/lib/types/relationships.ts"],"names":[],"mappings":""}
|