occam-verify-cli 1.0.809 → 1.0.816
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/lib/context/bounded.js +6 -6
- package/lib/context/branching.js +3 -3
- package/lib/context/ephemeral.js +7 -3
- package/lib/context/file/nominal.js +16 -16
- package/lib/context/liminal.js +26 -30
- package/lib/context/synoptic.js +62 -2
- package/lib/context.js +66 -54
- package/lib/element/assertion/defined.js +12 -11
- package/lib/element/assertion/satisfies.js +15 -11
- package/lib/element/assertion.js +5 -5
- package/lib/element/assumption/metaLevel.js +3 -3
- package/lib/element/conclusion.js +11 -8
- package/lib/element/deduction.js +11 -8
- package/lib/element/frame.js +6 -14
- package/lib/element/label.js +5 -8
- package/lib/element/metavariable.js +17 -17
- package/lib/element/procedureCall.js +10 -6
- package/lib/element/proofAssertion/premise.js +27 -27
- package/lib/element/proofAssertion/step.js +25 -5
- package/lib/element/proofAssertion/supposition.js +27 -27
- package/lib/element/proofAssertion.js +10 -10
- package/lib/element/reference.js +9 -13
- package/lib/element/rule.js +41 -43
- package/lib/element/signature.js +8 -8
- package/lib/element/statement.js +35 -45
- package/lib/element/subproof.js +4 -4
- package/lib/element/substitution/frame.js +16 -11
- package/lib/element/substitution/reference.js +15 -10
- package/lib/element/substitution/statement.js +55 -51
- package/lib/element/substitution/term.js +17 -12
- package/lib/element/substitution.js +35 -29
- package/lib/element/term.js +18 -16
- package/lib/element/topLevelAssertion/axiom.js +5 -3
- package/lib/element/topLevelAssertion.js +36 -38
- package/lib/element/variable.js +7 -7
- package/lib/node/frame.js +1 -9
- package/lib/node/statement.js +1 -9
- package/lib/node/term.js +10 -19
- package/lib/process/assign.js +23 -31
- package/lib/utilities/element.js +33 -5
- package/lib/utilities/equivalence.js +4 -4
- package/lib/utilities/equivalences.js +30 -15
- package/lib/utilities/string.js +2 -2
- package/lib/utilities/substitutions.js +16 -15
- package/lib/utilities/unification.js +133 -124
- package/package.json +1 -1
- package/src/context/bounded.js +5 -5
- package/src/context/branching.js +2 -2
- package/src/context/ephemeral.js +10 -2
- package/src/context/file/nominal.js +15 -15
- package/src/context/liminal.js +29 -35
- package/src/context/synoptic.js +81 -1
- package/src/context.js +88 -69
- package/src/element/assertion/defined.js +17 -16
- package/src/element/assertion/satisfies.js +17 -10
- package/src/element/assertion.js +8 -8
- package/src/element/assumption/metaLevel.js +4 -2
- package/src/element/conclusion.js +12 -7
- package/src/element/deduction.js +12 -7
- package/src/element/frame.js +7 -20
- package/src/element/label.js +3 -5
- package/src/element/metavariable.js +27 -27
- package/src/element/procedureCall.js +14 -9
- package/src/element/proofAssertion/premise.js +41 -41
- package/src/element/proofAssertion/step.js +37 -7
- package/src/element/proofAssertion/supposition.js +41 -41
- package/src/element/proofAssertion.js +10 -9
- package/src/element/reference.js +9 -13
- package/src/element/rule.js +57 -61
- package/src/element/signature.js +7 -7
- package/src/element/statement.js +54 -68
- package/src/element/subproof.js +3 -3
- package/src/element/substitution/frame.js +18 -8
- package/src/element/substitution/reference.js +16 -7
- package/src/element/substitution/statement.js +78 -67
- package/src/element/substitution/term.js +19 -10
- package/src/element/substitution.js +45 -35
- package/src/element/term.js +28 -26
- package/src/element/topLevelAssertion/axiom.js +5 -2
- package/src/element/topLevelAssertion.js +49 -53
- package/src/element/variable.js +6 -6
- package/src/node/frame.js +0 -12
- package/src/node/statement.js +0 -12
- package/src/node/term.js +14 -28
- package/src/process/assign.js +35 -46
- package/src/utilities/element.js +32 -4
- package/src/utilities/equivalence.js +3 -4
- package/src/utilities/equivalences.js +31 -19
- package/src/utilities/string.js +2 -2
- package/src/utilities/substitutions.js +17 -15
- package/src/utilities/unification.js +145 -119
|
@@ -38,9 +38,12 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
38
38
|
|
|
39
39
|
context = this.getContext();
|
|
40
40
|
|
|
41
|
-
const generalContext = context
|
|
41
|
+
const generalContext = context, ///
|
|
42
|
+
signatureAComparesToSignatureB = signatureA.compareSignature(signatureB, generalContext, specificContext);
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
if (signatureAComparesToSignatureB) {
|
|
45
|
+
comparesToSignature = true;
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
return comparesToSignature;
|
|
@@ -16,8 +16,8 @@ import { labelsFromJSON,
|
|
|
16
16
|
hypothesesToHypothesesJSON,
|
|
17
17
|
suppositionsToSuppositionsJSON } from "../utilities/json";
|
|
18
18
|
|
|
19
|
-
const {
|
|
20
|
-
{ asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
|
|
19
|
+
const { reverse, correlate } = arrayUtilities,
|
|
20
|
+
{ asyncExtract, asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
|
|
21
21
|
|
|
22
22
|
export default class TopLevelAssertion extends Element {
|
|
23
23
|
constructor(context, string, node, labels, suppositions, deduction, proof, signature, hypotheses) {
|
|
@@ -59,6 +59,12 @@ export default class TopLevelAssertion extends Element {
|
|
|
59
59
|
this.hypotheses = hypotheses;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
getSupposition(index) {
|
|
63
|
+
const supposition = this.suppositions[index] || null;
|
|
64
|
+
|
|
65
|
+
return supposition;
|
|
66
|
+
}
|
|
67
|
+
|
|
62
68
|
isHypothetical() {
|
|
63
69
|
const hypothesesLength = this.hypotheses.length,
|
|
64
70
|
hypothetical = (hypothesesLength > 0);
|
|
@@ -73,22 +79,16 @@ export default class TopLevelAssertion extends Element {
|
|
|
73
79
|
return unconditional;
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
return supposition;
|
|
80
|
-
}
|
|
82
|
+
matchMetavariableNode(metavariableNode) {
|
|
83
|
+
const metavariableNodeMatches = this.labels.some((label) => {
|
|
84
|
+
const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
|
|
81
85
|
|
|
82
|
-
|
|
83
|
-
const comparesToMetavariableName = this.labels.some((label) => {
|
|
84
|
-
const labelComparesToMetavariableName = label.compareMetavariableName(metavariableName);
|
|
85
|
-
|
|
86
|
-
if (labelComparesToMetavariableName) {
|
|
86
|
+
if (metavariableNodeMatches) {
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return metavariableNodeMatches;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
correlateHypotheses(context) {
|
|
@@ -120,28 +120,6 @@ export default class TopLevelAssertion extends Element {
|
|
|
120
120
|
return correlatesToHypotheses;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
unifyStatementWithDeduction(statement, context) {
|
|
124
|
-
let statementUnifiesWithDeduction = false;
|
|
125
|
-
|
|
126
|
-
const statementString = statement.getString(),
|
|
127
|
-
deductionString = this.deduction.getString(),
|
|
128
|
-
topLevelAssertionString = this.getString(); ///
|
|
129
|
-
|
|
130
|
-
context.trace(`Unifying the '${statementString}' statement with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction...`);
|
|
131
|
-
|
|
132
|
-
const statementUnifies = this.deduction.unifyStatement(statement, context);
|
|
133
|
-
|
|
134
|
-
if (statementUnifies) {
|
|
135
|
-
statementUnifiesWithDeduction = true;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (statementUnifiesWithDeduction) {
|
|
139
|
-
context.debug(`...unified the '${statementString}' statement with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction.`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return statementUnifiesWithDeduction;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
123
|
async verify() {
|
|
146
124
|
let verifies = false;
|
|
147
125
|
|
|
@@ -304,47 +282,65 @@ export default class TopLevelAssertion extends Element {
|
|
|
304
282
|
return suppositionsVerify;
|
|
305
283
|
}
|
|
306
284
|
|
|
307
|
-
async
|
|
308
|
-
let
|
|
285
|
+
async unifyStepWithDeduction(step, context) {
|
|
286
|
+
let stepUnifiesWithDeduction = false;
|
|
287
|
+
|
|
288
|
+
await this.break(context);
|
|
289
|
+
|
|
290
|
+
const stepString = step.getString(),
|
|
291
|
+
deductionString = this.deduction.getString(),
|
|
292
|
+
topLevelAssertionString = this.getString(); ///
|
|
293
|
+
|
|
294
|
+
context.trace(`Unifying the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction...`);
|
|
295
|
+
|
|
296
|
+
const stepUnifies = await this.deduction.unifyStep(step, context);
|
|
297
|
+
|
|
298
|
+
if (stepUnifies) {
|
|
299
|
+
stepUnifiesWithDeduction = true;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (stepUnifiesWithDeduction) {
|
|
303
|
+
context.debug(`...unified the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction.`);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return stepUnifiesWithDeduction;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context) {
|
|
310
|
+
let stepAndSubproofOrProofAssertionsUnify = false;
|
|
309
311
|
|
|
310
312
|
const correlatesToHypotheses = this.correlateHypotheses(context);
|
|
311
313
|
|
|
312
314
|
if (correlatesToHypotheses) {
|
|
313
|
-
const
|
|
315
|
+
const stepUnifiesWithDeduction = await this.unifyStepWithDeduction(step, context);
|
|
314
316
|
|
|
315
|
-
if (
|
|
317
|
+
if (stepUnifiesWithDeduction) {
|
|
316
318
|
const subproofOrProofAssertionsUnifiesWithSuppositions = await this.unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, context);
|
|
317
319
|
|
|
318
320
|
if (subproofOrProofAssertionsUnifiesWithSuppositions) {
|
|
319
321
|
const substitutionsResolved = context.areSubstitutionsResolved();
|
|
320
322
|
|
|
321
323
|
if (substitutionsResolved) {
|
|
322
|
-
|
|
324
|
+
stepAndSubproofOrProofAssertionsUnify = true;
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
329
|
|
|
328
|
-
return
|
|
330
|
+
return stepAndSubproofOrProofAssertionsUnify;
|
|
329
331
|
}
|
|
330
332
|
|
|
331
333
|
async unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, context) {
|
|
332
334
|
let subproofOrProofAssertionsUnifiesWithSupposition = false;
|
|
333
335
|
|
|
336
|
+
await this.break(context);
|
|
337
|
+
|
|
334
338
|
if (!subproofOrProofAssertionsUnifiesWithSupposition) {
|
|
335
|
-
const subproofOrProofAssertion =
|
|
336
|
-
const subproofOrProofAssertionUnifies = supposition.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
|
|
339
|
+
const subproofOrProofAssertion = await asyncExtract(subproofOrProofAssertions, async (subproofOrProofAssertion) => {
|
|
340
|
+
const subproofOrProofAssertionUnifies = await supposition.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
|
|
337
341
|
|
|
338
342
|
if (subproofOrProofAssertionUnifies) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
context = this.getContext();
|
|
342
|
-
|
|
343
|
-
const generalContext = context; ///
|
|
344
|
-
|
|
345
|
-
context = specificContext; ///
|
|
346
|
-
|
|
347
|
-
context.resolveSubstitutions(generalContext, specificContext);
|
|
343
|
+
context.resolveSubstitutions();
|
|
348
344
|
|
|
349
345
|
return true;
|
|
350
346
|
}
|
|
@@ -371,7 +367,7 @@ export default class TopLevelAssertion extends Element {
|
|
|
371
367
|
|
|
372
368
|
subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
|
|
373
369
|
|
|
374
|
-
subproofOrProofAssertionsUnifiesWithSuppositions = asyncBackwardsEvery(this.suppositions, async (supposition) => {
|
|
370
|
+
subproofOrProofAssertionsUnifiesWithSuppositions = await asyncBackwardsEvery(this.suppositions, async (supposition) => {
|
|
375
371
|
const stepUnifiesWithSupposition = await this.unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, context);
|
|
376
372
|
|
|
377
373
|
if (stepUnifiesWithSupposition) {
|
package/src/element/variable.js
CHANGED
|
@@ -45,11 +45,11 @@ export default define(class Variable extends Element {
|
|
|
45
45
|
return identifierEqualTo;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
compareVariable(variable) {
|
|
49
49
|
const variableIdentifier = variable.getIdentifier(),
|
|
50
|
-
|
|
50
|
+
comparesToVariable = (this.identifier === variableIdentifier);
|
|
51
51
|
|
|
52
|
-
return
|
|
52
|
+
return comparesToVariable;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
compareParamter(parameter) {
|
|
@@ -117,9 +117,9 @@ export default define(class Variable extends Element {
|
|
|
117
117
|
|
|
118
118
|
variable = this; ///
|
|
119
119
|
|
|
120
|
-
const
|
|
120
|
+
const variableNode = variable.getNode();
|
|
121
121
|
|
|
122
|
-
substitution = context.
|
|
122
|
+
substitution = context.findSubstitutionByVariableNode(variableNode);
|
|
123
123
|
|
|
124
124
|
if (substitution !== null) {
|
|
125
125
|
const substitutionComparesToTerm = substitution.compareTerm(term, context);
|
|
@@ -137,7 +137,7 @@ export default define(class Variable extends Element {
|
|
|
137
137
|
|
|
138
138
|
context = generalContext; ///
|
|
139
139
|
|
|
140
|
-
const variableNode = variable.
|
|
140
|
+
const variableNode = variable.getNode();
|
|
141
141
|
|
|
142
142
|
variable = context.findVariableByVariableNode(variableNode);
|
|
143
143
|
|
package/src/node/frame.js
CHANGED
|
@@ -22,18 +22,6 @@ export default class FrameNode extends NonTerminalNode {
|
|
|
22
22
|
return singular;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
getMetavariableName() {
|
|
26
|
-
let metavariableName = null;
|
|
27
|
-
|
|
28
|
-
const metavariableNode = this.getMetavariableNode();
|
|
29
|
-
|
|
30
|
-
if (metavariableNode !== null) {
|
|
31
|
-
metavariableName = metavariableNode.getMetavariableName();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return metavariableName;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
25
|
getAssumptionNodes() {
|
|
38
26
|
const ruleName = ASSUMPTION_RULE_NAME,
|
|
39
27
|
declarationNodes = this.getNodesByRuleName(ruleName);
|
package/src/node/statement.js
CHANGED
|
@@ -31,18 +31,6 @@ export default class StatementNode extends NonTerminalNode {
|
|
|
31
31
|
return singular;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
getMetavariableName() {
|
|
35
|
-
let metavariableName = null;
|
|
36
|
-
|
|
37
|
-
const metavariableNode = this.getMetavariableNode();
|
|
38
|
-
|
|
39
|
-
if (metavariableNode !== null) {
|
|
40
|
-
metavariableName = metavariableNode.getMetavariableName();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return metavariableName;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
34
|
getMetavariableNode() {
|
|
47
35
|
const singularMetavariableNode = this.getSingularMetavariableNode(),
|
|
48
36
|
metavariableNode = singularMetavariableNode; ///
|
package/src/node/term.js
CHANGED
|
@@ -5,6 +5,20 @@ import { NonTerminalNode } from "occam-languages";
|
|
|
5
5
|
import { ARGUMENT_RULE_NAME, VARIABLE_RULE_NAME } from "../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class TermNode extends NonTerminalNode {
|
|
8
|
+
getVariableIdentifier() {
|
|
9
|
+
let variableIdentifier = null;
|
|
10
|
+
|
|
11
|
+
const singular = this.isSingular();
|
|
12
|
+
|
|
13
|
+
if (singular) {
|
|
14
|
+
const variableNode = this.getVariableNode();
|
|
15
|
+
|
|
16
|
+
variableIdentifier = variableNode.getVariableIdentifier();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return variableIdentifier;
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
isSingular() {
|
|
9
23
|
let singular = false;
|
|
10
24
|
|
|
@@ -36,34 +50,6 @@ export default class TermNode extends NonTerminalNode {
|
|
|
36
50
|
return singularTermNode;
|
|
37
51
|
}
|
|
38
52
|
|
|
39
|
-
getVariableIdentifier() {
|
|
40
|
-
let variableIdentifier = null;
|
|
41
|
-
|
|
42
|
-
const singular = this.isSingular();
|
|
43
|
-
|
|
44
|
-
if (singular) {
|
|
45
|
-
const singularVariableNode = this.getSingularVariableNode();
|
|
46
|
-
|
|
47
|
-
variableIdentifier = singularVariableNode.getVariableIdentifier();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return variableIdentifier;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getSingularVariableIdentifier() {
|
|
54
|
-
let singularVariableIdentifier = null;
|
|
55
|
-
|
|
56
|
-
const singularVariableNode = this.getSingularVariableNode();
|
|
57
|
-
|
|
58
|
-
if (singularVariableNode !== null) {
|
|
59
|
-
const variableIdentifier = singularVariableNode.getVariableIdentifier();
|
|
60
|
-
|
|
61
|
-
singularVariableIdentifier = variableIdentifier; ///
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return singularVariableIdentifier;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
53
|
getVariableNodes() {
|
|
68
54
|
const ruleName = VARIABLE_RULE_NAME,
|
|
69
55
|
variableNodes = this.getNodesByRuleName(ruleName);
|
package/src/process/assign.js
CHANGED
|
@@ -24,37 +24,17 @@ export function judgementAssignmentFromJudgement(judgement, context) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export function leftVariableAssignmentFromEquality(equality, context) {
|
|
27
|
-
let leftVariableAssignment = (contxt) => {
|
|
28
|
-
///
|
|
29
|
-
};
|
|
30
|
-
|
|
31
27
|
const type = equality.getType(),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (singularVariableNode !== null) {
|
|
36
|
-
const leftVariableNode = singularVariableNode; ///
|
|
37
|
-
|
|
38
|
-
leftVariableAssignment = variableAssignmentFromVariableNodeAndType(leftVariableNode, type, context);
|
|
39
|
-
}
|
|
28
|
+
leftTerm = equality.getLeftTerm(),
|
|
29
|
+
leftVariableAssignment = variableAssignmentFromTermAndType(leftTerm, type, context);
|
|
40
30
|
|
|
41
31
|
return leftVariableAssignment;
|
|
42
32
|
}
|
|
43
33
|
|
|
44
34
|
export function rightVariableAssignmentFromEquality(equality, context) {
|
|
45
|
-
let rightVariableAssignment = (context) => {
|
|
46
|
-
///
|
|
47
|
-
};
|
|
48
|
-
|
|
49
35
|
const type = equality.getType(),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (singularVariableNode !== null) {
|
|
54
|
-
const rightVariableNode = singularVariableNode; ///
|
|
55
|
-
|
|
56
|
-
rightVariableAssignment = variableAssignmentFromVariableNodeAndType(rightVariableNode, type, context);
|
|
57
|
-
}
|
|
36
|
+
rightTerm = equality.getRightTerm(),
|
|
37
|
+
rightVariableAssignment = variableAssignmentFromTermAndType(rightTerm, type, context);
|
|
58
38
|
|
|
59
39
|
return rightVariableAssignment;
|
|
60
40
|
}
|
|
@@ -68,15 +48,10 @@ export function variableAssignmentFromTypeAssertion(typeAssertion, context) {
|
|
|
68
48
|
termSingular = term.isSingular();
|
|
69
49
|
|
|
70
50
|
if (termSingular) {
|
|
71
|
-
const
|
|
72
|
-
|
|
51
|
+
const type = typeAssertion.getType(),
|
|
52
|
+
variableNode = term.getVariableNode();
|
|
73
53
|
|
|
74
|
-
|
|
75
|
-
const type = typeAssertion.getType(),
|
|
76
|
-
variableNode = variable.getNode();
|
|
77
|
-
|
|
78
|
-
variableAssignment = variableAssignmentFromVariableNodeAndType(variableNode, type, context);
|
|
79
|
-
}
|
|
54
|
+
variableAssignment = variableAssignmentFromTermAndType(variableNode, type, context);
|
|
80
55
|
}
|
|
81
56
|
|
|
82
57
|
return variableAssignment;
|
|
@@ -104,26 +79,40 @@ export function variableAssignmentFromPrepertyAssertion(propertyAssertion, conte
|
|
|
104
79
|
|
|
105
80
|
}
|
|
106
81
|
|
|
107
|
-
function
|
|
108
|
-
|
|
82
|
+
function variableAssignmentFromTermAndType(term, type, context) {
|
|
83
|
+
let variableAssignment = (context) => {
|
|
84
|
+
///
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const termSingular = term.isSingular();
|
|
109
88
|
|
|
110
|
-
|
|
89
|
+
if (termSingular) {
|
|
90
|
+
const termType = term.getType(),
|
|
91
|
+
termTypeEqualToType = termType.isEqualTo(type);
|
|
111
92
|
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
if (!termTypeEqualToType) {
|
|
94
|
+
const variableNode = term.getVariableNode(),
|
|
95
|
+
variable = variableFromVariableNode(variableNode, context);
|
|
114
96
|
|
|
115
|
-
|
|
97
|
+
variable.setType(type);
|
|
116
98
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
assigned = true; ///
|
|
99
|
+
variableAssignment = (context) => {
|
|
100
|
+
const declaredVariable = variable; ///
|
|
120
101
|
|
|
121
|
-
|
|
122
|
-
context.trace(`Assigned the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`) :
|
|
123
|
-
context.debug(`Unable to assign the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`);
|
|
102
|
+
context.addDeclaredVariable(declaredVariable);
|
|
124
103
|
|
|
125
|
-
|
|
126
|
-
|
|
104
|
+
const declaredVariableTypeString = declaredVariable.getTypeString(),
|
|
105
|
+
declaredVariableString = declaredVariable.getString(),
|
|
106
|
+
assigned = true; ///
|
|
107
|
+
|
|
108
|
+
assigned ?
|
|
109
|
+
context.trace(`Assigned the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`) :
|
|
110
|
+
context.debug(`Unable to assign the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`);
|
|
111
|
+
|
|
112
|
+
return assigned;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
127
116
|
|
|
128
117
|
return variableAssignment;
|
|
129
118
|
}
|
package/src/utilities/element.js
CHANGED
|
@@ -618,9 +618,10 @@ export function termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, c
|
|
|
618
618
|
const { TermSubstitution } = elements,
|
|
619
619
|
node = termSubstitutionNode, ///
|
|
620
620
|
string = context.nodeAsString(node),
|
|
621
|
+
generalContext = generalContextFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
621
622
|
targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
622
623
|
replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
623
|
-
termSubstitution = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
|
|
624
|
+
termSubstitution = new TermSubstitution(context, string, node, generalContext, targetTerm, replacementTerm);
|
|
624
625
|
|
|
625
626
|
return termSubstitution;
|
|
626
627
|
}
|
|
@@ -629,9 +630,10 @@ export function frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode
|
|
|
629
630
|
const { FrameSubstitution } = elements,
|
|
630
631
|
node = frameSubstitutionNode, ///
|
|
631
632
|
string = context.nodeAsString(node),
|
|
633
|
+
generalContext = generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
632
634
|
targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
633
635
|
replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
634
|
-
frameSubstitution = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
|
|
636
|
+
frameSubstitution = new FrameSubstitution(context, string, node, generalContext, targetFrame, replacementFrame);
|
|
635
637
|
|
|
636
638
|
return frameSubstitution;
|
|
637
639
|
}
|
|
@@ -767,9 +769,10 @@ export function referenceSubstitutionFromReferenceSubstitutionNode(referenceSubs
|
|
|
767
769
|
const { ReferenceSubstitution } = elements,
|
|
768
770
|
node = referenceSubstitutionNode, ///
|
|
769
771
|
string = context.nodeAsString(node),
|
|
772
|
+
generalContext = generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
770
773
|
targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
771
774
|
replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
772
|
-
referenceSubstitution = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
|
|
775
|
+
referenceSubstitution = new ReferenceSubstitution(context, string, node, generalContext, targetReference, replacementReference);
|
|
773
776
|
|
|
774
777
|
return referenceSubstitution;
|
|
775
778
|
}
|
|
@@ -779,11 +782,12 @@ export function statementSubstitutionFromStatementSubstitutionNode(statementSubs
|
|
|
779
782
|
const { StatementSubstitution } = elements,
|
|
780
783
|
node = statementSubstitutionNode, ///
|
|
781
784
|
string = context.nodeAsString(node),
|
|
785
|
+
generalContext = generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
782
786
|
resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
783
787
|
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
784
788
|
targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
785
789
|
replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
786
|
-
statementSubstitution = new StatementSubstitution(context, string, node, resolved, substitution, targetStatement, replacementStatement);
|
|
790
|
+
statementSubstitution = new StatementSubstitution(context, string, node, generalContext, resolved, substitution, targetStatement, replacementStatement);
|
|
787
791
|
|
|
788
792
|
return statementSubstitution;
|
|
789
793
|
}
|
|
@@ -1757,6 +1761,12 @@ export function topLevelMetaAssertionFromReferenceNode(referenceNode, context) {
|
|
|
1757
1761
|
return topLevelMetaAssertion;
|
|
1758
1762
|
}
|
|
1759
1763
|
|
|
1764
|
+
export function generalContextFromTermSubstitutionNode(termSubstitutionNode, context) {
|
|
1765
|
+
const generalContext = null;
|
|
1766
|
+
|
|
1767
|
+
return generalContext;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1760
1770
|
export function deductionFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, context) {
|
|
1761
1771
|
const deductionNode = metaLemmaMetathoremNode.getDeductionNode(),
|
|
1762
1772
|
deduction = deductionFromDeductionNode(deductionNode, context);
|
|
@@ -1778,6 +1788,12 @@ export function replacementTermFromTermSubstitutionNode(termSubstitutionNode, co
|
|
|
1778
1788
|
return replacementTerm;
|
|
1779
1789
|
}
|
|
1780
1790
|
|
|
1791
|
+
export function generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context) {
|
|
1792
|
+
const generalContext = null;
|
|
1793
|
+
|
|
1794
|
+
return generalContext;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1781
1797
|
export function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
|
|
1782
1798
|
let superTypes = [];
|
|
1783
1799
|
|
|
@@ -1881,6 +1897,18 @@ export function provisionalFromComplexTypeDeclarationNode(complexTypeDeclaration
|
|
|
1881
1897
|
return provisional;
|
|
1882
1898
|
}
|
|
1883
1899
|
|
|
1900
|
+
export function generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context) {
|
|
1901
|
+
const generalContext = null;
|
|
1902
|
+
|
|
1903
|
+
return generalContext;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
export function generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
|
|
1907
|
+
const generalContext = null;
|
|
1908
|
+
|
|
1909
|
+
return generalContext;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1884
1912
|
export function metavariableFromMetavariableDeclarationNode(metavariableDeclarationNode, context) {
|
|
1885
1913
|
const metavariableNode = metavariableDeclarationNode.getMetavariableNode(),
|
|
1886
1914
|
metavariable = metavariableFromMetavariableNode(metavariableNode, context);
|
|
@@ -8,16 +8,15 @@ export function variablesFromTerm(term, context) {
|
|
|
8
8
|
const termNode = term.getNode(),
|
|
9
9
|
variableNodes = termNode.getVariableNodes(),
|
|
10
10
|
variables = variableNodes.map((variableNode) => {
|
|
11
|
-
const
|
|
12
|
-
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
11
|
+
const variable = context.findVariableByVariableNode(variableNode);
|
|
13
12
|
|
|
14
13
|
return variable;
|
|
15
14
|
});
|
|
16
15
|
|
|
17
16
|
compress(variables, (variableA, variableB) => {
|
|
18
|
-
const
|
|
17
|
+
const variableAComparesToVariableB = variableA.compareVariable(variableB);
|
|
19
18
|
|
|
20
|
-
if (!
|
|
19
|
+
if (!variableAComparesToVariableB) {
|
|
21
20
|
return true;
|
|
22
21
|
}
|
|
23
22
|
});
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
+
import elements from "../elements";
|
|
6
|
+
|
|
5
7
|
import { variablesFromTerm } from "../utilities/equivalence";
|
|
6
8
|
|
|
7
9
|
const { push, separate } = arrayUtilities;
|
|
@@ -30,6 +32,16 @@ export function findEquivalenceByTerm(equivalences, term) {
|
|
|
30
32
|
return equivalence;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
export function equivalencesFromEquality(equality, context) {
|
|
36
|
+
const { Equivalence } = elements,
|
|
37
|
+
eaulivalence = Equivalence.fromEquality(equality, context),
|
|
38
|
+
equivalences = [
|
|
39
|
+
eaulivalence
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
return equivalences;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
export function findEquivalenceByTermNodes(equivalences, termNodes) {
|
|
34
46
|
const equivalence = equivalences.find((equivalence) => {
|
|
35
47
|
const termNodeMatches = equivalence.matchTermNodes(termNodes);
|
|
@@ -54,7 +66,7 @@ export function separateGroundedTermsAndDefinedVariables(equivalences, groundedT
|
|
|
54
66
|
|
|
55
67
|
separateInitiallyGroundedEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences, context);
|
|
56
68
|
|
|
57
|
-
const initiallyGroundedEquivalencesLength = initiallyGroundedEquivalences.
|
|
69
|
+
const initiallyGroundedEquivalencesLength = initiallyGroundedEquivalences.length;
|
|
58
70
|
|
|
59
71
|
if (initiallyGroundedEquivalencesLength > 0) {
|
|
60
72
|
groundedEquivalences = initiallyGroundedEquivalences; ///
|
|
@@ -85,7 +97,7 @@ export function separateGroundedTermsAndDefinedVariables(equivalences, groundedT
|
|
|
85
97
|
|
|
86
98
|
push(groundedEquivalences, implicitlyGroundedEquivalences);
|
|
87
99
|
|
|
88
|
-
implicitlyGroundedEquivalencesLength = implicitlyGroundedEquivalences.
|
|
100
|
+
implicitlyGroundedEquivalencesLength = implicitlyGroundedEquivalences.length; ///
|
|
89
101
|
}
|
|
90
102
|
}
|
|
91
103
|
}
|
|
@@ -114,6 +126,23 @@ function mergeEquivalence(equivalencesA, equivalenceB, context) {
|
|
|
114
126
|
return equivalencesA;
|
|
115
127
|
}
|
|
116
128
|
|
|
129
|
+
function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context) {
|
|
130
|
+
groundedTerms.forEach((groundedTerm) => {
|
|
131
|
+
const term = groundedTerm, ///
|
|
132
|
+
variables = variablesFromTerm(term, context);
|
|
133
|
+
|
|
134
|
+
variables.forEach((variable) => {
|
|
135
|
+
const definedVariablesIncludesTermVariable = definedVariables.includes(variable);
|
|
136
|
+
|
|
137
|
+
if (!definedVariablesIncludesTermVariable) {
|
|
138
|
+
const definedVariable = variable; ///
|
|
139
|
+
|
|
140
|
+
definedVariables.push(definedVariable);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
117
146
|
function separateInitiallyGroundedEquivalences(equivalences, remainingEquivalences, initiallyGroundedEquivalences, context) {
|
|
118
147
|
separate(equivalences, remainingEquivalences, initiallyGroundedEquivalences, (equivalence) => {
|
|
119
148
|
const equivalenceInitiallyGrounded = equivalence.isInitiallyGrounded(context);
|
|
@@ -134,23 +163,6 @@ function separateImplicitlyGroundedEquivalences(equivalences, remainingEquivalen
|
|
|
134
163
|
});
|
|
135
164
|
}
|
|
136
165
|
|
|
137
|
-
function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context) {
|
|
138
|
-
groundedTerms.forEach((groundedTerm) => {
|
|
139
|
-
const term = groundedTerm, ///
|
|
140
|
-
variables = variablesFromTerm(term, context);
|
|
141
|
-
|
|
142
|
-
variables.forEach((variable) => {
|
|
143
|
-
const definedVariablesIncludesTermVariable = definedVariables.includes(variable);
|
|
144
|
-
|
|
145
|
-
if (!definedVariablesIncludesTermVariable) {
|
|
146
|
-
const definedVariable = variable; ///
|
|
147
|
-
|
|
148
|
-
definedVariables.push(definedVariable);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
166
|
function groundedTermsFromGroundedEquivalencesAndDefinedVariables(groundedEquivalences, definedVariables, groundedTerms, context) {
|
|
155
167
|
groundedEquivalences.forEach((groundedEquivalence) => {
|
|
156
168
|
groundedEquivalence.getGroundedTerms(definedVariables, groundedTerms, context);
|
package/src/utilities/string.js
CHANGED
|
@@ -160,8 +160,8 @@ export function termSubstitutionStringFromTermAndVariable(term, variable) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
export function rulsStringFromLabelsPremisesAndConclusion(labels, premises, conclusion) {
|
|
163
|
-
const
|
|
164
|
-
|
|
163
|
+
const conclusionString = conclusion.getString(),
|
|
164
|
+
premisesString = premisesStringFromPremises(premises),
|
|
165
165
|
labelsString = labelsStringFromLabels(labels),
|
|
166
166
|
ruleString = (premisesString !== null) ?
|
|
167
167
|
`${labelsString} :: [${premisesString}]...${conclusionString}` :
|