occam-verify-cli 0.0.700 → 0.0.702
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/assignment/equality.js +2 -2
- package/lib/assignment/metavariable.js +2 -2
- package/lib/assignment/variable.js +2 -2
- package/lib/collection.js +44 -6
- package/lib/conclusion.js +6 -6
- package/lib/consequent.js +4 -4
- package/lib/context/file.js +9 -2
- package/lib/context/local.js +27 -64
- package/lib/context/localMeta.js +8 -1
- package/lib/equality.js +20 -4
- package/lib/premise.js +9 -9
- package/lib/supposition.js +4 -4
- package/lib/utilities/collection.js +27 -13
- package/lib/verifier/node/statementAsCombinator.js +4 -1
- package/lib/verifier/node/termAsConstructor.js +4 -20
- package/lib/verifier/nodes/equality.js +169 -0
- package/lib/verifier/nodes/metastatementForMetavariable.js +6 -7
- package/lib/verifier/nodes/statement.js +12 -4
- package/lib/verifier/nodes/statementForMetavariable.js +6 -7
- package/lib/verifier/nodes/termForVariable.js +19 -20
- package/lib/verify/consequent.js +3 -3
- package/lib/verify/derivation.js +28 -6
- package/lib/verify/equality.js +9 -4
- package/lib/verify/givenType.js +32 -0
- package/lib/verify/metastatement.js +3 -3
- package/lib/verify/statement/qualified.js +135 -37
- package/lib/verify/statement.js +34 -42
- package/lib/verify/supposition.js +13 -8
- package/lib/verify/suppositions.js +2 -11
- package/lib/verify/term.js +25 -59
- package/lib/verify/termAndGivenType.js +39 -0
- package/lib/verify/termAsGivenVariable.js +36 -0
- package/lib/verify/typeAssertion.js +35 -22
- package/package.json +1 -1
- package/src/assignment/equality.js +2 -2
- package/src/assignment/metavariable.js +2 -2
- package/src/assignment/variable.js +2 -2
- package/src/collection.js +55 -5
- package/src/conclusion.js +6 -6
- package/src/consequent.js +4 -4
- package/src/context/file.js +7 -1
- package/src/context/local.js +33 -78
- package/src/context/localMeta.js +6 -0
- package/src/equality.js +23 -2
- package/src/premise.js +10 -10
- package/src/supposition.js +3 -3
- package/src/utilities/collection.js +31 -11
- package/src/verifier/node/statementAsCombinator.js +6 -0
- package/src/verifier/node/termAsConstructor.js +5 -26
- package/src/verifier/nodes/equality.js +47 -0
- package/src/verifier/nodes/metastatementForMetavariable.js +10 -10
- package/src/verifier/nodes/statement.js +1 -1
- package/src/verifier/nodes/statementForMetavariable.js +10 -10
- package/src/verifier/nodes/termForVariable.js +30 -30
- package/src/verify/consequent.js +4 -4
- package/src/verify/derivation.js +37 -8
- package/src/verify/equality.js +12 -3
- package/src/verify/{standaloneType.js → givenType.js} +7 -7
- package/src/verify/metastatement.js +2 -2
- package/src/verify/statement/qualified.js +194 -39
- package/src/verify/statement.js +47 -47
- package/src/verify/supposition.js +15 -8
- package/src/verify/suppositions.js +1 -13
- package/src/verify/term.js +26 -62
- package/src/verify/termAndGivenType.js +37 -0
- package/src/verify/termAsGivenVariable.js +39 -0
- package/src/verify/typeAssertion.js +50 -28
- package/lib/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -114
- package/lib/verifier/nodes/metastatementForMetavariable/premise.js +0 -114
- package/lib/verifier/nodes/statementForMetavariable/conclusion.js +0 -114
- package/lib/verifier/nodes/statementForMetavariable/premise.js +0 -114
- package/lib/verifier/nodes/termForVariable/consequent.js +0 -114
- package/lib/verifier/nodes/termForVariable/supposition.js +0 -114
- package/lib/verify/standaloneType.js +0 -32
- package/lib/verify/termAndStandaloneType.js +0 -39
- package/lib/verify/termAsVariableAndStandaloneType.js +0 -39
- package/src/verifier/nodes/metastatementForMetavariable/conclusion.js +0 -11
- package/src/verifier/nodes/metastatementForMetavariable/premise.js +0 -11
- package/src/verifier/nodes/statementForMetavariable/conclusion.js +0 -11
- package/src/verifier/nodes/statementForMetavariable/premise.js +0 -11
- package/src/verifier/nodes/termForVariable/consequent.js +0 -11
- package/src/verifier/nodes/termForVariable/supposition.js +0 -11
- package/src/verify/termAndStandaloneType.js +0 -37
- package/src/verify/termAsVariableAndStandaloneType.js +0 -38
package/src/verify/statement.js
CHANGED
|
@@ -38,53 +38,32 @@ function verifyStatement(statementNode, assignments, derived, context, verifyAhe
|
|
|
38
38
|
return statementVerified;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
Object.assign(
|
|
42
|
-
|
|
41
|
+
Object.assign(statementNodesVerifier, {
|
|
42
|
+
verifyStatement
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
export default verifyStatement;
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
let combinators = context.getCombinators();
|
|
51
|
-
|
|
52
|
-
combinators = [ ///
|
|
53
|
-
bracketedCombinator,
|
|
54
|
-
...combinators
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
statementVerifiedAgainstCombinators = combinators.some((combinator) => {
|
|
58
|
-
const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead);
|
|
59
|
-
|
|
60
|
-
if (statementVerifiedAgainstCombinator) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
return statementVerifiedAgainstCombinators;
|
|
66
|
-
}
|
|
47
|
+
function verifyStatementAsEquality(statementNode, assignments, derived, context, verifyAhead) {
|
|
48
|
+
let statementVerifiedAsEquality = false;
|
|
67
49
|
|
|
68
|
-
|
|
69
|
-
let statementVerifiedAgainstCombinator;
|
|
50
|
+
const equalityNode = equalityNodeQuery(statementNode);
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
if (equalityNode !== null) {
|
|
53
|
+
const statementString = context.nodeAsString(statementNode);
|
|
73
54
|
|
|
74
|
-
|
|
55
|
+
context.trace(`Verifying the '${statementString}' statement as an equality...`, statementNode);
|
|
75
56
|
|
|
76
|
-
|
|
77
|
-
nonTerminalNodeA = statementNode, ///
|
|
78
|
-
nonTerminalNodeB = combinatorStatementNode, ///
|
|
79
|
-
nonTerminalNodeVerified = statementNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context, verifyAhead);
|
|
57
|
+
const equalityVerified = verifyEquality(equalityNode, assignments, derived, context, verifyAhead);
|
|
80
58
|
|
|
81
|
-
|
|
59
|
+
statementVerifiedAsEquality = equalityVerified; ///
|
|
82
60
|
|
|
83
|
-
|
|
84
|
-
|
|
61
|
+
if (statementVerifiedAsEquality) {
|
|
62
|
+
context.debug(`...verified the '${statementString}' statement as an equality.`, statementNode);
|
|
63
|
+
}
|
|
85
64
|
}
|
|
86
65
|
|
|
87
|
-
return
|
|
66
|
+
return statementVerifiedAsEquality;
|
|
88
67
|
}
|
|
89
68
|
|
|
90
69
|
function verifyStatementAsTypeAssertion(statementNode, assignments, derived, context, verifyAhead) {
|
|
@@ -109,24 +88,45 @@ function verifyStatementAsTypeAssertion(statementNode, assignments, derived, con
|
|
|
109
88
|
return statementVerifiedAsTypeAssertion;
|
|
110
89
|
}
|
|
111
90
|
|
|
112
|
-
function
|
|
113
|
-
let
|
|
91
|
+
function verifyStatementAgainstCombinators(statementNode, assignments, derived, context, verifyAhead) {
|
|
92
|
+
let statementVerifiedAgainstCombinators;
|
|
114
93
|
|
|
115
|
-
|
|
94
|
+
let combinators = context.getCombinators();
|
|
116
95
|
|
|
117
|
-
|
|
118
|
-
|
|
96
|
+
combinators = [ ///
|
|
97
|
+
bracketedCombinator,
|
|
98
|
+
...combinators
|
|
99
|
+
];
|
|
119
100
|
|
|
120
|
-
|
|
101
|
+
statementVerifiedAgainstCombinators = combinators.some((combinator) => {
|
|
102
|
+
const statementVerifiedAgainstCombinator = verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead);
|
|
121
103
|
|
|
122
|
-
|
|
104
|
+
if (statementVerifiedAgainstCombinator) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
123
108
|
|
|
124
|
-
|
|
109
|
+
return statementVerifiedAgainstCombinators;
|
|
110
|
+
}
|
|
125
111
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
function verifyStatementAgainstCombinator(statementNode, combinator, context, verifyAhead) {
|
|
113
|
+
let statementVerifiedAgainstCombinator;
|
|
114
|
+
|
|
115
|
+
const statementString = context.nodeAsString(statementNode),
|
|
116
|
+
combinatorString = combinator.getString();
|
|
117
|
+
|
|
118
|
+
context.trace(`Verifying the '${statementString}' statement against the '${combinatorString}' combinator...`, statementNode);
|
|
119
|
+
|
|
120
|
+
const combinatorStatementNode = combinator.getStatementNode(),
|
|
121
|
+
nonTerminalNodeA = statementNode, ///
|
|
122
|
+
nonTerminalNodeB = combinatorStatementNode, ///
|
|
123
|
+
nonTerminalNodeVerified = statementNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context, verifyAhead);
|
|
124
|
+
|
|
125
|
+
statementVerifiedAgainstCombinator = nonTerminalNodeVerified; ///
|
|
126
|
+
|
|
127
|
+
if (statementVerifiedAgainstCombinator) {
|
|
128
|
+
context.debug(`...verified the '${statementString}' statement against the '${combinatorString}' combinator.`, statementNode);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
return
|
|
131
|
+
return statementVerifiedAgainstCombinator;
|
|
132
132
|
}
|
|
@@ -9,30 +9,37 @@ import { nodeQuery } from "../utilities/query";
|
|
|
9
9
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!"),
|
|
10
10
|
unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement!");
|
|
11
11
|
|
|
12
|
-
export default function verifySupposition(suppositionNode, suppositions,
|
|
13
|
-
let suppositionVerified;
|
|
12
|
+
export default function verifySupposition(suppositionNode, suppositions, localContext) {
|
|
13
|
+
let suppositionVerified = false;
|
|
14
14
|
|
|
15
15
|
const suppositionString = localContext.nodeAsString(suppositionNode);
|
|
16
16
|
|
|
17
17
|
localContext.trace(`Verifying the '${suppositionString}' supposition...`, suppositionNode);
|
|
18
18
|
|
|
19
19
|
const derived = false,
|
|
20
|
+
assignments = [],
|
|
20
21
|
unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
21
22
|
unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, assignments, derived, localContext);
|
|
22
23
|
|
|
23
24
|
if (unqualifiedStatementVerified) {
|
|
25
|
+
suppositionVerified = assignments.every((assignment) => { ///
|
|
26
|
+
const assigned = assignment.assign(localContext);
|
|
27
|
+
|
|
28
|
+
if (assigned) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (suppositionVerified) {
|
|
24
35
|
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
supposition = Supposition.fromStatementNode(statementNode),
|
|
37
|
+
proofStep = ProofStep.fromStatementNode(statementNode);
|
|
27
38
|
|
|
28
39
|
suppositions.push(supposition);
|
|
29
40
|
|
|
30
41
|
localContext.addProofStep(proofStep);
|
|
31
42
|
|
|
32
|
-
suppositionVerified = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (suppositionVerified) {
|
|
36
43
|
localContext.debug(`...verified the '${suppositionString}' supposition.`, suppositionNode);
|
|
37
44
|
}
|
|
38
45
|
|
|
@@ -5,25 +5,13 @@ import verifySupposition from "../verify/supposition";
|
|
|
5
5
|
export default function verifySuppositions(suppositionNodes, suppositions, localContext) {
|
|
6
6
|
let suppositionsVerified;
|
|
7
7
|
|
|
8
|
-
const assignments = [];
|
|
9
|
-
|
|
10
8
|
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
11
|
-
const suppositionVerified = verifySupposition(suppositionNode, suppositions,
|
|
9
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, localContext);
|
|
12
10
|
|
|
13
11
|
if (suppositionVerified) {
|
|
14
12
|
return true;
|
|
15
13
|
}
|
|
16
14
|
});
|
|
17
15
|
|
|
18
|
-
if (suppositionsVerified) {
|
|
19
|
-
suppositionsVerified = assignments.every((assignment) => { ///
|
|
20
|
-
const assigned = assignment.assign(localContext);
|
|
21
|
-
|
|
22
|
-
if (assigned) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
16
|
return suppositionsVerified;
|
|
29
17
|
}
|
package/src/verify/term.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import Term from "../term";
|
|
4
4
|
import termNodesVerifier from "../verifier/nodes/term";
|
|
5
|
+
import verifyTermAsGivenVariable from "../verify/termAsGivenVariable";
|
|
5
6
|
|
|
6
7
|
import { first } from "../utilities/array";
|
|
7
|
-
import { nodeQuery } from "../utilities/query";
|
|
8
|
-
|
|
9
|
-
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
10
8
|
|
|
11
9
|
function verifyTerm(termNode, terms, context, verifyAhead) {
|
|
12
10
|
let termVerified;
|
|
@@ -16,7 +14,7 @@ function verifyTerm(termNode, terms, context, verifyAhead) {
|
|
|
16
14
|
context.trace(`Verifying the '${termString}' term...`, termNode);
|
|
17
15
|
|
|
18
16
|
const verifyTermFunctions = [
|
|
19
|
-
|
|
17
|
+
verifyTermAsVariable,
|
|
20
18
|
verifyTermAgainstConstructors
|
|
21
19
|
];
|
|
22
20
|
|
|
@@ -41,65 +39,15 @@ Object.assign(termNodesVerifier, {
|
|
|
41
39
|
|
|
42
40
|
export default verifyTerm;
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
const constructors = context.getConstructors();
|
|
48
|
-
|
|
49
|
-
termVerifiedAgainstConstructors = constructors.some((constructor) => {
|
|
50
|
-
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead);
|
|
51
|
-
|
|
52
|
-
if (termVerifiedAgainstConstructor) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
return termVerifiedAgainstConstructors;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function verifyTermAsVariable(termNode, variables, context, verifyAhead) {
|
|
61
|
-
let termVerifiedAsVariable = false;
|
|
62
|
-
|
|
63
|
-
const variableNode = variableNodeQuery(termNode);
|
|
64
|
-
|
|
65
|
-
if (variableNode !== null) {
|
|
66
|
-
const termString = context.nodeAsString(termNode);
|
|
67
|
-
|
|
68
|
-
context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
69
|
-
|
|
70
|
-
const variable = context.findVariableByVariableNode(variableNode);
|
|
71
|
-
|
|
72
|
-
if (variable !== null) {
|
|
73
|
-
let verifiedAhead;
|
|
74
|
-
|
|
75
|
-
variables.push(variable);
|
|
76
|
-
|
|
77
|
-
verifiedAhead = verifyAhead();
|
|
78
|
-
|
|
79
|
-
if (!verifiedAhead) {
|
|
80
|
-
variables.pop();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
termVerifiedAsVariable = verifiedAhead; ///
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (termVerifiedAsVariable) {
|
|
87
|
-
context.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return termVerifiedAsVariable;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function verifyTermAsStandaloneVariable(termNode, terms, context, verifyAhead) {
|
|
95
|
-
let termVerifiedAsStandaloneVariable;
|
|
42
|
+
function verifyTermAsVariable(termNode, terms, context, verifyAhead) {
|
|
43
|
+
let termVerifiedAsVariable;
|
|
96
44
|
|
|
97
45
|
const termString = context.nodeAsString(termNode);
|
|
98
46
|
|
|
99
|
-
context.trace(`Verifying the '${termString}' term as a
|
|
47
|
+
context.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
100
48
|
|
|
101
49
|
const variables = [],
|
|
102
|
-
|
|
50
|
+
termVerifiedAsGivenVariable = verifyTermAsGivenVariable(termNode, variables, context, () => {
|
|
103
51
|
let verifiedAhead;
|
|
104
52
|
|
|
105
53
|
const firstVariable = first(variables),
|
|
@@ -118,13 +66,29 @@ function verifyTermAsStandaloneVariable(termNode, terms, context, verifyAhead) {
|
|
|
118
66
|
return verifiedAhead;
|
|
119
67
|
});
|
|
120
68
|
|
|
121
|
-
|
|
69
|
+
termVerifiedAsVariable = termVerifiedAsGivenVariable; ///
|
|
122
70
|
|
|
123
|
-
if (
|
|
124
|
-
context.debug(`...verified the '${termString}' term as a
|
|
71
|
+
if (termVerifiedAsVariable) {
|
|
72
|
+
context.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
125
73
|
}
|
|
126
74
|
|
|
127
|
-
return
|
|
75
|
+
return termVerifiedAsVariable;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function verifyTermAgainstConstructors(termNode, terms, context, verifyAhead) {
|
|
79
|
+
let termVerifiedAgainstConstructors;
|
|
80
|
+
|
|
81
|
+
const constructors = context.getConstructors();
|
|
82
|
+
|
|
83
|
+
termVerifiedAgainstConstructors = constructors.some((constructor) => {
|
|
84
|
+
const termVerifiedAgainstConstructor = verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead);
|
|
85
|
+
|
|
86
|
+
if (termVerifiedAgainstConstructor) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return termVerifiedAgainstConstructors;
|
|
128
92
|
}
|
|
129
93
|
|
|
130
94
|
function verifyTermAgainstConstructor(termNode, terms, constructor, context, verifyAhead) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifyTerm from "../verify/term";
|
|
4
|
+
import verifyGivenType from "../verify/givenType";
|
|
5
|
+
|
|
6
|
+
export default function verifyTermAndGivenType(termNode, typeNode, terms, types, context, verifyAhead) {
|
|
7
|
+
let termAndGivenTypeVerified;
|
|
8
|
+
|
|
9
|
+
const termString = context.nodeAsString(termNode),
|
|
10
|
+
typeString = context.nodeAsString(typeNode);
|
|
11
|
+
|
|
12
|
+
context.trace(`Verifying the '${termString}' term and the given '${typeString}' type...`, termNode);
|
|
13
|
+
|
|
14
|
+
const termVerified = verifyTerm(termNode, terms, context, () => {
|
|
15
|
+
let verifiedAhead;
|
|
16
|
+
|
|
17
|
+
const givenTypeVerified = verifyGivenType(typeNode, types, context, () => {
|
|
18
|
+
let verifiedAhead;
|
|
19
|
+
|
|
20
|
+
verifiedAhead = verifyAhead();
|
|
21
|
+
|
|
22
|
+
return verifiedAhead;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
verifiedAhead = givenTypeVerified; ///
|
|
26
|
+
|
|
27
|
+
return verifiedAhead;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
termAndGivenTypeVerified = termVerified; ///
|
|
31
|
+
|
|
32
|
+
if (termAndGivenTypeVerified) {
|
|
33
|
+
context.debug(`...verified the '${termString}' term and the given '${typeString}' type.`, termNode);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return termAndGivenTypeVerified
|
|
37
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery } from "../utilities/query";
|
|
4
|
+
|
|
5
|
+
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
6
|
+
|
|
7
|
+
export default function verifyTermAsGivenVariable(termNode, variables, context, verifyAhead) {
|
|
8
|
+
let termVerifiedAsVariable = false;
|
|
9
|
+
|
|
10
|
+
const variableNode = variableNodeQuery(termNode);
|
|
11
|
+
|
|
12
|
+
if (variableNode !== null) {
|
|
13
|
+
const termString = context.nodeAsString(termNode);
|
|
14
|
+
|
|
15
|
+
context.trace(`Verifying the '${termString}' term as a given variable...`, termNode);
|
|
16
|
+
|
|
17
|
+
const variable = context.findVariableByVariableNode(variableNode);
|
|
18
|
+
|
|
19
|
+
if (variable !== null) {
|
|
20
|
+
let verifiedAhead;
|
|
21
|
+
|
|
22
|
+
variables.push(variable);
|
|
23
|
+
|
|
24
|
+
verifiedAhead = verifyAhead();
|
|
25
|
+
|
|
26
|
+
if (!verifiedAhead) {
|
|
27
|
+
variables.pop();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
termVerifiedAsVariable = verifiedAhead; ///
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (termVerifiedAsVariable) {
|
|
34
|
+
context.debug(`...verified the '${termString}' term as a given variable.`, termNode);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return termVerifiedAsVariable;
|
|
39
|
+
}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import Variable from "../variable";
|
|
4
4
|
import VariableAssignment from "../assignment/variable";
|
|
5
|
-
import
|
|
6
|
-
import verifyTermAsVariableAndStandaloneType from "../verify/termAsVariableAndStandaloneType";
|
|
5
|
+
import verifyTermAndGivenType from "../verify/termAndGivenType";
|
|
7
6
|
|
|
8
7
|
import { first } from "../utilities/array";
|
|
9
8
|
import { nodeQuery } from "../utilities/query";
|
|
9
|
+
import { verifyTermAsGivenVariable } from "./term";
|
|
10
10
|
|
|
11
11
|
const termNodeQuery = nodeQuery("/typeAssertion/term!"),
|
|
12
|
-
typeNodeQuery = nodeQuery("/typeAssertion/type!")
|
|
12
|
+
typeNodeQuery = nodeQuery("/typeAssertion/type!"),
|
|
13
|
+
variableNodeQuery = nodeQuery("/term/variable!");
|
|
13
14
|
|
|
14
15
|
export default function verifyTypeAssertion(typeAssertionNode, assignments, derived, context, verifyAhead) {
|
|
15
16
|
let typeAssertionVerified;
|
|
@@ -50,28 +51,43 @@ function verifyDerivedTypeAssertion(typeAssertionNode, assignments, derived, con
|
|
|
50
51
|
types = [],
|
|
51
52
|
termNode = termNodeQuery(typeAssertionNode),
|
|
52
53
|
typeNode = typeNodeQuery(typeAssertionNode),
|
|
53
|
-
|
|
54
|
+
termAndGivenTypeVerified = verifyTermAndGivenType(termNode, typeNode, terms, types, context, () => {
|
|
54
55
|
let verifiedAhead = false;
|
|
55
56
|
|
|
56
57
|
const firstTerm = first(terms),
|
|
57
58
|
firstType = first(types),
|
|
58
59
|
term = firstTerm, ///
|
|
59
60
|
type = firstType, ///
|
|
60
|
-
termType =
|
|
61
|
-
|
|
61
|
+
termType = context.getTermType(term),
|
|
62
|
+
typeEqualToOrSuperTypeOfTermType = type.isEqualToOrSuperTypeOf(termType);
|
|
62
63
|
|
|
63
|
-
if (
|
|
64
|
-
|
|
64
|
+
if (typeEqualToOrSuperTypeOfTermType) {
|
|
65
|
+
const variableNode = variableNodeQuery(termNode);
|
|
65
66
|
|
|
66
|
-
if (
|
|
67
|
+
if (variableNode === null) {
|
|
67
68
|
verifiedAhead = verifyAhead();
|
|
69
|
+
} else {
|
|
70
|
+
let variable = context.findVariableByVariableNode(variableNode);
|
|
71
|
+
|
|
72
|
+
variable = Variable.fromVariableAndType(variable, type);
|
|
73
|
+
|
|
74
|
+
const variableAssignment = VariableAssignment.fromVariable(variable),
|
|
75
|
+
assignment = variableAssignment; ///
|
|
76
|
+
|
|
77
|
+
assignments.push(assignment);
|
|
78
|
+
|
|
79
|
+
verifiedAhead = verifyAhead();
|
|
80
|
+
|
|
81
|
+
if (!verifiedAhead) {
|
|
82
|
+
assignments.pop();
|
|
83
|
+
}
|
|
68
84
|
}
|
|
69
85
|
}
|
|
70
86
|
|
|
71
87
|
return verifiedAhead;
|
|
72
88
|
});
|
|
73
89
|
|
|
74
|
-
derivedTypeAssertionVerified =
|
|
90
|
+
derivedTypeAssertionVerified = termAndGivenTypeVerified; ///
|
|
75
91
|
|
|
76
92
|
if (derivedTypeAssertionVerified) {
|
|
77
93
|
context.trace(`...verified the '${typeAssertionString}' derived type assertion.`, typeAssertionNode);
|
|
@@ -89,41 +105,47 @@ function verifyGivenTypeAssertion(typeAssertionNode, assignments, derived, conte
|
|
|
89
105
|
|
|
90
106
|
context.trace(`Verifying the '${typeAssertionString}' given type assertion...`, typeAssertionNode);
|
|
91
107
|
|
|
92
|
-
const
|
|
93
|
-
|
|
108
|
+
const terms = [],
|
|
109
|
+
types = [],
|
|
94
110
|
termNode = termNodeQuery(typeAssertionNode),
|
|
95
111
|
typeNode = typeNodeQuery(typeAssertionNode),
|
|
96
|
-
|
|
112
|
+
termAndGivenTypeVerified = verifyTermAndGivenType(termNode, typeNode, terms, types, context, () => {
|
|
97
113
|
let verifiedAhead = false;
|
|
98
114
|
|
|
99
|
-
const
|
|
115
|
+
const firstTerm = first(terms),
|
|
116
|
+
firstType = first(types),
|
|
117
|
+
term = firstTerm, ///
|
|
118
|
+
type = firstType, ///
|
|
119
|
+
termType = term.getType(),
|
|
120
|
+
typeEqualToOrSubTypeOfTermType = type.isEqualToOrSubTypeOf(termType);
|
|
100
121
|
|
|
101
|
-
|
|
122
|
+
if (typeEqualToOrSubTypeOfTermType) {
|
|
123
|
+
const variableNode = variableNodeQuery(termNode);
|
|
102
124
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
125
|
+
if (variableNode === null) {
|
|
126
|
+
verifiedAhead = verifyAhead();
|
|
127
|
+
} else {
|
|
128
|
+
let variable = context.findVariableByVariableNode(variableNode);
|
|
107
129
|
|
|
108
|
-
|
|
109
|
-
variable = Variable.fromVariableAndType(variable, type); ///
|
|
130
|
+
variable = Variable.fromVariableAndType(variable, type);
|
|
110
131
|
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
const variableAssignment = VariableAssignment.fromVariable(variable),
|
|
133
|
+
assignment = variableAssignment; ///
|
|
113
134
|
|
|
114
|
-
|
|
135
|
+
assignments.push(assignment);
|
|
115
136
|
|
|
116
|
-
|
|
137
|
+
verifiedAhead = verifyAhead();
|
|
117
138
|
|
|
118
|
-
|
|
119
|
-
|
|
139
|
+
if (!verifiedAhead) {
|
|
140
|
+
assignments.pop();
|
|
141
|
+
}
|
|
120
142
|
}
|
|
121
143
|
}
|
|
122
144
|
|
|
123
145
|
return verifiedAhead;
|
|
124
146
|
});
|
|
125
147
|
|
|
126
|
-
givenTypeAssertionVerified =
|
|
148
|
+
givenTypeAssertionVerified = termAndGivenTypeVerified; ///
|
|
127
149
|
|
|
128
150
|
if (givenTypeAssertionVerified) {
|
|
129
151
|
context.trace(`...verified the '${typeAssertionString}' given type assertion.`, typeAssertionNode);
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return _default;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var _metastatementForMetavariable = /*#__PURE__*/ _interop_require_default(require("../../../verifier/nodes/metastatementForMetavariable"));
|
|
12
|
-
function _assert_this_initialized(self) {
|
|
13
|
-
if (self === void 0) {
|
|
14
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
|
-
}
|
|
16
|
-
return self;
|
|
17
|
-
}
|
|
18
|
-
function _class_call_check(instance, Constructor) {
|
|
19
|
-
if (!(instance instanceof Constructor)) {
|
|
20
|
-
throw new TypeError("Cannot call a class as a function");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function _define_property(obj, key, value) {
|
|
24
|
-
if (key in obj) {
|
|
25
|
-
Object.defineProperty(obj, key, {
|
|
26
|
-
value: value,
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
obj[key] = value;
|
|
33
|
-
}
|
|
34
|
-
return obj;
|
|
35
|
-
}
|
|
36
|
-
function _get_prototype_of(o) {
|
|
37
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
38
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
39
|
-
};
|
|
40
|
-
return _get_prototype_of(o);
|
|
41
|
-
}
|
|
42
|
-
function _inherits(subClass, superClass) {
|
|
43
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
44
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
45
|
-
}
|
|
46
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
47
|
-
constructor: {
|
|
48
|
-
value: subClass,
|
|
49
|
-
writable: true,
|
|
50
|
-
configurable: true
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
54
|
-
}
|
|
55
|
-
function _interop_require_default(obj) {
|
|
56
|
-
return obj && obj.__esModule ? obj : {
|
|
57
|
-
default: obj
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function _possible_constructor_return(self, call) {
|
|
61
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
62
|
-
return call;
|
|
63
|
-
}
|
|
64
|
-
return _assert_this_initialized(self);
|
|
65
|
-
}
|
|
66
|
-
function _set_prototype_of(o, p) {
|
|
67
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
68
|
-
o.__proto__ = p;
|
|
69
|
-
return o;
|
|
70
|
-
};
|
|
71
|
-
return _set_prototype_of(o, p);
|
|
72
|
-
}
|
|
73
|
-
function _type_of(obj) {
|
|
74
|
-
"@swc/helpers - typeof";
|
|
75
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
76
|
-
}
|
|
77
|
-
function _is_native_reflect_construct() {
|
|
78
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
79
|
-
if (Reflect.construct.sham) return false;
|
|
80
|
-
if (typeof Proxy === "function") return true;
|
|
81
|
-
try {
|
|
82
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
83
|
-
return true;
|
|
84
|
-
} catch (e) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function _create_super(Derived) {
|
|
89
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
90
|
-
return function _createSuperInternal() {
|
|
91
|
-
var Super = _get_prototype_of(Derived), result;
|
|
92
|
-
if (hasNativeReflectConstruct) {
|
|
93
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
94
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
95
|
-
} else {
|
|
96
|
-
result = Super.apply(this, arguments);
|
|
97
|
-
}
|
|
98
|
-
return _possible_constructor_return(this, result);
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
var ConclusionMetastatementForMetavariableNodesVerifier = /*#__PURE__*/ function(MetastatementForMetavariableNodesVerifier) {
|
|
102
|
-
_inherits(ConclusionMetastatementForMetavariableNodesVerifier, MetastatementForMetavariableNodesVerifier);
|
|
103
|
-
var _super = _create_super(ConclusionMetastatementForMetavariableNodesVerifier);
|
|
104
|
-
function ConclusionMetastatementForMetavariableNodesVerifier() {
|
|
105
|
-
_class_call_check(this, ConclusionMetastatementForMetavariableNodesVerifier);
|
|
106
|
-
return _super.apply(this, arguments);
|
|
107
|
-
}
|
|
108
|
-
return ConclusionMetastatementForMetavariableNodesVerifier;
|
|
109
|
-
}(_metastatementForMetavariable.default);
|
|
110
|
-
_define_property(ConclusionMetastatementForMetavariableNodesVerifier, "createSubstitutions", false);
|
|
111
|
-
var conclusionMetastatementForMetavariableNodesVerifier = new ConclusionMetastatementForMetavariableNodesVerifier();
|
|
112
|
-
var _default = conclusionMetastatementForMetavariableNodesVerifier;
|
|
113
|
-
|
|
114
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy92ZXJpZmllci9ub2Rlcy9tZXRhc3RhdGVtZW50Rm9yTWV0YXZhcmlhYmxlL2NvbmNsdXNpb24uanMiXSwic291cmNlc0NvbnRlbnQiOlsiXCJ1c2Ugc3RyaWN0XCI7XG5cbmltcG9ydCBNZXRhc3RhdGVtZW50Rm9yTWV0YXZhcmlhYmxlTm9kZXNWZXJpZmllciBmcm9tIFwiLi4vLi4vLi4vdmVyaWZpZXIvbm9kZXMvbWV0YXN0YXRlbWVudEZvck1ldGF2YXJpYWJsZVwiO1xuXG5jbGFzcyBDb25jbHVzaW9uTWV0YXN0YXRlbWVudEZvck1ldGF2YXJpYWJsZU5vZGVzVmVyaWZpZXIgZXh0ZW5kcyBNZXRhc3RhdGVtZW50Rm9yTWV0YXZhcmlhYmxlTm9kZXNWZXJpZmllciB7XG4gIHN0YXRpYyBjcmVhdGVTdWJzdGl0dXRpb25zID0gZmFsc2U7XG59XG5cbmNvbnN0IGNvbmNsdXNpb25NZXRhc3RhdGVtZW50Rm9yTWV0YXZhcmlhYmxlTm9kZXNWZXJpZmllciA9IG5ldyBDb25jbHVzaW9uTWV0YXN0YXRlbWVudEZvck1ldGF2YXJpYWJsZU5vZGVzVmVyaWZpZXIoKTtcblxuZXhwb3J0IGRlZmF1bHQgY29uY2x1c2lvbk1ldGFzdGF0ZW1lbnRGb3JNZXRhdmFyaWFibGVOb2Rlc1ZlcmlmaWVyO1xuIl0sIm5hbWVzIjpbIkNvbmNsdXNpb25NZXRhc3RhdGVtZW50Rm9yTWV0YXZhcmlhYmxlTm9kZXNWZXJpZmllciIsIk1ldGFzdGF0ZW1lbnRGb3JNZXRhdmFyaWFibGVOb2Rlc1ZlcmlmaWVyIiwiY3JlYXRlU3Vic3RpdHV0aW9ucyIsImNvbmNsdXNpb25NZXRhc3RhdGVtZW50Rm9yTWV0YXZhcmlhYmxlTm9kZXNWZXJpZmllciJdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7K0JBVUE7OztlQUFBOzs7bUZBUnNEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFFdEQsSUFBQSxBQUFNQSxvRUFBRCxBQUFMO2NBQU1BOytCQUFBQTthQUFBQTtnQ0FBQUE7OztXQUFBQTtFQUE0REMscUNBQXlDO0FBQ3pHLGlCQURJRCxxREFDR0UsdUJBQXNCO0FBRy9CLElBQU1DLHNEQUFzRCxJQUFJSDtJQUVoRSxXQUFlRyJ9
|