occam-verify-cli 0.0.1073 → 0.0.1075
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/type.js +47 -54
- package/lib/assignment/equality.js +8 -2
- package/lib/assignment/variable.js +2 -2
- package/lib/axiom.js +9 -12
- package/lib/combinator/bracketed.js +3 -2
- package/lib/combinator.js +6 -6
- package/lib/conclusion.js +2 -3
- package/lib/conjecture.js +10 -15
- package/lib/consequent.js +2 -3
- package/lib/constructor/bracketed.js +3 -2
- package/lib/constructor.js +6 -6
- package/lib/context/file.js +48 -107
- package/lib/context/local.js +52 -73
- package/lib/declaration/combinator.js +5 -5
- package/lib/declaration/constructor.js +5 -5
- package/lib/declaration/metavariable.js +4 -5
- package/lib/declaration/type.js +3 -3
- package/lib/declaration/variable.js +5 -5
- package/lib/declaration.js +6 -2
- package/lib/derivation.js +6 -2
- package/lib/equality.js +53 -22
- package/lib/equivalence.js +22 -24
- package/lib/frame.js +11 -13
- package/lib/index.js +13 -1
- package/lib/judgement.js +11 -8
- package/lib/label.js +6 -7
- package/lib/lemma.js +10 -15
- package/lib/metaLemma.js +15 -15
- package/lib/metatheorem.js +9 -14
- package/lib/metavariable.js +17 -23
- package/lib/mixins/statement/qualified/unify.js +2 -2
- package/lib/mixins/statement/verify.js +8 -12
- package/lib/mixins/term/verify.js +4 -4
- package/lib/premise.js +2 -3
- package/lib/proof.js +8 -4
- package/lib/proofStep.js +10 -8
- package/lib/reference.js +3 -3
- package/lib/rule.js +11 -16
- package/lib/statement/qualified.js +6 -2
- package/lib/statement/unqualified.js +1 -1
- package/lib/statement.js +5 -5
- package/lib/subDerivation.js +6 -2
- package/lib/subproof.js +10 -7
- package/lib/substitution/statementForMetavariable.js +14 -15
- package/lib/substitution.js +13 -13
- package/lib/substitutions.js +51 -47
- package/lib/supposition.js +2 -3
- package/lib/term.js +5 -5
- package/lib/theorem.js +10 -15
- package/lib/topLevelAssertion.js +3 -3
- package/lib/type.js +15 -22
- package/lib/unifier/equality.js +2 -2
- package/lib/unifier/metaLevel.js +6 -6
- package/lib/unifier/metavariable.js +5 -5
- package/lib/unifier/statementWithCombinator.js +2 -2
- package/lib/utilities/brackets.js +2 -2
- package/lib/utilities/equivalences.js +8 -8
- package/lib/utilities/node.js +2 -7
- package/lib/utilities/nominal.js +26 -0
- package/lib/utilities/subproof.js +2 -2
- package/lib/utilities/tokens.js +3 -7
- package/lib/variable.js +13 -9
- package/lib/verifier/metaLevel.js +2 -2
- package/lib/verifier/statementAsCombinator.js +2 -2
- package/lib/verifier/termAsConstructor.js +2 -2
- package/lib/verifier/topLevel.js +9 -15
- package/package.json +1 -1
- package/src/assertion/type.js +52 -57
- package/src/assignment/equality.js +3 -1
- package/src/assignment/variable.js +2 -1
- package/src/axiom.js +6 -8
- package/src/combinator/bracketed.js +6 -3
- package/src/combinator.js +4 -4
- package/src/conclusion.js +2 -2
- package/src/conjecture.js +8 -11
- package/src/consequent.js +2 -2
- package/src/constructor/bracketed.js +6 -3
- package/src/constructor.js +4 -4
- package/src/context/file.js +46 -90
- package/src/context/local.js +51 -90
- package/src/declaration/combinator.js +5 -4
- package/src/declaration/constructor.js +5 -4
- package/src/declaration/metavariable.js +3 -4
- package/src/declaration/type.js +2 -2
- package/src/declaration/variable.js +5 -4
- package/src/declaration.js +7 -1
- package/src/derivation.js +7 -1
- package/src/equality.js +80 -27
- package/src/equivalence.js +30 -28
- package/src/frame.js +10 -9
- package/src/index.js +12 -0
- package/src/judgement.js +11 -5
- package/src/label.js +5 -5
- package/src/lemma.js +8 -11
- package/src/metaLemma.js +13 -11
- package/src/metatheorem.js +6 -10
- package/src/metavariable.js +18 -34
- package/src/mixins/statement/qualified/unify.js +1 -2
- package/src/mixins/statement/verify.js +19 -18
- package/src/mixins/term/verify.js +4 -3
- package/src/premise.js +2 -2
- package/src/proof.js +10 -3
- package/src/proofStep.js +12 -7
- package/src/reference.js +3 -2
- package/src/rule.js +10 -12
- package/src/statement/qualified.js +7 -1
- package/src/statement/unqualified.js +0 -1
- package/src/statement.js +3 -3
- package/src/subDerivation.js +8 -2
- package/src/subproof.js +12 -5
- package/src/substitution/statementForMetavariable.js +12 -12
- package/src/substitution.js +9 -9
- package/src/substitutions.js +42 -34
- package/src/supposition.js +2 -2
- package/src/term.js +3 -3
- package/src/theorem.js +8 -11
- package/src/topLevelAssertion.js +3 -2
- package/src/type.js +15 -28
- package/src/unifier/equality.js +1 -1
- package/src/unifier/metaLevel.js +8 -10
- package/src/unifier/metavariable.js +5 -5
- package/src/unifier/statementWithCombinator.js +5 -5
- package/src/utilities/brackets.js +2 -2
- package/src/utilities/equivalences.js +9 -9
- package/src/utilities/node.js +1 -10
- package/src/utilities/nominal.js +14 -0
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/tokens.js +2 -9
- package/src/variable.js +16 -11
- package/src/verifier/metaLevel.js +2 -2
- package/src/verifier/statementAsCombinator.js +3 -3
- package/src/verifier/termAsConstructor.js +2 -2
- package/src/verifier/topLevel.js +15 -14
- package/lib/assignment/metavariable.js +0 -62
- package/lib/unifier/intrinsicLevel.js +0 -144
- package/lib/utilities/unify.js +0 -24
- package/lib/verifier/intrinsicLevel.js +0 -140
- package/src/assignment/metavariable.js +0 -30
- package/src/unifier/intrinsicLevel.js +0 -54
- package/src/utilities/unify.js +0 -23
- package/src/verifier/intrinsicLevel.js +0 -42
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "../../shim";
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../../utilities/query";
|
|
6
6
|
|
|
7
|
-
const variableNodeQuery = nodeQuery("/term/variable");
|
|
7
|
+
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
8
8
|
|
|
9
9
|
function verifyTermAsVariable(term, localContext, verifyAhead) {
|
|
10
10
|
let termVerifiedAsVariable = false;
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const { Variable } = shim,
|
|
13
|
+
termNode = term.getNode(),
|
|
13
14
|
variableNode = variableNodeQuery(termNode),
|
|
14
15
|
variable = Variable.fromVariableNode(variableNode, localContext);
|
|
15
16
|
|
package/src/premise.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
5
|
import SubproofAssertion from "./assertion/subproof";
|
|
6
|
-
import UnqualifiedStatement from "./statement/unqualified";
|
|
7
6
|
|
|
8
7
|
import { nodeQuery } from "./utilities/query";
|
|
9
8
|
import { assignAssignments } from "./utilities/assignments";
|
|
@@ -162,7 +161,8 @@ class Premise {
|
|
|
162
161
|
}
|
|
163
162
|
|
|
164
163
|
static fromPremiseNode(suppositionNode, fileContext) {
|
|
165
|
-
const
|
|
164
|
+
const { UnqualifiedStatement } = shim,
|
|
165
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
166
166
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
167
167
|
premise = new Premise(fileContext, unqualifiedStatement);
|
|
168
168
|
|
package/src/proof.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "./utilities/query";
|
|
7
7
|
|
|
8
8
|
const derivationNodeQuery = nodeQuery("/proof/derivation");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
class Proof {
|
|
11
11
|
constructor(derivation) {
|
|
12
12
|
this.derivation = derivation;
|
|
13
13
|
}
|
|
@@ -47,7 +47,8 @@ export default class Proof {
|
|
|
47
47
|
let proof = null;
|
|
48
48
|
|
|
49
49
|
if (proofNode !== null) {
|
|
50
|
-
const
|
|
50
|
+
const { Derivation } = shim,
|
|
51
|
+
derivationNode = derivationNodeQuery(proofNode),
|
|
51
52
|
derivation = Derivation.fromDerivationNode(derivationNode, fileContext);
|
|
52
53
|
|
|
53
54
|
proof = new Proof(derivation);
|
|
@@ -56,3 +57,9 @@ export default class Proof {
|
|
|
56
57
|
return proof;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
60
|
+
|
|
61
|
+
Object.assign(shim, {
|
|
62
|
+
Proof
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export default Proof;
|
package/src/proofStep.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import Subproof from "./subproof";
|
|
5
|
-
import Substitutions from "./substitutions";
|
|
6
|
-
import QualifiedStatement from "./statement/qualified";
|
|
7
|
-
import UnqualifiedStatement from "./statement/unqualified";
|
|
8
4
|
|
|
9
5
|
import { nodeQuery } from "./utilities/query";
|
|
6
|
+
import { assignAssignments } from "./utilities/assignments";
|
|
10
7
|
|
|
11
8
|
const subproofNodeQuery = nodeQuery("/proofStep|lastProofStep/subproof"),
|
|
12
9
|
qualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/qualifiedStatement"),
|
|
@@ -48,7 +45,8 @@ class ProofStep {
|
|
|
48
45
|
unifyStatement(statement, localContext) {
|
|
49
46
|
let statementUnified = false;
|
|
50
47
|
|
|
51
|
-
const
|
|
48
|
+
const { Substitutions } = shim,
|
|
49
|
+
substitutions = Substitutions.fromNothing();
|
|
52
50
|
|
|
53
51
|
if (this.qualifiedStatement !== null) {
|
|
54
52
|
const localContextA = localContext, ///
|
|
@@ -91,7 +89,13 @@ class ProofStep {
|
|
|
91
89
|
assignments = [],
|
|
92
90
|
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
93
91
|
|
|
94
|
-
|
|
92
|
+
if (unqualifiedStatementVerified) {
|
|
93
|
+
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
94
|
+
|
|
95
|
+
if (assignmentsAssigned) {
|
|
96
|
+
verified = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
if (verified) {
|
|
@@ -104,7 +108,8 @@ class ProofStep {
|
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
static fromProofStepNode(proofStepNode, fileContext) {
|
|
107
|
-
const
|
|
111
|
+
const { Subproof, QualifiedStatement, UnqualifiedStatement } = shim,
|
|
112
|
+
subproofNode = subproofNodeQuery(proofStepNode),
|
|
108
113
|
qualifiedStatementNode = qualifiedStatementNodeQuery(proofStepNode),
|
|
109
114
|
unqualifiedStatementNode = unqualifiedStatementNodeQuery(proofStepNode),
|
|
110
115
|
subproof = Subproof.fromSubproofNode(subproofNode, fileContext),
|
package/src/reference.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "./utilities/query";
|
|
@@ -67,7 +67,8 @@ export default class Reference {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
static fromReferenceNode(referenceNode, fileContext) {
|
|
70
|
-
const
|
|
70
|
+
const { Metavariable } = shim,
|
|
71
|
+
metavariableNode = metavariableNodeQuery(referenceNode),
|
|
71
72
|
localContext = LocalContext.fromFileContext(fileContext),
|
|
72
73
|
metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
|
|
73
74
|
reference = new Reference(metavariable);
|
package/src/rule.js
CHANGED
|
@@ -3,12 +3,7 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
5
|
import shim from "./shim";
|
|
6
|
-
import Label from "./label";
|
|
7
|
-
import Proof from "./proof";
|
|
8
|
-
import Premise from "./premise";
|
|
9
|
-
import Conclusion from "./conclusion";
|
|
10
6
|
import LocalContext from "./context/local";
|
|
11
|
-
import Substitutions from "./substitutions";
|
|
12
7
|
|
|
13
8
|
import { stringFromLabels } from "./topLevelAssertion";
|
|
14
9
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
@@ -75,7 +70,8 @@ class Rule {
|
|
|
75
70
|
unifyStatement(statement, localContext) {
|
|
76
71
|
let statementUnified = false;
|
|
77
72
|
|
|
78
|
-
const
|
|
73
|
+
const { Substitutions } = shim,
|
|
74
|
+
proofSteps = localContext.getProofSteps(),
|
|
79
75
|
substitutions = Substitutions.fromNothing(),
|
|
80
76
|
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
81
77
|
|
|
@@ -125,15 +121,15 @@ class Rule {
|
|
|
125
121
|
|
|
126
122
|
this.fileContext.trace(`Verifying the '${ruleString}' rule...`);
|
|
127
123
|
|
|
128
|
-
const
|
|
129
|
-
const
|
|
124
|
+
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
125
|
+
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
130
126
|
|
|
131
|
-
if (
|
|
127
|
+
if (labelVVerifiedWhenDeclared) {
|
|
132
128
|
return true;
|
|
133
129
|
}
|
|
134
130
|
});
|
|
135
131
|
|
|
136
|
-
if (
|
|
132
|
+
if (labelsVerifiedWhenDeclared) {
|
|
137
133
|
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
138
134
|
premisesVerified = this.premises.every((premise) => {
|
|
139
135
|
const premiseVerified = premise.verify(localContext);
|
|
@@ -150,7 +146,8 @@ class Rule {
|
|
|
150
146
|
let proofVerified = true; ///
|
|
151
147
|
|
|
152
148
|
if (this.proof !== null) {
|
|
153
|
-
const
|
|
149
|
+
const { Substitutions } = shim,
|
|
150
|
+
substitutions = Substitutions.fromNothing();
|
|
154
151
|
|
|
155
152
|
proofVerified = this.proof.verify(substitutions, this.conclusion, localContext);
|
|
156
153
|
}
|
|
@@ -204,7 +201,8 @@ class Rule {
|
|
|
204
201
|
}
|
|
205
202
|
|
|
206
203
|
static fromRuleNode(ruleNode, fileContext) {
|
|
207
|
-
const
|
|
204
|
+
const { Label, Proof, Premise, Conclusion } = shim,
|
|
205
|
+
proofNode = proofNodeQuery(ruleNode),
|
|
208
206
|
labelNodes = labelNodesQuery(ruleNode),
|
|
209
207
|
premiseNodes = premiseNodesQuery(ruleNode),
|
|
210
208
|
conclusionNode = conclusionNodeQuery(ruleNode),
|
|
@@ -12,7 +12,7 @@ import { assignAssignments } from "../utilities/assignments";
|
|
|
12
12
|
const statementNodeQuery = nodeQuery("/qualifiedStatement/statement"),
|
|
13
13
|
referenceNodeQuery = nodeQuery("/qualifiedStatement/reference");
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
class QualifiedStatement {
|
|
16
16
|
constructor(string, statement, reference) {
|
|
17
17
|
this.string = string;
|
|
18
18
|
this.statement = statement;
|
|
@@ -127,3 +127,9 @@ export default class QualifiedStatement {
|
|
|
127
127
|
return qualifiedStatement;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
|
|
131
|
+
Object.assign(shim, {
|
|
132
|
+
QualifiedStatement
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export default QualifiedStatement;
|
|
@@ -50,7 +50,6 @@ class UnqualifiedStatement {
|
|
|
50
50
|
if (verified) {
|
|
51
51
|
localContext.debug(`...verified the '${unqualifiedStatementString}' unqualified statement.`);
|
|
52
52
|
}
|
|
53
|
-
|
|
54
53
|
} else {
|
|
55
54
|
localContext.debug(`Cannot verify the '${unqualifiedStatementString}' unqualified statement because it is nonsense.`);
|
|
56
55
|
}
|
package/src/statement.js
CHANGED
|
@@ -171,18 +171,18 @@ class Statement {
|
|
|
171
171
|
return verified;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
verifyWhenDeclared(fileContext) {
|
|
175
175
|
let verifiedAtTopLevel;
|
|
176
176
|
|
|
177
177
|
const statementNode = this.node, ///
|
|
178
178
|
statementString = this.string; ///
|
|
179
179
|
|
|
180
|
-
fileContext.trace(`Verifying the '${statementString}' statement
|
|
180
|
+
fileContext.trace(`Verifying the '${statementString}' statement when declared...`);
|
|
181
181
|
|
|
182
182
|
verifiedAtTopLevel = statementAsCombinatorVerifier.verifyStatement(statementNode, fileContext);
|
|
183
183
|
|
|
184
184
|
if (verifiedAtTopLevel) {
|
|
185
|
-
fileContext.debug(`...verified the '${statementString}' statement
|
|
185
|
+
fileContext.debug(`...verified the '${statementString}' statement when declared.`);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
return verifiedAtTopLevel;
|
package/src/subDerivation.js
CHANGED
|
@@ -10,7 +10,7 @@ const { last } = arrayUtilities;
|
|
|
10
10
|
|
|
11
11
|
const proofStepNodesQuery = nodesQuery("/subDerivation/proofStep|lastProofStep");
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
class SubDerivation {
|
|
14
14
|
constructor(proofSteps) {
|
|
15
15
|
this.proofSteps = proofSteps;
|
|
16
16
|
}
|
|
@@ -52,4 +52,10 @@ export default class SubDerivation {
|
|
|
52
52
|
return subDerivation;
|
|
53
53
|
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Object.assign(shim, {
|
|
58
|
+
SubDerivation
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export default SubDerivation;
|
package/src/subproof.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
|
|
4
5
|
import LocalContext from "./context/local";
|
|
5
|
-
import SubDerivation from "./subDerivation";
|
|
6
6
|
|
|
7
7
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
|
-
import {
|
|
8
|
+
import { subproofStringFromSubproofNode } from "./utilities/subproof";
|
|
9
9
|
|
|
10
10
|
const suppositionNodesQuery = nodesQuery("/subproof/supposition"),
|
|
11
11
|
subDerivationNodeQuery = nodeQuery("/subproof/subDerivation");
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
class Subproof {
|
|
14
14
|
constructor(string, suppositions, subDerivation) {
|
|
15
15
|
this.string = string;
|
|
16
16
|
this.suppositions = suppositions;
|
|
@@ -79,7 +79,8 @@ export default class Subproof {
|
|
|
79
79
|
let subproof = null;
|
|
80
80
|
|
|
81
81
|
if (subproofNode !== null) {
|
|
82
|
-
const
|
|
82
|
+
const { Supposition, SubDerivation } = shim,
|
|
83
|
+
subproofString = subproofStringFromSubproofNode(subproofNode, fileContext),
|
|
83
84
|
suppositionNodes = suppositionNodesQuery(subproofNode),
|
|
84
85
|
subDerivationNode = subDerivationNodeQuery(subproofNode),
|
|
85
86
|
string = subproofString, ///
|
|
@@ -96,3 +97,9 @@ export default class Subproof {
|
|
|
96
97
|
return subproof;
|
|
97
98
|
}
|
|
98
99
|
}
|
|
100
|
+
|
|
101
|
+
Object.assign(shim, {
|
|
102
|
+
Subproof
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export default Subproof;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
5
|
import LocalContext from "../context/local";
|
|
6
|
-
import Substitutions from "../substitutions";
|
|
7
6
|
import metaLevelUnifier from "../unifier/metaLevel";
|
|
8
7
|
|
|
9
8
|
import { stripBracketsFromStatementNode } from "../utilities/brackets";
|
|
@@ -30,10 +29,10 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
30
29
|
return this.substitution;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
const
|
|
32
|
+
getMetavariableNode() {
|
|
33
|
+
const metavariableNode = this.metavariable.getNode();
|
|
35
34
|
|
|
36
|
-
return
|
|
35
|
+
return metavariableNode;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
isSimple() {
|
|
@@ -49,8 +48,8 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
49
48
|
|
|
50
49
|
localContextB.trace(`Resolving the ${substitutionString} substitution...`);
|
|
51
50
|
|
|
52
|
-
const
|
|
53
|
-
simpleSubstitution = substitutions.
|
|
51
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
52
|
+
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode);
|
|
54
53
|
|
|
55
54
|
if (simpleSubstitution !== null) {
|
|
56
55
|
const substitution = simpleSubstitution, ///
|
|
@@ -104,7 +103,8 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
104
103
|
unifyStatement(statement, localContextA, localContextB) {
|
|
105
104
|
let substitution = null;
|
|
106
105
|
|
|
107
|
-
const
|
|
106
|
+
const { Substitutions } = shim,
|
|
107
|
+
substitutions = Substitutions.fromNothing(),
|
|
108
108
|
statementUnified = this.statement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
109
109
|
|
|
110
110
|
if (statementUnified) {
|
|
@@ -128,7 +128,7 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
128
128
|
return statementNodeMatches;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
132
132
|
|
|
133
133
|
matchSubstitutionNode(substitutionNode) {
|
|
134
134
|
let substitutionNodeMatches;
|
|
@@ -146,12 +146,12 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
146
146
|
return substitutionNodeMatches;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
const
|
|
149
|
+
matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
150
|
+
const metavariableNodeMatches = this.matchMetavariableNode(metavariableNode),
|
|
151
151
|
substitutionNodeMatches = this.matchSubstitutionNode(substitutionNode),
|
|
152
|
-
|
|
152
|
+
metavariableNodeAndSubstitutionNodeMatches = (metavariableNodeMatches && substitutionNodeMatches);
|
|
153
153
|
|
|
154
|
-
return
|
|
154
|
+
return metavariableNodeAndSubstitutionNodeMatches;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
toJSON() {
|
package/src/substitution.js
CHANGED
|
@@ -35,10 +35,10 @@ class Substitution {
|
|
|
35
35
|
return substitutionNode;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
const
|
|
38
|
+
getMetavariableNode() {
|
|
39
|
+
const metavariableNode = null;
|
|
40
40
|
|
|
41
|
-
return
|
|
41
|
+
return metavariableNode;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
isSimple() {
|
|
@@ -90,16 +90,16 @@ class Substitution {
|
|
|
90
90
|
return variableNameMatches;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
const
|
|
93
|
+
matchMetavariableNode(metavariableNode) {
|
|
94
|
+
const metavariableNodeMatches = false;
|
|
95
95
|
|
|
96
|
-
return
|
|
96
|
+
return metavariableNodeMatches;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
const
|
|
99
|
+
matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
100
|
+
const metavariableNodeAndSubstitutionNodeMatches = false;
|
|
101
101
|
|
|
102
|
-
return
|
|
102
|
+
return metavariableNodeAndSubstitutionNodeMatches;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
unifyWithEquivalence(equivalence, substitutions, localContextA, localContextB) {
|
package/src/substitutions.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
|
|
3
5
|
import { arrayUtilities } from "necessary";
|
|
4
6
|
|
|
5
7
|
import { EMPTY_STRING } from "./constants";
|
|
6
8
|
|
|
7
9
|
const { find, first, prune, filter, compress } = arrayUtilities;
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
class Substitutions {
|
|
10
12
|
constructor(array, savedArray) {
|
|
11
13
|
this.array = array;
|
|
12
14
|
this.savedArray = savedArray;
|
|
@@ -34,24 +36,26 @@ export default class Substitutions {
|
|
|
34
36
|
return firstSubstitution;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
+
getMetavariableNodes() {
|
|
40
|
+
const metavariableNodes = [];
|
|
39
41
|
|
|
40
42
|
this.forEachSubstitution((substitution) => {
|
|
41
|
-
const
|
|
43
|
+
const metavariableNode = substitution.getMetavariableNode();
|
|
42
44
|
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
+
if (metavariableNode !== null) {
|
|
46
|
+
metavariableNodes.push(metavariableNode);
|
|
45
47
|
}
|
|
46
48
|
});
|
|
47
49
|
|
|
48
|
-
compress(
|
|
49
|
-
|
|
50
|
+
compress(metavariableNodes, (metavariableNodeA, metavariableNodeB) => {
|
|
51
|
+
const metavariableNodeAMatchesMetavariableNodeB = metavariableNodeB.match(metavariableNodeA);
|
|
52
|
+
|
|
53
|
+
if (metavariableNodeAMatchesMetavariableNodeB) {
|
|
50
54
|
return true;
|
|
51
55
|
}
|
|
52
56
|
});
|
|
53
57
|
|
|
54
|
-
return
|
|
58
|
+
return metavariableNodes;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
mapSubstitution(callback) { return this.array.map(callback); }
|
|
@@ -102,11 +106,11 @@ export default class Substitutions {
|
|
|
102
106
|
return substitution;
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
|
|
109
|
+
findSubstitutionByMetavariableNode(metavariableNode) {
|
|
106
110
|
const substitution = this.findSubstitution((substitution) => {
|
|
107
|
-
const
|
|
111
|
+
const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
|
|
108
112
|
|
|
109
|
-
if (
|
|
113
|
+
if (metavariableNodeMatches) {
|
|
110
114
|
return true;
|
|
111
115
|
}
|
|
112
116
|
});
|
|
@@ -114,11 +118,11 @@ export default class Substitutions {
|
|
|
114
118
|
return substitution;
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
findSubstitutionsByMetavariableNode(metavariableNode) {
|
|
118
122
|
const substitutions = this.findSubstitutions((substitution) => {
|
|
119
|
-
const
|
|
123
|
+
const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
|
|
120
124
|
|
|
121
|
-
if (
|
|
125
|
+
if (metavariableNodeMatches) {
|
|
122
126
|
return true;
|
|
123
127
|
}
|
|
124
128
|
});
|
|
@@ -126,8 +130,8 @@ export default class Substitutions {
|
|
|
126
130
|
return substitutions;
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
const substitutions = this.
|
|
133
|
+
findSimpleSubstitutionByMetavariableNode(metavariableNode) {
|
|
134
|
+
const substitutions = this.findSubstitutionsByMetavariableNode(metavariableNode),
|
|
131
135
|
simpleSubstitutions = substitutions.filterSubstitution((substitution) => {
|
|
132
136
|
const substitutionSimple = substitution.isSimple();
|
|
133
137
|
|
|
@@ -141,8 +145,8 @@ export default class Substitutions {
|
|
|
141
145
|
return simpleSubstitution;
|
|
142
146
|
}
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
const substitutions = this.
|
|
148
|
+
findComplexSubstitutionsByMetavariableNode(metavariableNode) {
|
|
149
|
+
const substitutions = this.findSubstitutionsByMetavariableNode(metavariableNode),
|
|
146
150
|
complexSubstitutions = substitutions.filterSubstitution((substitution) => {
|
|
147
151
|
const substitutionComplex = substitution.isComplex();
|
|
148
152
|
|
|
@@ -154,11 +158,11 @@ export default class Substitutions {
|
|
|
154
158
|
return complexSubstitutions;
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
158
162
|
const substitutions = this.findSubstitutions((substitution) => {
|
|
159
|
-
const
|
|
163
|
+
const metavariableNodeAndSubstitutionNodeMatch = substitution.matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
160
164
|
|
|
161
|
-
if (
|
|
165
|
+
if (metavariableNodeAndSubstitutionNodeMatch) {
|
|
162
166
|
return true;
|
|
163
167
|
}
|
|
164
168
|
}),
|
|
@@ -168,15 +172,15 @@ export default class Substitutions {
|
|
|
168
172
|
return substitution;
|
|
169
173
|
}
|
|
170
174
|
|
|
171
|
-
|
|
172
|
-
const simpleSubstitution = this.
|
|
175
|
+
isSimpleSubstitutionPresentByMetavariableNode(metavariableNode) {
|
|
176
|
+
const simpleSubstitution = this.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
173
177
|
simpleSubstitutionPresent = (simpleSubstitution !== null);
|
|
174
178
|
|
|
175
179
|
return simpleSubstitutionPresent;
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
|
|
179
|
-
const substitution = this.
|
|
182
|
+
isSubstitutionPresentByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
183
|
+
const substitution = this.findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
|
|
180
184
|
substitutionPresent = (substitution !== null);
|
|
181
185
|
|
|
182
186
|
return substitutionPresent;
|
|
@@ -220,9 +224,9 @@ export default class Substitutions {
|
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
resolve(localContextA, localContextB) {
|
|
223
|
-
const
|
|
224
|
-
resolved =
|
|
225
|
-
const complexSubstitutions = this.
|
|
227
|
+
const metavariableNodes = this.getMetavariableNodes(),
|
|
228
|
+
resolved = metavariableNodes.every((metavariableNode) => {
|
|
229
|
+
const complexSubstitutions = this.findComplexSubstitutionsByMetavariableNode(metavariableNode),
|
|
226
230
|
complexSubstitutionsResolved = complexSubstitutions.everySubstitution((complexSubstitution) => {
|
|
227
231
|
const substitution = complexSubstitution, ///
|
|
228
232
|
substitutions = this, ///
|
|
@@ -252,7 +256,7 @@ export default class Substitutions {
|
|
|
252
256
|
...this.array
|
|
253
257
|
];
|
|
254
258
|
|
|
255
|
-
|
|
259
|
+
leftDifference(array, this.savedArray);
|
|
256
260
|
|
|
257
261
|
array.forEach((substitution) => {
|
|
258
262
|
this.removeSubstitution(substitution, localContext);
|
|
@@ -303,11 +307,15 @@ export default class Substitutions {
|
|
|
303
307
|
}
|
|
304
308
|
}
|
|
305
309
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
310
|
+
Object.assign(shim, {
|
|
311
|
+
Substitutions
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
function leftDifference(arrayA, arrayB) {
|
|
315
|
+
filter(arrayA, (elementA) => {
|
|
316
|
+
const arrayBIncludesElementA = arrayB.includes(elementA);
|
|
309
317
|
|
|
310
|
-
if (!
|
|
318
|
+
if (!arrayBIncludesElementA) {
|
|
311
319
|
return true;
|
|
312
320
|
}
|
|
313
321
|
});
|
package/src/supposition.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
5
|
import SubproofAssertion from "./assertion/subproof";
|
|
6
|
-
import UnqualifiedStatement from "./statement/unqualified";
|
|
7
6
|
|
|
8
7
|
import { nodeQuery } from "./utilities/query";
|
|
9
8
|
import { assignAssignments } from "./utilities/assignments";
|
|
@@ -155,7 +154,8 @@ class Supposition {
|
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
static fromSuppositionNode(suppositionNode, fileContext) {
|
|
158
|
-
const
|
|
157
|
+
const { UnqualifiedStatement } = shim,
|
|
158
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
159
159
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
160
160
|
supposition = new Supposition(fileContext, unqualifiedStatement);
|
|
161
161
|
|
package/src/term.js
CHANGED
|
@@ -213,12 +213,12 @@ class Term {
|
|
|
213
213
|
return verifiedGivenType;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
verifyWhenDeclared(fileContext) {
|
|
217
217
|
let verifiedAtTopLevel;
|
|
218
218
|
|
|
219
219
|
const termString = this.string; ///
|
|
220
220
|
|
|
221
|
-
fileContext.trace(`Verifying the '${termString}' term
|
|
221
|
+
fileContext.trace(`Verifying the '${termString}' term when declared...`);
|
|
222
222
|
|
|
223
223
|
const termNode = this.node, ///
|
|
224
224
|
termVerifiedAsConstructor = termAsConstructorVerifier.verifyTerm(termNode, fileContext);
|
|
@@ -230,7 +230,7 @@ class Term {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
if (verifiedAtTopLevel) {
|
|
233
|
-
fileContext.debug(`...verified the '${termString}' term
|
|
233
|
+
fileContext.debug(`...verified the '${termString}' term when declared.`);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
return verifiedAtTopLevel;
|