occam-verify-cli 0.0.1067 → 0.0.1068
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/assertion/contained.js +2 -2
- package/lib/assertion/defined.js +2 -2
- package/lib/assignment/judgement.js +3 -3
- package/lib/conclusion.js +4 -4
- package/lib/consequent.js +4 -4
- package/lib/declaration.js +90 -3
- package/lib/frame.js +109 -48
- package/lib/judgement.js +84 -5
- package/lib/metaType.js +24 -3
- package/lib/metavariable.js +93 -25
- package/lib/mixins/statement/unify.js +2 -17
- package/lib/mixins/statement/verify.js +13 -13
- package/lib/premise.js +10 -6
- package/lib/reference.js +11 -9
- package/lib/rule.js +5 -2
- package/lib/ruleNames.js +5 -1
- package/lib/statement/unqualified.js +26 -2
- package/lib/statement.js +4 -2
- package/lib/substitution/frameForMetavariable.js +61 -60
- package/lib/substitution/statementForMetavariable.js +52 -29
- package/lib/substitution/termForVariable.js +53 -52
- package/lib/substitution.js +28 -28
- package/lib/substitutions.js +46 -40
- package/lib/supposition.js +4 -4
- package/lib/unifier/intrinsicLevel.js +4 -4
- package/lib/unifier/metaLevel.js +11 -7
- package/lib/unifier/statementWithCombinator.js +2 -2
- package/lib/utilities/node.js +24 -10
- package/lib/utilities/tokens.js +8 -1
- package/lib/variable.js +9 -5
- package/package.json +1 -1
- package/src/assertion/contained.js +1 -1
- package/src/assertion/defined.js +1 -1
- package/src/assignment/judgement.js +3 -4
- package/src/conclusion.js +4 -4
- package/src/consequent.js +4 -4
- package/src/declaration.js +57 -4
- package/src/frame.js +149 -90
- package/src/judgement.js +109 -3
- package/src/metaType.js +29 -3
- package/src/metavariable.js +145 -42
- package/src/mixins/statement/unify.js +1 -23
- package/src/mixins/statement/verify.js +15 -13
- package/src/premise.js +13 -6
- package/src/reference.js +11 -7
- package/src/rule.js +7 -1
- package/src/ruleNames.js +1 -0
- package/src/statement/unqualified.js +31 -1
- package/src/statement.js +3 -1
- package/src/substitution/frameForMetavariable.js +65 -84
- package/src/substitution/statementForMetavariable.js +63 -32
- package/src/substitution/termForVariable.js +56 -77
- package/src/substitution.js +21 -21
- package/src/substitutions.js +51 -46
- package/src/supposition.js +4 -4
- package/src/unifier/intrinsicLevel.js +4 -3
- package/src/unifier/metaLevel.js +19 -7
- package/src/unifier/statementWithCombinator.js +1 -1
- package/src/utilities/node.js +26 -10
- package/src/utilities/tokens.js +7 -0
- package/src/variable.js +14 -5
- package/lib/unify/metavariableWithFrame.js +0 -40
- package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -31
- package/lib/verify/declaration.js +0 -83
- package/lib/verify/frame.js +0 -120
- package/lib/verify/judgement.js +0 -88
- package/lib/verify/metavariableGivenMetaType.js +0 -44
- package/src/unify/metavariableWithFrame.js +0 -40
- package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -27
- package/src/verify/declaration.js +0 -113
- package/src/verify/frame.js +0 -157
- package/src/verify/judgement.js +0 -127
- package/src/verify/metavariableGivenMetaType.js +0 -45
package/src/metavariable.js
CHANGED
|
@@ -4,6 +4,7 @@ import shim from "./shim";
|
|
|
4
4
|
import Argument from "./argument";
|
|
5
5
|
import LocalContext from "./context/local";
|
|
6
6
|
import metavariableUnifier from "./unifier/metavariable";
|
|
7
|
+
import FrameForMetavariableSubstitution from "./substitution/frameForMetavariable";
|
|
7
8
|
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
8
9
|
|
|
9
10
|
import { nodeQuery } from "./utilities/query";
|
|
@@ -13,6 +14,7 @@ import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
|
13
14
|
const argumentNodeQuery = nodeQuery("/metavariable/argument"),
|
|
14
15
|
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
15
16
|
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
|
|
17
|
+
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
16
18
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
17
19
|
|
|
18
20
|
class Metavariable {
|
|
@@ -50,6 +52,12 @@ class Metavariable {
|
|
|
50
52
|
return metaTypeName;
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
matchMetaType(metaType) {
|
|
56
|
+
const metaTypeMatches = (this.metaType === metaType);
|
|
57
|
+
|
|
58
|
+
return metaTypeMatches;
|
|
59
|
+
}
|
|
60
|
+
|
|
53
61
|
matchMetavariableName(metavariableName) {
|
|
54
62
|
const metavariableNameMatches = (this.name === metavariableName);
|
|
55
63
|
|
|
@@ -62,6 +70,107 @@ class Metavariable {
|
|
|
62
70
|
return metavariableNodeMatches;
|
|
63
71
|
}
|
|
64
72
|
|
|
73
|
+
unifyFrame(frame, substitutions, localContext) {
|
|
74
|
+
let frameUnified = false;
|
|
75
|
+
|
|
76
|
+
const frameNode = frame.getNode(),
|
|
77
|
+
frameString = frame.getString(),
|
|
78
|
+
metavariableString = this.string; ///
|
|
79
|
+
|
|
80
|
+
localContext.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
81
|
+
|
|
82
|
+
const metavariableName = this.name, ///
|
|
83
|
+
simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableName(metavariableName);
|
|
84
|
+
|
|
85
|
+
if (simpleSubstitutionPresent) {
|
|
86
|
+
const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableName(metavariableName),
|
|
87
|
+
substitution = simpleSubstitution, ///
|
|
88
|
+
frameNodeMatches = substitution.matchFrameNode(frameNode);
|
|
89
|
+
|
|
90
|
+
if (frameNodeMatches) {
|
|
91
|
+
frameUnified = true;
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
const metavariableNode = this.node, ///
|
|
95
|
+
metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
|
|
96
|
+
frameMetavariable = frameMetavariableFromStatementNode(frameNode, localContext);
|
|
97
|
+
|
|
98
|
+
if (metavariable === frameMetavariable) {
|
|
99
|
+
frameUnified = true;
|
|
100
|
+
} else {
|
|
101
|
+
const metavariable = this, ///
|
|
102
|
+
frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameAndMetavariable(frame, metavariable, localContext),
|
|
103
|
+
substitution = frameForMetavariableSubstitution; ///
|
|
104
|
+
|
|
105
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
106
|
+
|
|
107
|
+
frameUnified = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (frameUnified) {
|
|
112
|
+
localContext.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return frameUnified;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
unifyStatement(statement, substitution, substitutions, localContext) {
|
|
119
|
+
let statementUnified = false;
|
|
120
|
+
|
|
121
|
+
const statementString = statement.getString(),
|
|
122
|
+
metavariableString = this.string, ///
|
|
123
|
+
substitutionString = (substitution !== null) ?
|
|
124
|
+
substitution.getString() :
|
|
125
|
+
null;
|
|
126
|
+
|
|
127
|
+
(substitutionString !== null) ?
|
|
128
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution...`) :
|
|
129
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
130
|
+
|
|
131
|
+
const statementNode = statement.getNode(),
|
|
132
|
+
metavariableNode = this.node, ///
|
|
133
|
+
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
134
|
+
substitutionNode = (substitution !== null) ?
|
|
135
|
+
substitution.getSubstitutionNode() :
|
|
136
|
+
null,
|
|
137
|
+
substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode);
|
|
138
|
+
|
|
139
|
+
if (substitutionPresent) {
|
|
140
|
+
const substitution = substitutions.findSubstitutionByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode),
|
|
141
|
+
statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
142
|
+
|
|
143
|
+
if (statementNodeMatches) {
|
|
144
|
+
statementUnified = true;
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
const metavariableNode = this.node, ///
|
|
148
|
+
metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
|
|
149
|
+
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
150
|
+
|
|
151
|
+
if (metavariable === statementMetavariable) {
|
|
152
|
+
statementUnified = true;
|
|
153
|
+
} else {
|
|
154
|
+
const metavariable = this, ///
|
|
155
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
|
|
156
|
+
|
|
157
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
158
|
+
|
|
159
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
160
|
+
|
|
161
|
+
statementUnified = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (statementUnified) {
|
|
166
|
+
(substitutionString !== null) ?
|
|
167
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution.`) :
|
|
168
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return statementUnified;
|
|
172
|
+
}
|
|
173
|
+
|
|
65
174
|
verify(localContext) {
|
|
66
175
|
let verified;
|
|
67
176
|
|
|
@@ -80,7 +189,6 @@ class Metavariable {
|
|
|
80
189
|
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
81
190
|
|
|
82
191
|
verified = metavariableUnified; ///
|
|
83
|
-
|
|
84
192
|
}
|
|
85
193
|
|
|
86
194
|
if (verified) {
|
|
@@ -125,55 +233,29 @@ class Metavariable {
|
|
|
125
233
|
return verifiedAtTopLevel;
|
|
126
234
|
}
|
|
127
235
|
|
|
128
|
-
|
|
129
|
-
let
|
|
130
|
-
|
|
131
|
-
const statementString = statement.getString(),
|
|
132
|
-
metavariableString = this.string, ///
|
|
133
|
-
substitutionString = (substitution !== null) ?
|
|
134
|
-
substitution.getString() :
|
|
135
|
-
null;
|
|
136
|
-
|
|
137
|
-
(substitutionString !== null) ?
|
|
138
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution...`) :
|
|
139
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
140
|
-
|
|
141
|
-
const statementNode = statement.getNode(),
|
|
142
|
-
metavariableNode = this.node, ///
|
|
143
|
-
substitutionNode = (substitution !== null) ?
|
|
144
|
-
substitution.getSubstitutionNode() :
|
|
145
|
-
null,
|
|
146
|
-
substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
147
|
-
|
|
148
|
-
if (substitutionPresent) {
|
|
149
|
-
const substitution = substitutions.findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
|
|
150
|
-
statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
236
|
+
verifyGivenMetaType(metaType, localContext) {
|
|
237
|
+
let verifiedGivenMetaType = false;
|
|
151
238
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
const metavariable = this, ///
|
|
157
|
-
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
239
|
+
const metavariableString = this.string, ///
|
|
240
|
+
metaTypeString = metaType.getString();
|
|
158
241
|
|
|
159
|
-
|
|
160
|
-
statementUnified = true;
|
|
161
|
-
} else {
|
|
162
|
-
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
|
|
242
|
+
localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
|
|
163
243
|
|
|
164
|
-
|
|
244
|
+
const name = this.getName(),
|
|
245
|
+
metavariableName = name, ///
|
|
246
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
165
247
|
|
|
166
|
-
|
|
248
|
+
if (metavariable !== null) {
|
|
249
|
+
const metaTypeMatches = metavariable.matchMetaType(metaType);
|
|
167
250
|
|
|
168
|
-
|
|
169
|
-
}
|
|
251
|
+
verifiedGivenMetaType = metaTypeMatches; ///
|
|
170
252
|
}
|
|
171
253
|
|
|
172
|
-
(
|
|
173
|
-
localContext.debug(`...
|
|
174
|
-
|
|
254
|
+
if (verifiedGivenMetaType) {
|
|
255
|
+
localContext.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type.`);
|
|
256
|
+
}
|
|
175
257
|
|
|
176
|
-
return
|
|
258
|
+
return verifiedGivenMetaType;
|
|
177
259
|
}
|
|
178
260
|
|
|
179
261
|
toJSON() {
|
|
@@ -257,6 +339,27 @@ function metaTypeFromJSON(json, fileContext) {
|
|
|
257
339
|
return metaType;
|
|
258
340
|
}
|
|
259
341
|
|
|
342
|
+
function metavariableFromMetavariableNode(metavariableNode, localContext) {
|
|
343
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
344
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
345
|
+
|
|
346
|
+
return metavariable;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function frameMetavariableFromStatementNode(frameNode, localContext) {
|
|
350
|
+
let frameMetavariable = null;
|
|
351
|
+
|
|
352
|
+
const frameMetavariableNode = frameMetavariableNodeQuery(frameNode);
|
|
353
|
+
|
|
354
|
+
if (frameMetavariableNode !== null) {
|
|
355
|
+
const frameMetavariableName = metavariableNameFromMetavariableNode(frameMetavariableNode);
|
|
356
|
+
|
|
357
|
+
frameMetavariable = localContext.findMetavariableByMetavariableName(frameMetavariableName);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
return frameMetavariable;
|
|
361
|
+
}
|
|
362
|
+
|
|
260
363
|
function statementMetavariableFromStatementNode(statementNode, localContext) {
|
|
261
364
|
let statementMetavariable = null;
|
|
262
365
|
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
3
|
import BracketedCombinator from "../../combinator/bracketed";
|
|
6
4
|
import statementWithCombinatorUnifier from "../../unifier/statementWithCombinator";
|
|
7
5
|
|
|
8
|
-
const { reverse } = arrayUtilities;
|
|
9
|
-
|
|
10
6
|
function unifyWithBracketedCombinator(statement, assignments, stated, localContext) {
|
|
11
7
|
let unifiedWithBracketedCombinator;
|
|
12
8
|
|
|
@@ -47,28 +43,10 @@ function unifyWithCombinators(statement, assignments, stated, localContext) {
|
|
|
47
43
|
return unifiedWithCombinators;
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
function unifyWithProofSteps(statement, assignments, stated, localContext) {
|
|
51
|
-
let unifiedWithProofSteps;
|
|
52
|
-
|
|
53
|
-
let proofSteps = localContext.getProofSteps();
|
|
54
|
-
|
|
55
|
-
proofSteps = reverse(proofSteps); ///
|
|
56
|
-
|
|
57
|
-
unifiedWithProofSteps = proofSteps.some((proofStep) => {
|
|
58
|
-
const statementUnified = proofStep.unifyStatement(statement, localContext);
|
|
59
|
-
|
|
60
|
-
if (statementUnified) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
return unifiedWithProofSteps;
|
|
66
|
-
}
|
|
67
46
|
|
|
68
47
|
const unifyMixins = [
|
|
69
48
|
unifyWithBracketedCombinator,
|
|
70
|
-
unifyWithCombinators
|
|
71
|
-
unifyWithProofSteps
|
|
49
|
+
unifyWithCombinators
|
|
72
50
|
];
|
|
73
51
|
|
|
74
52
|
export default unifyMixins;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Frame from "../../frame";
|
|
3
4
|
import Equality from "../../equality";
|
|
5
|
+
import Judgement from "../../judgement";
|
|
6
|
+
import Declaration from "../../declaration";
|
|
4
7
|
import Metavariable from "../../metavariable";
|
|
5
8
|
import TypeAssertion from "../../assertion/type";
|
|
6
9
|
import DefinedAssertion from "../../assertion/defined";
|
|
7
10
|
import SubproofAssertion from "../../assertion/subproof";
|
|
8
11
|
import ContainedAssertion from "../../assertion/contained";
|
|
9
12
|
|
|
10
|
-
import verifyFrame from "../../verify/frame";
|
|
11
|
-
import verifyJudgement from "../../verify/judgement";
|
|
12
|
-
import verifyDeclaration from "../../verify/declaration";
|
|
13
|
-
|
|
14
13
|
import { nodeQuery } from "../../utilities/query";
|
|
15
14
|
|
|
16
15
|
const frameNodeQuery = nodeQuery("/statement/frame!"),
|
|
@@ -75,14 +74,15 @@ function verifyAsFrame(statement, assignments, stated, localContext) {
|
|
|
75
74
|
let verifiedAsFrame = false;
|
|
76
75
|
|
|
77
76
|
const statementNode = statement.getNode(),
|
|
78
|
-
frameNode = frameNodeQuery(statementNode)
|
|
77
|
+
frameNode = frameNodeQuery(statementNode),
|
|
78
|
+
frame = Frame.fromFrameNode(frameNode, localContext);
|
|
79
79
|
|
|
80
|
-
if (
|
|
80
|
+
if (frame !== null) {
|
|
81
81
|
const statementString = statement.getString();
|
|
82
82
|
|
|
83
83
|
localContext.trace(`Verifying the '${statementString}' statement as a frame...`);
|
|
84
84
|
|
|
85
|
-
const frameVerified =
|
|
85
|
+
const frameVerified = frame.verify(assignments, stated, localContext);
|
|
86
86
|
|
|
87
87
|
verifiedAsFrame = frameVerified; ///
|
|
88
88
|
|
|
@@ -98,14 +98,15 @@ function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
|
98
98
|
let verifiedAsJudgement = false;
|
|
99
99
|
|
|
100
100
|
const statementNode = statement.getNode(),
|
|
101
|
-
judgementNode = judgementNodeQuery(statementNode)
|
|
101
|
+
judgementNode = judgementNodeQuery(statementNode),
|
|
102
|
+
judgement = Judgement.fromJudgementNode(judgementNode, localContext);
|
|
102
103
|
|
|
103
|
-
if (
|
|
104
|
+
if (judgement !== null) {
|
|
104
105
|
const statementString = statement.getString();
|
|
105
106
|
|
|
106
107
|
localContext.trace(`Verifying the '${statementString}' statement as a judgement...`);
|
|
107
108
|
|
|
108
|
-
const judgementVerified =
|
|
109
|
+
const judgementVerified = judgement.verify(assignments, stated, localContext);
|
|
109
110
|
|
|
110
111
|
verifiedAsJudgement = judgementVerified; ///
|
|
111
112
|
|
|
@@ -121,14 +122,15 @@ function verifyAsDeclaration(statement, assignments, stated, localContext) {
|
|
|
121
122
|
let verifiedAsDeclaration = false;
|
|
122
123
|
|
|
123
124
|
const statementNode = statement.getNode(),
|
|
124
|
-
declarationNode = declarationNodeQuery(statementNode)
|
|
125
|
+
declarationNode = declarationNodeQuery(statementNode),
|
|
126
|
+
declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
125
127
|
|
|
126
|
-
if (
|
|
128
|
+
if (declaration !== null) {
|
|
127
129
|
const statementString = statement.getString();
|
|
128
130
|
|
|
129
131
|
localContext.trace(`Verifying the '${statementString}' statement as a declaration...`);
|
|
130
132
|
|
|
131
|
-
const declarationVerified =
|
|
133
|
+
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
132
134
|
|
|
133
135
|
verifiedAsDeclaration = declarationVerified; ///
|
|
134
136
|
|
package/src/premise.js
CHANGED
|
@@ -61,12 +61,19 @@ export default class Premise {
|
|
|
61
61
|
|
|
62
62
|
substitutions.snapshot();
|
|
63
63
|
|
|
64
|
+
let subproofUnified = false,
|
|
65
|
+
statementUnified = false;
|
|
66
|
+
|
|
64
67
|
if (false) {
|
|
65
68
|
///
|
|
66
69
|
} else if (subproof !== null) {
|
|
67
|
-
|
|
70
|
+
subproofUnified = this.unifySubproof(subproof, substitutions, localContext);
|
|
68
71
|
} else if (statement !== null) {
|
|
69
|
-
|
|
72
|
+
statementUnified = this.unifyStatement(statement, substitutions, localContext);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (subproofUnified || statementUnified) {
|
|
76
|
+
proofStepUnified = true;
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
proofStepUnified ?
|
|
@@ -82,18 +89,18 @@ export default class Premise {
|
|
|
82
89
|
const statementString = statement.getString(),
|
|
83
90
|
premiseString = this.getString();
|
|
84
91
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const localContextB = localContext;
|
|
92
|
+
const localContextB = localContext; ///
|
|
88
93
|
|
|
89
94
|
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
90
95
|
|
|
91
96
|
const localContextA = localContext; ///
|
|
92
97
|
|
|
98
|
+
localContextB.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
|
|
99
|
+
|
|
93
100
|
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
94
101
|
|
|
95
102
|
if (statementUnified) {
|
|
96
|
-
|
|
103
|
+
localContextB.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
return statementUnified;
|
package/src/reference.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Metavariable from "./metavariable";
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "./utilities/query";
|
|
6
|
+
import { referenceMetaType } from "./metaType";
|
|
6
7
|
|
|
7
8
|
const metavariableNodeQuery = nodeQuery("//reference/metavariable");
|
|
8
9
|
|
|
@@ -25,20 +26,23 @@ export default class Reference {
|
|
|
25
26
|
return metavariableNode;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
let
|
|
29
|
+
verify(localContext) {
|
|
30
|
+
let verified;
|
|
30
31
|
|
|
31
32
|
const referenceString = this.getString(); ///
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
localContext.trace(`Verifying the '${referenceString}' reference...`);
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
const metaType = referenceMetaType, ///
|
|
37
|
+
metavariableVerifiedGivenMetaType = this.metavariable.verifyGivenMetaType(metaType, localContext);
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
verified = metavariableVerifiedGivenMetaType; ///
|
|
40
|
+
|
|
41
|
+
if (verified) {
|
|
42
|
+
localContext.debug(`...verified the '${referenceString}' reference.`);
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
return
|
|
45
|
+
return verified;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
toJSON() {
|
package/src/rule.js
CHANGED
|
@@ -70,7 +70,13 @@ export default class Rule {
|
|
|
70
70
|
const statementUnifiedWithConclusion = this.conclusion.unifyStatement(statement, substitutions, localContext); ///
|
|
71
71
|
|
|
72
72
|
if (statementUnifiedWithConclusion) {
|
|
73
|
-
const
|
|
73
|
+
const localContextB = localContext; ///
|
|
74
|
+
|
|
75
|
+
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
76
|
+
|
|
77
|
+
const localContextA = localContext; ///
|
|
78
|
+
|
|
79
|
+
const substitutionsResolved = substitutions.resolve(localContextA, localContextB);
|
|
74
80
|
|
|
75
81
|
statementUnified = substitutionsResolved; ///
|
|
76
82
|
}
|
package/src/ruleNames.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
export const VARIABLE_RULE_NAME = "variable";
|
|
4
4
|
export const METAVARIABLE_RULE_NAME = "metavariable";
|
|
5
|
+
export const SUBSTITUTION_RULE_NAME = "substitution";
|
|
5
6
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
6
7
|
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
3
5
|
import shim from "../shim";
|
|
4
6
|
import LocalContext from "../context/local";
|
|
5
7
|
|
|
6
8
|
import { trim } from "../utilities/string";
|
|
7
9
|
import { nodeQuery } from "../utilities/query";
|
|
8
10
|
|
|
11
|
+
const { reverse } = arrayUtilities;
|
|
12
|
+
|
|
9
13
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement");
|
|
10
14
|
|
|
11
15
|
export default class UnqualifiedStatement {
|
|
@@ -32,7 +36,15 @@ export default class UnqualifiedStatement {
|
|
|
32
36
|
|
|
33
37
|
const statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
if (statementVerified) {
|
|
40
|
+
verified = true;
|
|
41
|
+
} else {
|
|
42
|
+
const statementUnifiedWithProofSteps = this.unifyStatementWithProofSteps(this.statement, assignments, stated, localContext);
|
|
43
|
+
|
|
44
|
+
if (statementUnifiedWithProofSteps) {
|
|
45
|
+
verified = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
36
48
|
|
|
37
49
|
if (verified) {
|
|
38
50
|
localContext.debug(`...verified the '${unqualifiedStatementString}' unqualified statement.`);
|
|
@@ -62,6 +74,24 @@ export default class UnqualifiedStatement {
|
|
|
62
74
|
return statementUnified;
|
|
63
75
|
}
|
|
64
76
|
|
|
77
|
+
unifyStatementWithProofSteps(statement, assignments, stated, localContext) {
|
|
78
|
+
let statementUnifiedWithProofSteps;
|
|
79
|
+
|
|
80
|
+
let proofSteps = localContext.getProofSteps();
|
|
81
|
+
|
|
82
|
+
proofSteps = reverse(proofSteps); ///
|
|
83
|
+
|
|
84
|
+
statementUnifiedWithProofSteps = proofSteps.some((proofStep) => {
|
|
85
|
+
const statementUnified = proofStep.unifyStatement(statement, localContext);
|
|
86
|
+
|
|
87
|
+
if (statementUnified) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return statementUnifiedWithProofSteps;
|
|
93
|
+
}
|
|
94
|
+
|
|
65
95
|
toJSON() {
|
|
66
96
|
const statementJSON = this.statement.toJSON(),
|
|
67
97
|
statement = statementJSON, ///
|
package/src/statement.js
CHANGED
|
@@ -126,7 +126,9 @@ class Statement {
|
|
|
126
126
|
|
|
127
127
|
statementUnified = unifiedAtMetaLevel; ///
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
if (statementUnified) {
|
|
130
|
+
localContextB.debug(`...unified the '${statementBString}' statement with the '${statementAString}' statement.`);
|
|
131
|
+
}
|
|
130
132
|
|
|
131
133
|
return statementUnified;
|
|
132
134
|
}
|