occam-verify-cli 1.0.437 → 1.0.438
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/element/derivation.js +3 -3
- package/lib/element/label.js +16 -18
- package/lib/element/premise.js +22 -22
- package/lib/element/rule.js +30 -54
- package/lib/element/statement.js +43 -45
- package/lib/element/step.js +14 -14
- package/lib/element/subDerivation.js +3 -3
- package/lib/element.js +19 -1
- package/lib/mixins/statement/validate.js +198 -0
- package/lib/utilities/element.js +10 -7
- package/lib/utilities/statement.js +11 -16
- package/package.json +6 -6
- package/src/element/derivation.js +2 -2
- package/src/element/label.js +11 -18
- package/src/element/premise.js +17 -16
- package/src/element/rule.js +30 -75
- package/src/element/statement.js +59 -44
- package/src/element/step.js +12 -12
- package/src/element/subDerivation.js +2 -2
- package/src/element.js +12 -0
- package/src/mixins/statement/validate.js +295 -0
- package/src/utilities/element.js +13 -9
- package/src/utilities/statement.js +27 -28
- package/lib/mixins/statement/verify.js +0 -198
- package/src/mixins/statement/verify.js +0 -295
package/src/element/statement.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
5
|
import Element from "../element";
|
|
6
|
-
import
|
|
6
|
+
import validateMixins from "../mixins/statement/validate";
|
|
7
7
|
|
|
8
8
|
import { define } from "../elements";
|
|
9
9
|
import { unifyStatement } from "../process/unify";
|
|
@@ -23,24 +23,32 @@ export default define(class Statement extends Element {
|
|
|
23
23
|
const singular = this.isSingular();
|
|
24
24
|
|
|
25
25
|
if (singular) {
|
|
26
|
-
|
|
26
|
+
const node = this.getNode();
|
|
27
|
+
|
|
28
|
+
metavariableName = node.getMetavariableName();
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
return metavariableName;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
isSingular() {
|
|
34
|
+
isSingular() {
|
|
35
|
+
const node = this.getNode(),
|
|
36
|
+
singular = node.isSingular();
|
|
37
|
+
|
|
38
|
+
return singular;
|
|
39
|
+
}
|
|
33
40
|
|
|
34
41
|
isTermContained(term, context) {
|
|
35
42
|
let termContained;
|
|
36
43
|
|
|
37
|
-
const
|
|
38
|
-
|
|
44
|
+
const node = this.getNode(),
|
|
45
|
+
termString = term.getString(),
|
|
46
|
+
statementString = this.getString(); ///
|
|
39
47
|
|
|
40
|
-
context.trace(`Is the '${termString}' term contained in the '${statementString}' statement...`,
|
|
48
|
+
context.trace(`Is the '${termString}' term contained in the '${statementString}' statement...`, node);
|
|
41
49
|
|
|
42
50
|
const termNode = term.getNode(),
|
|
43
|
-
statementNode =
|
|
51
|
+
statementNode = node, ///
|
|
44
52
|
statementNodeTermNodes = statementNode.getTermNodes();
|
|
45
53
|
|
|
46
54
|
termContained = statementNodeTermNodes.some((statementNodeTermNode) => { ///
|
|
@@ -52,7 +60,7 @@ export default define(class Statement extends Element {
|
|
|
52
60
|
});
|
|
53
61
|
|
|
54
62
|
if (termContained) {
|
|
55
|
-
context.debug(`...the '${termString}' term is contained in the '${statementString}' statement.`,
|
|
63
|
+
context.debug(`...the '${termString}' term is contained in the '${statementString}' statement.`, node);
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
return termContained;
|
|
@@ -61,13 +69,14 @@ export default define(class Statement extends Element {
|
|
|
61
69
|
isFrameContained(frame, context) {
|
|
62
70
|
let frameContained;
|
|
63
71
|
|
|
64
|
-
const
|
|
65
|
-
|
|
72
|
+
const node = this.getNode(),
|
|
73
|
+
frameString = frame.getString(),
|
|
74
|
+
statementString = this.getString(); ///
|
|
66
75
|
|
|
67
|
-
context.trace(`Is the '${frameString}' frame contained in the '${statementString}' statement...`,
|
|
76
|
+
context.trace(`Is the '${frameString}' frame contained in the '${statementString}' statement...`, node);
|
|
68
77
|
|
|
69
78
|
const frameNode = frame.getNode(),
|
|
70
|
-
statementNode =
|
|
79
|
+
statementNode = node,
|
|
71
80
|
statementNodeFrameNodes = statementNode.getFrameNodes();
|
|
72
81
|
|
|
73
82
|
frameContained = statementNodeFrameNodes.some((statementNodeFrameNode) => { ///
|
|
@@ -79,7 +88,7 @@ export default define(class Statement extends Element {
|
|
|
79
88
|
});
|
|
80
89
|
|
|
81
90
|
if (frameContained) {
|
|
82
|
-
context.debug(`...the '${frameString}' frame is contained in the '${statementString}' statement.`,
|
|
91
|
+
context.debug(`...the '${frameString}' frame is contained in the '${statementString}' statement.`, node);
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
return frameContained;
|
|
@@ -91,8 +100,9 @@ export default define(class Statement extends Element {
|
|
|
91
100
|
const singular = this.isSingular();
|
|
92
101
|
|
|
93
102
|
if (singular) {
|
|
94
|
-
const
|
|
95
|
-
|
|
103
|
+
const node = this.getNode(),
|
|
104
|
+
metavariableA = metavariable, ///
|
|
105
|
+
singularMetavariableNode = node.getSingularMetavariableNode(),
|
|
96
106
|
metavariableName = singularMetavariableNode.getMetavariableName();
|
|
97
107
|
|
|
98
108
|
metavariable = context.findMetavariableByMetavariableName(metavariableName)
|
|
@@ -106,63 +116,64 @@ export default define(class Statement extends Element {
|
|
|
106
116
|
return metavariableEqualToMetavariable;
|
|
107
117
|
}
|
|
108
118
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
verify(assignments, stated, context) {
|
|
112
|
-
let verifies;
|
|
119
|
+
validate(assignments, stated, context) {
|
|
120
|
+
let validates;
|
|
113
121
|
|
|
114
|
-
const
|
|
122
|
+
const node = this.getNode(),
|
|
123
|
+
statementString = this.getString(); ///
|
|
115
124
|
|
|
116
|
-
context.trace(`
|
|
125
|
+
context.trace(`Validating the '${statementString}' statement...`, node);
|
|
117
126
|
|
|
118
|
-
|
|
127
|
+
validates = validateMixins.some((validateMixin) => {
|
|
119
128
|
const statement = this, ///
|
|
120
|
-
|
|
129
|
+
validates = validateMixin(statement, assignments, stated, context);
|
|
121
130
|
|
|
122
|
-
if (
|
|
131
|
+
if (validates) {
|
|
123
132
|
return true;
|
|
124
133
|
}
|
|
125
134
|
});
|
|
126
135
|
|
|
127
|
-
if (
|
|
136
|
+
if (validates) {
|
|
128
137
|
const statement = this; ///
|
|
129
138
|
|
|
130
139
|
context.addStatement(statement);
|
|
131
140
|
|
|
132
|
-
context.debug(`...
|
|
141
|
+
context.debug(`...validated the '${statementString}' statement.`, node);
|
|
133
142
|
}
|
|
134
143
|
|
|
135
|
-
return
|
|
144
|
+
return validates;
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
|
|
139
|
-
let
|
|
147
|
+
validateGivenMetaType(metaType, assignments, stated, context) {
|
|
148
|
+
let validatesGivenMetaType = false;
|
|
140
149
|
|
|
141
|
-
const
|
|
142
|
-
|
|
150
|
+
const node = this.getNode(),
|
|
151
|
+
metaTypeString = metaType.getString(),
|
|
152
|
+
statementString = this.getString(); ///
|
|
143
153
|
|
|
144
|
-
context.trace(`
|
|
154
|
+
context.trace(`Validating the '${statementString}' statement given the '${metaTypeString}' meta-type...`, node);
|
|
145
155
|
|
|
146
156
|
const metaTypeName = metaType.getName();
|
|
147
157
|
|
|
148
158
|
if (metaTypeName === STATEMENT_META_TYPE_NAME) {
|
|
149
|
-
const
|
|
159
|
+
const validates = this.validate(assignments, stated, context)
|
|
150
160
|
|
|
151
|
-
|
|
161
|
+
validatesGivenMetaType = validates; ///
|
|
152
162
|
}
|
|
153
163
|
|
|
154
|
-
if (
|
|
155
|
-
context.debug(`...
|
|
164
|
+
if (validatesGivenMetaType) {
|
|
165
|
+
context.debug(`...validated the '${statementString}' statement given the '${metaTypeString}' meta-type.`, node);
|
|
156
166
|
}
|
|
157
167
|
|
|
158
|
-
return
|
|
168
|
+
return validatesGivenMetaType;
|
|
159
169
|
}
|
|
160
170
|
|
|
161
171
|
unifySubproof(subproof, substitutions, generalContext, specificContext) {
|
|
162
172
|
let subproofUnifies = false;
|
|
163
173
|
|
|
164
|
-
const
|
|
165
|
-
|
|
174
|
+
const node = this.getNode(),
|
|
175
|
+
context = specificContext, ///
|
|
176
|
+
statementNode = node,
|
|
166
177
|
subproofAssertionNode = statementNode.getSubproofAssertionNode(),
|
|
167
178
|
assertionNode = subproofAssertionNode; ///
|
|
168
179
|
|
|
@@ -219,11 +230,12 @@ export default define(class Statement extends Element {
|
|
|
219
230
|
let unifiesIndependently = false;
|
|
220
231
|
|
|
221
232
|
const context = specificContext, ///
|
|
222
|
-
statementString = this.
|
|
233
|
+
statementString = this.getString(); ///
|
|
223
234
|
|
|
224
235
|
context.trace(`Unifying the '${statementString}' statement independently...`);
|
|
225
236
|
|
|
226
|
-
const
|
|
237
|
+
const node = this.getNode(),
|
|
238
|
+
statementNode = node, ///
|
|
227
239
|
definedAssertionNode = statementNode.getDefinedAssertionNode(),
|
|
228
240
|
containedAssertionNode = statementNode.getContainedAssertionNode();
|
|
229
241
|
|
|
@@ -260,7 +272,7 @@ export default define(class Statement extends Element {
|
|
|
260
272
|
}
|
|
261
273
|
|
|
262
274
|
toJSON() {
|
|
263
|
-
const string = this.
|
|
275
|
+
const string = this.getString(),
|
|
264
276
|
json = {
|
|
265
277
|
string
|
|
266
278
|
};
|
|
@@ -273,8 +285,11 @@ export default define(class Statement extends Element {
|
|
|
273
285
|
static fromJSON(json, context) {
|
|
274
286
|
const { string } = json,
|
|
275
287
|
statmentNode = instantiateStatement(string, context),
|
|
276
|
-
node = statmentNode
|
|
277
|
-
|
|
288
|
+
node = statmentNode; ///,
|
|
289
|
+
|
|
290
|
+
context = null;
|
|
291
|
+
|
|
292
|
+
const statement = new Statement(context, string, node);
|
|
278
293
|
|
|
279
294
|
return statement;
|
|
280
295
|
}
|
package/src/element/step.js
CHANGED
|
@@ -67,8 +67,8 @@ export default define(class Step extends Element {
|
|
|
67
67
|
return termAndPropertyRelationMatch;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
let
|
|
70
|
+
validate(substitutions, assignments, context) {
|
|
71
|
+
let validates = false;
|
|
72
72
|
|
|
73
73
|
const temporaryContext = TemporaryContext.fromNothing(context);
|
|
74
74
|
|
|
@@ -76,11 +76,11 @@ export default define(class Step extends Element {
|
|
|
76
76
|
|
|
77
77
|
const stepString = this.string; ///
|
|
78
78
|
|
|
79
|
-
context.trace(`
|
|
79
|
+
context.trace(`Validating the '${stepString}' step...`, this.node);
|
|
80
80
|
|
|
81
81
|
if (this.statement !== null) {
|
|
82
82
|
const stated = this.isStated(),
|
|
83
|
-
statementVerifies = this.statement.
|
|
83
|
+
statementVerifies = this.statement.validate(assignments, stated, context);
|
|
84
84
|
|
|
85
85
|
if (statementVerifies) {
|
|
86
86
|
const qualified = this.isQualified(),
|
|
@@ -89,34 +89,34 @@ export default define(class Step extends Element {
|
|
|
89
89
|
if (false) {
|
|
90
90
|
///
|
|
91
91
|
} else if (qualified) {
|
|
92
|
-
const referenceVerifies = this.reference.
|
|
92
|
+
const referenceVerifies = this.reference.validate(context);
|
|
93
93
|
|
|
94
94
|
if (referenceVerifies) {
|
|
95
|
-
|
|
95
|
+
validates = true;
|
|
96
96
|
}
|
|
97
97
|
} else if (satisfied) {
|
|
98
98
|
const stated = true,
|
|
99
99
|
assignments = null,
|
|
100
|
-
satisfiesAssertionVerifies = this.satisfiesAssertion.
|
|
100
|
+
satisfiesAssertionVerifies = this.satisfiesAssertion.validate(assignments, stated, context);
|
|
101
101
|
|
|
102
102
|
if (satisfiesAssertionVerifies) {
|
|
103
|
-
|
|
103
|
+
validates = true;
|
|
104
104
|
}
|
|
105
105
|
} else {
|
|
106
|
-
|
|
106
|
+
validates = true;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
} else {
|
|
110
|
-
context.debug(`Cannot
|
|
110
|
+
context.debug(`Cannot validate the '${stepString}' step because it is nonsense.`, this.node);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
if (
|
|
113
|
+
if (validates) {
|
|
114
114
|
this.context = context;
|
|
115
115
|
|
|
116
116
|
context.debug(`...verified the '${stepString}' step.`, this.node);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
return
|
|
119
|
+
return validates;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
unify(substitutions, context) {
|
|
@@ -32,9 +32,9 @@ export default define(class SubDerivation extends Element {
|
|
|
32
32
|
|
|
33
33
|
verifies = this.stepsOrSubproofs.every((stepOrSubproof) => { ///
|
|
34
34
|
const assignments = [],
|
|
35
|
-
|
|
35
|
+
stepOrSubproofValidates = stepOrSubproof.validate(substitutions, assignments, context);
|
|
36
36
|
|
|
37
|
-
if (
|
|
37
|
+
if (stepOrSubproofValidates) {
|
|
38
38
|
const stepOrSubproofUnifies = stepOrSubproof.unify(substitutions, context);
|
|
39
39
|
|
|
40
40
|
if (stepOrSubproofUnifies) {
|
package/src/element.js
CHANGED
|
@@ -19,6 +19,18 @@ export default class Element {
|
|
|
19
19
|
return this.node;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
setContext(context) {
|
|
23
|
+
this.context = context;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setString(string) {
|
|
27
|
+
this.string = string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setNode(node) {
|
|
31
|
+
this.node = node;
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
isEQualTo(element) {
|
|
23
35
|
const elementNode = element.getNode(),
|
|
24
36
|
matches = this.node.match(elementNode),
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import elements from "../../elements";
|
|
4
|
+
|
|
5
|
+
import { equalityFromStatement,
|
|
6
|
+
judgementFromStatement,
|
|
7
|
+
metavariableFromStatement,
|
|
8
|
+
typeAssertionFromStatement,
|
|
9
|
+
definedAssertionFromStatement,
|
|
10
|
+
propertyAssertionFromStatement,
|
|
11
|
+
subproofAssertionFromStatement,
|
|
12
|
+
containedAssertionFromStatement,
|
|
13
|
+
satisfiesAssertionFromStatement } from "../../utilities/statement";
|
|
14
|
+
|
|
15
|
+
function validateAsMetavariableAndSubstitution(statement, assignments, stated, context) {
|
|
16
|
+
let validatesAsMetavariableAndSubstitution = false;
|
|
17
|
+
|
|
18
|
+
const metavariable = metavariableFromStatement(statement, context);
|
|
19
|
+
|
|
20
|
+
if (metavariable !== null) {
|
|
21
|
+
const statementString = statement.getString();
|
|
22
|
+
|
|
23
|
+
context.trace(`Validating the '${statementString}' statement as a metavariable and substitution...`);
|
|
24
|
+
|
|
25
|
+
const metavariableValidates = metavariable.validate(context);
|
|
26
|
+
|
|
27
|
+
if (metavariableValidates) {
|
|
28
|
+
const { TermSubstitution, FrameSubstitution } = elements,
|
|
29
|
+
frameSubstitution = FrameSubstitution.fromStatement(statement, context),
|
|
30
|
+
termSubstitution = TermSubstitution.fromStatement(statement, context),
|
|
31
|
+
substitution = (termSubstitution || frameSubstitution);
|
|
32
|
+
|
|
33
|
+
if (substitution !== null) {
|
|
34
|
+
const substitutionValidates = substitution.validate(context);
|
|
35
|
+
|
|
36
|
+
if (substitutionValidates) {
|
|
37
|
+
validatesAsMetavariableAndSubstitution = true;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
validatesAsMetavariableAndSubstitution = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (validatesAsMetavariableAndSubstitution) {
|
|
45
|
+
context.debug(`...validated the '${statementString}' statement as a metavariable and substitution.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return validatesAsMetavariableAndSubstitution;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function unifyWithBracketedCombinatorStatement(statement, assignments, stated, context) {
|
|
53
|
+
stated = true; ///
|
|
54
|
+
|
|
55
|
+
assignments = null; ///
|
|
56
|
+
|
|
57
|
+
const { BracketedCombinatorStatement } = elements,
|
|
58
|
+
bracketedCombinatorStatement = BracketedCombinatorStatement.fromNothing(),
|
|
59
|
+
unifiesWithBracketedCombinatorStatement = bracketedCombinatorStatement.unifyStatement(statement, assignments, stated, context);
|
|
60
|
+
|
|
61
|
+
return unifiesWithBracketedCombinatorStatement;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function unifyWithCombinators(statement, assignments, stated, context) {
|
|
65
|
+
stated = true; ///
|
|
66
|
+
|
|
67
|
+
assignments = null; ///
|
|
68
|
+
|
|
69
|
+
const combinators = context.getCombinators(),
|
|
70
|
+
unifiesWithCombinators = combinators.some((combinator) => {
|
|
71
|
+
const unifiesWithCombinator = combinator.unifyStatement(statement, assignments, stated, context);
|
|
72
|
+
|
|
73
|
+
if (unifiesWithCombinator) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return unifiesWithCombinators;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function validateAsEquality(statement, assignments, stated, context) {
|
|
82
|
+
let validatesAsEquality = false;
|
|
83
|
+
|
|
84
|
+
const equality = equalityFromStatement(statement, context);
|
|
85
|
+
|
|
86
|
+
if (equality !== null) {
|
|
87
|
+
const statementString = statement.getString();
|
|
88
|
+
|
|
89
|
+
context.trace(`Validating the '${statementString}' statement as an equality...`);
|
|
90
|
+
|
|
91
|
+
const equalityValidates = equality.validate(assignments, stated, context);
|
|
92
|
+
|
|
93
|
+
validatesAsEquality = equalityValidates; ///
|
|
94
|
+
|
|
95
|
+
if (validatesAsEquality) {
|
|
96
|
+
context.debug(`...validated the '${statementString}' statement as an equality.`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return validatesAsEquality;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function validateAsJudgement(statement, assignments, stated, context) {
|
|
104
|
+
let validatesAsJudgement = false;
|
|
105
|
+
|
|
106
|
+
const judgement = judgementFromStatement(statement, context);
|
|
107
|
+
|
|
108
|
+
if (judgement !== null) {
|
|
109
|
+
const statementString = statement.getString();
|
|
110
|
+
|
|
111
|
+
context.trace(`Validating the '${statementString}' statement as a judgement...`);
|
|
112
|
+
|
|
113
|
+
const judgementValidates = judgement.validate(assignments, stated, context);
|
|
114
|
+
|
|
115
|
+
validatesAsJudgement = judgementValidates; ///
|
|
116
|
+
|
|
117
|
+
if (validatesAsJudgement) {
|
|
118
|
+
context.debug(`...validated the '${statementString}' statement as a judgement.`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return validatesAsJudgement;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function validateAsTypeAssertion(statement, assignments, stated, context) {
|
|
126
|
+
let validatesAsTypeAssertion = false;
|
|
127
|
+
|
|
128
|
+
const typeAssertion = typeAssertionFromStatement(statement, context);
|
|
129
|
+
|
|
130
|
+
if (typeAssertion !== null) {
|
|
131
|
+
const statementString = statement.getString();
|
|
132
|
+
|
|
133
|
+
context.trace(`Validating the '${statementString}' statement as a type assertion...`);
|
|
134
|
+
|
|
135
|
+
const typeAssertionValidates = typeAssertion.validate(assignments, stated, context);
|
|
136
|
+
|
|
137
|
+
validatesAsTypeAssertion = typeAssertionValidates; ///
|
|
138
|
+
|
|
139
|
+
if (validatesAsTypeAssertion) {
|
|
140
|
+
const assertion = typeAssertion; ///
|
|
141
|
+
|
|
142
|
+
context.addAssertion(assertion);
|
|
143
|
+
|
|
144
|
+
context.debug(`...validated the '${statementString}' statement as a type assertion.`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return validatesAsTypeAssertion;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function validateAsDefinedAssertion(statement, assignments, stated, context) {
|
|
152
|
+
let validatesAsDefinedAssertion = false;
|
|
153
|
+
|
|
154
|
+
const definedAssertion = definedAssertionFromStatement(statement, context);
|
|
155
|
+
|
|
156
|
+
if (definedAssertion !== null) {
|
|
157
|
+
const statementString = statement.getString();
|
|
158
|
+
|
|
159
|
+
context.trace(`Validating the '${statementString}' statement as a defined assertion...`);
|
|
160
|
+
|
|
161
|
+
const definedAssertionValidates = definedAssertion.validate(assignments, stated, context);
|
|
162
|
+
|
|
163
|
+
validatesAsDefinedAssertion = definedAssertionValidates; ///
|
|
164
|
+
|
|
165
|
+
if (validatesAsDefinedAssertion) {
|
|
166
|
+
const assertion = definedAssertion; ///
|
|
167
|
+
|
|
168
|
+
context.addAssertion(assertion);
|
|
169
|
+
|
|
170
|
+
context.debug(`...validated the '${statementString}' statement as a defined assertion.`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return validatesAsDefinedAssertion;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function validateAsPropertyAssertion(statement, assignments, stated, context) {
|
|
178
|
+
let validatesAsPropertyAssertion = false;
|
|
179
|
+
|
|
180
|
+
const propertyAssertion = propertyAssertionFromStatement(statement, context);
|
|
181
|
+
|
|
182
|
+
if (propertyAssertion !== null) {
|
|
183
|
+
const statementString = statement.getString();
|
|
184
|
+
|
|
185
|
+
context.trace(`Validating the '${statementString}' statement as a property assertion...`);
|
|
186
|
+
|
|
187
|
+
const propertyAssertionValidates = propertyAssertion.validate(assignments, stated, context);
|
|
188
|
+
|
|
189
|
+
validatesAsPropertyAssertion = propertyAssertionValidates; ///
|
|
190
|
+
|
|
191
|
+
if (validatesAsPropertyAssertion) {
|
|
192
|
+
const assertion = propertyAssertion; ///
|
|
193
|
+
|
|
194
|
+
context.addAssertion(assertion);
|
|
195
|
+
|
|
196
|
+
context.debug(`...validated the '${statementString}' statement as a property assertion.`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return validatesAsPropertyAssertion;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function validateAsSubproofAssertion(statement, assignments, stated, context) {
|
|
204
|
+
let validatesAsSubproofAssertion = false;
|
|
205
|
+
|
|
206
|
+
const subproofAssertion = subproofAssertionFromStatement(statement, context);
|
|
207
|
+
|
|
208
|
+
if (subproofAssertion !== null) {
|
|
209
|
+
const statementString = statement.getString();
|
|
210
|
+
|
|
211
|
+
context.trace(`Validating the '${statementString}' statement as a subproof assertion...`);
|
|
212
|
+
|
|
213
|
+
const subproofAssertionValidates = subproofAssertion.validate(assignments, stated, context);
|
|
214
|
+
|
|
215
|
+
validatesAsSubproofAssertion = subproofAssertionValidates; ///
|
|
216
|
+
|
|
217
|
+
if (validatesAsSubproofAssertion) {
|
|
218
|
+
const assertion = subproofAssertion; ///
|
|
219
|
+
|
|
220
|
+
context.addAssertion(assertion);
|
|
221
|
+
|
|
222
|
+
context.debug(`...validated the '${statementString}' statement as a subproof assertion.`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return validatesAsSubproofAssertion;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function validateAsContainedAssertion(statement, assignments, stated, context) {
|
|
230
|
+
let validatesAsContainedAssertion = false;
|
|
231
|
+
|
|
232
|
+
const containedAssertion = containedAssertionFromStatement(statement, context);
|
|
233
|
+
|
|
234
|
+
if (containedAssertion !== null) {
|
|
235
|
+
const statementString = statement.getString();
|
|
236
|
+
|
|
237
|
+
context.trace(`Validating the '${statementString}' statement as a contained assertion...`);
|
|
238
|
+
|
|
239
|
+
const containedAssertionValidates = containedAssertion.validate(assignments, stated, context);
|
|
240
|
+
|
|
241
|
+
validatesAsContainedAssertion = containedAssertionValidates; ///
|
|
242
|
+
|
|
243
|
+
if (validatesAsContainedAssertion) {
|
|
244
|
+
const assertion = containedAssertion; ///
|
|
245
|
+
|
|
246
|
+
context.addAssertion(assertion);
|
|
247
|
+
|
|
248
|
+
context.debug(`...validated the '${statementString}' statement as a contained assertion.`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return validatesAsContainedAssertion;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function validateAsSatisfiesAssertion(statement, assignments, stated, context) {
|
|
256
|
+
let validatesAsSatisfiesAssertion = false;
|
|
257
|
+
|
|
258
|
+
const satisfiesAssertion = satisfiesAssertionFromStatement(statement, context);
|
|
259
|
+
|
|
260
|
+
if (satisfiesAssertion !== null) {
|
|
261
|
+
const statementString = statement.getString();
|
|
262
|
+
|
|
263
|
+
context.trace(`Validating the '${statementString}' statement as a satisfies assertion...`);
|
|
264
|
+
|
|
265
|
+
const satisfiesAssertionValidates = satisfiesAssertion.validate(assignments, stated, context);
|
|
266
|
+
|
|
267
|
+
validatesAsSatisfiesAssertion = satisfiesAssertionValidates; ///
|
|
268
|
+
|
|
269
|
+
if (validatesAsSatisfiesAssertion) {
|
|
270
|
+
const assertion = satisfiesAssertion; ///
|
|
271
|
+
|
|
272
|
+
context.addAssertion(assertion);
|
|
273
|
+
|
|
274
|
+
context.debug(`...validated the '${statementString}' statement as a satisfies assertion.`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return validatesAsSatisfiesAssertion;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const validateMixins = [
|
|
282
|
+
validateAsMetavariableAndSubstitution,
|
|
283
|
+
unifyWithBracketedCombinatorStatement,
|
|
284
|
+
unifyWithCombinators,
|
|
285
|
+
validateAsEquality,
|
|
286
|
+
validateAsJudgement,
|
|
287
|
+
validateAsTypeAssertion,
|
|
288
|
+
validateAsDefinedAssertion,
|
|
289
|
+
validateAsPropertyAssertion,
|
|
290
|
+
validateAsSubproofAssertion,
|
|
291
|
+
validateAsContainedAssertion,
|
|
292
|
+
validateAsSatisfiesAssertion
|
|
293
|
+
];
|
|
294
|
+
|
|
295
|
+
export default validateMixins;
|
package/src/utilities/element.js
CHANGED
|
@@ -40,8 +40,11 @@ export function termFromTermNode(termNode, context) {
|
|
|
40
40
|
const { Term } = elements,
|
|
41
41
|
node = termNode, ///
|
|
42
42
|
string = context.nodeAsString(node),
|
|
43
|
-
type = null
|
|
44
|
-
|
|
43
|
+
type = null;
|
|
44
|
+
|
|
45
|
+
context = null;
|
|
46
|
+
|
|
47
|
+
const term = new Term(context, string, node, type);
|
|
45
48
|
|
|
46
49
|
return term;
|
|
47
50
|
}
|
|
@@ -67,7 +70,7 @@ export function ruleFromRuleNode(ruleNode, context) {
|
|
|
67
70
|
ruleString = rulsStringFromLabelsPremisesAndConclusion(labels, premises, conclusion),
|
|
68
71
|
node = ruleNode, ///
|
|
69
72
|
string = ruleString, ///
|
|
70
|
-
rule = new Rule(context, string, node, labels, premises, conclusion
|
|
73
|
+
rule = new Rule(context, string, node, proof, labels, premises, conclusion);
|
|
71
74
|
|
|
72
75
|
return rule;
|
|
73
76
|
}
|
|
@@ -278,8 +281,11 @@ export function deductionFromDeductionNode(deductionNode, context) {
|
|
|
278
281
|
export function statementFromStatementNode(statementNode, context) {
|
|
279
282
|
const { Statement } = elements,
|
|
280
283
|
node = statementNode, ///
|
|
281
|
-
string = context.nodeAsString(node)
|
|
282
|
-
|
|
284
|
+
string = context.nodeAsString(node);
|
|
285
|
+
|
|
286
|
+
context = null;
|
|
287
|
+
|
|
288
|
+
const statement = new Statement(context, string, node);
|
|
283
289
|
|
|
284
290
|
return statement;
|
|
285
291
|
}
|
|
@@ -1122,11 +1128,9 @@ export function termFromTermSubstitutionNode(termSubstitutionNode, context) {
|
|
|
1122
1128
|
export function metavariableFromStatementNode(statementNode, context) {
|
|
1123
1129
|
let metavariable = null;
|
|
1124
1130
|
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
if (singularMetavariableNode !== null) {
|
|
1128
|
-
const metavariableNode = singularMetavariableNode; ///
|
|
1131
|
+
const metavariableNode = statementNode.getMetavariableNode();
|
|
1129
1132
|
|
|
1133
|
+
if (metavariableNode !== null) {
|
|
1130
1134
|
metavariable = metavariableFromMetavariableNode(metavariableNode, context);
|
|
1131
1135
|
}
|
|
1132
1136
|
|