occam-verify-cli 0.0.960 → 0.0.962
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 +39 -0
- package/lib/unify/termWithConstructors.js +61 -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 +39 -65
- 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 +39 -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 +44 -93
- package/src/verify/termAsConstructor.js +1 -1
- package/src/verify/termGivenType.js +32 -0
package/src/verify/term.js
CHANGED
|
@@ -2,34 +2,43 @@
|
|
|
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
|
+
import { first } from "../utilities/array";
|
|
8
9
|
import { nodeQuery } from "../utilities/query";
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
|
|
11
|
+
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
12
|
+
|
|
13
|
+
const unifyTermFunctions = [
|
|
14
|
+
unifyTermWithBracketedConstructor,
|
|
15
|
+
unifyTermWithConstructors,
|
|
16
|
+
];
|
|
12
17
|
|
|
13
18
|
function verifyTerm(termNode, terms, localContext, verifyAhead) {
|
|
14
|
-
let termVerified;
|
|
19
|
+
let termVerified = false;
|
|
15
20
|
|
|
16
21
|
const termString = localContext.nodeAsString(termNode);
|
|
17
22
|
|
|
18
23
|
localContext.trace(`Verifying the '${termString}' term...`, termNode);
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
verifyTermAsVariable,
|
|
22
|
-
unifyTermWithConstructors,
|
|
23
|
-
unifyTermWithBracketedConstructor
|
|
24
|
-
];
|
|
25
|
+
if (!termVerified) {
|
|
26
|
+
const termVerifiedAsVariable = verifyTermAsVariable(termNode, terms, localContext, verifyAhead);
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
termVerified = termVerifiedAsVariable; ///
|
|
29
|
+
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if (!termVerified) {
|
|
32
|
+
const termUnified = unifyTermFunctions.some((unifyTermFunction) => {
|
|
33
|
+
const termUnified = unifyTermFunction(termNode, terms, localContext, verifyAhead);
|
|
34
|
+
|
|
35
|
+
if (termUnified) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
termVerified = termUnified; ///
|
|
41
|
+
}
|
|
33
42
|
|
|
34
43
|
if (termVerified) {
|
|
35
44
|
localContext.debug(`...verified the '${termString}' term.`, termNode);
|
|
@@ -54,12 +63,15 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
|
|
|
54
63
|
|
|
55
64
|
localContext.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
56
65
|
|
|
57
|
-
const
|
|
66
|
+
const variables = [],
|
|
67
|
+
variableVerified = verifyVariable(variableNode, variables, localContext);
|
|
58
68
|
|
|
59
|
-
if (
|
|
69
|
+
if (variableVerified) {
|
|
60
70
|
let verifiedAhead;
|
|
61
71
|
|
|
62
|
-
const
|
|
72
|
+
const firstVariable = first(variables),
|
|
73
|
+
variable = firstVariable, ///
|
|
74
|
+
type = variable.getType(),
|
|
63
75
|
term = Term.fromTermNodeAndType(termNode, type);
|
|
64
76
|
|
|
65
77
|
terms.push(term);
|
|
@@ -79,87 +91,26 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
|
|
|
79
91
|
return termVerifiedAsVariable;
|
|
80
92
|
}
|
|
81
93
|
|
|
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
|
-
}
|
|
94
|
+
function verifyVariable(variableNode, variables, localContext) {
|
|
95
|
+
let variableVerified = false;
|
|
101
96
|
|
|
102
|
-
|
|
103
|
-
let termUnifiedWithBracketedConstructor;
|
|
97
|
+
const variableString = localContext.nodeAsString(variableNode);
|
|
104
98
|
|
|
105
|
-
|
|
106
|
-
bracketedTerms = [];
|
|
99
|
+
localContext.trace(`Verifying the '${variableString}' variable...`, variableNode);
|
|
107
100
|
|
|
108
|
-
localContext.
|
|
101
|
+
const variable = localContext.findVariableByVariableNode(variableNode);
|
|
109
102
|
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
if (variable === null) {
|
|
104
|
+
localContext.trace(`The '${variableString}' variable is not present.`, variableNode);
|
|
105
|
+
} else {
|
|
106
|
+
variables.push(variable);
|
|
112
107
|
|
|
113
|
-
|
|
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);
|
|
108
|
+
variableVerified = true;
|
|
126
109
|
}
|
|
127
110
|
|
|
128
|
-
|
|
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();
|
|
137
|
-
|
|
138
|
-
localContext.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`, termNode);
|
|
139
|
-
|
|
140
|
-
const termNodeA = termNode, ///
|
|
141
|
-
constructorTermNodeB = constructorTermNode, ///
|
|
142
|
-
unified = termWithConstructorUnifier.unify(termNodeA, constructorTermNodeB, localContext);
|
|
143
|
-
|
|
144
|
-
if (unified) {
|
|
145
|
-
let verifiedAhead;
|
|
146
|
-
|
|
147
|
-
const type = constructor.getType(),
|
|
148
|
-
term = Term.fromTermNodeAndType(termNode, type);
|
|
149
|
-
|
|
150
|
-
terms.push(term);
|
|
151
|
-
|
|
152
|
-
verifiedAhead = verifyAhead();
|
|
153
|
-
|
|
154
|
-
terms.pop();
|
|
155
|
-
|
|
156
|
-
termUnifiedWithConstructor = verifiedAhead; ///
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (termUnifiedWithConstructor) {
|
|
160
|
-
localContext.debug(`...unified the '${termString}' term with the '${constructorString}' constructor.`, termNode);
|
|
111
|
+
if (variableVerified) {
|
|
112
|
+
localContext.debug(`...verified the '${variableString}' variable.`, variableNode);
|
|
161
113
|
}
|
|
162
114
|
|
|
163
|
-
return
|
|
115
|
+
return variableVerified;
|
|
164
116
|
}
|
|
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
|
+
}
|