occam-verify-cli 0.0.1016 → 0.0.1020
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/argument.js +12 -11
- package/lib/assignment/equality.js +3 -3
- package/lib/axiom.js +102 -6
- package/lib/combinator.js +12 -12
- package/lib/conclusion.js +3 -4
- package/lib/consequent.js +75 -14
- package/lib/constructor/bracketed.js +3 -3
- package/lib/constructor.js +68 -18
- package/lib/context/file.js +49 -89
- package/lib/context/local.js +34 -58
- package/lib/declaration/combinator.js +3 -3
- package/lib/declaration/metavariable.js +15 -4
- package/lib/declaration/type.js +3 -3
- package/lib/declaration/variable.js +146 -0
- package/lib/equality.js +95 -19
- package/lib/index.js +6 -1
- package/lib/label.js +9 -9
- package/lib/lemma.js +107 -6
- package/lib/metavariable.js +14 -21
- package/lib/mixins/statement/qualified/unify.js +3 -3
- package/lib/mixins/statement/verify.js +4 -5
- package/lib/mixins/term/unify.js +82 -0
- package/lib/mixins/term/verify.js +44 -0
- package/lib/node/term/constructor/bracketed.js +15 -11
- package/lib/premise.js +3 -5
- package/lib/proofStep.js +2 -2
- package/lib/reference.js +9 -9
- package/lib/rule.js +5 -5
- package/lib/ruleNames.js +5 -5
- package/lib/statement/qualified.js +6 -3
- package/lib/statement.js +22 -39
- package/lib/supposition.js +75 -50
- package/lib/term.js +62 -16
- package/lib/topLevelAssertion.js +98 -33
- package/lib/type.js +22 -31
- package/lib/unifier/equality.js +12 -4
- package/lib/unifier/intrinsicLevel.js +1 -4
- package/lib/unifier/metaLevel.js +1 -4
- package/lib/unifier/metavariable.js +10 -7
- package/lib/unifier/statementWithCombinator.js +18 -9
- package/lib/unifier/termWithConstructor.js +11 -4
- package/lib/unify/frameWithMetaType.js +2 -2
- package/lib/utilities/name.js +9 -2
- package/lib/utilities/node.js +14 -14
- package/lib/utilities/tokens.js +7 -7
- package/lib/utilities/unify.js +3 -3
- package/lib/variable.js +155 -20
- package/lib/verifier/statementAsCombinator.js +2 -2
- package/lib/verifier/termAsConstructor.js +2 -2
- package/lib/verifier/topLevel.js +7 -7
- package/lib/verify/assertion/type.js +3 -4
- package/lib/verify/conjecture.js +2 -3
- package/lib/verify/frame.js +2 -6
- package/lib/verify/lemma.js +2 -3
- package/lib/verify/metaLemma.js +2 -3
- package/lib/verify/metatheorem.js +2 -3
- package/lib/verify/metavariableGivenMetaType.js +3 -3
- package/lib/verify/theorem.js +2 -3
- package/package.json +1 -1
- package/src/argument.js +11 -9
- package/src/assignment/equality.js +3 -4
- package/src/axiom.js +78 -1
- package/src/combinator.js +10 -9
- package/src/conclusion.js +2 -4
- package/src/consequent.js +88 -13
- package/src/constructor/bracketed.js +4 -1
- package/src/constructor.js +18 -14
- package/src/context/file.js +50 -93
- package/src/context/local.js +13 -31
- package/src/declaration/combinator.js +2 -2
- package/src/declaration/metavariable.js +20 -6
- package/src/declaration/type.js +2 -2
- package/src/declaration/variable.js +78 -0
- package/src/equality.js +123 -22
- package/src/index.js +6 -0
- package/src/label.js +7 -7
- package/src/lemma.js +91 -1
- package/src/metavariable.js +13 -22
- package/src/mixins/statement/qualified/unify.js +2 -2
- package/src/mixins/statement/verify.js +5 -5
- package/src/mixins/term/unify.js +110 -0
- package/src/mixins/term/verify.js +47 -0
- package/src/node/term/constructor/bracketed.js +4 -3
- package/src/premise.js +2 -5
- package/src/proofStep.js +1 -1
- package/src/reference.js +7 -7
- package/src/rule.js +4 -4
- package/src/ruleNames.js +1 -1
- package/src/statement/qualified.js +7 -3
- package/src/statement.js +28 -60
- package/src/supposition.js +106 -53
- package/src/term.js +70 -14
- package/src/topLevelAssertion.js +120 -33
- package/src/type.js +39 -41
- package/src/unifier/equality.js +15 -3
- package/src/unifier/intrinsicLevel.js +0 -4
- package/src/unifier/metaLevel.js +0 -4
- package/src/unifier/metavariable.js +16 -8
- package/src/unifier/statementWithCombinator.js +33 -11
- package/src/unifier/termWithConstructor.js +17 -4
- package/src/unify/frameWithMetaType.js +1 -1
- package/src/utilities/name.js +9 -1
- package/src/utilities/node.js +14 -14
- package/src/utilities/tokens.js +4 -4
- package/src/utilities/unify.js +2 -2
- package/src/variable.js +158 -22
- package/src/verifier/statementAsCombinator.js +1 -1
- package/src/verifier/termAsConstructor.js +1 -1
- package/src/verifier/topLevel.js +9 -6
- package/src/verify/assertion/type.js +1 -1
- package/src/verify/conjecture.js +1 -1
- package/src/verify/frame.js +1 -7
- package/src/verify/lemma.js +1 -1
- package/src/verify/metaLemma.js +1 -1
- package/src/verify/metatheorem.js +1 -1
- package/src/verify/metavariableGivenMetaType.js +2 -2
- package/src/verify/theorem.js +1 -1
- package/lib/tokens/constructorTerm/bracketed.js +0 -17
- package/lib/unify/termWithBracketedConstructor.js +0 -39
- package/lib/unify/termWithConstructor.js +0 -37
- package/lib/unify/termWithConstructors.js +0 -34
- package/lib/unify/termWithTerm.js +0 -27
- package/lib/unify/termWithType.js +0 -24
- package/lib/verify/axiom.js +0 -45
- package/lib/verify/consequent.js +0 -38
- package/lib/verify/declaration/variable.js +0 -67
- package/lib/verify/equality.js +0 -92
- package/lib/verify/proofStep.js +0 -28
- package/lib/verify/term.js +0 -97
- package/lib/verify/termAsConstructor.js +0 -58
- package/lib/verify/termGivenType.js +0 -34
- package/lib/verify/terms.js +0 -38
- package/lib/verify/type.js +0 -23
- package/lib/verify/variable.js +0 -25
- package/src/tokens/constructorTerm/bracketed.js +0 -10
- package/src/unify/termWithBracketedConstructor.js +0 -39
- package/src/unify/termWithConstructor.js +0 -39
- package/src/unify/termWithConstructors.js +0 -27
- package/src/unify/termWithTerm.js +0 -24
- package/src/unify/termWithType.js +0 -14
- package/src/verify/axiom.js +0 -56
- package/src/verify/consequent.js +0 -40
- package/src/verify/declaration/variable.js +0 -85
- package/src/verify/equality.js +0 -118
- package/src/verify/proofStep.js +0 -21
- package/src/verify/term.js +0 -123
- package/src/verify/termAsConstructor.js +0 -66
- package/src/verify/termGivenType.js +0 -32
- package/src/verify/terms.js +0 -38
- package/src/verify/type.js +0 -19
- package/src/verify/variable.js +0 -21
package/src/equality.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
3
4
|
import equalityUnifier from "./unifier/equality";
|
|
5
|
+
import EqualityAssignment from "./assignment/equality";
|
|
4
6
|
|
|
5
|
-
import {
|
|
7
|
+
import { nodeQuery } from "./utilities/query";
|
|
8
|
+
|
|
9
|
+
const leftTermNodeQuery = nodeQuery("/equality/term[0]"),
|
|
10
|
+
rightTermNodeQuery = nodeQuery("/equality/term[1]");
|
|
6
11
|
|
|
7
12
|
export default class Equality {
|
|
8
|
-
constructor(leftTerm, rightTerm) {
|
|
13
|
+
constructor(string,leftTerm, rightTerm) {
|
|
14
|
+
this.string = string;
|
|
9
15
|
this.leftTerm = leftTerm;
|
|
10
16
|
this.rightTerm = rightTerm;
|
|
11
17
|
}
|
|
12
18
|
|
|
19
|
+
getString() {
|
|
20
|
+
return this.string;
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
getLeftTerm() {
|
|
14
24
|
return this.leftTerm;
|
|
15
25
|
}
|
|
@@ -34,37 +44,128 @@ export default class Equality {
|
|
|
34
44
|
return equal;
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
let
|
|
47
|
+
verify(assignments, stated, localContext) {
|
|
48
|
+
let verified;
|
|
39
49
|
|
|
40
|
-
const
|
|
41
|
-
secondTerm = second(terms),
|
|
42
|
-
leftTerm = firstTerm, ///
|
|
43
|
-
rightTerm = secondTerm, ///
|
|
44
|
-
leftTermType = leftTerm.getType(),
|
|
45
|
-
rightTermType = rightTerm.getType(),
|
|
46
|
-
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
50
|
+
const equalityString = this.string; ///
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
const node = equalityNode; ///
|
|
52
|
+
localContext.trace(`Verifying the '${equalityString}' equality...`);
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
if (stated) {
|
|
55
|
+
const verifiedWhenStated = this.verifyWhenStated(localContext);
|
|
56
|
+
|
|
57
|
+
verified = verifiedWhenStated; ///
|
|
58
|
+
} else {
|
|
59
|
+
const verifiedWhenDerived = this.verifyWhenDerived(localContext);
|
|
60
|
+
|
|
61
|
+
verified = verifiedWhenDerived; ///
|
|
52
62
|
}
|
|
53
63
|
|
|
54
|
-
|
|
64
|
+
if (verified) {
|
|
65
|
+
if (assignments !== null) {
|
|
66
|
+
const equality = this, //
|
|
67
|
+
equalityAssignment = EqualityAssignment.fromEquality(equality),
|
|
68
|
+
assignment = equalityAssignment; ///
|
|
69
|
+
|
|
70
|
+
assignments.push(assignment);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
verified = true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (verified) {
|
|
77
|
+
localContext.debug(`...verified the '${equalityString}' equality.`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return verified;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
verifyTerms(localContext) {
|
|
84
|
+
let termsVerified;
|
|
85
|
+
|
|
86
|
+
const equalityString = this.string; ///
|
|
87
|
+
|
|
88
|
+
localContext.trace(`Verifying the '${equalityString}' equality's terms...`);
|
|
89
|
+
|
|
90
|
+
const leftTermVerified = this.leftTerm.verify(localContext, () => {
|
|
91
|
+
let verifiedAhead;
|
|
92
|
+
|
|
93
|
+
const rightTermVerified = this.rightTerm.verify(localContext, () => {
|
|
94
|
+
let verifiedAhead;
|
|
95
|
+
|
|
96
|
+
const leftTermType = this.leftTerm.getType(),
|
|
97
|
+
rightTermType = this.rightTerm.getType(),
|
|
98
|
+
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
99
|
+
|
|
100
|
+
verifiedAhead = leftTermTypeComparableToRightTermType; ///
|
|
101
|
+
|
|
102
|
+
return verifiedAhead;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
verifiedAhead = rightTermVerified; ///
|
|
106
|
+
|
|
107
|
+
return verifiedAhead;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
termsVerified = leftTermVerified; ///
|
|
111
|
+
|
|
112
|
+
if (termsVerified) {
|
|
113
|
+
localContext.debug(`...verified the '${equalityString}' equality's terms.`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return termsVerified;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
verifyWhenStated(localContext) {
|
|
120
|
+
let verifiedWhenStated;
|
|
121
|
+
|
|
122
|
+
const equalityString = this.string; ///
|
|
123
|
+
|
|
124
|
+
localContext.trace(`Verifying the '${equalityString}' equality when stated...`);
|
|
125
|
+
|
|
126
|
+
const termsVerified = this.verifyTerms(localContext);
|
|
127
|
+
|
|
128
|
+
verifiedWhenStated = termsVerified; ///
|
|
129
|
+
|
|
130
|
+
if (verifiedWhenStated) {
|
|
131
|
+
localContext.debug(`...verified the '${equalityString}' equality when stated.`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return verifiedWhenStated;
|
|
55
135
|
}
|
|
56
136
|
|
|
57
|
-
|
|
58
|
-
let
|
|
137
|
+
verifyWhenDerived(localContext) {
|
|
138
|
+
let verifiedWhenDerived = false;
|
|
139
|
+
|
|
140
|
+
const equalityString = this.string; ///
|
|
141
|
+
|
|
142
|
+
localContext.trace(`Verifying the '${equalityString}' equality when derived...`);
|
|
143
|
+
|
|
144
|
+
const termsVerified = this.verifyTerms(localContext);
|
|
59
145
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
leftTermTypeComparableToRightTermType = leftTermType.isComparableTo(rightTermType);
|
|
146
|
+
if (termsVerified) {
|
|
147
|
+
const equal = this.isEqual(localContext);
|
|
63
148
|
|
|
64
|
-
|
|
65
|
-
equality = new Equality(leftTerm, rightTerm);
|
|
149
|
+
verifiedWhenDerived = equal; ///
|
|
66
150
|
}
|
|
67
151
|
|
|
152
|
+
if (verifiedWhenDerived) {
|
|
153
|
+
localContext.debug(`...verified the '${equalityString}' equality when derived.`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return verifiedWhenDerived;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static fromEqualityNode(equalityNode, localContext) {
|
|
160
|
+
const { Term } = shim,
|
|
161
|
+
leftTermNode = leftTermNodeQuery(equalityNode),
|
|
162
|
+
rightTermNode = rightTermNodeQuery(equalityNode),
|
|
163
|
+
leftTerm = Term.fromTermNode(leftTermNode, localContext),
|
|
164
|
+
rightTerm = Term.fromTermNode(rightTermNode, localContext),
|
|
165
|
+
node = equalityNode, ///
|
|
166
|
+
string = localContext.nodeAsString(node),
|
|
167
|
+
equality = new Equality(string, leftTerm, rightTerm);
|
|
168
|
+
|
|
68
169
|
return equality;
|
|
69
170
|
}
|
|
70
171
|
}
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Type from "./type";
|
|
4
|
+
import Term from "./term";
|
|
5
|
+
import MetaType from "./metaType";
|
|
6
|
+
import Statement from "./statement";
|
|
7
|
+
import ProofStep from "./proofStep";
|
|
8
|
+
|
|
3
9
|
export { default as Log } from "./log";
|
|
4
10
|
export { default as verifyRelease } from "./verify/release";
|
|
5
11
|
export { default as ReleaseContext } from "./context/release";
|
package/src/label.js
CHANGED
|
@@ -19,12 +19,12 @@ export default class Label {
|
|
|
19
19
|
|
|
20
20
|
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
let
|
|
22
|
+
verifyAtTopLevel(fileContext) {
|
|
23
|
+
let verifiedAtTopLevel = false;
|
|
24
24
|
|
|
25
25
|
const labelString = this.getString(); ///
|
|
26
26
|
|
|
27
|
-
fileContext.trace(`Verifying the '${labelString}' label...`);
|
|
27
|
+
fileContext.trace(`Verifying the '${labelString}' label at top level...`);
|
|
28
28
|
|
|
29
29
|
const metavariableNode = this.metavariable.getNode(),
|
|
30
30
|
labelPresent = fileContext.isLabelPresentByMetavariableNode(metavariableNode);
|
|
@@ -32,14 +32,14 @@ export default class Label {
|
|
|
32
32
|
if (labelPresent) {
|
|
33
33
|
fileContext.debug(`The '${labelString}' label is already present.`);
|
|
34
34
|
} else {
|
|
35
|
-
|
|
35
|
+
verifiedAtTopLevel = true;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (
|
|
39
|
-
fileContext.debug(`...verified the '${labelString}' label.`);
|
|
38
|
+
if (verifiedAtTopLevel) {
|
|
39
|
+
fileContext.debug(`...verified the '${labelString}' label at top level.`);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
return
|
|
42
|
+
return verifiedAtTopLevel;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
toJSON() {
|
package/src/lemma.js
CHANGED
|
@@ -1,7 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Label from "./label";
|
|
4
|
+
import Proof from "./proof";
|
|
5
|
+
import Consequent from "./consequent";
|
|
6
|
+
import Supposition from "./supposition";
|
|
7
|
+
import LocalContext from "./context/local";
|
|
8
|
+
import Substitutions from "./substitutions";
|
|
3
9
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
4
10
|
|
|
11
|
+
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
12
|
+
import { labelsStringFromLabels } from "./topLevelAssertion";
|
|
13
|
+
|
|
14
|
+
const proofNodeQuery = nodeQuery("/lemma/proof"),
|
|
15
|
+
labelNodesQuery = nodesQuery("/lemma/label"),
|
|
16
|
+
consequentNodeQuery = nodeQuery("/lemma/consequent"),
|
|
17
|
+
suppositionNodesQuery = nodesQuery("/lemma/supposition");
|
|
18
|
+
|
|
5
19
|
export default class Lemma extends TopLevelAssertion {
|
|
6
|
-
|
|
20
|
+
verify() {
|
|
21
|
+
let verified = false;
|
|
22
|
+
|
|
23
|
+
const labelsString = labelsStringFromLabels(this.labels);
|
|
24
|
+
|
|
25
|
+
(labelsString === null) ?
|
|
26
|
+
this.fileContext.trace(`Verifying a lemma...`) :
|
|
27
|
+
this.fileContext.trace(`Verifying the '${labelsString}' lemma...`);
|
|
28
|
+
|
|
29
|
+
const labelsVerifiedAtTopLevel = this.labels.every((label) => {
|
|
30
|
+
const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
|
|
31
|
+
|
|
32
|
+
if (labelVVerifiedAtTopLevel) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (labelsVerifiedAtTopLevel) {
|
|
38
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
39
|
+
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
40
|
+
const suppositionVerified = supposition.verify(localContext);
|
|
41
|
+
|
|
42
|
+
if (suppositionVerified) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (suppositionsVerified) {
|
|
48
|
+
const consequentVerified = this.consequent.verify(localContext);
|
|
49
|
+
|
|
50
|
+
if (consequentVerified) {
|
|
51
|
+
const substitutions = Substitutions.fromNothing(),
|
|
52
|
+
proofVerified = this.proof.verify(substitutions, this.consequent, localContext);
|
|
53
|
+
|
|
54
|
+
if (proofVerified) {
|
|
55
|
+
const lemma = this; ///
|
|
56
|
+
|
|
57
|
+
this.fileContext.addLemma(lemma);
|
|
58
|
+
|
|
59
|
+
verified = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (verified) {
|
|
66
|
+
(labelsString === null) ?
|
|
67
|
+
this.fileContext.debug(`...verified a lemma.`) :
|
|
68
|
+
this.fileContext.debug(`...verified the '${labelsString}' lemma.`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return verified;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Lemma, json, fileContext); }
|
|
75
|
+
|
|
76
|
+
static fromLemmaNode(lemmaNode, fileContext) {
|
|
77
|
+
const proofNode = proofNodeQuery(lemmaNode),
|
|
78
|
+
labelNodes = labelNodesQuery(lemmaNode),
|
|
79
|
+
consequentNode = consequentNodeQuery(lemmaNode),
|
|
80
|
+
suppositionNodes = suppositionNodesQuery(lemmaNode),
|
|
81
|
+
labels = labelNodes.map((labelNode) => {
|
|
82
|
+
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
83
|
+
|
|
84
|
+
return label;
|
|
85
|
+
}),
|
|
86
|
+
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
87
|
+
const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
|
|
88
|
+
|
|
89
|
+
return supposition;
|
|
90
|
+
}),
|
|
91
|
+
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
92
|
+
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
93
|
+
lemma = new Lemma(fileContext, labels, suppositions, consequent, proof);
|
|
94
|
+
|
|
95
|
+
return lemma;
|
|
96
|
+
}
|
|
7
97
|
}
|
package/src/metavariable.js
CHANGED
|
@@ -54,31 +54,32 @@ export default class Metavariable {
|
|
|
54
54
|
return metavariableNodeMatches;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
verify(
|
|
57
|
+
verify(localContext) {
|
|
58
58
|
let verified = false;
|
|
59
59
|
|
|
60
60
|
const metavariableString = this.string; ///
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
localContext.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
63
63
|
|
|
64
64
|
debugger
|
|
65
65
|
|
|
66
66
|
if (verified) {
|
|
67
|
-
|
|
67
|
+
localContext.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
return verified;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
let
|
|
73
|
+
verifyAtTopLevel(fileContext) {
|
|
74
|
+
let verifiedAtTopLevel = false;
|
|
75
75
|
|
|
76
76
|
const metavariableString = this.string; ///
|
|
77
77
|
|
|
78
|
-
fileContext.trace(`Verifying the '${metavariableString}' metavariable
|
|
78
|
+
fileContext.trace(`Verifying the '${metavariableString}' metavariable at top level...`);
|
|
79
79
|
|
|
80
80
|
const metavariableNode = this.node, ///
|
|
81
|
-
|
|
81
|
+
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
82
|
+
metavariablePresent = fileContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
82
83
|
|
|
83
84
|
if (metavariablePresent) {
|
|
84
85
|
fileContext.debug(`The metavariable '${metavariableString}' is already present.`);
|
|
@@ -87,21 +88,21 @@ export default class Metavariable {
|
|
|
87
88
|
argument = Argument.fromArgumentNode(argumentNode, fileContext);
|
|
88
89
|
|
|
89
90
|
if (argument === null) {
|
|
90
|
-
|
|
91
|
+
verifiedAtTopLevel = true;
|
|
91
92
|
} else {
|
|
92
93
|
const argumentVerified = argument.verify(fileContext);
|
|
93
94
|
|
|
94
95
|
if (argumentVerified) {
|
|
95
|
-
|
|
96
|
+
verifiedAtTopLevel = true;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
if (
|
|
101
|
-
fileContext.debug(`...verified the '${metavariableString}' metavariable
|
|
101
|
+
if (verifiedAtTopLevel) {
|
|
102
|
+
fileContext.debug(`...verified the '${metavariableString}' metavariable at top level.`);
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
return
|
|
105
|
+
return verifiedAtTopLevel;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
toJSON() {
|
|
@@ -152,16 +153,6 @@ export default class Metavariable {
|
|
|
152
153
|
return metavariable;
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
static fromMetavariableNodeAndMetaType(metavariableNode, metaType, fileContext) {
|
|
156
|
-
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
157
|
-
node = metavariableNode, ///
|
|
158
|
-
name = metavariableName, ///
|
|
159
|
-
string = fileContext.nodeAsString(node),
|
|
160
|
-
metavariable = new Metavariable(string, node, name, metaType);
|
|
161
|
-
|
|
162
|
-
return metavariable;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
156
|
static fromMetavariableDeclarationNode(metavariableDeclarationNode, fileContext) {
|
|
166
157
|
const metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
|
|
167
158
|
metavariableNode = metavariableNodeQuery(metavariableDeclarationNode),
|
|
@@ -150,9 +150,9 @@ function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
|
|
|
150
150
|
referenceMetavariableNode = reference.getMetavariableNode(),
|
|
151
151
|
metavariableNodeA = referenceMetavariableNode, ///
|
|
152
152
|
metavariableNodeB = metavariableNode, ///
|
|
153
|
-
|
|
153
|
+
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
154
154
|
|
|
155
|
-
if (
|
|
155
|
+
if (metavariableUnified) {
|
|
156
156
|
const statementNode = statement.getNode(),
|
|
157
157
|
metavariableNode = metavariableNodeA, ///
|
|
158
158
|
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeAndMetavariableNode(statementNode, metavariableNode, localContextA, localContextB),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Equality from "../../equality";
|
|
4
|
+
|
|
3
5
|
import verifyFrame from "../../verify/frame";
|
|
4
|
-
import verifyEquality from "../../verify/equality";
|
|
5
6
|
import verifyJudgement from "../../verify/judgement";
|
|
6
7
|
import verifyDeclaration from "../../verify/declaration";
|
|
7
8
|
import verifyTypeAssertion from "../../verify/assertion/type";
|
|
@@ -57,7 +58,8 @@ function verifyAsEquality(statement, assignments, stated, localContext) {
|
|
|
57
58
|
|
|
58
59
|
localContext.trace(`Verifying the '${statementString}' statement as an equality...`);
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const equality = Equality.fromEqualityNode(equalityNode, localContext),
|
|
62
|
+
equalityVerified = equality.verify(assignments, stated, localContext);
|
|
61
63
|
|
|
62
64
|
verifiedAsEquality = equalityVerified; ///
|
|
63
65
|
|
|
@@ -261,9 +263,7 @@ function unifyMetavariable(metavariableNode, localContext) {
|
|
|
261
263
|
|
|
262
264
|
const metavariableNodeB = metavariableNode; ///
|
|
263
265
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
metavariableUnified = unified; ///
|
|
266
|
+
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
if (metavariableUnified) {
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import shim from "../../shim";
|
|
4
|
+
import BracketedConstructor from "../../constructor/bracketed";
|
|
5
|
+
import termWithConstructorUnifier from "../../unifier/termWithConstructor";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "../../utilities/query";
|
|
8
|
+
|
|
9
|
+
const termNodeQuery = nodeQuery("/term/argument/term");
|
|
10
|
+
|
|
11
|
+
function unifyTermWithBracketedConstructor(term, localContext, verifyAhead) {
|
|
12
|
+
let termUnifiedWithBracketedConstructor;
|
|
13
|
+
|
|
14
|
+
const termString = term.getString();
|
|
15
|
+
|
|
16
|
+
localContext.trace(`Unifying the '${termString}' term with the bracketed constructor...`, term);
|
|
17
|
+
|
|
18
|
+
const bracketedConstructor = BracketedConstructor.fromNothing();
|
|
19
|
+
|
|
20
|
+
termUnifiedWithBracketedConstructor = unifyTermWithConstructor(term, bracketedConstructor, localContext, () => {
|
|
21
|
+
let verifiedAhead = false;
|
|
22
|
+
|
|
23
|
+
const bracketedTerm = term, ///
|
|
24
|
+
bracketedTermNode = bracketedTerm.getNode(),
|
|
25
|
+
termNode = termNodeQuery(bracketedTermNode); ///
|
|
26
|
+
|
|
27
|
+
if (termNode !== null) {
|
|
28
|
+
const { Term } = shim;
|
|
29
|
+
|
|
30
|
+
term = Term.fromTermNode(termNode, localContext);
|
|
31
|
+
|
|
32
|
+
const termVVerified = term.verify(localContext, () => {
|
|
33
|
+
let verifiedAhead;
|
|
34
|
+
|
|
35
|
+
const type = term.getType();
|
|
36
|
+
|
|
37
|
+
bracketedTerm.setType(type);
|
|
38
|
+
|
|
39
|
+
verifiedAhead = verifyAhead();
|
|
40
|
+
|
|
41
|
+
return verifiedAhead;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
verifiedAhead = termVVerified; ///
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return verifiedAhead;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (termUnifiedWithBracketedConstructor) {
|
|
51
|
+
localContext.debug(`...unified the '${termString}' term with the bracketed constructor.`, term);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return termUnifiedWithBracketedConstructor;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function unifyTermWithConstructors(term, localContext, verifyAhead) {
|
|
58
|
+
let termUnifiedWithConstructors = false;
|
|
59
|
+
|
|
60
|
+
const constructors = localContext.getConstructors();
|
|
61
|
+
|
|
62
|
+
termUnifiedWithConstructors = constructors.some((constructor) => {
|
|
63
|
+
const termUnifiedWithConstructor = unifyTermWithConstructor(term, constructor, localContext, verifyAhead);
|
|
64
|
+
|
|
65
|
+
if (termUnifiedWithConstructor) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return termUnifiedWithConstructors;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const unifyMixins = [
|
|
74
|
+
unifyTermWithBracketedConstructor,
|
|
75
|
+
unifyTermWithConstructors
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
export default unifyMixins;
|
|
79
|
+
|
|
80
|
+
function unifyTermWithConstructor(term, constructor, localContext, verifyAhead) {
|
|
81
|
+
let termUnifiedWithConstructor = false;
|
|
82
|
+
|
|
83
|
+
const termString = term.getString(),
|
|
84
|
+
constructorString = constructor.getString();
|
|
85
|
+
|
|
86
|
+
localContext.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`, term);
|
|
87
|
+
|
|
88
|
+
const termNode = term.getNode(),
|
|
89
|
+
constructorTerm = constructor.getTerm(),
|
|
90
|
+
constructorTermNode = constructorTerm.getNode(),
|
|
91
|
+
unified = termWithConstructorUnifier.unify(termNode, constructorTermNode, localContext);
|
|
92
|
+
|
|
93
|
+
if (unified) {
|
|
94
|
+
let verifiedAhead;
|
|
95
|
+
|
|
96
|
+
const type = constructor.getType();
|
|
97
|
+
|
|
98
|
+
term.setType(type);
|
|
99
|
+
|
|
100
|
+
verifiedAhead = verifyAhead();
|
|
101
|
+
|
|
102
|
+
termUnifiedWithConstructor = verifiedAhead; ///
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (termUnifiedWithConstructor) {
|
|
106
|
+
localContext.debug(`...unified the '${termString}' term with the '${constructorString}' constructor.`, term);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return termUnifiedWithConstructor;
|
|
110
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Variable from "../../variable";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "../../utilities/query";
|
|
6
|
+
|
|
7
|
+
const variableNodeQuery = nodeQuery("/term/variable");
|
|
8
|
+
|
|
9
|
+
function verifyTermAsVariable(term, localContext, verifyAhead) {
|
|
10
|
+
let termVerifiedAsVariable = false;
|
|
11
|
+
|
|
12
|
+
const termNode = term.getNode(),
|
|
13
|
+
variableNode = variableNodeQuery(termNode);
|
|
14
|
+
|
|
15
|
+
if (variableNode !== null) {
|
|
16
|
+
const termString = localContext.nodeAsString(termNode);
|
|
17
|
+
|
|
18
|
+
localContext.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
19
|
+
|
|
20
|
+
const variable = Variable.fromVariableNode(variableNode, localContext),
|
|
21
|
+
variableVerified = variable.verify(localContext);
|
|
22
|
+
|
|
23
|
+
if (variableVerified) {
|
|
24
|
+
let verifiedAhead;
|
|
25
|
+
|
|
26
|
+
const type = variable.getType();
|
|
27
|
+
|
|
28
|
+
term.setType(type);
|
|
29
|
+
|
|
30
|
+
verifiedAhead = verifyAhead();
|
|
31
|
+
|
|
32
|
+
termVerifiedAsVariable = verifiedAhead; ///
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (termVerifiedAsVariable) {
|
|
36
|
+
localContext.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return termVerifiedAsVariable;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const verifyMixins = [
|
|
44
|
+
verifyTermAsVariable
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
export default verifyMixins;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { OBJECT_TYPE_NAME } from "../../../typeNames";
|
|
4
|
+
import { termNodeFromTermString } from "../../../utilities/node";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
export const bracketedConstructorTermString = `(${OBJECT_TYPE_NAME})`;
|
|
6
7
|
|
|
7
|
-
const bracketedConstructorTermNode =
|
|
8
|
+
const bracketedConstructorTermNode = termNodeFromTermString(bracketedConstructorTermString)
|
|
8
9
|
|
|
9
10
|
export default bracketedConstructorTermNode;
|
package/src/premise.js
CHANGED
|
@@ -6,10 +6,8 @@ import metaLevelUnifier from "./unifier/metaLevel";
|
|
|
6
6
|
import SubproofAssertion from "./assertion/subproof";
|
|
7
7
|
import UnqualifiedStatement from "./statement/unqualified";
|
|
8
8
|
|
|
9
|
-
import { trim } from "./utilities/string";
|
|
10
9
|
import { nodeQuery } from "./utilities/query";
|
|
11
10
|
import { assignAssignments } from "./utilities/assignments";
|
|
12
|
-
import { unqualifiedStatementNodeFromUnqualifiedStatementString } from "./utilities/node";
|
|
13
11
|
|
|
14
12
|
const unqualifiedStatementNodeQuery = nodeQuery("/premise/unqualifiedStatement");
|
|
15
13
|
|
|
@@ -108,10 +106,9 @@ export default class Premise {
|
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
verify(localContext) {
|
|
111
|
-
let verified = false
|
|
112
|
-
premiseString = this.getString(); ///
|
|
109
|
+
let verified = false;
|
|
113
110
|
|
|
114
|
-
premiseString =
|
|
111
|
+
const premiseString = this.getString(); ///
|
|
115
112
|
|
|
116
113
|
if (this.unqualifiedStatement !== null) {
|
|
117
114
|
localContext.trace(`Verifying the '${premiseString}' premise...`);
|
package/src/proofStep.js
CHANGED
|
@@ -73,7 +73,7 @@ class ProofStep {
|
|
|
73
73
|
} else if (this.unqualifiedStatement !== null) {
|
|
74
74
|
const stated = true,
|
|
75
75
|
assignments = [],
|
|
76
|
-
unqualifiedStatementVerified = this.unqualifiedStatement.verify(
|
|
76
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
77
77
|
|
|
78
78
|
verified = unqualifiedStatementVerified; ///
|
|
79
79
|
}
|