occam-verify-cli 0.0.960 → 0.0.961
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/context/local.js +3 -9
- package/lib/proofStep.js +8 -5
- package/lib/substitution/termForVariable.js +24 -25
- package/lib/unifier/statementWithCombinator.js +6 -6
- package/lib/unify/statementAtainstStatement.js +16 -16
- package/lib/unify/statementWithBracketedCombinator.js +30 -0
- package/lib/unify/statementWithCombinators.js +40 -0
- package/lib/unify/statementWithMetaType.js +6 -30
- package/lib/unify/termWithBracketedConstructor.js +37 -0
- package/lib/unify/termWithConstructors.js +53 -0
- package/lib/unify/termWithType.js +4 -12
- package/lib/utilities/assignments.js +9 -12
- package/lib/verifier/intrinsicLevel.js +140 -0
- package/lib/verifier/metaLevel.js +11 -20
- package/lib/verifier/statementAsCombinator.js +9 -9
- package/lib/verifier/termAsConstructor.js +5 -5
- package/lib/verify/assertion/contained.js +2 -3
- package/lib/verify/assertion/defined.js +2 -4
- package/lib/verify/assertion/subproof.js +20 -18
- package/lib/verify/assertion/type.js +1 -2
- package/lib/verify/declaration.js +27 -9
- package/lib/verify/frame.js +25 -6
- package/lib/verify/premise.js +3 -3
- package/lib/verify/proofStep.js +23 -30
- package/lib/verify/statement/qualified.js +93 -137
- package/lib/verify/statement/unqualified.js +18 -104
- package/lib/verify/statement.js +95 -76
- package/lib/verify/statementAsCombinator.js +2 -2
- package/lib/verify/statementGivenMetaType.js +41 -0
- package/lib/verify/supposition.js +3 -3
- package/lib/verify/term.js +36 -64
- package/lib/verify/termAsConstructor.js +2 -2
- package/lib/verify/termGivenType.js +34 -0
- package/package.json +1 -1
- package/src/context/local.js +4 -13
- package/src/proofStep.js +10 -5
- package/src/substitution/termForVariable.js +33 -30
- package/src/unifier/statementWithCombinator.js +5 -5
- package/src/unify/statementAtainstStatement.js +13 -13
- package/src/unify/statementWithBracketedCombinator.js +22 -0
- package/src/unify/statementWithCombinators.js +38 -0
- package/src/unify/statementWithMetaType.js +6 -42
- package/src/unify/termWithBracketedConstructor.js +36 -0
- package/src/unify/termWithConstructors.js +63 -0
- package/src/unify/termWithType.js +4 -20
- package/src/utilities/assignments.js +6 -13
- package/src/verifier/intrinsicLevel.js +42 -0
- package/src/verifier/metaLevel.js +13 -21
- package/src/verifier/statementAsCombinator.js +11 -7
- package/src/verifier/termAsConstructor.js +4 -3
- package/src/verify/assertion/contained.js +1 -3
- package/src/verify/assertion/defined.js +1 -4
- package/src/verify/assertion/subproof.js +22 -18
- package/src/verify/assertion/type.js +0 -1
- package/src/verify/declaration.js +34 -11
- package/src/verify/frame.js +32 -5
- package/src/verify/premise.js +3 -3
- package/src/verify/proofStep.js +26 -38
- package/src/verify/statement/qualified.js +104 -184
- package/src/verify/statement/unqualified.js +19 -149
- package/src/verify/statement.js +126 -72
- package/src/verify/statementAsCombinator.js +1 -1
- package/src/verify/statementGivenMetaType.js +37 -0
- package/src/verify/supposition.js +3 -3
- package/src/verify/term.js +38 -93
- package/src/verify/termAsConstructor.js +1 -1
- package/src/verify/termGivenType.js +32 -0
package/src/verify/term.js
CHANGED
|
@@ -2,34 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Term from "../term";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import unifyTermWithConstructors from "../unify/termWithConstructors";
|
|
6
|
+
import unifyTermWithBracketedConstructor from "../unify/termWithBracketedConstructor";
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "../utilities/query";
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
11
|
+
|
|
12
|
+
const unifyTermFunctions = [
|
|
13
|
+
unifyTermWithBracketedConstructor,
|
|
14
|
+
unifyTermWithConstructors,
|
|
15
|
+
];
|
|
12
16
|
|
|
13
17
|
function verifyTerm(termNode, terms, localContext, verifyAhead) {
|
|
14
|
-
let termVerified;
|
|
18
|
+
let termVerified = false;
|
|
15
19
|
|
|
16
20
|
const termString = localContext.nodeAsString(termNode);
|
|
17
21
|
|
|
18
22
|
localContext.trace(`Verifying the '${termString}' term...`, termNode);
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
verifyTermAsVariable,
|
|
22
|
-
unifyTermWithConstructors,
|
|
23
|
-
unifyTermWithBracketedConstructor
|
|
24
|
-
];
|
|
24
|
+
if (!termVerified) {
|
|
25
|
+
const termVerifiedAsVariable = verifyTermAsVariable(termNode, terms, localContext, verifyAhead);
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
termVerified = termVerifiedAsVariable; ///
|
|
28
|
+
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
if (!termVerified) {
|
|
31
|
+
const termUnified = unifyTermFunctions.some((unifyTermFunction) => {
|
|
32
|
+
const termUnified = unifyTermFunction(termNode, terms, localContext, verifyAhead);
|
|
33
|
+
|
|
34
|
+
if (termUnified) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
termVerified = termUnified; ///
|
|
40
|
+
}
|
|
33
41
|
|
|
34
42
|
if (termVerified) {
|
|
35
43
|
localContext.debug(`...verified the '${termString}' term.`, termNode);
|
|
@@ -54,9 +62,9 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
|
|
|
54
62
|
|
|
55
63
|
localContext.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
56
64
|
|
|
57
|
-
const
|
|
65
|
+
const variableVerified = verifyVariable(variableNode, localContext);
|
|
58
66
|
|
|
59
|
-
if (
|
|
67
|
+
if (variableVerified) {
|
|
60
68
|
let verifiedAhead;
|
|
61
69
|
|
|
62
70
|
const type = variable.getType(),
|
|
@@ -79,87 +87,24 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
|
|
|
79
87
|
return termVerifiedAsVariable;
|
|
80
88
|
}
|
|
81
89
|
|
|
82
|
-
function
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
const variableNode = variableNodeQuery(termNode);
|
|
86
|
-
|
|
87
|
-
if (variableNode === null) {
|
|
88
|
-
const constructors = localContext.getConstructors();
|
|
89
|
-
|
|
90
|
-
termUnifiedWithConstructors = constructors.some((constructor) => {
|
|
91
|
-
const termUnifiedWithConstructor = unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead);
|
|
92
|
-
|
|
93
|
-
if (termUnifiedWithConstructor) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return termUnifiedWithConstructors;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function unifyTermWithBracketedConstructor(termNode, terms, localContext, verifyAhead) {
|
|
103
|
-
let termUnifiedWithBracketedConstructor;
|
|
104
|
-
|
|
105
|
-
const termString = localContext.nodeAsString(termNode),
|
|
106
|
-
bracketedTerms = [];
|
|
107
|
-
|
|
108
|
-
localContext.trace(`Unifying the '${termString}' term with the bracketed constructor...`, termNode);
|
|
109
|
-
|
|
110
|
-
termUnifiedWithBracketedConstructor = unifyTermWithConstructor(termNode, bracketedTerms, bracketedConstructor, localContext, () => {
|
|
111
|
-
let verifiedAhead;
|
|
112
|
-
|
|
113
|
-
const bracketedTermNode = termNode; ///
|
|
114
|
-
|
|
115
|
-
termNode = termNodeQuery(bracketedTermNode); ///
|
|
116
|
-
|
|
117
|
-
const termVVerified = verifyTerm(termNode, terms, localContext, verifyAhead);
|
|
118
|
-
|
|
119
|
-
verifiedAhead = termVVerified; ///
|
|
120
|
-
|
|
121
|
-
return verifiedAhead;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
if (termUnifiedWithBracketedConstructor) {
|
|
125
|
-
localContext.debug(`...unified the '${termString}' term with the bracketed constructor.`, termNode);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return termUnifiedWithBracketedConstructor;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead) {
|
|
132
|
-
let termUnifiedWithConstructor = false;
|
|
133
|
-
|
|
134
|
-
const termString = localContext.nodeAsString(termNode),
|
|
135
|
-
constructorString = constructor.getString(),
|
|
136
|
-
constructorTermNode = constructor.getTermNode();
|
|
90
|
+
function verifyVariable(variableNode, localContext) {
|
|
91
|
+
let variableVerified = false;
|
|
137
92
|
|
|
138
|
-
localContext.
|
|
93
|
+
const variableString = localContext.nodeAsString(variableNode);
|
|
139
94
|
|
|
140
|
-
|
|
141
|
-
constructorTermNodeB = constructorTermNode, ///
|
|
142
|
-
unified = termWithConstructorUnifier.unify(termNodeA, constructorTermNodeB, localContext);
|
|
95
|
+
localContext.trace(`Verifying the '${variableString}' variable...`, variableNode);
|
|
143
96
|
|
|
144
|
-
|
|
145
|
-
let verifiedAhead;
|
|
97
|
+
const variablePresent = localContext.isVariablePresentByVariableNode(variableNode);
|
|
146
98
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
verifiedAhead = verifyAhead();
|
|
153
|
-
|
|
154
|
-
terms.pop();
|
|
155
|
-
|
|
156
|
-
termUnifiedWithConstructor = verifiedAhead; ///
|
|
99
|
+
if (!variablePresent) {
|
|
100
|
+
localContext.trace(`The '${variableString}' variable is not present.`, variableNode);
|
|
101
|
+
} else {
|
|
102
|
+
variableVerified = true;
|
|
157
103
|
}
|
|
158
104
|
|
|
159
|
-
if (
|
|
160
|
-
localContext.debug(`...
|
|
105
|
+
if (variableVerified) {
|
|
106
|
+
localContext.debug(`...verified the '${variableString}' variable.`, variableNode);
|
|
161
107
|
}
|
|
162
108
|
|
|
163
|
-
return
|
|
109
|
+
return variableVerified;
|
|
164
110
|
}
|
|
165
|
-
|
|
@@ -22,7 +22,7 @@ export default function verifyTermAsConstructor(termNode, typeNode, fileContext)
|
|
|
22
22
|
|
|
23
23
|
type = firstType; ///
|
|
24
24
|
|
|
25
|
-
termVerifiedAsConstructor = termAsConstructorVerifier.
|
|
25
|
+
termVerifiedAsConstructor = termAsConstructorVerifier.verifyTerm(termNode, fileContext);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (termVerifiedAsConstructor) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import shim from "../shim";
|
|
4
|
+
|
|
5
|
+
import { first } from "../utilities/array";
|
|
6
|
+
|
|
7
|
+
export default function verifyTermGivenType(termNode, type, localContext) {
|
|
8
|
+
let termVerifiedGivenType = false;
|
|
9
|
+
|
|
10
|
+
if (type !== null) {
|
|
11
|
+
const { verifyTerm } = shim,
|
|
12
|
+
terms = [],
|
|
13
|
+
termVerified = verifyTerm(termNode, terms, localContext, () => {
|
|
14
|
+
let verifiedAhead = false;
|
|
15
|
+
|
|
16
|
+
const firstTerm = first(terms),
|
|
17
|
+
term = firstTerm, ///
|
|
18
|
+
termType = term.getType(),
|
|
19
|
+
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
20
|
+
|
|
21
|
+
if (termTypeEqualToOrSubTypeOfType) {
|
|
22
|
+
verifiedAhead = true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return verifiedAhead;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
termVerifiedGivenType = termVerified; ///
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return termVerifiedGivenType;
|
|
32
|
+
}
|