occam-verify-cli 0.0.1075 → 0.0.1077
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 +6 -4
- package/lib/assertion/defined.js +2 -2
- package/lib/assertion/subproof.js +46 -30
- package/lib/declaration.js +5 -8
- package/lib/metavariable.js +6 -5
- package/lib/mixins/statement/unify.js +2 -2
- package/lib/mixins/statement/verify.js +16 -46
- package/lib/premise.js +23 -19
- package/lib/proofStep.js +61 -23
- package/lib/rule.js +8 -10
- package/lib/statement/qualified.js +3 -3
- package/lib/substitution/statementForMetavariable.js +23 -13
- package/lib/substitutions.js +23 -3
- package/lib/supposition.js +29 -21
- package/lib/topLevelAssertion.js +11 -5
- package/lib/variable.js +2 -2
- package/lib/verifier/statementAsCombinator.js +4 -11
- package/lib/verifier/termAsConstructor.js +3 -3
- package/package.json +1 -1
- package/src/assertion/contained.js +7 -5
- package/src/assertion/defined.js +2 -2
- package/src/assertion/subproof.js +61 -42
- package/src/declaration.js +5 -8
- package/src/metavariable.js +5 -8
- package/src/mixins/statement/unify.js +2 -2
- package/src/mixins/statement/verify.js +23 -77
- package/src/premise.js +39 -31
- package/src/proofStep.js +89 -28
- package/src/rule.js +8 -13
- package/src/statement/qualified.js +2 -4
- package/src/substitution/statementForMetavariable.js +33 -18
- package/src/substitutions.js +34 -12
- package/src/supposition.js +48 -33
- package/src/topLevelAssertion.js +14 -6
- package/src/variable.js +1 -1
- package/src/verifier/statementAsCombinator.js +3 -17
- package/src/verifier/termAsConstructor.js +2 -2
- package/lib/verifier/metaLevel.js +0 -147
- package/src/verifier/metaLevel.js +0 -54
|
@@ -5,7 +5,6 @@ import { arrayUtilities } from "necessary";
|
|
|
5
5
|
import shim from "../shim";
|
|
6
6
|
import LocalContext from "../context/local";
|
|
7
7
|
import metaLevelUnifier from "../unifier/metaLevel";
|
|
8
|
-
import metaLevelVerifier from "../verifier/metaLevel";
|
|
9
8
|
|
|
10
9
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
10
|
|
|
@@ -33,6 +32,39 @@ export default class SubproofAssertion {
|
|
|
33
32
|
return this.statements;
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
unifySubproof(subproof, substitutions, fileContext, localContext) {
|
|
36
|
+
let subproofUnified;
|
|
37
|
+
|
|
38
|
+
const subproofString = subproof.getString(),
|
|
39
|
+
subproofAssertionString = this.string; ///
|
|
40
|
+
|
|
41
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion...`);
|
|
42
|
+
|
|
43
|
+
const subproofStatements = subproof.getStatements(),
|
|
44
|
+
subproofAssertionStatements = this.statements; ///
|
|
45
|
+
|
|
46
|
+
subproofUnified = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
|
|
47
|
+
const subproofAssertionStatementNode = subproofAssertionStatement.getNode(),
|
|
48
|
+
subproofStatementNode = subproofStatement.getNode(),
|
|
49
|
+
nodeA = subproofAssertionStatementNode, ///
|
|
50
|
+
nodeB = subproofStatementNode, ///
|
|
51
|
+
fileContextA = fileContext, ///
|
|
52
|
+
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
53
|
+
localContextB = localContext, ///
|
|
54
|
+
unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
55
|
+
|
|
56
|
+
if (unifiedAtMetaLevel) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (subproofUnified) {
|
|
62
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion.`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return subproofUnified;
|
|
66
|
+
}
|
|
67
|
+
|
|
36
68
|
verify(assignments, stated, localContext) {
|
|
37
69
|
let verified;
|
|
38
70
|
|
|
@@ -40,24 +72,31 @@ export default class SubproofAssertion {
|
|
|
40
72
|
|
|
41
73
|
localContext.trace(`Verifying the '${subproofAssertionString}' subproof assertion...`);
|
|
42
74
|
|
|
43
|
-
|
|
44
|
-
verifiedWhenDerived = false;
|
|
75
|
+
stated = true; ///
|
|
45
76
|
|
|
46
|
-
|
|
47
|
-
verifiedWhenStated = this.verifyWhenStated(localContext);
|
|
48
|
-
} else {
|
|
49
|
-
verifiedWhenDerived = this.verifyWhenDerived(localContext);
|
|
50
|
-
}
|
|
77
|
+
assignments = null; ///
|
|
51
78
|
|
|
52
|
-
|
|
53
|
-
|
|
79
|
+
const statementsVerified = this.statements.map((statement) => {
|
|
80
|
+
const statementVerified = statement.verify(assignments, stated, localContext);
|
|
54
81
|
|
|
55
|
-
|
|
82
|
+
if (statementVerified) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (statementsVerified) {
|
|
88
|
+
let verifiedWhenStated = false,
|
|
89
|
+
verifiedWhenDerived = false;
|
|
56
90
|
|
|
57
|
-
|
|
58
|
-
|
|
91
|
+
if (stated) {
|
|
92
|
+
verifiedWhenStated = this.verifyWhenStated(localContext);
|
|
93
|
+
} else {
|
|
94
|
+
verifiedWhenDerived = this.verifyWhenDerived(localContext);
|
|
95
|
+
}
|
|
59
96
|
|
|
60
|
-
|
|
97
|
+
if (verifiedWhenStated || verifiedWhenDerived) {
|
|
98
|
+
verified = true; ///
|
|
99
|
+
}
|
|
61
100
|
}
|
|
62
101
|
|
|
63
102
|
if (verified) {
|
|
@@ -90,42 +129,22 @@ export default class SubproofAssertion {
|
|
|
90
129
|
|
|
91
130
|
localContext.trace(`Verifying the '${subproofAssertionString}' derived subproof assertion...`);
|
|
92
131
|
|
|
93
|
-
|
|
132
|
+
const proofSteps = localContext.getProofSteps();
|
|
94
133
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
unifySubproof(subproof, substitutions, fileContext, localContext) {
|
|
101
|
-
let subproofUnified;
|
|
102
|
-
|
|
103
|
-
const subproofString = subproof.getString(),
|
|
104
|
-
subproofStatements = subproof.getStatements(),
|
|
105
|
-
subproofAssertionString = this.string; ///
|
|
134
|
+
derivedSubproofAssertionVerified = proofSteps.some((proofStep) => {
|
|
135
|
+
const subproofAssertion = this,
|
|
136
|
+
subproofAssertionUnified = proofStep.unifySubproofAssertion(subproofAssertion, localContext);
|
|
106
137
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
subproofUnified = match(this.statements, subproofStatements, (statement, subproofStatement) => {
|
|
110
|
-
const statementNode = statement.getNode(),
|
|
111
|
-
subproofStatementNode = subproofStatement.getNode(),
|
|
112
|
-
nodeA = statementNode, ///
|
|
113
|
-
nodeB = subproofStatementNode, ///
|
|
114
|
-
fileContextA = fileContext, ///
|
|
115
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
116
|
-
localContextB = localContext, ///
|
|
117
|
-
unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
118
|
-
|
|
119
|
-
if (unifiedAtMetaLevel) {
|
|
138
|
+
if (subproofAssertionUnified) {
|
|
120
139
|
return true;
|
|
121
140
|
}
|
|
122
141
|
});
|
|
123
142
|
|
|
124
|
-
if (
|
|
125
|
-
localContext.debug(`...
|
|
143
|
+
if (derivedSubproofAssertionVerified) {
|
|
144
|
+
localContext.debug(`...verified the '${subproofAssertionString}' derived subproof assertion.`);
|
|
126
145
|
}
|
|
127
146
|
|
|
128
|
-
return
|
|
147
|
+
return derivedSubproofAssertionVerified;
|
|
129
148
|
}
|
|
130
149
|
|
|
131
150
|
static fromStatementNode(statementNode, localContext) {
|
package/src/declaration.js
CHANGED
|
@@ -100,17 +100,14 @@ class Declaration {
|
|
|
100
100
|
|
|
101
101
|
localContext.trace(`Verifying the '${declarationString}' declaration...`);
|
|
102
102
|
|
|
103
|
-
stated = true;
|
|
103
|
+
stated = true; ///
|
|
104
104
|
|
|
105
|
-
assignments = null;
|
|
105
|
+
assignments = null; ///
|
|
106
106
|
|
|
107
|
-
const referenceVerified = this.reference.verify(localContext)
|
|
107
|
+
const referenceVerified = this.reference.verify(localContext),
|
|
108
|
+
statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
const statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
111
|
-
|
|
112
|
-
verified = statementVerified; ///
|
|
113
|
-
}
|
|
110
|
+
verified = (referenceVerified && statementVerified);
|
|
114
111
|
|
|
115
112
|
if (verified) {
|
|
116
113
|
localContext.debug(`...verified the '${declarationString}' declaration.`);
|
package/src/metavariable.js
CHANGED
|
@@ -6,6 +6,7 @@ import FrameForMetavariableSubstitution from "./substitution/frameForMetavariabl
|
|
|
6
6
|
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "./utilities/query";
|
|
9
|
+
import { EMPTY_STRING } from "./constants";
|
|
9
10
|
import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
10
11
|
import { metaTypeFromJSON, metaTypeToMetaTypeJSON } from "./utilities/json";
|
|
11
12
|
import { typeNameFromTypeNode, metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
@@ -122,11 +123,9 @@ class Metavariable {
|
|
|
122
123
|
metavariableString = this.string, ///
|
|
123
124
|
substitutionString = (substitution !== null) ?
|
|
124
125
|
substitution.getString() :
|
|
125
|
-
|
|
126
|
+
EMPTY_STRING;
|
|
126
127
|
|
|
127
|
-
(substitutionString
|
|
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...`);
|
|
128
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
|
|
130
129
|
|
|
131
130
|
const statementNode = statement.getNode(),
|
|
132
131
|
metavariableNode = this.node, ///
|
|
@@ -147,7 +146,7 @@ class Metavariable {
|
|
|
147
146
|
metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
|
|
148
147
|
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
149
148
|
|
|
150
|
-
if (metavariable === statementMetavariable) {
|
|
149
|
+
if ((metavariable !== null) && (metavariable === statementMetavariable)) {
|
|
151
150
|
statementUnified = true;
|
|
152
151
|
} else {
|
|
153
152
|
const metavariable = this, ///
|
|
@@ -162,9 +161,7 @@ class Metavariable {
|
|
|
162
161
|
}
|
|
163
162
|
|
|
164
163
|
if (statementUnified) {
|
|
165
|
-
(substitutionString
|
|
166
|
-
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution.`) :
|
|
167
|
-
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
164
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
|
|
168
165
|
}
|
|
169
166
|
|
|
170
167
|
return statementUnified;
|
|
@@ -28,10 +28,10 @@ function unifyWithCombinators(statement, assignments, stated, localContext) {
|
|
|
28
28
|
|
|
29
29
|
const combinators = localContext.getCombinators();
|
|
30
30
|
|
|
31
|
-
assignments = null; ///
|
|
32
|
-
|
|
33
31
|
stated = true; ///
|
|
34
32
|
|
|
33
|
+
assignments = null; ///
|
|
34
|
+
|
|
35
35
|
unifiedWithCombinators = combinators.some((combinator) => {
|
|
36
36
|
const unifiedWithCombinator = unifyStatementWithCombinator(statement, combinator, assignments, stated, localContext);
|
|
37
37
|
|
|
@@ -8,10 +8,8 @@ import ContainedAssertion from "../../assertion/contained";
|
|
|
8
8
|
|
|
9
9
|
import { nodeQuery } from "../../utilities/query";
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
equalityNodeQuery = nodeQuery("/statement/equality"),
|
|
11
|
+
const equalityNodeQuery = nodeQuery("/statement/equality"),
|
|
13
12
|
judgementNodeQuery = nodeQuery("/statement/judgement"),
|
|
14
|
-
declarationNodeQuery = nodeQuery("/statement/declaration"),
|
|
15
13
|
metavariableNodeQuery = nodeQuery("/statement/metavariable!"),
|
|
16
14
|
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion"),
|
|
17
15
|
definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion"),
|
|
@@ -68,31 +66,6 @@ function verifyAsEquality(statement, assignments, stated, localContext) {
|
|
|
68
66
|
return verifiedAsEquality;
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
function verifyAsFrame(statement, assignments, stated, localContext) {
|
|
72
|
-
let verifiedAsFrame = false;
|
|
73
|
-
|
|
74
|
-
const { Frame } = shim,
|
|
75
|
-
statementNode = statement.getNode(),
|
|
76
|
-
frameNode = frameNodeQuery(statementNode),
|
|
77
|
-
frame = Frame.fromFrameNode(frameNode, localContext);
|
|
78
|
-
|
|
79
|
-
if (frame !== null) {
|
|
80
|
-
const statementString = statement.getString();
|
|
81
|
-
|
|
82
|
-
localContext.trace(`Verifying the '${statementString}' statement as a frame...`);
|
|
83
|
-
|
|
84
|
-
const frameVerified = frame.verify(assignments, stated, localContext);
|
|
85
|
-
|
|
86
|
-
verifiedAsFrame = frameVerified; ///
|
|
87
|
-
|
|
88
|
-
if (verifiedAsFrame) {
|
|
89
|
-
localContext.debug(`...verified the '${statementString}' statement as a frame.`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return verifiedAsFrame;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
69
|
function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
97
70
|
let verifiedAsJudgement = false;
|
|
98
71
|
|
|
@@ -118,31 +91,6 @@ function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
|
118
91
|
return verifiedAsJudgement;
|
|
119
92
|
}
|
|
120
93
|
|
|
121
|
-
function verifyAsDeclaration(statement, assignments, stated, localContext) {
|
|
122
|
-
let verifiedAsDeclaration = false;
|
|
123
|
-
|
|
124
|
-
const { Declaration } = shim,
|
|
125
|
-
statementNode = statement.getNode(),
|
|
126
|
-
declarationNode = declarationNodeQuery(statementNode),
|
|
127
|
-
declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
128
|
-
|
|
129
|
-
if (declaration !== null) {
|
|
130
|
-
const statementString = statement.getString();
|
|
131
|
-
|
|
132
|
-
localContext.trace(`Verifying the '${statementString}' statement as a declaration...`);
|
|
133
|
-
|
|
134
|
-
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
135
|
-
|
|
136
|
-
verifiedAsDeclaration = declarationVerified; ///
|
|
137
|
-
|
|
138
|
-
if (verifiedAsDeclaration) {
|
|
139
|
-
localContext.debug(`...verified the '${statementString}' statement as a declaration.`);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return verifiedAsDeclaration;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
94
|
function verifyAsTypeAssertion(statement, assignments, stated, localContext) {
|
|
147
95
|
let verifiedAsTypeAssertion = false;
|
|
148
96
|
|
|
@@ -191,60 +139,58 @@ function verifyAsDefinedAssertion(statement, assignments, stated, localContext)
|
|
|
191
139
|
return verifiedAsDefinedAssertion;
|
|
192
140
|
}
|
|
193
141
|
|
|
194
|
-
function
|
|
195
|
-
let
|
|
142
|
+
function verifyAsContainedAssertion(statement, assignments, stated, localContext) {
|
|
143
|
+
let verifiedAsContainedAssertion = false;
|
|
196
144
|
|
|
197
145
|
const statementNode = statement.getNode(),
|
|
198
|
-
|
|
199
|
-
|
|
146
|
+
containedAssertionNode = containedAssertionNodeQuery(statementNode),
|
|
147
|
+
containedAssertion = ContainedAssertion.fromContainedAssertionNode(containedAssertionNode, localContext);
|
|
200
148
|
|
|
201
|
-
if (
|
|
149
|
+
if (containedAssertion !== null) {
|
|
202
150
|
const statementString = statement.getString();
|
|
203
151
|
|
|
204
|
-
localContext.trace(`Verifying the '${statementString}' statement as a
|
|
152
|
+
localContext.trace(`Verifying the '${statementString}' statement as a contained assertion...`);
|
|
205
153
|
|
|
206
|
-
const
|
|
154
|
+
const containedAssertionVerified = containedAssertion.verify(assignments, stated, localContext);
|
|
207
155
|
|
|
208
|
-
|
|
156
|
+
verifiedAsContainedAssertion = containedAssertionVerified; ///
|
|
209
157
|
|
|
210
|
-
if (
|
|
211
|
-
localContext.debug(`...verified the '${statementString}' statement as a
|
|
158
|
+
if (verifiedAsContainedAssertion) {
|
|
159
|
+
localContext.debug(`...verified the '${statementString}' statement as a contained assertion.`);
|
|
212
160
|
}
|
|
213
161
|
}
|
|
214
162
|
|
|
215
|
-
return
|
|
163
|
+
return verifiedAsContainedAssertion;
|
|
216
164
|
}
|
|
217
165
|
|
|
218
|
-
function
|
|
219
|
-
let
|
|
166
|
+
function verifyAsSubproofAssertion(statement, assignments, stated, localContext) {
|
|
167
|
+
let verifiedAsSubproofAssertion = false;
|
|
220
168
|
|
|
221
169
|
const statementNode = statement.getNode(),
|
|
222
|
-
|
|
223
|
-
|
|
170
|
+
subproofAssertionNode = subproofAssertionNodeQuery(statementNode),
|
|
171
|
+
subproofAssertion = SubproofAssertion.fromSubproofAssertionNode(subproofAssertionNode, localContext);
|
|
224
172
|
|
|
225
|
-
if (
|
|
173
|
+
if (subproofAssertionNode !== null) {
|
|
226
174
|
const statementString = statement.getString();
|
|
227
175
|
|
|
228
|
-
localContext.trace(`Verifying the '${statementString}' statement as a
|
|
176
|
+
localContext.trace(`Verifying the '${statementString}' statement as a subproof assertion...`);
|
|
229
177
|
|
|
230
|
-
const
|
|
178
|
+
const subproofAssertionVerified = subproofAssertion.verify(assignments, stated, localContext);
|
|
231
179
|
|
|
232
|
-
|
|
180
|
+
verifiedAsSubproofAssertion = subproofAssertionVerified; ///
|
|
233
181
|
|
|
234
|
-
if (
|
|
235
|
-
localContext.debug(`...verified the '${statementString}' statement as a
|
|
182
|
+
if (verifiedAsSubproofAssertion) {
|
|
183
|
+
localContext.debug(`...verified the '${statementString}' statement as a subproof assertion.`);
|
|
236
184
|
}
|
|
237
185
|
}
|
|
238
186
|
|
|
239
|
-
return
|
|
187
|
+
return verifiedAsSubproofAssertion;
|
|
240
188
|
}
|
|
241
189
|
|
|
242
190
|
const verifyMixins = [
|
|
243
191
|
verifyAsMetavariable,
|
|
244
192
|
verifyAsEquality,
|
|
245
|
-
verifyAsFrame,
|
|
246
193
|
verifyAsJudgement,
|
|
247
|
-
verifyAsDeclaration,
|
|
248
194
|
verifyAsTypeAssertion,
|
|
249
195
|
verifyAsDefinedAssertion,
|
|
250
196
|
verifyAsSubproofAssertion,
|
package/src/premise.js
CHANGED
|
@@ -28,37 +28,6 @@ class Premise {
|
|
|
28
28
|
|
|
29
29
|
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
30
30
|
|
|
31
|
-
unifySubproof(subproof, substitutions, localContext) {
|
|
32
|
-
let subproofUnified = false;
|
|
33
|
-
|
|
34
|
-
const premise = this, ///
|
|
35
|
-
subproofString = subproof.getString(),
|
|
36
|
-
premiseStatement = premise.getStatement(),
|
|
37
|
-
premiseStatementString = premiseStatement.getString();
|
|
38
|
-
|
|
39
|
-
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
40
|
-
|
|
41
|
-
const statement = this.unqualifiedStatement.getStatement(),
|
|
42
|
-
statementNode = statement.getNode(),
|
|
43
|
-
statementTokens = statement.getTokens(),
|
|
44
|
-
context = this.fileContext, ///
|
|
45
|
-
tokens = statementTokens; ///
|
|
46
|
-
|
|
47
|
-
localContext = LocalContext.fromContextAndTokens(context, tokens); ///
|
|
48
|
-
|
|
49
|
-
const subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, localContext);
|
|
50
|
-
|
|
51
|
-
if (subproofAssertion !== null) {
|
|
52
|
-
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (subproofUnified) {
|
|
56
|
-
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return subproofUnified;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
31
|
unifyProofStep(proofStep, substitutions, localContext) {
|
|
63
32
|
let proofStepUnified = false;
|
|
64
33
|
|
|
@@ -79,6 +48,14 @@ class Premise {
|
|
|
79
48
|
}
|
|
80
49
|
|
|
81
50
|
if (subproofUnified || statementUnified) {
|
|
51
|
+
const localContextB = localContext; ///
|
|
52
|
+
|
|
53
|
+
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
54
|
+
|
|
55
|
+
const localContextA = localContext; ///
|
|
56
|
+
|
|
57
|
+
substitutions.resolve(localContextA, localContextB);
|
|
58
|
+
|
|
82
59
|
proofStepUnified = true;
|
|
83
60
|
}
|
|
84
61
|
|
|
@@ -112,6 +89,37 @@ class Premise {
|
|
|
112
89
|
return statementUnified;
|
|
113
90
|
}
|
|
114
91
|
|
|
92
|
+
unifySubproof(subproof, substitutions, localContext) {
|
|
93
|
+
let subproofUnified = false;
|
|
94
|
+
|
|
95
|
+
const premise = this, ///
|
|
96
|
+
subproofString = subproof.getString(),
|
|
97
|
+
premiseStatement = premise.getStatement(),
|
|
98
|
+
premiseStatementString = premiseStatement.getString();
|
|
99
|
+
|
|
100
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
101
|
+
|
|
102
|
+
const statement = this.unqualifiedStatement.getStatement(),
|
|
103
|
+
statementNode = statement.getNode(),
|
|
104
|
+
statementTokens = statement.getTokens(),
|
|
105
|
+
context = this.fileContext, ///
|
|
106
|
+
tokens = statementTokens; ///
|
|
107
|
+
|
|
108
|
+
localContext = LocalContext.fromContextAndTokens(context, tokens); ///
|
|
109
|
+
|
|
110
|
+
const subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, localContext);
|
|
111
|
+
|
|
112
|
+
if (subproofAssertion !== null) {
|
|
113
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (subproofUnified) {
|
|
117
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return subproofUnified;
|
|
121
|
+
}
|
|
122
|
+
|
|
115
123
|
verify(localContext) {
|
|
116
124
|
let verified = false;
|
|
117
125
|
|
package/src/proofStep.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
3
5
|
import shim from "./shim";
|
|
6
|
+
import metaLevelUnifier from "./unifier/metaLevel";
|
|
4
7
|
|
|
5
8
|
import { nodeQuery } from "./utilities/query";
|
|
6
9
|
import { assignAssignments } from "./utilities/assignments";
|
|
7
10
|
|
|
11
|
+
const { match } = arrayUtilities;
|
|
12
|
+
|
|
8
13
|
const subproofNodeQuery = nodeQuery("/proofStep|lastProofStep/subproof"),
|
|
9
14
|
qualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/qualifiedStatement"),
|
|
10
15
|
unqualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/unqualifiedStatement");
|
|
@@ -45,56 +50,112 @@ class ProofStep {
|
|
|
45
50
|
unifyStatement(statement, localContext) {
|
|
46
51
|
let statementUnified = false;
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
if ((this.qualifiedStatement !== null) || (this.unqualifiedStatement !== null !== null)) {
|
|
54
|
+
const statementString = statement.getString();
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
const localContextA = localContext, ///
|
|
53
|
-
localContextB = localContext; ///
|
|
56
|
+
localContext.trace(`Unifying the '${statementString}' statement...`);
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
const { Substitutions } = shim,
|
|
59
|
+
localContextA = localContext, ///
|
|
60
|
+
localContextB = localContext, ///
|
|
61
|
+
substitutions = Substitutions.fromNothing();
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
if (this.qualifiedStatement !== null) {
|
|
64
|
+
statementUnified = this.qualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
65
|
+
}
|
|
61
66
|
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
if (this.unqualifiedStatement !== null) {
|
|
68
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
69
|
+
}
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
const substitutionsLength = substitutions.getLength();
|
|
66
72
|
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
if (substitutionsLength > 0) {
|
|
74
|
+
statementUnified = false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (statementUnified) {
|
|
78
|
+
localContext.debug(`...unified the '${statementString}' statement.`);
|
|
79
|
+
}
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
return statementUnified;
|
|
72
83
|
}
|
|
73
84
|
|
|
85
|
+
unifySubproofAssertion(subproofAssertion, localContext) {
|
|
86
|
+
let subproofAssertionUnified = false;
|
|
87
|
+
|
|
88
|
+
if (this.subproof !== null) {
|
|
89
|
+
const subproofString = this.subproof.getString(),
|
|
90
|
+
subproofAssertionString = subproofAssertion.getString();
|
|
91
|
+
|
|
92
|
+
localContext.trace(`Unifying the '${subproofAssertionString}' subproof assertion with the '${subproofString}' subproof...`);
|
|
93
|
+
|
|
94
|
+
const { Substitutions } = shim,
|
|
95
|
+
substitutions = Substitutions.fromNothing(),
|
|
96
|
+
subproofStatements = this.subproof.getStatements(),
|
|
97
|
+
subproofAssertionStatements = subproofAssertion.getStatements();
|
|
98
|
+
|
|
99
|
+
subproofAssertionUnified = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
|
|
100
|
+
const subproofAssertionStatementNode = subproofAssertionStatement.getNode(),
|
|
101
|
+
subproofStatementNode = subproofStatement.getNode(),
|
|
102
|
+
nodeA = subproofAssertionStatementNode, ///
|
|
103
|
+
nodeB = subproofStatementNode, ///
|
|
104
|
+
localContextA = localContext, ///
|
|
105
|
+
localContextB = localContext, ///
|
|
106
|
+
unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
107
|
+
|
|
108
|
+
if (unifiedAtMetaLevel) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (subproofAssertionUnified) {
|
|
114
|
+
const substitutionsLength = substitutions.getLength();
|
|
115
|
+
|
|
116
|
+
if (substitutionsLength > 0) {
|
|
117
|
+
subproofAssertionUnified = false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (subproofAssertionUnified) {
|
|
122
|
+
localContext.trace(`...unified the '${subproofAssertionString}' subproof assertion with the '${subproofString}' subproof.`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return subproofAssertionUnified;
|
|
127
|
+
}
|
|
128
|
+
|
|
74
129
|
verify(substitutions, localContext) {
|
|
75
130
|
let verified = false;
|
|
76
131
|
|
|
132
|
+
let stated = false;
|
|
133
|
+
|
|
134
|
+
const assignments = [];
|
|
135
|
+
|
|
136
|
+
let subproofVerified = false,
|
|
137
|
+
qualifiedStatementVerified = false,
|
|
138
|
+
unqualifiedStatementVerified = false;
|
|
139
|
+
|
|
77
140
|
if (false) {
|
|
78
141
|
///
|
|
79
142
|
} else if (this.subproof !== null) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
verified = subproofVerified; ///
|
|
143
|
+
subproofVerified = this.subproof.verify(substitutions, localContext);
|
|
83
144
|
} else if (this.qualifiedStatement !== null) {
|
|
84
|
-
|
|
145
|
+
stated = true;
|
|
85
146
|
|
|
86
|
-
|
|
147
|
+
qualifiedStatementVerified = this.qualifiedStatement.verify(substitutions, assignments, stated, localContext);
|
|
87
148
|
} else if (this.unqualifiedStatement !== null) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
149
|
+
stated = false;
|
|
150
|
+
|
|
151
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
152
|
+
}
|
|
91
153
|
|
|
92
|
-
|
|
93
|
-
|
|
154
|
+
if (subproofVerified || qualifiedStatementVerified || unqualifiedStatementVerified) {
|
|
155
|
+
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
94
156
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
157
|
+
if (assignmentsAssigned) {
|
|
158
|
+
verified = true;
|
|
98
159
|
}
|
|
99
160
|
}
|
|
100
161
|
|
package/src/rule.js
CHANGED
|
@@ -68,24 +68,19 @@ class Rule {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
unifyStatement(statement, localContext) {
|
|
71
|
-
let statementUnified
|
|
71
|
+
let statementUnified;
|
|
72
72
|
|
|
73
73
|
const { Substitutions } = shim,
|
|
74
|
-
|
|
75
|
-
substitutions = Substitutions.fromNothing(),
|
|
76
|
-
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
74
|
+
substitutions = Substitutions.fromNothing();
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
const statementUnifiedWithConclusion = this.conclusion.unifyStatement(statement, substitutions, localContext); ///
|
|
76
|
+
statementUnified = this.conclusion.unifyStatement(statement, substitutions, localContext); ///
|
|
80
77
|
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
if (statementUnified) {
|
|
79
|
+
const proofSteps = localContext.getProofSteps(),
|
|
80
|
+
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const localContextA = localContext; ///
|
|
87
|
-
|
|
88
|
-
const substitutionsResolved = substitutions.resolve(localContextA, localContextB);
|
|
82
|
+
if (proofStepsUnified) {
|
|
83
|
+
const substitutionsResolved = substitutions.areResolved();
|
|
89
84
|
|
|
90
85
|
statementUnified = substitutionsResolved; ///
|
|
91
86
|
}
|