occam-verify-cli 1.0.448 → 1.0.472
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/constants.js +13 -5
- package/lib/context/ephemeral.js +270 -0
- package/lib/context/file.js +136 -128
- package/lib/context/liminal.js +120 -0
- package/lib/context/literal.js +92 -0
- package/lib/context/nominal.js +15 -1
- package/lib/context/release.js +68 -9
- package/lib/context/scoped.js +322 -0
- package/lib/context/synthetic.js +133 -0
- package/lib/element/assertion/contained.js +66 -66
- package/lib/element/assertion/defined.js +32 -32
- package/lib/element/assertion/property.js +39 -39
- package/lib/element/assertion/satisfies.js +22 -22
- package/lib/element/assumption.js +71 -87
- package/lib/element/combinator/bracketed.js +1 -10
- package/lib/element/conclusion.js +19 -15
- package/lib/element/constructor/bracketed.js +1 -10
- package/lib/element/constructor.js +2 -2
- package/lib/element/declaration/combinator.js +1 -2
- package/lib/element/declaration/metavariable.js +3 -3
- package/lib/element/declaration/variable.js +3 -3
- package/lib/element/deduction.js +26 -20
- package/lib/element/derivation.js +3 -3
- package/lib/element/equality.js +5 -5
- package/lib/element/equivalence.js +112 -107
- package/lib/element/equivalences.js +24 -10
- package/lib/element/error.js +3 -3
- package/lib/element/frame.js +73 -62
- package/lib/element/hypothesis.js +2 -2
- package/lib/element/judgement.js +40 -60
- package/lib/element/metaType.js +4 -4
- package/lib/element/metavariable.js +49 -38
- package/lib/element/parameter.js +13 -5
- package/lib/element/procedureCall.js +16 -16
- package/lib/element/proof.js +14 -13
- package/lib/element/proofAssertion/premise.js +319 -0
- package/lib/element/proofAssertion/step.js +309 -0
- package/lib/element/proofAssertion/supposition.js +333 -0
- package/lib/element/proofAssertion.js +20 -10
- package/lib/element/propertyRelation.js +2 -2
- package/lib/element/reference.js +72 -30
- package/lib/element/rule.js +26 -28
- package/lib/element/section.js +5 -5
- package/lib/element/signature.js +9 -6
- package/lib/element/statement.js +44 -36
- package/lib/element/subproof.js +18 -17
- package/lib/element/substitution/frame.js +86 -49
- package/lib/element/substitution/reference.js +101 -19
- package/lib/element/substitution/statement.js +128 -105
- package/lib/element/substitution/term.js +93 -57
- package/lib/element/substitution.js +20 -69
- package/lib/element/substitutions.js +49 -34
- package/lib/element/term.js +41 -30
- package/lib/element/topLevelAssertion/axiom.js +331 -0
- package/lib/element/{conjecture.js → topLevelAssertion/conjecture.js} +10 -10
- package/lib/element/{lemma.js → topLevelAssertion/lemma.js} +9 -9
- package/lib/element/{theorem.js → topLevelAssertion/theorem.js} +8 -8
- package/lib/element/topLevelAssertion.js +434 -0
- package/lib/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +8 -8
- package/lib/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +8 -8
- package/lib/element/topLevelMetaAssertion.js +293 -0
- package/lib/element/type.js +4 -4
- package/lib/element/variable.js +48 -40
- package/lib/index.js +3 -3
- package/lib/main.js +3 -3
- package/lib/metaTypes.js +18 -15
- package/lib/node/frame.js +2 -2
- package/lib/node/metavariable.js +4 -4
- package/lib/node/parameter.js +28 -7
- package/lib/node/proofAssertion/premise.js +116 -0
- package/lib/node/proofAssertion/step.js +152 -0
- package/lib/node/proofAssertion/supposition.js +116 -0
- package/lib/node/{premise.js → proofAssertion.js} +11 -18
- package/lib/node/statement.js +2 -2
- package/lib/node/substitution/frame.js +9 -31
- package/lib/node/substitution/reference.js +137 -0
- package/lib/node/substitution/statement.js +9 -31
- package/lib/node/substitution/term.js +9 -23
- package/lib/node/{axiom.js → topLevelAssertion/axiom.js} +7 -7
- package/lib/node/{conjecture.js → topLevelAssertion/conjecture.js} +7 -7
- package/lib/node/{lemma.js → topLevelAssertion/lemma.js} +7 -7
- package/lib/node/{theorem.js → topLevelAssertion/theorem.js} +7 -7
- package/lib/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +9 -9
- package/lib/node/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +7 -7
- package/lib/node/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +7 -7
- package/lib/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +9 -9
- package/lib/nonTerminalNodeMap.js +15 -14
- package/lib/preamble.js +10 -10
- package/lib/process/instantiate.js +6 -21
- package/lib/process/unify.js +11 -10
- package/lib/tokenTypes.js +22 -0
- package/lib/types.js +3 -3
- package/lib/utilities/bnf.js +5 -5
- package/lib/utilities/context.js +63 -0
- package/lib/utilities/element.js +235 -408
- package/lib/utilities/instance.js +12 -34
- package/lib/utilities/json.js +3 -2
- package/lib/utilities/string.js +56 -21
- package/lib/utilities/unification.js +38 -32
- package/lib/utilities/validation.js +47 -50
- package/package.json +2 -2
- package/src/constants.js +12 -1
- package/src/context/ephemeral.js +257 -0
- package/src/context/file.js +108 -116
- package/src/context/liminal.js +67 -0
- package/src/context/literal.js +51 -0
- package/src/context/nominal.js +12 -0
- package/src/context/release.js +48 -8
- package/src/context/{local.js → scoped.js} +43 -125
- package/src/context/synthetic.js +60 -0
- package/src/element/assertion/contained.js +49 -47
- package/src/element/assertion/defined.js +29 -27
- package/src/element/assertion/property.js +35 -35
- package/src/element/assertion/satisfies.js +19 -18
- package/src/element/assumption.js +71 -93
- package/src/element/combinator/bracketed.js +0 -7
- package/src/element/conclusion.js +25 -24
- package/src/element/constructor/bracketed.js +0 -7
- package/src/element/constructor.js +1 -1
- package/src/element/declaration/combinator.js +0 -1
- package/src/element/declaration/metavariable.js +2 -2
- package/src/element/declaration/variable.js +5 -5
- package/src/element/deduction.js +33 -31
- package/src/element/derivation.js +2 -2
- package/src/element/equality.js +4 -4
- package/src/element/equivalence.js +115 -135
- package/src/element/equivalences.js +9 -7
- package/src/element/error.js +4 -2
- package/src/element/frame.js +80 -65
- package/src/element/hypothesis.js +1 -1
- package/src/element/judgement.js +42 -62
- package/src/element/metaType.js +3 -4
- package/src/element/metavariable.js +59 -56
- package/src/element/parameter.js +10 -5
- package/src/element/procedureCall.js +20 -18
- package/src/element/proof.js +14 -16
- package/src/element/{premise.js → proofAssertion/premise.js} +57 -53
- package/src/element/{step.js → proofAssertion/step.js} +59 -62
- package/src/element/{supposition.js → proofAssertion/supposition.js} +67 -56
- package/src/element/proofAssertion.js +24 -13
- package/src/element/propertyRelation.js +1 -1
- package/src/element/reference.js +87 -37
- package/src/element/rule.js +31 -37
- package/src/element/section.js +5 -5
- package/src/element/signature.js +8 -8
- package/src/element/statement.js +52 -48
- package/src/element/subproof.js +16 -18
- package/src/element/substitution/frame.js +104 -50
- package/src/element/substitution/reference.js +120 -20
- package/src/element/substitution/statement.js +169 -130
- package/src/element/substitution/term.js +104 -63
- package/src/element/substitution.js +16 -58
- package/src/element/substitutions.js +43 -41
- package/src/element/term.js +47 -41
- package/src/element/{axiom.js → topLevelAssertion/axiom.js} +22 -20
- package/src/element/{conjecture.js → topLevelAssertion/conjecture.js} +5 -6
- package/src/element/{lemma.js → topLevelAssertion/lemma.js} +5 -6
- package/src/element/{theorem.js → topLevelAssertion/theorem.js} +5 -5
- package/src/element/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +37 -33
- package/src/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +5 -6
- package/src/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +5 -6
- package/src/element/{metaLemmaMetatheorem.js → topLevelMetaAssertion.js} +19 -17
- package/src/element/type.js +2 -4
- package/src/element/variable.js +47 -48
- package/src/index.js +2 -1
- package/src/main.js +2 -1
- package/src/metaTypes.js +25 -9
- package/src/node/frame.js +1 -1
- package/src/node/metavariable.js +3 -3
- package/src/node/parameter.js +32 -5
- package/src/node/proofAssertion/premise.js +16 -0
- package/src/node/{step.js → proofAssertion/step.js} +4 -18
- package/src/node/proofAssertion/supposition.js +16 -0
- package/src/node/proofAssertion.js +23 -0
- package/src/node/statement.js +1 -1
- package/src/node/substitution/frame.js +6 -32
- package/src/node/substitution/reference.js +38 -0
- package/src/node/substitution/statement.js +6 -32
- package/src/node/substitution/term.js +6 -22
- package/src/node/topLevelAssertion/axiom.js +13 -0
- package/src/node/topLevelAssertion/conjecture.js +13 -0
- package/src/node/topLevelAssertion/lemma.js +13 -0
- package/src/node/topLevelAssertion/theorem.js +13 -0
- package/src/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +1 -1
- package/src/node/topLevelMetaAssertion/metaLemma.js +13 -0
- package/src/node/topLevelMetaAssertion/metatheorem.js +13 -0
- package/src/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +1 -1
- package/src/nonTerminalNodeMap.js +15 -12
- package/src/preamble.js +9 -9
- package/src/process/instantiate.js +27 -36
- package/src/process/unify.js +10 -9
- package/src/tokenTypes.js +4 -0
- package/src/types.js +4 -2
- package/src/utilities/bnf.js +3 -2
- package/src/utilities/context.js +46 -0
- package/src/utilities/element.js +302 -509
- package/src/utilities/instance.js +19 -42
- package/src/utilities/json.js +3 -1
- package/src/utilities/string.js +69 -28
- package/src/utilities/unification.js +41 -38
- package/src/utilities/validation.js +66 -75
- package/lib/context/local.js +0 -605
- package/lib/context/temporary.js +0 -752
- package/lib/element/axiom.js +0 -329
- package/lib/element/axiomLemmaTheoremConjecture.js +0 -427
- package/lib/element/metaLemmaMetatheorem.js +0 -289
- package/lib/element/premise.js +0 -307
- package/lib/element/step.js +0 -311
- package/lib/element/supposition.js +0 -320
- package/lib/log.js +0 -150
- package/lib/node/step.js +0 -166
- package/lib/node/supposition.js +0 -130
- package/src/context/temporary.js +0 -476
- package/src/log.js +0 -118
- package/src/node/axiom.js +0 -13
- package/src/node/conjecture.js +0 -13
- package/src/node/lemma.js +0 -13
- package/src/node/metaLemma.js +0 -13
- package/src/node/metatheorem.js +0 -13
- package/src/node/premise.js +0 -30
- package/src/node/supposition.js +0 -30
- package/src/node/theorem.js +0 -13
package/src/element/equality.js
CHANGED
|
@@ -76,7 +76,7 @@ export default define(class Equality extends Element {
|
|
|
76
76
|
verify(assignments, stated, context) {
|
|
77
77
|
let verifies = false;
|
|
78
78
|
|
|
79
|
-
const equalityString = this.
|
|
79
|
+
const equalityString = this.getString(); ///
|
|
80
80
|
|
|
81
81
|
context.trace(`Verifying the '${equalityString}' equality...`);
|
|
82
82
|
|
|
@@ -113,7 +113,7 @@ export default define(class Equality extends Element {
|
|
|
113
113
|
verifyTerms(context) {
|
|
114
114
|
let termsVerify;
|
|
115
115
|
|
|
116
|
-
const equalityString = this.
|
|
116
|
+
const equalityString = this.getString(); ///
|
|
117
117
|
|
|
118
118
|
context.trace(`Verifying the '${equalityString}' equality's terms...`);
|
|
119
119
|
|
|
@@ -149,7 +149,7 @@ export default define(class Equality extends Element {
|
|
|
149
149
|
verifyWhenStated(assignments, context) {
|
|
150
150
|
let verifiesWhenStated;
|
|
151
151
|
|
|
152
|
-
const equalityString = this.
|
|
152
|
+
const equalityString = this.getString(); ///
|
|
153
153
|
|
|
154
154
|
context.trace(`Verifying the '${equalityString}' stated equality...`);
|
|
155
155
|
|
|
@@ -165,7 +165,7 @@ export default define(class Equality extends Element {
|
|
|
165
165
|
verifyWhenDerived(context) {
|
|
166
166
|
let verifiesWhenDerived;
|
|
167
167
|
|
|
168
|
-
const equalityString = this.
|
|
168
|
+
const equalityString = this.getString(); ///
|
|
169
169
|
|
|
170
170
|
context.trace(`Verifying the '${equalityString}' derived equality...`);
|
|
171
171
|
|
|
@@ -5,10 +5,11 @@ import { arrayUtilities } from "necessary";
|
|
|
5
5
|
import Element from "../element";
|
|
6
6
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
|
+
import { literally } from "../utilities/context";
|
|
8
9
|
import { termsStringFromTerms } from "../utilities/string";
|
|
9
10
|
import { instantiateEquivalence } from "../process/instantiate";
|
|
10
11
|
import { stripBracketsFromTermNode } from "../utilities/brackets";
|
|
11
|
-
import {
|
|
12
|
+
import { equivalenceFromEquivalenceNode } from "../utilities/element";
|
|
12
13
|
|
|
13
14
|
const { compress } = arrayUtilities;
|
|
14
15
|
|
|
@@ -22,40 +23,6 @@ export default define(class Equivalence extends Element {
|
|
|
22
23
|
return this.terms;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
addTerm(term, context) {
|
|
26
|
-
const termString = term.getString(),
|
|
27
|
-
equivalenceString = this.asString(); ///
|
|
28
|
-
|
|
29
|
-
context.trace(`Adding the '${termString}' term to the '${equivalenceString}' equivalence...`);
|
|
30
|
-
|
|
31
|
-
const termA = term, ///
|
|
32
|
-
termPresent = this.someTerm((term) => {
|
|
33
|
-
const termB = term, ///
|
|
34
|
-
termAEqualToTermB = termA.isEqualTo(termB);
|
|
35
|
-
|
|
36
|
-
if (termAEqualToTermB) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (!termPresent) {
|
|
42
|
-
this.terms.push(term);
|
|
43
|
-
|
|
44
|
-
const termsString = termsStringFromTerms(this.terms),
|
|
45
|
-
string = termsString, ///
|
|
46
|
-
equalivanceNode = instantiateEquivalence(string, context),
|
|
47
|
-
equalivance = equalivanceFromEquivalenceNode(equalivanceNode, context);
|
|
48
|
-
|
|
49
|
-
this.node = equalivance.getNode();
|
|
50
|
-
|
|
51
|
-
this.string = equalivance.getString();
|
|
52
|
-
|
|
53
|
-
const equivalenceString = this.string; ///
|
|
54
|
-
|
|
55
|
-
context.debug(`...added the '${termString}' term to the '${equivalenceString}' equivalence.`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
26
|
getType() {
|
|
60
27
|
const type = this.terms.reduce((type, term) => {
|
|
61
28
|
const termType = term.getType();
|
|
@@ -76,6 +43,89 @@ export default define(class Equivalence extends Element {
|
|
|
76
43
|
return type;
|
|
77
44
|
}
|
|
78
45
|
|
|
46
|
+
getGroundedTerms(definedVariables, groundedTerms, context) {
|
|
47
|
+
this.terms.forEach((term) => {
|
|
48
|
+
const termGrounded = term.isGrounded(definedVariables, context);
|
|
49
|
+
|
|
50
|
+
if (termGrounded) {
|
|
51
|
+
const termMatchesGroundedTerm = groundedTerms.some((groundedTerm) => {
|
|
52
|
+
const groundedTermNode = groundedTerm.getNode(),
|
|
53
|
+
groundedTermNodeMatches = term.matchNode(groundedTermNode);
|
|
54
|
+
|
|
55
|
+
if (groundedTermNodeMatches) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
if (!termMatchesGroundedTerm) {
|
|
61
|
+
const groundedTerm = term;
|
|
62
|
+
|
|
63
|
+
groundedTerms.push(groundedTerm);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getInitiallyGroundedTerms(context) {
|
|
70
|
+
const initiallyGroundedTerms = this.terms.reduce((initiallyGroundedTerms, term) => {
|
|
71
|
+
const termInitiallyGrounded = term.isInitiallyGrounded(context);
|
|
72
|
+
|
|
73
|
+
if (termInitiallyGrounded) {
|
|
74
|
+
const initiallyGroundedTerm = term; ///
|
|
75
|
+
|
|
76
|
+
initiallyGroundedTerms.push(initiallyGroundedTerm);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return initiallyGroundedTerms;
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
return initiallyGroundedTerms;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getImplicitlyGroundedTerms(definedVariables, context) {
|
|
86
|
+
const implicitlyGroundedTerms = this.terms.reduce((implicitlyGroundedTerms, term) => {
|
|
87
|
+
const termImplicitlyGrounded = term.isImplicitlyGrounded(definedVariables, context);
|
|
88
|
+
|
|
89
|
+
if (termImplicitlyGrounded) {
|
|
90
|
+
const implicitlyGroundedTerm = term; ///
|
|
91
|
+
|
|
92
|
+
implicitlyGroundedTerms.push(implicitlyGroundedTerm);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return implicitlyGroundedTerms;
|
|
96
|
+
}, []);
|
|
97
|
+
|
|
98
|
+
return implicitlyGroundedTerms;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
isDisjointFrom(equivalence) {
|
|
102
|
+
const disjointFrom = equivalence.everyTerm((term) => {
|
|
103
|
+
const comparesToTerm = this.compareTerm(term);
|
|
104
|
+
|
|
105
|
+
if (!comparesToTerm) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return disjointFrom;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
isInitiallyGrounded(context) {
|
|
114
|
+
const initiallyGroundedTerms = this.getInitiallyGroundedTerms(context),
|
|
115
|
+
initiallyGroundedTermsLength = initiallyGroundedTerms.length,
|
|
116
|
+
initiallyGrounded = (initiallyGroundedTermsLength > 0);
|
|
117
|
+
|
|
118
|
+
return initiallyGrounded;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
isImplicitlyGrounded(definedVariables, context) {
|
|
122
|
+
const implicitlyGroundedTerms = this.getImplicitlyGroundedTerms(definedVariables, context),
|
|
123
|
+
implicitlyGroundedTermsLength = implicitlyGroundedTerms.length,
|
|
124
|
+
implicitlyGrounded = (implicitlyGroundedTermsLength > 0);
|
|
125
|
+
|
|
126
|
+
return implicitlyGrounded;
|
|
127
|
+
}
|
|
128
|
+
|
|
79
129
|
compareTerm(term) {
|
|
80
130
|
const termA = term, ///
|
|
81
131
|
comparesToTerm = this.someTerm((term) => {
|
|
@@ -135,41 +185,6 @@ export default define(class Equivalence extends Element {
|
|
|
135
185
|
return variableNodeMatches;
|
|
136
186
|
}
|
|
137
187
|
|
|
138
|
-
isDisjointFrom(equivalence) {
|
|
139
|
-
const disjointFrom = equivalence.everyTerm((term) => {
|
|
140
|
-
const comparesToTerm = this.compareTerm(term);
|
|
141
|
-
|
|
142
|
-
if (!comparesToTerm) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
return disjointFrom;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
mergedWith(equivalence) {
|
|
151
|
-
const equivalenceA = this,
|
|
152
|
-
equivalenceB = equivalence, ///
|
|
153
|
-
equivalenceATerms = equivalenceA.getTerms(),
|
|
154
|
-
equivalenceTermsB = equivalenceB.getTerms(),
|
|
155
|
-
terms = [
|
|
156
|
-
...equivalenceATerms,
|
|
157
|
-
...equivalenceTermsB
|
|
158
|
-
];
|
|
159
|
-
|
|
160
|
-
compress(terms, (termA, termB) => {
|
|
161
|
-
const termAEqualToTermB = termA.isEqualTo(termB);
|
|
162
|
-
|
|
163
|
-
if (!termAEqualToTermB) {
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
equivalence = new Equivalence(terms);
|
|
169
|
-
|
|
170
|
-
return equivalence;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
188
|
someTerm(callback) { return this.terms.some(callback); }
|
|
174
189
|
|
|
175
190
|
everyTerm(callback) { return this.terms.every(callback); }
|
|
@@ -189,84 +204,49 @@ export default define(class Equivalence extends Element {
|
|
|
189
204
|
return result;
|
|
190
205
|
}
|
|
191
206
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
207
|
+
combineTerms(terms) {
|
|
208
|
+
const combinedTerms = [
|
|
209
|
+
...this.terms,
|
|
210
|
+
...terms
|
|
211
|
+
];
|
|
195
212
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const groundedTermNode = groundedTerm.getNode(),
|
|
199
|
-
groundedTermNodeMatches = term.matchNode(groundedTermNode);
|
|
213
|
+
compress(combinedTerms, (combinedTermA, combinedTermB) => {
|
|
214
|
+
const combinedTermAEqualToCombinedTermB = combinedTermA.isEqualTo(combinedTermB);
|
|
200
215
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
|
|
206
|
-
if (!termMatchesGroundedTerm) {
|
|
207
|
-
const groundedTerm = term;
|
|
208
|
-
|
|
209
|
-
groundedTerms.push(groundedTerm);
|
|
210
|
-
}
|
|
216
|
+
if (!combinedTermAEqualToCombinedTermB) {
|
|
217
|
+
return true;
|
|
211
218
|
}
|
|
212
219
|
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
isInitiallyGrounded(context) {
|
|
216
|
-
const initiallyGroundedTerms = this.getInitiallyGroundedTerms(context),
|
|
217
|
-
initiallyGroundedTermsLength = initiallyGroundedTerms.length,
|
|
218
|
-
initiallyGrounded = (initiallyGroundedTermsLength > 0);
|
|
219
220
|
|
|
220
|
-
return
|
|
221
|
+
return combinedTerms;
|
|
221
222
|
}
|
|
222
223
|
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
implicitlyGrounded = (implicitlyGroundedTermsLength > 0);
|
|
227
|
-
|
|
228
|
-
return implicitlyGrounded;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
getInitiallyGroundedTerms(context) {
|
|
232
|
-
const initiallyGroundedTerms = this.terms.reduce((initiallyGroundedTerms, term) => {
|
|
233
|
-
const termInitiallyGrounded = term.isInitiallyGrounded(context);
|
|
234
|
-
|
|
235
|
-
if (termInitiallyGrounded) {
|
|
236
|
-
const initiallyGroundedTerm = term; ///
|
|
237
|
-
|
|
238
|
-
initiallyGroundedTerms.push(initiallyGroundedTerm);
|
|
239
|
-
}
|
|
224
|
+
mergedWith(equivalence, context) {
|
|
225
|
+
const terms = equivalence.getTerms(),
|
|
226
|
+
combinedTerms = this.combineTerms(terms);
|
|
240
227
|
|
|
241
|
-
|
|
242
|
-
|
|
228
|
+
return literally((context) => {
|
|
229
|
+
const terms = combinedTerms, ///
|
|
230
|
+
termsString = termsStringFromTerms(terms),
|
|
231
|
+
string = termsString, ///
|
|
232
|
+
equivalenceNode = instantiateEquivalence(string, context),
|
|
233
|
+
equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
|
|
243
234
|
|
|
244
|
-
|
|
235
|
+
return equivalence;
|
|
236
|
+
}, context);
|
|
245
237
|
}
|
|
246
238
|
|
|
247
|
-
|
|
248
|
-
const implicitlyGroundedTerms = this.terms.reduce((implicitlyGroundedTerms, term) => {
|
|
249
|
-
const termImplicitlyGrounded = term.isImplicitlyGrounded(definedVariables, context);
|
|
250
|
-
|
|
251
|
-
if (termImplicitlyGrounded) {
|
|
252
|
-
const implicitlyGroundedTerm = term; ///
|
|
253
|
-
|
|
254
|
-
implicitlyGroundedTerms.push(implicitlyGroundedTerm);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return implicitlyGroundedTerms;
|
|
258
|
-
}, []);
|
|
259
|
-
|
|
260
|
-
return implicitlyGroundedTerms;
|
|
261
|
-
}
|
|
239
|
+
static name = "Equivalence";
|
|
262
240
|
|
|
263
241
|
static fromEquality(equality, context) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
242
|
+
return literally((context) => {
|
|
243
|
+
const terms = equality.getTerms(),
|
|
244
|
+
termsString = termsStringFromTerms(terms),
|
|
245
|
+
string = termsString, ///
|
|
246
|
+
equivalenceNode = instantiateEquivalence(string, context),
|
|
247
|
+
equivalence = equivalenceFromEquivalenceNode(equivalenceNode, context);
|
|
269
248
|
|
|
270
|
-
|
|
249
|
+
return equivalence;
|
|
250
|
+
}, context);
|
|
271
251
|
}
|
|
272
252
|
});
|
|
@@ -73,18 +73,18 @@ export default define(class Equivalences extends Element {
|
|
|
73
73
|
return equivalence;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
mergedWith(equivalences) {
|
|
76
|
+
mergedWith(equivalences, context) {
|
|
77
77
|
let mergedEquivalences = this.clone(); ///
|
|
78
78
|
|
|
79
79
|
equivalences.forEachEquivalence((equivalence) => {
|
|
80
|
-
mergedEquivalences = mergedEquivalences.mergedWithEquivalence(equivalence);
|
|
80
|
+
mergedEquivalences = mergedEquivalences.mergedWithEquivalence(equivalence, context);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
return mergedEquivalences;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
mergedWithEquivalence(equivalence) {
|
|
87
|
-
const equivalences = Equivalences.fromNothing();
|
|
86
|
+
mergedWithEquivalence(equivalence, context) {
|
|
87
|
+
const equivalences = Equivalences.fromNothing(context);
|
|
88
88
|
|
|
89
89
|
let mergedEquivalence = equivalence; ///
|
|
90
90
|
|
|
@@ -94,7 +94,7 @@ export default define(class Equivalences extends Element {
|
|
|
94
94
|
if (mergedEquivalenceDisjointFromEquivalence) {
|
|
95
95
|
equivalences.addEquivalence(equivalence);
|
|
96
96
|
} else {
|
|
97
|
-
mergedEquivalence = mergedEquivalence.mergedWith(equivalence);
|
|
97
|
+
mergedEquivalence = mergedEquivalence.mergedWith(equivalence, context);
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
|
|
@@ -139,9 +139,9 @@ export default define(class Equivalences extends Element {
|
|
|
139
139
|
initiallyGroundedEquivalences,
|
|
140
140
|
implicitlyGroundedEquivalences;
|
|
141
141
|
|
|
142
|
-
remainingEquivalences =Equivalences.fromNothing();
|
|
142
|
+
remainingEquivalences =Equivalences.fromNothing(context);
|
|
143
143
|
|
|
144
|
-
initiallyGroundedEquivalences = Equivalences.fromNothing();
|
|
144
|
+
initiallyGroundedEquivalences = Equivalences.fromNothing(context);
|
|
145
145
|
|
|
146
146
|
equivalences.separateInitiallyGroundedEquivalences(remainingEquivalences, initiallyGroundedEquivalences, context);
|
|
147
147
|
|
|
@@ -190,6 +190,8 @@ export default define(class Equivalences extends Element {
|
|
|
190
190
|
return equivalences;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
static name = "Equivalences";
|
|
194
|
+
|
|
193
195
|
static fromNothing(context) {
|
|
194
196
|
const string = EMPTY_STRING,
|
|
195
197
|
node = null,
|
package/src/element/error.js
CHANGED
|
@@ -12,9 +12,11 @@ export default define(class Error extends Element {
|
|
|
12
12
|
verify() {
|
|
13
13
|
let verifies = false;
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const node = this.getNode(),
|
|
16
|
+
context = this.getContext(),
|
|
17
|
+
errorString = this.getString(); ///
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
context.warning(`The '${errorString}' error cannot be verified.`, node);
|
|
18
20
|
|
|
19
21
|
return verifies;
|
|
20
22
|
}
|
package/src/element/frame.js
CHANGED
|
@@ -6,8 +6,8 @@ import Element from "../element";
|
|
|
6
6
|
import elements from "../elements";
|
|
7
7
|
|
|
8
8
|
import { define } from "../elements";
|
|
9
|
-
import { S, NOTHING } from "../constants";
|
|
10
9
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
10
|
+
import { assumptionsStringFromAssumptions } from "../utilities/string";
|
|
11
11
|
|
|
12
12
|
const { first } = arrayUtilities;
|
|
13
13
|
|
|
@@ -53,18 +53,18 @@ export default define(class Frame extends Element {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
getMetavariableName() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const singular = this.isSingular();
|
|
59
|
-
|
|
60
|
-
if (singular) {
|
|
61
|
-
metavariableName = this.node.getMetavariableName();
|
|
62
|
-
}
|
|
56
|
+
const node = this.getNode(),
|
|
57
|
+
metavariableName = node.getMetavariableName();
|
|
63
58
|
|
|
64
59
|
return metavariableName;
|
|
65
60
|
}
|
|
66
61
|
|
|
67
|
-
isSingular() {
|
|
62
|
+
isSingular() {
|
|
63
|
+
const node = this.getNode(),
|
|
64
|
+
singular = node.isSingular();
|
|
65
|
+
|
|
66
|
+
return singular;
|
|
67
|
+
}
|
|
68
68
|
|
|
69
69
|
isMetavariableEqualToMetavariable(metavariable, context) {
|
|
70
70
|
let metavariableEqualToMetavariable;
|
|
@@ -72,8 +72,9 @@ export default define(class Frame extends Element {
|
|
|
72
72
|
const singular = this.isSingular();
|
|
73
73
|
|
|
74
74
|
if (singular) {
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const node = this.getNode(),
|
|
76
|
+
metavariableA = metavariable, ///
|
|
77
|
+
singularMetavariableNode = node.getSingularMetavariableNode(),
|
|
77
78
|
metavariableName = singularMetavariableNode.getMetavariableName();
|
|
78
79
|
|
|
79
80
|
metavariable = context.findMetavariableByMetavariableName(metavariableName)
|
|
@@ -87,6 +88,26 @@ export default define(class Frame extends Element {
|
|
|
87
88
|
return metavariableEqualToMetavariable;
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
compareParameter(parameter) {
|
|
92
|
+
let comparesToParamter = false;
|
|
93
|
+
|
|
94
|
+
const singular = this.isSingular();
|
|
95
|
+
|
|
96
|
+
if (singular) {
|
|
97
|
+
const parameterName = parameter.getName();
|
|
98
|
+
|
|
99
|
+
if (parameterName !== null) {
|
|
100
|
+
const metavariableName = this.getMetavariableName();
|
|
101
|
+
|
|
102
|
+
if (parameterName === metavariableName) {
|
|
103
|
+
comparesToParamter = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return comparesToParamter;
|
|
109
|
+
}
|
|
110
|
+
|
|
90
111
|
compareSubstitution(substitution, context) {
|
|
91
112
|
let comparesToSubstitution = false;
|
|
92
113
|
|
|
@@ -115,7 +136,7 @@ export default define(class Frame extends Element {
|
|
|
115
136
|
compareSubstitutions(substitutions, context) {
|
|
116
137
|
let comparesToSubstitutions;
|
|
117
138
|
|
|
118
|
-
const frameString = this.
|
|
139
|
+
const frameString = this.getString(), ///
|
|
119
140
|
substitutionsString = substitutions.asString();
|
|
120
141
|
|
|
121
142
|
context.trace(`Comparing the '${frameString}' frame to the '${substitutionsString}' substitutions...`);
|
|
@@ -135,117 +156,111 @@ export default define(class Frame extends Element {
|
|
|
135
156
|
return comparesToSubstitutions;
|
|
136
157
|
}
|
|
137
158
|
|
|
138
|
-
|
|
139
|
-
let
|
|
159
|
+
validate(assignments, stated, context) {
|
|
160
|
+
let validates = false;
|
|
140
161
|
|
|
141
|
-
const frameString = this.
|
|
162
|
+
const frameString = this.getString(); ///
|
|
142
163
|
|
|
143
|
-
context.trace(`
|
|
164
|
+
context.trace(`Validating the '${frameString}' frame...`);
|
|
144
165
|
|
|
145
|
-
const
|
|
166
|
+
const assumptionsValidate = this.validateAssumptions(assignments, stated, context);
|
|
146
167
|
|
|
147
|
-
if (
|
|
148
|
-
let
|
|
149
|
-
|
|
168
|
+
if (assumptionsValidate) {
|
|
169
|
+
let validatesWhenStated = false,
|
|
170
|
+
validatesWhenDerived = false;
|
|
150
171
|
|
|
151
172
|
if (stated) {
|
|
152
|
-
|
|
173
|
+
validatesWhenStated = this.validateWhenStated(assignments, context);
|
|
153
174
|
} else {
|
|
154
|
-
|
|
175
|
+
validatesWhenDerived = this.validateWhenDerived(context);
|
|
155
176
|
}
|
|
156
177
|
|
|
157
|
-
if (
|
|
158
|
-
|
|
178
|
+
if (validatesWhenStated || validatesWhenDerived) {
|
|
179
|
+
validates = true;
|
|
159
180
|
}
|
|
160
181
|
}
|
|
161
182
|
|
|
162
|
-
if (
|
|
183
|
+
if (validates) {
|
|
163
184
|
const frame = this; ///
|
|
164
185
|
|
|
165
186
|
context.addFrame(frame);
|
|
166
187
|
|
|
167
|
-
context.debug(`...
|
|
188
|
+
context.debug(`...validated the '${frameString}' frame.`);
|
|
168
189
|
}
|
|
169
190
|
|
|
170
|
-
return
|
|
191
|
+
return validates;
|
|
171
192
|
}
|
|
172
193
|
|
|
173
|
-
|
|
174
|
-
let
|
|
194
|
+
validateWhenStated(assignments, context) {
|
|
195
|
+
let validatesWhenStated = false;
|
|
175
196
|
|
|
176
|
-
const frameString = this.
|
|
197
|
+
const frameString = this.getString(); ///
|
|
177
198
|
|
|
178
|
-
context.trace(`
|
|
199
|
+
context.trace(`Validating the '${frameString}' stated frame...`);
|
|
179
200
|
|
|
180
201
|
const singular = this.isSingular();
|
|
181
202
|
|
|
182
|
-
if (
|
|
183
|
-
|
|
203
|
+
if (singular) {
|
|
204
|
+
validatesWhenStated = true;
|
|
184
205
|
} else {
|
|
185
|
-
|
|
206
|
+
context.trace(`The '${frameString}' stated frame must be singular.`);
|
|
186
207
|
}
|
|
187
208
|
|
|
188
|
-
if (
|
|
189
|
-
context.debug(`...
|
|
209
|
+
if (validatesWhenStated) {
|
|
210
|
+
context.debug(`...validated the '${frameString}' stated frame.`);
|
|
190
211
|
}
|
|
191
212
|
|
|
192
|
-
return
|
|
213
|
+
return validatesWhenStated;
|
|
193
214
|
}
|
|
194
215
|
|
|
195
|
-
|
|
196
|
-
let
|
|
216
|
+
validateWhenDerived(context) {
|
|
217
|
+
let validatesWhenDerived;
|
|
197
218
|
|
|
198
|
-
const frameString = this.
|
|
219
|
+
const frameString = this.getString(); ///
|
|
199
220
|
|
|
200
221
|
context.trace(`Verifying the '${frameString}' derived frame...`);
|
|
201
222
|
|
|
202
|
-
|
|
223
|
+
validatesWhenDerived = true;
|
|
203
224
|
|
|
204
|
-
if (
|
|
225
|
+
if (validatesWhenDerived) {
|
|
205
226
|
context.debug(`...verified the '${frameString}' derived frame.`);
|
|
206
227
|
}
|
|
207
228
|
|
|
208
|
-
return
|
|
229
|
+
return validatesWhenDerived;
|
|
209
230
|
}
|
|
210
231
|
|
|
211
|
-
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
const length = this.getLength();
|
|
232
|
+
validateAssumptions(assignments, stated, context) {
|
|
233
|
+
let assumptionsValidate;
|
|
215
234
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
S :
|
|
219
|
-
NOTHING,
|
|
220
|
-
assumptionsString = assumptionsStringFromAssumptions(this.assumptions);
|
|
235
|
+
const frameString = this.getString(), ///
|
|
236
|
+
assumptionsString = assumptionsStringFromAssumptions(this.assumptions);
|
|
221
237
|
|
|
222
|
-
|
|
238
|
+
context.trace(`Validating the '${assumptionsString}' assumptions of the '${frameString}' frame...`);
|
|
223
239
|
|
|
224
|
-
|
|
240
|
+
stated = true; ///
|
|
225
241
|
|
|
226
|
-
|
|
242
|
+
assignments = null; ///
|
|
227
243
|
|
|
228
|
-
|
|
229
|
-
|
|
244
|
+
assumptionsValidate = this.assumptions.every((assumption) => {
|
|
245
|
+
const assumptionVerifies = assumption.validate(assignments, stated, context);
|
|
230
246
|
|
|
231
|
-
|
|
232
|
-
|
|
247
|
+
return assumptionVerifies;
|
|
248
|
+
});
|
|
233
249
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
250
|
+
if (assumptionsValidate) {
|
|
251
|
+
context.debug(`...validated the '${assumptionsString}' assumptions of the '${frameString}' frame.`);
|
|
237
252
|
}
|
|
238
253
|
|
|
239
|
-
return
|
|
254
|
+
return assumptionsValidate;
|
|
240
255
|
}
|
|
241
256
|
|
|
242
257
|
validateGivenMetaType(metaType, assignments, stated, context) {
|
|
243
258
|
let validatesGivenMetaType = false;
|
|
244
259
|
|
|
245
|
-
const frameString = this.
|
|
260
|
+
const frameString = this.getString(), ///
|
|
246
261
|
metaTypeString = metaType.getString();
|
|
247
262
|
|
|
248
|
-
context.trace(`
|
|
263
|
+
context.trace(`Validating the '${frameString}' frame given the '${metaTypeString}' meta-type...`);
|
|
249
264
|
|
|
250
265
|
const metaTypeName = metaType.getName();
|
|
251
266
|
|
|
@@ -20,7 +20,7 @@ export default define(class Hypothesis extends Element {
|
|
|
20
20
|
verify(context) {
|
|
21
21
|
let verifies = false;
|
|
22
22
|
|
|
23
|
-
const hypothesisString = this.
|
|
23
|
+
const hypothesisString = this.getString(); ///
|
|
24
24
|
|
|
25
25
|
context.trace(`Verifying the '${hypothesisString}' hypothesis...`, this.node);
|
|
26
26
|
|