occam-verify-cli 0.0.1035 → 0.0.1037
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/subproof.js +73 -49
- package/lib/assertion/type.js +5 -5
- package/lib/context/file.js +6 -20
- package/lib/context/release.js +24 -84
- package/lib/equality.js +5 -5
- package/lib/metavariable.js +51 -6
- package/lib/mixins/statement/verify.js +3 -3
- package/lib/premise.js +23 -32
- package/lib/substitution/statementForMetavariable.js +12 -4
- package/lib/substitution/termForVariable.js +2 -2
- package/lib/supposition.js +48 -57
- package/lib/unifier/metaLevel.js +3 -4
- package/lib/unifier/statementWithCombinator.js +1 -2
- package/lib/variable.js +13 -6
- package/lib/verify/assertion/subproof.js +1 -49
- package/package.json +1 -1
- package/src/assertion/subproof.js +95 -56
- package/src/assertion/type.js +4 -4
- package/src/context/file.js +2 -48
- package/src/context/release.js +27 -65
- package/src/equality.js +4 -4
- package/src/metavariable.js +69 -6
- package/src/mixins/statement/verify.js +3 -2
- package/src/premise.js +32 -46
- package/src/substitution/statementForMetavariable.js +20 -3
- package/src/substitution/termForVariable.js +1 -1
- package/src/supposition.js +64 -78
- package/src/unifier/metaLevel.js +11 -5
- package/src/unifier/statementWithCombinator.js +0 -1
- package/src/variable.js +12 -5
- package/src/verify/assertion/subproof.js +0 -63
- package/lib/unify/conclusionWithStatement.js +0 -34
- package/lib/unify/consequentWithStatement.js +0 -34
- package/lib/unify/metavariableWithStatement.js +0 -40
- package/lib/unify/suppositionWithProffStep.js +0 -41
- package/lib/unify/suppositionsWithProofSteps.js +0 -31
- package/lib/unify/unqualifiedStatement.js +0 -25
- package/lib/verify/file.js +0 -35
- package/lib/verify/subDerivation.js +0 -31
- package/src/unify/conclusionWithStatement.js +0 -34
- package/src/unify/consequentWithStatement.js +0 -34
- package/src/unify/metavariableWithStatement.js +0 -40
- package/src/unify/suppositionWithProffStep.js +0 -54
- package/src/unify/suppositionsWithProofSteps.js +0 -23
- package/src/unify/unqualifiedStatement.js +0 -24
- package/src/verify/file.js +0 -29
- package/src/verify/subDerivation.js +0 -24
package/src/metavariable.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import Argument from "./argument";
|
|
5
5
|
import LocalContext from "./context/local";
|
|
6
|
+
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
6
7
|
|
|
7
8
|
import { nodeQuery } from "./utilities/query";
|
|
8
9
|
import { metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
@@ -10,16 +11,22 @@ import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
|
10
11
|
|
|
11
12
|
const argumentNodeQuery = nodeQuery("/metavariable/argument"),
|
|
12
13
|
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
13
|
-
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable")
|
|
14
|
+
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
|
|
15
|
+
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable");
|
|
14
16
|
|
|
15
17
|
export default class Metavariable {
|
|
16
|
-
constructor(string, node, name, metaType) {
|
|
18
|
+
constructor(fileContext, string, node, name, metaType) {
|
|
19
|
+
this.fileContext = fileContext;
|
|
17
20
|
this.string = string;
|
|
18
21
|
this.node = node;
|
|
19
22
|
this.name = name;
|
|
20
23
|
this.metaType = metaType;
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
getFileContext() {
|
|
27
|
+
return this.fileContext;
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
getString() {
|
|
24
31
|
return this.string;
|
|
25
32
|
}
|
|
@@ -105,6 +112,48 @@ export default class Metavariable {
|
|
|
105
112
|
return verifiedAtTopLevel;
|
|
106
113
|
}
|
|
107
114
|
|
|
115
|
+
unifyStatement(statement, substitutions, localContext) {
|
|
116
|
+
let statementUnified = false;
|
|
117
|
+
|
|
118
|
+
const statementString = statement.getString(),
|
|
119
|
+
metavariableString = this.string;
|
|
120
|
+
|
|
121
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
122
|
+
|
|
123
|
+
const statementNode = statement.getNode(),
|
|
124
|
+
metavariableNode = this.node, ///
|
|
125
|
+
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
126
|
+
substitution = simpleSubstitution; ///
|
|
127
|
+
|
|
128
|
+
if (substitution !== null) {
|
|
129
|
+
const statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
130
|
+
|
|
131
|
+
if (statementNodeMatches) {
|
|
132
|
+
statementUnified = true;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
const metavariable = this, ///
|
|
136
|
+
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
137
|
+
|
|
138
|
+
if (metavariable === statementMetavariable) {
|
|
139
|
+
statementUnified = true;
|
|
140
|
+
} else {
|
|
141
|
+
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
|
|
142
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
143
|
+
|
|
144
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
145
|
+
|
|
146
|
+
statementUnified = true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (statementUnified) {
|
|
151
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return statementUnified;
|
|
155
|
+
}
|
|
156
|
+
|
|
108
157
|
toJSON() {
|
|
109
158
|
const metaTypeJSON = (this.metaType !== null) ?
|
|
110
159
|
this.metaType.toJSON() :
|
|
@@ -129,7 +178,7 @@ export default class Metavariable {
|
|
|
129
178
|
node = metavariableNode, ///
|
|
130
179
|
name = metavariableName, ///
|
|
131
180
|
metaType = metaTypeFromJSON(json, fileContext),
|
|
132
|
-
metavariable = new Metavariable(string, node, name, metaType);
|
|
181
|
+
metavariable = new Metavariable(fileContext, string, node, name, metaType);
|
|
133
182
|
|
|
134
183
|
return metavariable;
|
|
135
184
|
}
|
|
@@ -140,7 +189,7 @@ export default class Metavariable {
|
|
|
140
189
|
name = metavariableName, ///
|
|
141
190
|
string = fileContext.nodeAsString(node),
|
|
142
191
|
metaType = null,
|
|
143
|
-
metavariable = new Metavariable(string, node, name, metaType);
|
|
192
|
+
metavariable = new Metavariable(fileContext, string, node, name, metaType);
|
|
144
193
|
|
|
145
194
|
return metavariable;
|
|
146
195
|
}
|
|
@@ -156,7 +205,7 @@ export default class Metavariable {
|
|
|
156
205
|
node = metavariableNode, ///
|
|
157
206
|
name = metavariableName, ///
|
|
158
207
|
metaType = MetaType.fromMetaTypeNode(metaTypeNode, localContext),
|
|
159
|
-
metavariable = new Metavariable(string, node, name, metaType);
|
|
208
|
+
metavariable = new Metavariable(fileContext, string, node, name, metaType);
|
|
160
209
|
|
|
161
210
|
return metavariable;
|
|
162
211
|
}
|
|
@@ -173,4 +222,18 @@ function metaTypeFromJSON(json, fileContext) {
|
|
|
173
222
|
}
|
|
174
223
|
|
|
175
224
|
return metaType;
|
|
176
|
-
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function statementMetavariableFromStatementNode(statementNode, localContext) {
|
|
228
|
+
let statementMetavariable = null;
|
|
229
|
+
|
|
230
|
+
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
|
|
231
|
+
|
|
232
|
+
if (statementMetavariableNode !== null) {
|
|
233
|
+
const statementMetavariableName = variableNameFromMetavariableNode(statementMetavariableNode);
|
|
234
|
+
|
|
235
|
+
statementMetavariable = localContext.findMetavariableByMetavariableName(statementMetavariableName);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return statementMetavariable;
|
|
239
|
+
}
|
|
@@ -8,11 +8,11 @@ import verifyJudgement from "../../verify/judgement";
|
|
|
8
8
|
import verifyDeclaration from "../../verify/declaration";
|
|
9
9
|
import metavariableUnifier from "../../unifier/metavariable";
|
|
10
10
|
import verifyDefinedAssertion from "../../verify/assertion/defined";
|
|
11
|
-
import verifySubproofAssertion from "../../verify/assertion/subproof";
|
|
12
11
|
import verifyContainedAssertion from "../../verify/assertion/contained";
|
|
13
12
|
|
|
14
13
|
import { nodeQuery } from "../../utilities/query";
|
|
15
14
|
import { metavariableNameFromMetavariableNode } from "../../utilities/name";
|
|
15
|
+
import SubproofAssertion from "../../assertion/subproof";
|
|
16
16
|
|
|
17
17
|
const frameNodeQuery = nodeQuery("/statement/frame!"),
|
|
18
18
|
equalityNodeQuery = nodeQuery("/statement/equality!"),
|
|
@@ -198,7 +198,8 @@ function verifyAsSubproofAssertion(statement, assignments, stated, localContext)
|
|
|
198
198
|
|
|
199
199
|
localContext.trace(`Verifying the '${statementString}' statement as a subproof assertion...`);
|
|
200
200
|
|
|
201
|
-
const
|
|
201
|
+
const subproofAssertion = SubproofAssertion.fromSubproofAssertionNode(subproofAssertionNode, localContext),
|
|
202
|
+
subproofAssertionVerified = subproofAssertion.verify(assignments, stated, localContext);
|
|
202
203
|
|
|
203
204
|
verifiedAsSubproofAssertion = subproofAssertionVerified; ///
|
|
204
205
|
|
package/src/premise.js
CHANGED
|
@@ -12,9 +12,8 @@ import { assignAssignments } from "./utilities/assignments";
|
|
|
12
12
|
const unqualifiedStatementNodeQuery = nodeQuery("/premise/unqualifiedStatement");
|
|
13
13
|
|
|
14
14
|
export default class Premise {
|
|
15
|
-
constructor(fileContext,
|
|
15
|
+
constructor(fileContext, unqualifiedStatement) {
|
|
16
16
|
this.fileContext = fileContext;
|
|
17
|
-
this.subproofAssertion = subproofAssertion;
|
|
18
17
|
this.unqualifiedStatement = unqualifiedStatement;
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -22,10 +21,6 @@ export default class Premise {
|
|
|
22
21
|
return this.fileContext;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
getSubproofAssertion() {
|
|
26
|
-
return this.subproofAssertion;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
24
|
getUnqualifiedStatement() {
|
|
30
25
|
return this.unqualifiedStatement;
|
|
31
26
|
}
|
|
@@ -34,6 +29,30 @@ export default class Premise {
|
|
|
34
29
|
|
|
35
30
|
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
36
31
|
|
|
32
|
+
unifySubproof(subproof, substitutions, localContext) {
|
|
33
|
+
let subproofUnified = false;
|
|
34
|
+
|
|
35
|
+
const premise = this, ///
|
|
36
|
+
subproofString = subproof.getString(),
|
|
37
|
+
premiseStatement = premise.getStatement(),
|
|
38
|
+
premiseStatementString = premiseStatement.getString();
|
|
39
|
+
|
|
40
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
41
|
+
|
|
42
|
+
const statement = this.unqualifiedStatement.getStatement(),
|
|
43
|
+
subproofAssertion = SubproofAssertion.fromStatement(statement, this.fileContext);
|
|
44
|
+
|
|
45
|
+
if (subproofAssertion !== null) {
|
|
46
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (subproofUnified) {
|
|
50
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return subproofUnified;
|
|
54
|
+
}
|
|
55
|
+
|
|
37
56
|
unifyProofStep(proofStep, substitutions, localContext) {
|
|
38
57
|
let proofStepUnified = false;
|
|
39
58
|
|
|
@@ -85,27 +104,6 @@ export default class Premise {
|
|
|
85
104
|
return statementUnified;
|
|
86
105
|
}
|
|
87
106
|
|
|
88
|
-
unifySubproof(subproof, substitutions, localContext) {
|
|
89
|
-
let subproofUnified = false;
|
|
90
|
-
|
|
91
|
-
const premise = this, ///
|
|
92
|
-
subproofString = subproof.getString(),
|
|
93
|
-
premiseStatement = premise.getStatement(),
|
|
94
|
-
premiseStatementString = premiseStatement.getString();
|
|
95
|
-
|
|
96
|
-
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
97
|
-
|
|
98
|
-
if (this.subproofAssertion !== null) {
|
|
99
|
-
subproofUnified = this.subproofAssertion.unifySubproof(subproof, substitutions, localContext);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (subproofUnified) {
|
|
103
|
-
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return subproofUnified;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
107
|
verify(localContext) {
|
|
110
108
|
let verified = false;
|
|
111
109
|
|
|
@@ -143,33 +141,22 @@ export default class Premise {
|
|
|
143
141
|
|
|
144
142
|
toJSON() {
|
|
145
143
|
const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
subproofAssertion = subproofAssertionJSON, ///
|
|
151
|
-
json = {
|
|
152
|
-
unqualifiedStatement,
|
|
153
|
-
subproofAssertion
|
|
154
|
-
};
|
|
144
|
+
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
145
|
+
json = {
|
|
146
|
+
unqualifiedStatement
|
|
147
|
+
};
|
|
155
148
|
|
|
156
149
|
return json;
|
|
157
150
|
}
|
|
158
151
|
|
|
159
152
|
static fromJSON(json, fileContext) {
|
|
160
|
-
let {
|
|
153
|
+
let { unqualifiedStatement } = json;
|
|
161
154
|
|
|
162
155
|
json = unqualifiedStatement; ///
|
|
163
156
|
|
|
164
157
|
unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
|
|
165
158
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
subproofAssertion = (json !== null) ?
|
|
169
|
-
SubproofAssertion.fromJSON(json, fileContext) :
|
|
170
|
-
null;
|
|
171
|
-
|
|
172
|
-
const premise = new Premise(fileContext, subproofAssertion, unqualifiedStatement);
|
|
159
|
+
const premise = new Premise(fileContext, unqualifiedStatement);
|
|
173
160
|
|
|
174
161
|
return premise;
|
|
175
162
|
}
|
|
@@ -177,8 +164,7 @@ export default class Premise {
|
|
|
177
164
|
static fromSuppositionNode(suppositionNode, fileContext) {
|
|
178
165
|
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
179
166
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
180
|
-
|
|
181
|
-
premise = new Premise(fileContext, subproofAssertion, unqualifiedStatement);
|
|
167
|
+
premise = new Premise(fileContext, unqualifiedStatement);
|
|
182
168
|
|
|
183
169
|
return premise
|
|
184
170
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "../shim";
|
|
3
4
|
import Substitution from "../substitution";
|
|
4
5
|
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
5
6
|
import FrameForMetavariableSubstitution from "../substitution/frameForMetavariable";
|
|
@@ -53,11 +54,18 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
53
54
|
return metavariableNodeMatches;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
static
|
|
57
|
+
static fromStatementAndMetavariable(statement, metavariable, localContext) {
|
|
58
|
+
let statementNode = statement.getNode();
|
|
59
|
+
|
|
57
60
|
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
58
61
|
|
|
59
|
-
const
|
|
60
|
-
|
|
62
|
+
const { Statement } = shim;
|
|
63
|
+
|
|
64
|
+
statement = Statement.fromStatementNode(statementNode, localContext); ///
|
|
65
|
+
|
|
66
|
+
const string = stringFromStatementAndMetavariable(statement, metavariable),
|
|
67
|
+
substitution = null,
|
|
68
|
+
metavariableNode = metavariable.getNode(),
|
|
61
69
|
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(string, statementNode, metavariableNode, substitution);
|
|
62
70
|
|
|
63
71
|
return statementForMetavariableSubstitution;
|
|
@@ -74,6 +82,15 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
|
|
85
|
+
function stringFromStatementAndMetavariable(statement, metavariable) {
|
|
86
|
+
const statementString = statement.getString(),
|
|
87
|
+
metavariableString = metavariable.getString(),
|
|
88
|
+
string = `[${statementString} for ${metavariableString}]`;
|
|
89
|
+
|
|
90
|
+
return string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
77
94
|
function substitutionFromSubstitutionNode(substitutionNode, localContextA, localContextB) {
|
|
78
95
|
let substitution = null;
|
|
79
96
|
|
|
@@ -90,7 +90,7 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
90
90
|
|
|
91
91
|
const { Term } = shim;
|
|
92
92
|
|
|
93
|
-
term = Term.fromTermNode(termNode, localContext)
|
|
93
|
+
term = Term.fromTermNode(termNode, localContext); ///
|
|
94
94
|
|
|
95
95
|
const string = stringFromTermAndVariable(term, variable),
|
|
96
96
|
variableNode = variable.getNode(),
|
package/src/supposition.js
CHANGED
|
@@ -12,9 +12,8 @@ import { assignAssignments } from "./utilities/assignments";
|
|
|
12
12
|
const unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement");
|
|
13
13
|
|
|
14
14
|
export default class Supposition {
|
|
15
|
-
constructor(fileContext,
|
|
15
|
+
constructor(fileContext, unqualifiedStatement) {
|
|
16
16
|
this.fileContext = fileContext;
|
|
17
|
-
this.subproofAssertion = subproofAssertion;
|
|
18
17
|
this.unqualifiedStatement = unqualifiedStatement;
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -22,10 +21,6 @@ export default class Supposition {
|
|
|
22
21
|
return this.fileContext;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
getSubproofAssertion() {
|
|
26
|
-
return this.subproofAssertion;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
24
|
getUnqualifiedStatement() {
|
|
30
25
|
return this.unqualifiedStatement;
|
|
31
26
|
}
|
|
@@ -34,6 +29,65 @@ export default class Supposition {
|
|
|
34
29
|
|
|
35
30
|
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
36
31
|
|
|
32
|
+
verify(localContext) {
|
|
33
|
+
let verified = false;
|
|
34
|
+
|
|
35
|
+
const suppositionString = this.getString(); ///
|
|
36
|
+
|
|
37
|
+
if (this.unqualifiedStatement !== null) {
|
|
38
|
+
localContext.trace(`Verifying the '${suppositionString}' supposition...`);
|
|
39
|
+
|
|
40
|
+
const stated = true,
|
|
41
|
+
assignments = [],
|
|
42
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
43
|
+
|
|
44
|
+
if (unqualifiedStatementVerified) {
|
|
45
|
+
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
46
|
+
|
|
47
|
+
if (assignmentsAssigned) {
|
|
48
|
+
const { ProofStep } = shim,
|
|
49
|
+
proofStep = ProofStep.fromUnqualifiedStatement(this.unqualifiedStatement);
|
|
50
|
+
|
|
51
|
+
localContext.addProofStep(proofStep);
|
|
52
|
+
|
|
53
|
+
verified = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (verified) {
|
|
58
|
+
localContext.debug(`...verified the '${suppositionString}' supposition.`);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
localContext.debug(`The '${suppositionString}' supposition cannot be verified because it is nonsense.`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return verified;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
unifySubproof(subproof, substitutions, localContext) {
|
|
68
|
+
let subproofUnified = false;
|
|
69
|
+
|
|
70
|
+
const supposition = this, ///
|
|
71
|
+
subproofString = subproof.getString(),
|
|
72
|
+
suppositionStatement = supposition.getStatement(),
|
|
73
|
+
suppositionStatementString = suppositionStatement.getString();
|
|
74
|
+
|
|
75
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
|
|
76
|
+
|
|
77
|
+
const statement = this.unqualifiedStatement.getStatement(),
|
|
78
|
+
subproofAssertion = SubproofAssertion.fromStatement(statement, this.fileContext);
|
|
79
|
+
|
|
80
|
+
if (subproofAssertion !== null) {
|
|
81
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (subproofUnified) {
|
|
85
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return subproofUnified;
|
|
89
|
+
}
|
|
90
|
+
|
|
37
91
|
unifyProofStep(proofStep, substitutions, localContext) {
|
|
38
92
|
let proofStepUnified = false;
|
|
39
93
|
|
|
@@ -85,91 +139,24 @@ export default class Supposition {
|
|
|
85
139
|
return statementUnified;
|
|
86
140
|
}
|
|
87
141
|
|
|
88
|
-
unifySubproof(subproof, substitutions, localContext) {
|
|
89
|
-
let subproofUnified = false;
|
|
90
|
-
|
|
91
|
-
const supposition = this, ///
|
|
92
|
-
subproofString = subproof.getString(),
|
|
93
|
-
suppositionStatement = supposition.getStatement(),
|
|
94
|
-
suppositionStatementString = suppositionStatement.getString();
|
|
95
|
-
|
|
96
|
-
localContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
|
|
97
|
-
|
|
98
|
-
if (this.subproofAssertion !== null) {
|
|
99
|
-
subproofUnified = this.subproofAssertion.unifySubproof(subproof, substitutions, localContext);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (subproofUnified) {
|
|
103
|
-
localContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return subproofUnified;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
verify(localContext) {
|
|
110
|
-
let verified = false;
|
|
111
|
-
|
|
112
|
-
const suppositionString = this.getString(); ///
|
|
113
|
-
|
|
114
|
-
if (this.unqualifiedStatement !== null) {
|
|
115
|
-
localContext.trace(`Verifying the '${suppositionString}' supposition...`);
|
|
116
|
-
|
|
117
|
-
const stated = true,
|
|
118
|
-
assignments = [],
|
|
119
|
-
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
120
|
-
|
|
121
|
-
if (unqualifiedStatementVerified) {
|
|
122
|
-
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
123
|
-
|
|
124
|
-
if (assignmentsAssigned) {
|
|
125
|
-
const { ProofStep } = shim,
|
|
126
|
-
proofStep = ProofStep.fromUnqualifiedStatement(this.unqualifiedStatement);
|
|
127
|
-
|
|
128
|
-
localContext.addProofStep(proofStep);
|
|
129
|
-
|
|
130
|
-
verified = true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (verified) {
|
|
135
|
-
localContext.debug(`...verified the '${suppositionString}' supposition.`);
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
localContext.debug(`The '${suppositionString}' supposition cannot be verified because it is nonsense.`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return verified;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
142
|
toJSON() {
|
|
145
143
|
const unqualifiedStatementJSON = this.unqualifiedStatement.toJSON(),
|
|
146
|
-
subproofAssertionJSON = (this.subproofAssertion !== null) ?
|
|
147
|
-
this.subproofAssertion.toJSON() :
|
|
148
|
-
null,
|
|
149
144
|
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
150
|
-
subproofAssertion = subproofAssertionJSON, ///
|
|
151
145
|
json = {
|
|
152
|
-
unqualifiedStatement
|
|
153
|
-
subproofAssertion
|
|
146
|
+
unqualifiedStatement
|
|
154
147
|
};
|
|
155
148
|
|
|
156
149
|
return json;
|
|
157
150
|
}
|
|
158
151
|
|
|
159
152
|
static fromJSON(json, fileContext) {
|
|
160
|
-
let {
|
|
153
|
+
let { unqualifiedStatement } = json;
|
|
161
154
|
|
|
162
155
|
json = unqualifiedStatement; ///
|
|
163
156
|
|
|
164
157
|
unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
|
|
165
158
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
subproofAssertion = (json !== null) ?
|
|
169
|
-
SubproofAssertion.fromJSON(json, fileContext) :
|
|
170
|
-
null;
|
|
171
|
-
|
|
172
|
-
const supposition = new Supposition(fileContext, subproofAssertion, unqualifiedStatement);
|
|
159
|
+
const supposition = new Supposition(fileContext, unqualifiedStatement);
|
|
173
160
|
|
|
174
161
|
return supposition;
|
|
175
162
|
}
|
|
@@ -177,8 +164,7 @@ export default class Supposition {
|
|
|
177
164
|
static fromSuppositionNode(suppositionNode, fileContext) {
|
|
178
165
|
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
179
166
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
180
|
-
|
|
181
|
-
supposition = new Supposition(fileContext, subproofAssertion, unqualifiedStatement);
|
|
167
|
+
supposition = new Supposition(fileContext, unqualifiedStatement);
|
|
182
168
|
|
|
183
169
|
return supposition
|
|
184
170
|
}
|
package/src/unifier/metaLevel.js
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Unifier from "../unifier";
|
|
5
5
|
import unifyMetavariableWithFrame from "../unify/metavariableWithFrame";
|
|
6
|
-
import unifyMetavariableWithStatement from "../unify/metavariableWithStatement";
|
|
7
6
|
import unifyMetavariableWithStatementGivenSubstitution from "../unify/metavariableWithStatementGivenSubstitution";
|
|
8
7
|
|
|
9
8
|
import { nodeQuery } from "../utilities/query";
|
|
10
|
-
import { variableNameFromVariableNode } from "../utilities/name";
|
|
9
|
+
import { variableNameFromVariableNode, metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
11
10
|
|
|
12
11
|
const termNodeQuery = nodeQuery("/term!"),
|
|
13
12
|
frameNodeQuery = nodeQuery("/frame!"),
|
|
@@ -49,9 +48,16 @@ class MetaLevelUnifier extends Unifier {
|
|
|
49
48
|
statementSubstitutionNodeA = statementSubstitutionNodeQuery(statementNodeA);
|
|
50
49
|
|
|
51
50
|
if (statementSubstitutionNodeA === null) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const { Statement } = shim,
|
|
52
|
+
metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
53
|
+
metavariableA = localContextA.findMetavariableByMetavariableName(metavariableNameA),
|
|
54
|
+
statementB = Statement.fromStatementNode(statementNodeB, localContextB),
|
|
55
|
+
localContext = localContextB, ///
|
|
56
|
+
metavariable = metavariableA, ///
|
|
57
|
+
statement = statementB, ///
|
|
58
|
+
statementUnified = metavariable.unifyStatement(statement, substitutions, localContext);
|
|
59
|
+
|
|
60
|
+
statementUnifiedWithStatement = statementUnified; ///
|
|
55
61
|
} else {
|
|
56
62
|
const substitutionNodeA = statementSubstitutionNodeA, ///
|
|
57
63
|
metavariableUnifiedWithStatementGivenSubstitution = unifyMetavariableWithStatementGivenSubstitution(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB);
|
|
@@ -5,7 +5,6 @@ import Unifier from "../unifier";
|
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
8
|
-
import local from "../context/local";
|
|
9
8
|
|
|
10
9
|
const termNodeQuery = nodeQuery("/term!"),
|
|
11
10
|
typeNodeQuery = nodeQuery("/type!"),
|
package/src/variable.js
CHANGED
|
@@ -8,19 +8,25 @@ import { nodeQuery } from "./utilities/query";
|
|
|
8
8
|
import { objectType } from "./type";
|
|
9
9
|
import { variableNameFromVariableNode} from "./utilities/name";
|
|
10
10
|
import { variableNodeFromVariableString } from "./utilities/node";
|
|
11
|
+
import local from "./context/local";
|
|
11
12
|
|
|
12
13
|
const typeNodeQuery = nodeQuery("/variableDeclaration/type"),
|
|
13
14
|
variableNodeQuery = nodeQuery("/variableDeclaration/variable"),
|
|
14
15
|
termVariableNodeQuery = nodeQuery("/term/variable");
|
|
15
16
|
|
|
16
17
|
export default class Variable {
|
|
17
|
-
constructor(string, node, name, type) {
|
|
18
|
+
constructor(localContext, string, node, name, type) {
|
|
19
|
+
this.localContext = localContext; ///
|
|
18
20
|
this.string = string;
|
|
19
21
|
this.node = node;
|
|
20
22
|
this.name = name;
|
|
21
23
|
this.type = type;
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
getLocalContext() {
|
|
27
|
+
return this.localContext;
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
getString() {
|
|
25
31
|
return this.string;
|
|
26
32
|
}
|
|
@@ -195,10 +201,11 @@ export default class Variable {
|
|
|
195
201
|
variableString = string, ///
|
|
196
202
|
variableNode = variableNodeFromVariableString(variableString, lexer, parser),
|
|
197
203
|
variableName = variableNameFromVariableNode(variableNode),
|
|
204
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
198
205
|
node = variableNode,
|
|
199
206
|
name = variableName, ///
|
|
200
207
|
type = typeFromJSON(json, fileContext),
|
|
201
|
-
variable = new Variable(string, node, name, type);
|
|
208
|
+
variable = new Variable(localContext, string, node, name, type);
|
|
202
209
|
|
|
203
210
|
return variable;
|
|
204
211
|
}
|
|
@@ -213,7 +220,7 @@ export default class Variable {
|
|
|
213
220
|
name = variableName, ///
|
|
214
221
|
type = null;
|
|
215
222
|
|
|
216
|
-
variable = new Variable(string, node, name, type);
|
|
223
|
+
variable = new Variable(localContext, string, node, name, type);
|
|
217
224
|
}
|
|
218
225
|
|
|
219
226
|
return variable;
|
|
@@ -224,7 +231,7 @@ export default class Variable {
|
|
|
224
231
|
variableName = variableNameFromVariableNode(variableNode),
|
|
225
232
|
string = localContext.nodeAsString(node),
|
|
226
233
|
name = variableName, ///
|
|
227
|
-
variable = new Variable(string, node, name, type);
|
|
234
|
+
variable = new Variable(localContext, string, node, name, type);
|
|
228
235
|
|
|
229
236
|
return variable;
|
|
230
237
|
}
|
|
@@ -240,7 +247,7 @@ export default class Variable {
|
|
|
240
247
|
node = variableNode, ///
|
|
241
248
|
name = variableName, ///
|
|
242
249
|
type = Type.fromTypeNode(typeNode, localContext),
|
|
243
|
-
variable = new Variable(string, node, name, type);
|
|
250
|
+
variable = new Variable(localContext, string, node, name, type);
|
|
244
251
|
|
|
245
252
|
return variable;
|
|
246
253
|
}
|