occam-verify-cli 0.0.1063 → 0.0.1065
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/bin/action/verify.js +2 -0
- package/lib/assertion/contained.js +1 -2
- package/lib/assertion/defined.js +31 -47
- package/lib/assertion/subproof.js +3 -3
- package/lib/conclusion.js +5 -8
- package/lib/consequent.js +5 -8
- package/lib/metavariable.js +30 -33
- package/lib/premise.js +5 -8
- package/lib/proofStep.js +2 -2
- package/lib/statement/unqualified.js +14 -1
- package/lib/statement.js +23 -23
- package/lib/substitution/statementForMetavariable.js +22 -27
- package/lib/substitution/termForVariable.js +9 -9
- package/lib/supposition.js +5 -8
- package/lib/unifier/intrinsicLevel.js +4 -4
- package/lib/unifier/metaLevel.js +9 -13
- package/lib/unifier/metavariable.js +4 -4
- package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +3 -3
- package/lib/unify/statementWithSttaemetnGivenEquivalences.js +5 -5
- package/lib/utilities/unify.js +4 -21
- package/lib/variable.js +14 -2
- package/package.json +1 -1
- package/src/assertion/contained.js +0 -2
- package/src/assertion/defined.js +34 -61
- package/src/assertion/subproof.js +2 -2
- package/src/conclusion.js +5 -18
- package/src/consequent.js +5 -18
- package/src/metavariable.js +46 -33
- package/src/premise.js +5 -18
- package/src/proofStep.js +1 -1
- package/src/statement/unqualified.js +17 -0
- package/src/statement.js +37 -34
- package/src/substitution/statementForMetavariable.js +27 -34
- package/src/substitution/termForVariable.js +15 -12
- package/src/supposition.js +5 -18
- package/src/unifier/intrinsicLevel.js +3 -3
- package/src/unifier/metaLevel.js +16 -21
- package/src/unifier/metavariable.js +3 -3
- package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +2 -2
- package/src/unify/statementWithSttaemetnGivenEquivalences.js +4 -4
- package/src/utilities/unify.js +0 -14
- package/src/variable.js +20 -1
- package/lib/unify/frameWithMetaType.js +0 -24
- package/lib/verify/frameGivenMetaType.js +0 -37
- package/src/unify/frameWithMetaType.js +0 -14
- package/src/verify/frameGivenMetaType.js +0 -31
package/src/consequent.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import LocalContext from "./context/local";
|
|
4
|
-
import metaLevelUnifier from "./unifier/metaLevel";
|
|
5
3
|
import UnqualifiedStatement from "./statement/unqualified";
|
|
6
4
|
|
|
7
5
|
import { nodeQuery } from "./utilities/query";
|
|
@@ -29,26 +27,15 @@ export default class Consequent {
|
|
|
29
27
|
unifyStatement(statement, substitutions, localContext) {
|
|
30
28
|
let statementUnified;
|
|
31
29
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
consequentStatement = consequent.getStatement(),
|
|
35
|
-
consequentStatementString = consequentStatement.getString();
|
|
30
|
+
const statementString = statement.getString(),
|
|
31
|
+
consequentString = this.getString();
|
|
36
32
|
|
|
37
|
-
localContext.trace(`Unifying the '${statementString}' statement with the
|
|
33
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${consequentString}' consequent...`);
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
consequentStatementNode = consequentStatement.getNode(),
|
|
41
|
-
nodeA = consequentStatementNode, ///
|
|
42
|
-
nodeB = statementNode, ///
|
|
43
|
-
fileContextA = this.fileContext, ///
|
|
44
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
45
|
-
localContextB = localContext, ///
|
|
46
|
-
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
47
|
-
|
|
48
|
-
statementUnified = unified; ///
|
|
35
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, this.fileContext, localContext);
|
|
49
36
|
|
|
50
37
|
if (statementUnified) {
|
|
51
|
-
localContext.debug(`...unified the '${statementString}' statement with the
|
|
38
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${consequentString}' consequent.`);
|
|
52
39
|
}
|
|
53
40
|
|
|
54
41
|
return statementUnified;
|
package/src/metavariable.js
CHANGED
|
@@ -13,7 +13,7 @@ import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
|
13
13
|
const argumentNodeQuery = nodeQuery("/metavariable/argument"),
|
|
14
14
|
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
15
15
|
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
|
|
16
|
-
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable");
|
|
16
|
+
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
17
17
|
|
|
18
18
|
class Metavariable {
|
|
19
19
|
constructor(fileContext, string, node, name, metaType) {
|
|
@@ -174,40 +174,38 @@ class Metavariable {
|
|
|
174
174
|
substitutionString = substitution.getString(),
|
|
175
175
|
metavariableString = this.string; ///
|
|
176
176
|
|
|
177
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
// }
|
|
207
|
-
// }
|
|
177
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the '${substitutionString}' substitution...`);
|
|
178
|
+
|
|
179
|
+
const statementNode = statement.getNode(),
|
|
180
|
+
metavariableNode = this.node, ///
|
|
181
|
+
substitutionNode = substitution.getNode(),
|
|
182
|
+
complexSubstitution = substitutions.findComplexSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
183
|
+
|
|
184
|
+
if (complexSubstitution !== null) {
|
|
185
|
+
const statementNodeMatches = complexSubstitution.matchStatementNode(statementNode);
|
|
186
|
+
|
|
187
|
+
if (statementNodeMatches) {
|
|
188
|
+
statementUnifiedGivenSubstitution = true;
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
const metavariable = metavariableFromStatementNode(statementNode, localContext);
|
|
192
|
+
|
|
193
|
+
if (this === metavariable) { ///
|
|
194
|
+
statementUnifiedGivenSubstitution = false; ///
|
|
195
|
+
} else {
|
|
196
|
+
const metavariable = this, ///
|
|
197
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
|
|
198
|
+
|
|
199
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
200
|
+
|
|
201
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
202
|
+
|
|
203
|
+
statementUnifiedGivenSubstitution = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
208
206
|
|
|
209
207
|
if (statementUnifiedGivenSubstitution) {
|
|
210
|
-
localContext.trace(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable
|
|
208
|
+
localContext.trace(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable given the '${substitutionString}' substitution.`);
|
|
211
209
|
}
|
|
212
210
|
|
|
213
211
|
return statementUnifiedGivenSubstitution;
|
|
@@ -294,6 +292,21 @@ function metaTypeFromJSON(json, fileContext) {
|
|
|
294
292
|
return metaType;
|
|
295
293
|
}
|
|
296
294
|
|
|
295
|
+
function metavariableFromStatementNode(statementNode, localContext) {
|
|
296
|
+
let metavariable = null;
|
|
297
|
+
|
|
298
|
+
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode)
|
|
299
|
+
|
|
300
|
+
if (statementMetavariableNode !== null) {
|
|
301
|
+
const metavariableNode = statementMetavariableNode, ///
|
|
302
|
+
metavariableName = metavariableNameFromMetavariableNode(metavariableNode);
|
|
303
|
+
|
|
304
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return metavariable;
|
|
308
|
+
}
|
|
309
|
+
|
|
297
310
|
function statementMetavariableFromStatementNode(statementNode, localContext) {
|
|
298
311
|
let statementMetavariable = null;
|
|
299
312
|
|
package/src/premise.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import LocalContext from "./context/local";
|
|
5
|
-
import metaLevelUnifier from "./unifier/metaLevel";
|
|
6
4
|
import SubproofAssertion from "./assertion/subproof";
|
|
7
5
|
import UnqualifiedStatement from "./statement/unqualified";
|
|
8
6
|
|
|
@@ -80,26 +78,15 @@ export default class Premise {
|
|
|
80
78
|
unifyStatement(statement, substitutions, localContext) {
|
|
81
79
|
let statementUnified;
|
|
82
80
|
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
premiseStatement = premise.getStatement(),
|
|
86
|
-
premiseStatementString = premiseStatement.getString();
|
|
87
|
-
|
|
88
|
-
localContext.trace(`Unifying the '${statementString}' statement with the premise's '${premiseStatementString}' statement...`);
|
|
81
|
+
const statementString = statement.getString(),
|
|
82
|
+
premiseString = this.getString();
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
premiseStatementNode = premiseStatement.getNode(),
|
|
92
|
-
nodeA = premiseStatementNode, ///
|
|
93
|
-
nodeB = statementNode, ///
|
|
94
|
-
fileContextA = this.fileContext, ///
|
|
95
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
96
|
-
localContextB = localContext, ///
|
|
97
|
-
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
84
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
|
|
98
85
|
|
|
99
|
-
statementUnified =
|
|
86
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, this.fileContext, localContext);
|
|
100
87
|
|
|
101
88
|
if (statementUnified) {
|
|
102
|
-
localContext.debug(`...unified the '${statementString}' statement with the
|
|
89
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
|
|
103
90
|
}
|
|
104
91
|
|
|
105
92
|
return statementUnified;
|
package/src/proofStep.js
CHANGED
|
@@ -71,7 +71,7 @@ class ProofStep {
|
|
|
71
71
|
|
|
72
72
|
verified = qualifiedStatementVerified; ///
|
|
73
73
|
} else if (this.unqualifiedStatement !== null) {
|
|
74
|
-
const stated =
|
|
74
|
+
const stated = false,
|
|
75
75
|
assignments = [],
|
|
76
76
|
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
77
77
|
|
|
@@ -45,6 +45,23 @@ export default class UnqualifiedStatement {
|
|
|
45
45
|
return verified;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
unifyStatement(statement, substitutions, fileContext, localContext) {
|
|
49
|
+
let statementUnified;
|
|
50
|
+
|
|
51
|
+
const statementString = statement.getString(),
|
|
52
|
+
unqualifiedStatementString = this.getString(); ///
|
|
53
|
+
|
|
54
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${unqualifiedStatementString}' unqualified statement...`);
|
|
55
|
+
|
|
56
|
+
statementUnified = this.statement.unifyStatement(statement, substitutions, fileContext, localContext);
|
|
57
|
+
|
|
58
|
+
if (statementUnified) {
|
|
59
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${unqualifiedStatementString}' unqualified statement.`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return statementUnified;
|
|
63
|
+
}
|
|
64
|
+
|
|
48
65
|
toJSON() {
|
|
49
66
|
const statementJSON = this.statement.toJSON(),
|
|
50
67
|
statement = statementJSON, ///
|
package/src/statement.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import unifyMixins from "./mixins/statement/unify";
|
|
5
5
|
import verifyMixins from "./mixins/statement/verify";
|
|
6
|
-
import
|
|
6
|
+
import LocalContext from "./context/local";
|
|
7
|
+
import metaLevelUnifier from "./unifier/metaLevel";
|
|
7
8
|
import statementAsCombinatorVerifier from "./verifier/statementAsCombinator";
|
|
8
9
|
|
|
9
10
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
@@ -11,14 +12,14 @@ import { STATEMENT_META_TYPE_NAME } from "./metaTypeNames";
|
|
|
11
12
|
import { statementNodeFromStatementString } from "./utilities/node";
|
|
12
13
|
|
|
13
14
|
const statementNodeQuery = nodeQuery("/*//statement"),
|
|
15
|
+
substitutionNodeQuery = nodeQuery("/statement/substitution"),
|
|
14
16
|
statementVariableNodesQuery = nodesQuery("/statement//variable"),
|
|
15
17
|
statementMetavariableNodesQuery = nodesQuery("/statement//metavariable");
|
|
16
18
|
|
|
17
19
|
class Statement {
|
|
18
|
-
constructor(string, node
|
|
20
|
+
constructor(string, node) {
|
|
19
21
|
this.string = string;
|
|
20
22
|
this.node = node;
|
|
21
|
-
this.substitution = substitution;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
getString() {
|
|
@@ -29,10 +30,6 @@ class Statement {
|
|
|
29
30
|
return this.node;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
getSubstitution() {
|
|
33
|
-
return this.substitution;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
33
|
isEqualTo(statement) {
|
|
37
34
|
const node = statement.getNode(),
|
|
38
35
|
matches = this.node.match(node),
|
|
@@ -172,14 +169,35 @@ class Statement {
|
|
|
172
169
|
return verifiedGivenMetaType;
|
|
173
170
|
}
|
|
174
171
|
|
|
172
|
+
unifyStatement(statement, substitutions, fileContext, localContext) {
|
|
173
|
+
let statementUnified;
|
|
174
|
+
|
|
175
|
+
const statementA = this, ///
|
|
176
|
+
statementB = statement, ///
|
|
177
|
+
statementAString = statementA.getString(),
|
|
178
|
+
statementBString = statementB.getString();
|
|
179
|
+
|
|
180
|
+
localContext.trace(`Unifying the '${statementBString}' statement with the '${statementAString}' statement...`);
|
|
181
|
+
|
|
182
|
+
const statementANode = statementA.getNode(),
|
|
183
|
+
statementBNode = statementB.getNode(),
|
|
184
|
+
nodeA = statementANode, ///
|
|
185
|
+
nodeB = statementBNode, ///
|
|
186
|
+
fileContextA = fileContext, ///
|
|
187
|
+
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
188
|
+
localContextB = localContext, ///
|
|
189
|
+
unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
190
|
+
|
|
191
|
+
statementUnified = unifiedAtMetaLevel; ///
|
|
192
|
+
|
|
193
|
+
localContext.debug(`...unified the '${statementBString}' statement with the '${statementAString}' statement.`);
|
|
194
|
+
|
|
195
|
+
return statementUnified;
|
|
196
|
+
}
|
|
197
|
+
|
|
175
198
|
toJSON() {
|
|
176
|
-
const
|
|
177
|
-
this.substitution.toJSON() :
|
|
178
|
-
null,
|
|
179
|
-
substitution = substitutionJSON, ///
|
|
180
|
-
string = this.string, ///
|
|
199
|
+
const string = this.string, ///
|
|
181
200
|
json = {
|
|
182
|
-
substitution,
|
|
183
201
|
string
|
|
184
202
|
};
|
|
185
203
|
|
|
@@ -192,17 +210,8 @@ class Statement {
|
|
|
192
210
|
lexer = fileContext.getLexer(),
|
|
193
211
|
parser = fileContext.getParser(),
|
|
194
212
|
statementNode = statementNodeFromStatementString(statementString, lexer, parser),
|
|
195
|
-
node = statementNode
|
|
196
|
-
|
|
197
|
-
let { substitution } = json;
|
|
198
|
-
|
|
199
|
-
json = substitution; ///
|
|
200
|
-
|
|
201
|
-
const statementSubstitution = StatementSubstitution.fromJSON(json, fileContext);
|
|
202
|
-
|
|
203
|
-
substitution = statementSubstitution; ///
|
|
204
|
-
|
|
205
|
-
const statement = new Statement(string, node, substitution);
|
|
213
|
+
node = statementNode, ///
|
|
214
|
+
statement = new Statement(string, node);
|
|
206
215
|
|
|
207
216
|
return statement;
|
|
208
217
|
}
|
|
@@ -212,11 +221,9 @@ class Statement {
|
|
|
212
221
|
|
|
213
222
|
if (statementNode !== null) {
|
|
214
223
|
const node = statementNode, ///
|
|
215
|
-
string = localContext.nodeAsString(node)
|
|
216
|
-
statementSubstitution = StatementSubstitution.fromStatementNode(statementNode, localContext),
|
|
217
|
-
substitution = statementSubstitution; ///
|
|
224
|
+
string = localContext.nodeAsString(node);
|
|
218
225
|
|
|
219
|
-
statement = new Statement(string, node
|
|
226
|
+
statement = new Statement(string, node);
|
|
220
227
|
}
|
|
221
228
|
|
|
222
229
|
return statement;
|
|
@@ -226,9 +233,7 @@ class Statement {
|
|
|
226
233
|
const statementNode = statementNodeQuery(definedAssertionNode),
|
|
227
234
|
node = statementNode, ///
|
|
228
235
|
string = localContext.nodeAsString(node),
|
|
229
|
-
|
|
230
|
-
substitution = statementSubstitution, ///
|
|
231
|
-
statement = new Statement(string, node, substitution);
|
|
236
|
+
statement = new Statement(string, node);
|
|
232
237
|
|
|
233
238
|
return statement;
|
|
234
239
|
}
|
|
@@ -237,9 +242,7 @@ class Statement {
|
|
|
237
242
|
const statementNode = statementNodeQuery(containedAssertionNode),
|
|
238
243
|
node = statementNode, ///
|
|
239
244
|
string = localContext.nodeAsString(node),
|
|
240
|
-
|
|
241
|
-
substitution = statementSubstitution, ///
|
|
242
|
-
statement = new Statement(string, node, substitution);
|
|
245
|
+
statement = new Statement(string, node);
|
|
243
246
|
|
|
244
247
|
return statement;
|
|
245
248
|
}
|
|
@@ -81,7 +81,7 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
81
81
|
statement = Statement.fromStatementNode(statementNode, localContext); ///
|
|
82
82
|
|
|
83
83
|
const metavariableNode = metavariable.getNode(),
|
|
84
|
-
string = stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution
|
|
84
|
+
string = stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution);
|
|
85
85
|
|
|
86
86
|
substitution = substitutionFromSubstitution(substitution, localContext);
|
|
87
87
|
|
|
@@ -91,53 +91,46 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
string = `[${statementString} for ${metavariableString}]`;
|
|
94
|
+
function substitutionFromSubstitution(substitution, localContext) {
|
|
95
|
+
if (substitution === null) {
|
|
96
|
+
const termForVariableSubstitution = TermForVariableSubstitution.fromSubstitution(substitution, localContext);
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
if (termForVariableSubstitution !== null) {
|
|
99
|
+
substitution = termForVariableSubstitution; ///
|
|
100
|
+
}
|
|
101
|
+
}
|
|
101
102
|
|
|
103
|
+
if (substitution === null) {
|
|
104
|
+
const frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromSubstitution(substitution, localContext);
|
|
102
105
|
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
if (frameForMetavariableSubstitution !== null) {
|
|
107
|
+
substitution = frameForMetavariableSubstitution; ///
|
|
108
|
+
}
|
|
109
|
+
}
|
|
105
110
|
|
|
106
|
-
|
|
111
|
+
return substitution;
|
|
112
|
+
}
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// substitution = termForVariableSubstitution; ///
|
|
113
|
-
// }
|
|
114
|
-
// }
|
|
115
|
-
//
|
|
116
|
-
// if (substitution === null) {
|
|
117
|
-
// const frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromSubstitution(substitutionNode, localContextA, localContextB);
|
|
118
|
-
//
|
|
119
|
-
// if (frameForMetavariableSubstitution !== null) {
|
|
120
|
-
// substitution = frameForMetavariableSubstitution; ///
|
|
121
|
-
// }
|
|
122
|
-
// }
|
|
114
|
+
function stringFromStatementAndMetavariable(statement, metavariable) {
|
|
115
|
+
const statementString = statement.getString(),
|
|
116
|
+
metavariableString = metavariable.getString(),
|
|
117
|
+
string = `[${statementString} for ${metavariableString}]`;
|
|
123
118
|
|
|
124
|
-
return
|
|
119
|
+
return string;
|
|
125
120
|
}
|
|
126
121
|
|
|
127
|
-
function stringFromStatementMetavariableAndSubstitution(
|
|
122
|
+
function stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution) {
|
|
128
123
|
let string;
|
|
129
124
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
metavariableNodeA = metavariableNode, ///
|
|
133
|
-
metavariableStringA = localContextA.nodeAsString(metavariableNodeA);
|
|
125
|
+
const statementString = statement.getString(),
|
|
126
|
+
metavariableString = metavariable.getString();
|
|
134
127
|
|
|
135
128
|
if (substitution === null) {
|
|
136
|
-
string = `[${
|
|
129
|
+
string = `[${statementString} for ${metavariableString}]`;
|
|
137
130
|
} else {
|
|
138
|
-
const substitutionString = substitution.
|
|
131
|
+
const substitutionString = substitution.getString();
|
|
139
132
|
|
|
140
|
-
string = `[${
|
|
133
|
+
string = `[${statementString} for ${metavariableString}${substitutionString}]`;
|
|
141
134
|
}
|
|
142
135
|
|
|
143
136
|
return string;
|
|
@@ -83,7 +83,7 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
83
83
|
return unifiedWithEquivalence;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
static fromSubstitution(substitution) {
|
|
86
|
+
static fromSubstitution(substitution, localContext) {
|
|
87
87
|
let termForVariableSubstitution = null;
|
|
88
88
|
|
|
89
89
|
const substitutionNode = substitution.getNode();
|
|
@@ -91,30 +91,33 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
91
91
|
let substitutionTermNode = substitutionTermNodeQuery(substitutionNode);
|
|
92
92
|
|
|
93
93
|
if (substitutionTermNode !== null) {
|
|
94
|
-
let termNode
|
|
95
|
-
|
|
96
|
-
termNode = stripBracketsFromTerm(termNode); ///
|
|
94
|
+
let termNode;
|
|
97
95
|
|
|
98
96
|
const substitutionVariableNode = substitutionsVariableNodeQuery(substitutionNode),
|
|
99
97
|
variableNode = substitutionVariableNode; ///
|
|
100
98
|
|
|
101
|
-
|
|
99
|
+
termNode = substitutionTermNode; ///
|
|
100
|
+
|
|
101
|
+
termNode = stripBracketsFromTerm(termNode); ///
|
|
102
|
+
|
|
103
|
+
const { Term, Variable } = shim,
|
|
104
|
+
term = Term.fromTermNode(termNode, localContext),
|
|
105
|
+
variable = Variable.fromVariableNode(variableNode, localContext),
|
|
106
|
+
string = stringFromTermAndVariable(term, variable);
|
|
107
|
+
|
|
108
|
+
termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode);
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
return termForVariableSubstitution;
|
|
105
112
|
}
|
|
106
113
|
|
|
107
|
-
static fromTernAndVariable(term, variable
|
|
114
|
+
static fromTernAndVariable(term, variable) {
|
|
108
115
|
let termNode = term.getNode();
|
|
109
116
|
|
|
110
117
|
termNode = stripBracketsFromTerm(termNode); ///
|
|
111
118
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
term = Term.fromTermNode(termNode, localContext); ///
|
|
115
|
-
|
|
116
|
-
const string = stringFromTermAndVariable(term, variable),
|
|
117
|
-
variableNode = variable.getNode(),
|
|
119
|
+
const variableNode = variable.getNode(),
|
|
120
|
+
string = stringFromTermAndVariable(term, variable),
|
|
118
121
|
termForVariableSubstitution = new TermForVariableSubstitution(string, termNode, variableNode);
|
|
119
122
|
|
|
120
123
|
return termForVariableSubstitution;
|
package/src/supposition.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import LocalContext from "./context/local";
|
|
5
|
-
import metaLevelUnifier from "./unifier/metaLevel";
|
|
6
4
|
import SubproofAssertion from "./assertion/subproof";
|
|
7
5
|
import UnqualifiedStatement from "./statement/unqualified";
|
|
8
6
|
|
|
@@ -111,26 +109,15 @@ export default class Supposition {
|
|
|
111
109
|
unifyStatement(statement, substitutions, localContext) {
|
|
112
110
|
let statementUnified;
|
|
113
111
|
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
suppositionStatement = supposition.getStatement(),
|
|
117
|
-
suppositionStatementString = suppositionStatement.getString();
|
|
118
|
-
|
|
119
|
-
localContext.trace(`Unifying the '${statementString}' statement with the supposition's '${suppositionStatementString}' statement...`);
|
|
112
|
+
const statementString = statement.getString(),
|
|
113
|
+
suppositionString = this.getString();
|
|
120
114
|
|
|
121
|
-
|
|
122
|
-
suppositionStatementNode = suppositionStatement.getNode(),
|
|
123
|
-
nodeA = suppositionStatementNode, ///
|
|
124
|
-
nodeB = statementNode, ///
|
|
125
|
-
fileContextA = this.fileContext, ///
|
|
126
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
127
|
-
localContextB = localContext, ///
|
|
128
|
-
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
115
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${suppositionString}' supposition...`);
|
|
129
116
|
|
|
130
|
-
statementUnified =
|
|
117
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, this.fileContext, localContext);
|
|
131
118
|
|
|
132
119
|
if (statementUnified) {
|
|
133
|
-
localContext.debug(`...unified the '${statementString}' statement with the
|
|
120
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${suppositionString}' supposition.`);
|
|
134
121
|
}
|
|
135
122
|
|
|
136
123
|
return statementUnified;
|
|
@@ -11,15 +11,15 @@ const termNodeQuery = nodeQuery("/term!"),
|
|
|
11
11
|
|
|
12
12
|
class IntrinsicLevelUnifier extends Unifier {
|
|
13
13
|
unify(nodeA, nodeB, substitutions, localContextA, localContextB) {
|
|
14
|
-
let
|
|
14
|
+
let unifiedAtIntrinsicLevel;
|
|
15
15
|
|
|
16
16
|
const nonTerminalNodeA = nodeA, ///
|
|
17
17
|
nonTerminalNodeB = nodeB, ///
|
|
18
18
|
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
unifiedAtIntrinsicLevel = nonTerminalNodeUnified; ///
|
|
21
21
|
|
|
22
|
-
return
|
|
22
|
+
return unifiedAtIntrinsicLevel;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
static maps = [
|
package/src/unifier/metaLevel.js
CHANGED
|
@@ -16,15 +16,15 @@ const termNodeQuery = nodeQuery("/term!"),
|
|
|
16
16
|
|
|
17
17
|
class MetaLevelUnifier extends Unifier {
|
|
18
18
|
unify(nodeA, nodeB, substitutions, localContextA, localContextB) {
|
|
19
|
-
let
|
|
19
|
+
let unifiedAtMetaLevel;
|
|
20
20
|
|
|
21
21
|
const nonTerminalNodeA = nodeA, ///
|
|
22
22
|
nonTerminalNodeB = nodeB, ///
|
|
23
23
|
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
unifiedAtMetaLevel = nonTerminalNodeUnified; ///
|
|
26
26
|
|
|
27
|
-
return
|
|
27
|
+
return unifiedAtMetaLevel;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
static maps = [
|
|
@@ -39,30 +39,23 @@ class MetaLevelUnifier extends Unifier {
|
|
|
39
39
|
if (matches) {
|
|
40
40
|
statementUnified = true;
|
|
41
41
|
} else {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
statementMetavariableNodeA = statementMetavariableNodeQuery(statementNodeA);
|
|
42
|
+
const statementNode = statementNodeA, ///
|
|
43
|
+
statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
|
|
45
44
|
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const statementA = Statement.fromStatementNode(statementNodeA, localContextA);
|
|
50
|
-
|
|
51
|
-
statement = statementA; ///
|
|
52
|
-
|
|
53
|
-
const substitution = statement.getSubstitution();
|
|
54
|
-
|
|
55
|
-
statement = statementB; ///
|
|
56
|
-
|
|
57
|
-
const localContext = localContextB, ///
|
|
58
|
-
metavariableNode = statementMetavariableNodeA, ///
|
|
45
|
+
if (statementMetavariableNode !== null) {
|
|
46
|
+
const { Statement } = shim,
|
|
47
|
+
metavariableNode = statementMetavariableNode, ///
|
|
59
48
|
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
60
|
-
metavariable = localContextA.findMetavariableByMetavariableName(metavariableName)
|
|
49
|
+
metavariable = localContextA.findMetavariableByMetavariableName(metavariableName),
|
|
50
|
+
substitution = substitutionA, ///
|
|
51
|
+
localContext = localContextB, ///
|
|
52
|
+
statementNode = statementNodeB, ///
|
|
53
|
+
statement = Statement.fromStatementNode(statementNode, localContext);
|
|
61
54
|
|
|
62
55
|
if (substitution === null) {
|
|
63
56
|
statementUnified = metavariable.unifyStatement(statement, substitutions, localContext);
|
|
64
57
|
} else {
|
|
65
|
-
const statementUnifiedGivenSubstitution =
|
|
58
|
+
const statementUnifiedGivenSubstitution = metavariable.unifyStatementGivenSubstitution(statement, substitution, substitutions, localContext);
|
|
66
59
|
|
|
67
60
|
statementUnified = statementUnifiedGivenSubstitution; ///
|
|
68
61
|
}
|
|
@@ -116,6 +109,8 @@ const metaLevelUnifier = new MetaLevelUnifier();
|
|
|
116
109
|
export default metaLevelUnifier;
|
|
117
110
|
|
|
118
111
|
function unifyStatementWithStatement(statementNodeA, statementNodeB, substitutions, localContextA, localContextB) {
|
|
112
|
+
substitutionA = null;
|
|
113
|
+
|
|
119
114
|
const nonTerminalNodeA = statementNodeA, ///
|
|
120
115
|
nonTerminalNodeB = statementNodeB, ///
|
|
121
116
|
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
@@ -11,15 +11,15 @@ const typeNodeQuery = nodeQuery("/type!"),
|
|
|
11
11
|
|
|
12
12
|
class MetavariableUnifier extends Unifier {
|
|
13
13
|
unify(metavariableNodeA, metavariableNodeB, localContext) {
|
|
14
|
-
let
|
|
14
|
+
let metavariableUnified;
|
|
15
15
|
|
|
16
16
|
const nonTerminalNodeA = metavariableNodeA, ///
|
|
17
17
|
nonTerminalNodeB = metavariableNodeB, ///
|
|
18
18
|
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
metavariableUnified = nonTerminalNodeUnified; ///
|
|
21
21
|
|
|
22
|
-
return
|
|
22
|
+
return metavariableUnified;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
static maps = [
|