occam-verify-cli 0.0.1074 → 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/assertion/type.js +4 -5
- 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 -102
- package/lib/context/local.js +21 -20
- 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 +10 -9
- package/lib/derivation.js +6 -2
- package/lib/equality.js +6 -2
- 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 +22 -27
- package/lib/mixins/statement/qualified/unify.js +2 -2
- package/lib/mixins/statement/unify.js +2 -2
- package/lib/mixins/statement/verify.js +20 -54
- package/lib/mixins/term/verify.js +3 -3
- package/lib/premise.js +24 -21
- package/lib/proof.js +8 -4
- package/lib/proofStep.js +62 -28
- package/lib/reference.js +3 -3
- package/lib/rule.js +17 -24
- package/lib/statement/qualified.js +8 -4
- package/lib/statement.js +5 -5
- package/lib/subDerivation.js +6 -2
- package/lib/subproof.js +10 -7
- package/lib/substitution/statementForMetavariable.js +36 -27
- package/lib/substitution.js +13 -13
- package/lib/substitutions.js +73 -49
- package/lib/supposition.js +30 -23
- package/lib/term.js +5 -5
- package/lib/theorem.js +10 -15
- package/lib/topLevelAssertion.js +12 -6
- package/lib/type.js +5 -5
- 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/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 +6 -6
- package/lib/verifier/statementAsCombinator.js +4 -11
- package/lib/verifier/termAsConstructor.js +4 -4
- package/lib/verifier/topLevel.js +9 -15
- 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/assertion/type.js +2 -2
- 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 -84
- package/src/context/local.js +15 -17
- 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 +12 -9
- package/src/derivation.js +7 -1
- package/src/equality.js +7 -1
- 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 +23 -42
- package/src/mixins/statement/qualified/unify.js +1 -2
- package/src/mixins/statement/unify.js +2 -2
- package/src/mixins/statement/verify.js +35 -88
- package/src/mixins/term/verify.js +3 -2
- package/src/premise.js +41 -33
- package/src/proof.js +10 -3
- package/src/proofStep.js +91 -32
- package/src/reference.js +3 -2
- package/src/rule.js +17 -24
- package/src/statement/qualified.js +9 -5
- package/src/statement.js +3 -3
- package/src/subDerivation.js +8 -2
- package/src/subproof.js +12 -5
- package/src/substitution/statementForMetavariable.js +45 -30
- package/src/substitution.js +9 -9
- package/src/substitutions.js +75 -45
- package/src/supposition.js +50 -35
- package/src/term.js +3 -3
- package/src/theorem.js +8 -11
- package/src/topLevelAssertion.js +16 -7
- package/src/type.js +3 -3
- 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/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 +4 -4
- package/src/verifier/statementAsCombinator.js +4 -18
- package/src/verifier/termAsConstructor.js +4 -4
- 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/lib/verifier/metaLevel.js +0 -147
- 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
- package/src/verifier/metaLevel.js +0 -54
package/src/proofStep.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
3
5
|
import shim from "./shim";
|
|
4
|
-
import
|
|
5
|
-
import Substitutions from "./substitutions";
|
|
6
|
-
import QualifiedStatement from "./statement/qualified";
|
|
7
|
-
import UnqualifiedStatement from "./statement/unqualified";
|
|
6
|
+
import metaLevelUnifier from "./unifier/metaLevel";
|
|
8
7
|
|
|
9
8
|
import { nodeQuery } from "./utilities/query";
|
|
10
9
|
import { assignAssignments } from "./utilities/assignments";
|
|
11
10
|
|
|
11
|
+
const { match } = arrayUtilities;
|
|
12
|
+
|
|
12
13
|
const subproofNodeQuery = nodeQuery("/proofStep|lastProofStep/subproof"),
|
|
13
14
|
qualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/qualifiedStatement"),
|
|
14
15
|
unqualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/unqualifiedStatement");
|
|
@@ -49,55 +50,112 @@ class ProofStep {
|
|
|
49
50
|
unifyStatement(statement, localContext) {
|
|
50
51
|
let statementUnified = false;
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
if ((this.qualifiedStatement !== null) || (this.unqualifiedStatement !== null !== null)) {
|
|
54
|
+
const statementString = statement.getString();
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
const localContextA = localContext, ///
|
|
56
|
-
localContextB = localContext; ///
|
|
56
|
+
localContext.trace(`Unifying the '${statementString}' statement...`);
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const { Substitutions } = shim,
|
|
59
|
+
localContextA = localContext, ///
|
|
60
|
+
localContextB = localContext, ///
|
|
61
|
+
substitutions = Substitutions.fromNothing();
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
if (this.qualifiedStatement !== null) {
|
|
64
|
+
statementUnified = this.qualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
65
|
+
}
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
if (this.unqualifiedStatement !== null) {
|
|
68
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
69
|
+
}
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
const substitutionsLength = substitutions.getLength();
|
|
69
72
|
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
if (substitutionsLength > 0) {
|
|
74
|
+
statementUnified = false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (statementUnified) {
|
|
78
|
+
localContext.debug(`...unified the '${statementString}' statement.`);
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
return statementUnified;
|
|
75
83
|
}
|
|
76
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
|
+
|
|
77
129
|
verify(substitutions, localContext) {
|
|
78
130
|
let verified = false;
|
|
79
131
|
|
|
132
|
+
let stated = false;
|
|
133
|
+
|
|
134
|
+
const assignments = [];
|
|
135
|
+
|
|
136
|
+
let subproofVerified = false,
|
|
137
|
+
qualifiedStatementVerified = false,
|
|
138
|
+
unqualifiedStatementVerified = false;
|
|
139
|
+
|
|
80
140
|
if (false) {
|
|
81
141
|
///
|
|
82
142
|
} else if (this.subproof !== null) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
verified = subproofVerified; ///
|
|
143
|
+
subproofVerified = this.subproof.verify(substitutions, localContext);
|
|
86
144
|
} else if (this.qualifiedStatement !== null) {
|
|
87
|
-
|
|
145
|
+
stated = true;
|
|
88
146
|
|
|
89
|
-
|
|
147
|
+
qualifiedStatementVerified = this.qualifiedStatement.verify(substitutions, assignments, stated, localContext);
|
|
90
148
|
} else if (this.unqualifiedStatement !== null) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
149
|
+
stated = false;
|
|
150
|
+
|
|
151
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
152
|
+
}
|
|
94
153
|
|
|
95
|
-
|
|
96
|
-
|
|
154
|
+
if (subproofVerified || qualifiedStatementVerified || unqualifiedStatementVerified) {
|
|
155
|
+
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
97
156
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
157
|
+
if (assignmentsAssigned) {
|
|
158
|
+
verified = true;
|
|
101
159
|
}
|
|
102
160
|
}
|
|
103
161
|
|
|
@@ -111,7 +169,8 @@ class ProofStep {
|
|
|
111
169
|
}
|
|
112
170
|
|
|
113
171
|
static fromProofStepNode(proofStepNode, fileContext) {
|
|
114
|
-
const
|
|
172
|
+
const { Subproof, QualifiedStatement, UnqualifiedStatement } = shim,
|
|
173
|
+
subproofNode = subproofNodeQuery(proofStepNode),
|
|
115
174
|
qualifiedStatementNode = qualifiedStatementNodeQuery(proofStepNode),
|
|
116
175
|
unqualifiedStatementNode = unqualifiedStatementNodeQuery(proofStepNode),
|
|
117
176
|
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";
|
|
@@ -73,23 +68,19 @@ class Rule {
|
|
|
73
68
|
}
|
|
74
69
|
|
|
75
70
|
unifyStatement(statement, localContext) {
|
|
76
|
-
let statementUnified
|
|
71
|
+
let statementUnified;
|
|
77
72
|
|
|
78
|
-
const
|
|
79
|
-
substitutions = Substitutions.fromNothing()
|
|
80
|
-
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
73
|
+
const { Substitutions } = shim,
|
|
74
|
+
substitutions = Substitutions.fromNothing();
|
|
81
75
|
|
|
82
|
-
|
|
83
|
-
const statementUnifiedWithConclusion = this.conclusion.unifyStatement(statement, substitutions, localContext); ///
|
|
76
|
+
statementUnified = this.conclusion.unifyStatement(statement, substitutions, localContext); ///
|
|
84
77
|
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
if (statementUnified) {
|
|
79
|
+
const proofSteps = localContext.getProofSteps(),
|
|
80
|
+
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
87
81
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const localContextA = localContext; ///
|
|
91
|
-
|
|
92
|
-
const substitutionsResolved = substitutions.resolve(localContextA, localContextB);
|
|
82
|
+
if (proofStepsUnified) {
|
|
83
|
+
const substitutionsResolved = substitutions.areResolved();
|
|
93
84
|
|
|
94
85
|
statementUnified = substitutionsResolved; ///
|
|
95
86
|
}
|
|
@@ -125,15 +116,15 @@ class Rule {
|
|
|
125
116
|
|
|
126
117
|
this.fileContext.trace(`Verifying the '${ruleString}' rule...`);
|
|
127
118
|
|
|
128
|
-
const
|
|
129
|
-
const
|
|
119
|
+
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
120
|
+
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
130
121
|
|
|
131
|
-
if (
|
|
122
|
+
if (labelVVerifiedWhenDeclared) {
|
|
132
123
|
return true;
|
|
133
124
|
}
|
|
134
125
|
});
|
|
135
126
|
|
|
136
|
-
if (
|
|
127
|
+
if (labelsVerifiedWhenDeclared) {
|
|
137
128
|
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
138
129
|
premisesVerified = this.premises.every((premise) => {
|
|
139
130
|
const premiseVerified = premise.verify(localContext);
|
|
@@ -150,7 +141,8 @@ class Rule {
|
|
|
150
141
|
let proofVerified = true; ///
|
|
151
142
|
|
|
152
143
|
if (this.proof !== null) {
|
|
153
|
-
const
|
|
144
|
+
const { Substitutions } = shim,
|
|
145
|
+
substitutions = Substitutions.fromNothing();
|
|
154
146
|
|
|
155
147
|
proofVerified = this.proof.verify(substitutions, this.conclusion, localContext);
|
|
156
148
|
}
|
|
@@ -204,7 +196,8 @@ class Rule {
|
|
|
204
196
|
}
|
|
205
197
|
|
|
206
198
|
static fromRuleNode(ruleNode, fileContext) {
|
|
207
|
-
const
|
|
199
|
+
const { Label, Proof, Premise, Conclusion } = shim,
|
|
200
|
+
proofNode = proofNodeQuery(ruleNode),
|
|
208
201
|
labelNodes = labelNodesQuery(ruleNode),
|
|
209
202
|
premiseNodes = premiseNodesQuery(ruleNode),
|
|
210
203
|
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;
|
|
@@ -71,7 +71,7 @@ export default class QualifiedStatement {
|
|
|
71
71
|
return statementUnified;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
verify(substitutions, localContext) {
|
|
74
|
+
verify(substitutions, assignments, stated, localContext) {
|
|
75
75
|
let verified;
|
|
76
76
|
|
|
77
77
|
const qualifiedStatementString = this.string; ///
|
|
@@ -79,9 +79,7 @@ export default class QualifiedStatement {
|
|
|
79
79
|
if (this.statement !== null) {
|
|
80
80
|
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement...`);
|
|
81
81
|
|
|
82
|
-
const
|
|
83
|
-
assignments = [],
|
|
84
|
-
statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
82
|
+
const statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
85
83
|
|
|
86
84
|
if (statementVerified) {
|
|
87
85
|
const unified = this.unify(substitutions, localContext);
|
|
@@ -127,3 +125,9 @@ export default class QualifiedStatement {
|
|
|
127
125
|
return qualifiedStatement;
|
|
128
126
|
}
|
|
129
127
|
}
|
|
128
|
+
|
|
129
|
+
Object.assign(shim, {
|
|
130
|
+
QualifiedStatement
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
export default QualifiedStatement;
|
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,21 +3,25 @@
|
|
|
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";
|
|
10
9
|
import { statementFromJSON, statementToStatementJSON, metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
|
|
11
10
|
|
|
12
11
|
export default class StatementForMetavariableSubstitution extends Substitution {
|
|
13
|
-
constructor(string, statement, metavariable, substitution) {
|
|
12
|
+
constructor(string, resolved, statement, metavariable, substitution) {
|
|
14
13
|
super(string);
|
|
15
14
|
|
|
15
|
+
this.resolved = resolved;
|
|
16
16
|
this.statement = statement;
|
|
17
17
|
this.metavariable = metavariable;
|
|
18
18
|
this.substitution = substitution;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
isResolved() {
|
|
22
|
+
return this.resolved;
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
getStatement() {
|
|
22
26
|
return this.statement;
|
|
23
27
|
}
|
|
@@ -30,10 +34,10 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
30
34
|
return this.substitution;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
const
|
|
37
|
+
getMetavariableNode() {
|
|
38
|
+
const metavariableNode = this.metavariable.getNode();
|
|
35
39
|
|
|
36
|
-
return
|
|
40
|
+
return metavariableNode;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
isSimple() {
|
|
@@ -43,27 +47,23 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
resolve(substitutions, localContextA, localContextB) {
|
|
46
|
-
let resolved = false;
|
|
47
|
-
|
|
48
50
|
const substitutionString = this.string;
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const metavariableName = this.getMetavariableName(),
|
|
53
|
-
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableName(metavariableName);
|
|
52
|
+
const metavariableNode = this.getMetavariableNode(),
|
|
53
|
+
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode);
|
|
54
54
|
|
|
55
55
|
if (simpleSubstitution !== null) {
|
|
56
|
+
localContextB.trace(`Resolving the ${substitutionString} substitution...`);
|
|
57
|
+
|
|
56
58
|
const substitution = simpleSubstitution, ///
|
|
57
59
|
substitutionResolved = substitution.resolveSubstitution(this.substitution, this.statement, substitutions, localContextA, localContextB);
|
|
58
60
|
|
|
59
|
-
resolved = substitutionResolved; ///
|
|
60
|
-
}
|
|
61
|
+
this.resolved = substitutionResolved; ///
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
if (this.resolved) {
|
|
64
|
+
localContextB.debug(`...resolved the ${substitutionString} substitution.`);
|
|
65
|
+
}
|
|
64
66
|
}
|
|
65
|
-
|
|
66
|
-
return resolved;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
resolveSubstitution(substitution, statement, substitutions, localContextA, localContextB) {
|
|
@@ -83,10 +83,21 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
83
83
|
|
|
84
84
|
substitutions.snapshot();
|
|
85
85
|
|
|
86
|
-
const
|
|
87
|
-
|
|
86
|
+
const substitutionNodeA = substitutionA.getSubstitutionNode(), ///
|
|
87
|
+
substitutionNodeB = substitutionB.getSubstitutionNode(), ///
|
|
88
|
+
substitutionStringA = localContextA.nodeAsString(substitutionNodeA),
|
|
89
|
+
substitutionStringB = localContextB.nodeAsString(substitutionNodeB);
|
|
90
|
+
|
|
91
|
+
localContextB.trace(`Unifying the '${substitutionStringB}' substitution with the '${substitutionStringA}' substitution...`);
|
|
92
|
+
|
|
93
|
+
const nodeA = substitutionNodeA, ///
|
|
94
|
+
nodeB = substitutionNodeB, ///
|
|
88
95
|
unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
89
96
|
|
|
97
|
+
if (unifiedAtMetaLevel) {
|
|
98
|
+
localContextB.trace(`...unified the '${substitutionStringB}' substitution with the '${substitutionStringA}' substitution.`);
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
unifiedAtMetaLevel ?
|
|
91
102
|
substitutions.continue() :
|
|
92
103
|
substitutions.rollback(localContextB);
|
|
@@ -104,7 +115,8 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
104
115
|
unifyStatement(statement, localContextA, localContextB) {
|
|
105
116
|
let substitution = null;
|
|
106
117
|
|
|
107
|
-
const
|
|
118
|
+
const { Substitutions } = shim,
|
|
119
|
+
substitutions = Substitutions.fromNothing(),
|
|
108
120
|
statementUnified = this.statement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
109
121
|
|
|
110
122
|
if (statementUnified) {
|
|
@@ -128,7 +140,7 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
128
140
|
return statementNodeMatches;
|
|
129
141
|
}
|
|
130
142
|
|
|
131
|
-
|
|
143
|
+
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
132
144
|
|
|
133
145
|
matchSubstitutionNode(substitutionNode) {
|
|
134
146
|
let substitutionNodeMatches;
|
|
@@ -146,12 +158,12 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
146
158
|
return substitutionNodeMatches;
|
|
147
159
|
}
|
|
148
160
|
|
|
149
|
-
|
|
150
|
-
const
|
|
161
|
+
matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
162
|
+
const metavariableNodeMatches = this.matchMetavariableNode(metavariableNode),
|
|
151
163
|
substitutionNodeMatches = this.matchSubstitutionNode(substitutionNode),
|
|
152
|
-
|
|
164
|
+
metavariableNodeAndSubstitutionNodeMatches = (metavariableNodeMatches && substitutionNodeMatches);
|
|
153
165
|
|
|
154
|
-
return
|
|
166
|
+
return metavariableNodeAndSubstitutionNodeMatches;
|
|
155
167
|
}
|
|
156
168
|
|
|
157
169
|
toJSON() {
|
|
@@ -171,10 +183,11 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
171
183
|
|
|
172
184
|
static fromJSON(json, fileContext) {
|
|
173
185
|
const { string } = json,
|
|
186
|
+
resolved = true,
|
|
174
187
|
statement = statementFromJSON(json, fileContext),
|
|
175
188
|
metavariable = metavariableFromJSON(json, fileContext),
|
|
176
189
|
substitution = null, ///
|
|
177
|
-
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(string, statement, metavariable, substitution);
|
|
190
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(string, resolved, statement, metavariable, substitution);
|
|
178
191
|
|
|
179
192
|
return statementForMetavariableSubstitution;
|
|
180
193
|
}
|
|
@@ -188,9 +201,10 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
188
201
|
|
|
189
202
|
statement = Statement.fromStatementNode(statementNode, localContext);
|
|
190
203
|
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
204
|
+
const string = stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext),
|
|
205
|
+
resolved = true,
|
|
206
|
+
substitution = null,
|
|
207
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(string, resolved, statement, metavariable, substitution);
|
|
194
208
|
|
|
195
209
|
return statementForMetavariableSubstitution;
|
|
196
210
|
}
|
|
@@ -205,7 +219,8 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
205
219
|
statement = Statement.fromStatementNode(statementNode, localContext);
|
|
206
220
|
|
|
207
221
|
const string = stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext),
|
|
208
|
-
|
|
222
|
+
resolved = false,
|
|
223
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(string, resolved, statement, metavariable, substitution);
|
|
209
224
|
|
|
210
225
|
return statementForMetavariableSubstitution;
|
|
211
226
|
}
|
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) {
|