occam-verify-cli 0.0.942 → 0.0.944
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/conclusion.js +3 -4
- package/lib/consequent.js +3 -4
- package/lib/constants.js +5 -1
- package/lib/context/file.js +1 -1
- package/lib/context/local.js +15 -5
- package/lib/equality.js +14 -1
- package/lib/metavariable.js +12 -4
- package/lib/premise.js +11 -12
- package/lib/proofStep.js +13 -18
- package/lib/rule.js +5 -38
- package/lib/substitution/statementForMetavariable.js +17 -3
- package/lib/substitution/termForVariable.js +16 -2
- package/lib/substitution.js +14 -1
- package/lib/substitutions.js +28 -10
- package/lib/supposition.js +11 -12
- package/lib/topLevelAssertion.js +5 -38
- package/lib/unifier/equality.js +6 -8
- package/lib/unifier/metaLevel.js +7 -10
- package/lib/unifier/statementAgainstCombinator.js +6 -9
- package/lib/unifier/termAgainstConstructor.js +5 -5
- package/lib/unifier.js +34 -13
- package/lib/unify/conclusionAgainstStatement.js +34 -0
- package/lib/unify/consequentAgainstStatement.js +34 -0
- package/lib/unify/metavariableAgainstStatement.js +23 -15
- package/lib/unify/premiseAgainstProofStep.js +41 -0
- package/lib/unify/premisesAgainstProofSteps.js +31 -0
- package/lib/unify/statementAgainstMetaType.js +5 -9
- package/lib/unify/suppositionAgainstProofStep.js +41 -0
- package/lib/unify/suppositionsAgainstProofSteps.js +31 -0
- package/lib/unify/termAgainstTerm.js +4 -5
- package/lib/unify/termAgainstType.js +7 -7
- package/lib/unify/variableAgainstTerm.js +11 -27
- package/lib/utilities/arguments.js +27 -0
- package/lib/utilities/array.js +5 -2
- package/lib/utilities/unify.js +19 -0
- package/lib/verifier/metaLevel.js +8 -11
- package/lib/verifier/statementAsCombinator.js +13 -22
- package/lib/verifier/topLevel.js +3 -6
- package/lib/verifier.js +28 -8
- package/lib/verify/assertion/type.js +3 -7
- package/lib/verify/declaration/metavariable.js +1 -1
- package/lib/verify/equality.js +12 -25
- package/lib/verify/metavariable.js +26 -63
- package/lib/verify/statement/qualified.js +55 -58
- package/lib/verify/statement/unqualified.js +3 -6
- package/lib/verify/statement.js +36 -34
- package/lib/verify/term.js +26 -32
- package/lib/verify/type.js +4 -7
- package/lib/verify/variable.js +3 -4
- package/package.json +1 -1
- package/src/conclusion.js +2 -6
- package/src/consequent.js +2 -6
- package/src/constants.js +1 -0
- package/src/context/file.js +5 -5
- package/src/context/local.js +20 -9
- package/src/equality.js +22 -0
- package/src/metavariable.js +1 -1
- package/src/premise.js +18 -24
- package/src/proofStep.js +16 -21
- package/src/rule.js +11 -65
- package/src/substitution/statementForMetavariable.js +17 -3
- package/src/substitution/termForVariable.js +17 -1
- package/src/substitution.js +12 -0
- package/src/substitutions.js +41 -7
- package/src/supposition.js +18 -24
- package/src/topLevelAssertion.js +11 -65
- package/src/unifier/equality.js +7 -8
- package/src/unifier/metaLevel.js +6 -10
- package/src/unifier/statementAgainstCombinator.js +9 -9
- package/src/unifier/termAgainstConstructor.js +6 -4
- package/src/unifier.js +35 -11
- package/src/unify/conclusionAgainstStatement.js +34 -0
- package/src/unify/consequentAgainstStatement.js +34 -0
- package/src/unify/metavariableAgainstStatement.js +32 -22
- package/src/unify/premiseAgainstProofStep.js +54 -0
- package/src/unify/premisesAgainstProofSteps.js +23 -0
- package/src/unify/statementAgainstMetaType.js +3 -11
- package/src/unify/suppositionAgainstProofStep.js +54 -0
- package/src/unify/suppositionsAgainstProofSteps.js +23 -0
- package/src/unify/termAgainstTerm.js +3 -7
- package/src/unify/termAgainstType.js +5 -6
- package/src/unify/variableAgainstTerm.js +17 -47
- package/src/utilities/arguments.js +18 -0
- package/src/utilities/array.js +1 -1
- package/src/utilities/unify.js +18 -0
- package/src/verifier/metaLevel.js +7 -11
- package/src/verifier/statementAsCombinator.js +15 -28
- package/src/verifier/topLevel.js +13 -17
- package/src/verifier.js +28 -6
- package/src/verify/assertion/type.js +2 -6
- package/src/verify/declaration/metavariable.js +9 -9
- package/src/verify/equality.js +12 -40
- package/src/verify/metavariable.js +31 -91
- package/src/verify/statement/qualified.js +54 -58
- package/src/verify/statement/unqualified.js +2 -6
- package/src/verify/statement.js +38 -36
- package/src/verify/term.js +25 -31
- package/src/verify/type.js +3 -7
- package/src/verify/variable.js +2 -4
|
@@ -1,116 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import Metavariable from "../metavariable";
|
|
4
|
-
import MetavariableAssignment from "../assignment/metavariable";
|
|
5
|
-
|
|
6
|
-
import { first } from "../utilities/array";
|
|
7
3
|
import { nodeQuery } from "../utilities/query";
|
|
8
4
|
import { nameFromMetavariableNode } from "../utilities/name";
|
|
5
|
+
import { verifyTermAgainstTermType } from "../metavariable";
|
|
9
6
|
|
|
10
|
-
const termNodeQuery = nodeQuery("/argument/term"),
|
|
11
|
-
typeNodeQuery = nodeQuery("/argument/type")
|
|
12
|
-
argumentNodeQuery = nodeQuery("/metavariable/argument!");
|
|
7
|
+
const termNodeQuery = nodeQuery("/metavariable/argument/term"),
|
|
8
|
+
typeNodeQuery = nodeQuery("/metavariable/argument/type");
|
|
13
9
|
|
|
14
|
-
export default function verifyMetavariable(metavariableNode,
|
|
10
|
+
export default function verifyMetavariable(metavariableNode, localContext) {
|
|
15
11
|
let metavariableVerified = false;
|
|
16
12
|
|
|
17
|
-
const metavariableString =
|
|
13
|
+
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
20
16
|
|
|
21
|
-
const
|
|
17
|
+
const name = nameFromMetavariableNode(metavariableNode),
|
|
18
|
+
metavariable = localContext.findMetavariableByName(name);
|
|
22
19
|
|
|
23
|
-
if (
|
|
24
|
-
|
|
20
|
+
if (metavariable === null) {
|
|
21
|
+
localContext.debug(`The metavariable '${metavariableString}' is not present.`, metavariableNode);
|
|
25
22
|
} else {
|
|
26
|
-
const
|
|
27
|
-
metaTypes = [],
|
|
28
|
-
argumentNode = argumentNodeQuery(metavariableNode),
|
|
29
|
-
argumentVerified = verifyArgument(argumentNode, termTypes, fileContext),
|
|
30
|
-
metaTypeVerified = verifyMetaType(metaTypeNode, metaTypes, fileContext);
|
|
31
|
-
|
|
32
|
-
if (argumentVerified && metaTypeVerified) {
|
|
33
|
-
let termType,
|
|
34
|
-
metaType;
|
|
35
|
-
|
|
36
|
-
const firstMetaType = first(metaTypes);
|
|
23
|
+
const typeNode = typeNodeQuery(metavariableNode);
|
|
37
24
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const termTypesLength = termTypes.length;
|
|
25
|
+
if (typeNode !== null) {
|
|
26
|
+
const typeString = localContext.nodeAsString(typeNode);
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
localContext.debug(`The '${typeString}' type was found when a term should be present.`, typeNode);
|
|
29
|
+
} else {
|
|
30
|
+
const termType = metavariable.getTermType(),
|
|
31
|
+
termNode = termNodeQuery(metavariableNode),
|
|
32
|
+
typeString = localContext.nodeAsString(typeNode),
|
|
33
|
+
termString = localContext.nodeAsString(termNode);
|
|
34
|
+
|
|
35
|
+
if (false) {
|
|
36
|
+
///
|
|
37
|
+
} else if ((termType === null) && (termNode === null)) {
|
|
38
|
+
metavariableVerified = true;
|
|
39
|
+
} else if ((termType === null) && (termNode !== null)) {
|
|
40
|
+
localContext.debug(`The '${termString}' term was found when none is expected.`, termNode);
|
|
41
|
+
} else if ((termType !== null) && (termNode === null)) {
|
|
42
|
+
localContext.debug(`No term was found when the metavariable's term type is '${typeString}'.`, termNode);
|
|
44
43
|
} else {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
termType = firstTermType; ///
|
|
48
|
-
}
|
|
44
|
+
const termVerifiedAgainstTermType = verifyTermAgainstTermType(termNode, termType, localContext);
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
name = nameFromMetavariableNode(metavariableNode),
|
|
52
|
-
metavariable = Metavariable.fromNodeNameTermTypeAndMetaType(node, name, termType, metaType),
|
|
53
|
-
metavariableAssignment = MetavariableAssignment.fromMetavariable(metavariable),
|
|
54
|
-
metavariableAssigned = metavariableAssignment.assign(fileContext);
|
|
55
|
-
|
|
56
|
-
if (metavariableAssigned) {
|
|
57
|
-
metavariableVerified = true;
|
|
46
|
+
metavariableVerified = termVerifiedAgainstTermType; ///
|
|
58
47
|
}
|
|
59
48
|
}
|
|
60
49
|
}
|
|
61
50
|
|
|
62
51
|
if (metavariableVerified) {
|
|
63
|
-
|
|
52
|
+
localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
64
53
|
}
|
|
65
54
|
|
|
66
55
|
return metavariableVerified;
|
|
67
56
|
}
|
|
68
|
-
|
|
69
|
-
function verifyArgument(argumentNode, termTypes, fileContext) {
|
|
70
|
-
let argumentVerified = false;
|
|
71
|
-
|
|
72
|
-
if (argumentNode === null) {
|
|
73
|
-
argumentVerified = true;
|
|
74
|
-
} else {
|
|
75
|
-
const termNode = termNodeQuery(argumentNode);
|
|
76
|
-
|
|
77
|
-
if (termNode === null) {
|
|
78
|
-
|
|
79
|
-
} else {
|
|
80
|
-
const termString = fileContext.nodeAsString(termNode);
|
|
81
|
-
|
|
82
|
-
fileContext.debug(`The '${termString}' term was found when a type should have been present.`, termNode);
|
|
83
|
-
}
|
|
84
|
-
const typeNode = typeNodeQuery(argumentNode);
|
|
85
|
-
|
|
86
|
-
if (typeNode !== null) {
|
|
87
|
-
const type = fileContext.findTypeByTypeNode(typeNode);
|
|
88
|
-
|
|
89
|
-
if (type !== null) {
|
|
90
|
-
const termType = type; ///
|
|
91
|
-
|
|
92
|
-
termTypes.push(termType);
|
|
93
|
-
|
|
94
|
-
argumentVerified = true;
|
|
95
|
-
} else {
|
|
96
|
-
const typeString = fileContext.nodeAsString(typeNode);
|
|
97
|
-
|
|
98
|
-
fileContext.debug(`The '${typeString}' type is not present.`, typeNode);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return argumentVerified;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function verifyMetaType(metaTypeNode, metaTypes, fileContext) {
|
|
107
|
-
let metaTypeVerified;
|
|
108
|
-
|
|
109
|
-
const metaType = fileContext.findMetaTypeByMetaTypeNode(metaTypeNode);
|
|
110
|
-
|
|
111
|
-
metaTypes.push(metaType);
|
|
112
|
-
|
|
113
|
-
metaTypeVerified = true;
|
|
114
|
-
|
|
115
|
-
return metaTypeVerified;
|
|
116
|
-
}
|
|
@@ -20,24 +20,24 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, substit
|
|
|
20
20
|
|
|
21
21
|
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement...`, qualifiedStatementNode);
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
const unifyQualifiedStatementFunctions = [
|
|
24
|
+
unifyQualifiedStatementAAgainstRule,
|
|
25
|
+
unifyQualifiedStatementAAgainstAxiom,
|
|
26
|
+
unifyQualifiedStatementAAgainstLemma,
|
|
27
|
+
unifyQualifiedStatementAAgainstTheorem,
|
|
28
|
+
unifyQualifiedStatementAAgainstConjecture,
|
|
29
|
+
unifyQualifiedStatementAAgainstReference
|
|
30
30
|
];
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
const
|
|
32
|
+
const qualifiedStatementUnified = unifyQualifiedStatementFunctions.some((unifyQualifiedStatementFunction) => { ///
|
|
33
|
+
const qualifiedStatementUnified = unifyQualifiedStatementFunction(qualifiedStatementNode, substitutions, localContext);
|
|
34
34
|
|
|
35
|
-
if (
|
|
35
|
+
if (qualifiedStatementUnified) {
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
if (
|
|
40
|
+
if (qualifiedStatementUnified) {
|
|
41
41
|
const derived = false,
|
|
42
42
|
statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
43
43
|
statedStatementVerified = verifyStatedStatement(statementNode, assignments, derived, localContext);
|
|
@@ -52,8 +52,8 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, substit
|
|
|
52
52
|
return qualifiedStatementVerified;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
function
|
|
56
|
-
let
|
|
55
|
+
function unifyQualifiedStatementAAgainstRule(qualifiedStatementNode, substitutions, localContext) {
|
|
56
|
+
let qualifiedStatementUnifiedAgainstRule = false;
|
|
57
57
|
|
|
58
58
|
const metavariableNode = metavariableNodeQuery(qualifiedStatementNode),
|
|
59
59
|
rule = localContext.findRuleByMetavariableNode(metavariableNode);
|
|
@@ -63,22 +63,22 @@ function verifyQualifiedStatementAAgainstRule(qualifiedStatementNode, substituti
|
|
|
63
63
|
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
64
64
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
65
65
|
|
|
66
|
-
localContext.trace(`
|
|
66
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' rule...`, qualifiedStatementNode);
|
|
67
67
|
|
|
68
68
|
const ruleMatchesStatement = rule.unifyStatement(statementNode, localContext);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
qualifiedStatementUnifiedAgainstRule = ruleMatchesStatement; ///
|
|
71
71
|
|
|
72
|
-
if (
|
|
73
|
-
localContext.debug(`...
|
|
72
|
+
if (qualifiedStatementUnifiedAgainstRule) {
|
|
73
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' rule.`, qualifiedStatementNode);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
return
|
|
77
|
+
return qualifiedStatementUnifiedAgainstRule;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function
|
|
81
|
-
let
|
|
80
|
+
function unifyQualifiedStatementAAgainstAxiom(qualifiedStatementNode, substitutions, localContext) {
|
|
81
|
+
let qualifiedStatementUnifiedAgainstAxiom = false;
|
|
82
82
|
|
|
83
83
|
const metavariableNode = metavariableNodeQuery(qualifiedStatementNode),
|
|
84
84
|
axiom = localContext.findAxiomByMetavariableNode(metavariableNode);
|
|
@@ -88,22 +88,22 @@ function verifyQualifiedStatementAAgainstAxiom(qualifiedStatementNode, substitut
|
|
|
88
88
|
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
89
89
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
90
90
|
|
|
91
|
-
localContext.trace(`
|
|
91
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' axiom...`, qualifiedStatementNode);
|
|
92
92
|
|
|
93
93
|
const axiomMatchesStatement = axiom.unifyStatement(statementNode, localContext);
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
qualifiedStatementUnifiedAgainstAxiom = axiomMatchesStatement; ///
|
|
96
96
|
|
|
97
|
-
if (
|
|
98
|
-
localContext.debug(`...
|
|
97
|
+
if (qualifiedStatementUnifiedAgainstAxiom) {
|
|
98
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' axiom.`, qualifiedStatementNode);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
return
|
|
102
|
+
return qualifiedStatementUnifiedAgainstAxiom;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function
|
|
106
|
-
let
|
|
105
|
+
function unifyQualifiedStatementAAgainstLemma(qualifiedStatementNode, substitutions, localContext) {
|
|
106
|
+
let qualifiedStatementUnifiedAgainstLemma = false;
|
|
107
107
|
|
|
108
108
|
const metavariableNode = metavariableNodeQuery(qualifiedStatementNode),
|
|
109
109
|
lemma = localContext.findLemmaByMetavariableNode(metavariableNode);
|
|
@@ -113,22 +113,22 @@ function verifyQualifiedStatementAAgainstLemma(qualifiedStatementNode, substitut
|
|
|
113
113
|
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
114
114
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
115
115
|
|
|
116
|
-
localContext.trace(`
|
|
116
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' lemma...`, qualifiedStatementNode);
|
|
117
117
|
|
|
118
118
|
const lemmaMatchesStatement = lemma.unifyStatement(statementNode, localContext);
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
qualifiedStatementUnifiedAgainstLemma = lemmaMatchesStatement; ///
|
|
121
121
|
|
|
122
|
-
if (
|
|
123
|
-
localContext.debug(`...
|
|
122
|
+
if (qualifiedStatementUnifiedAgainstLemma) {
|
|
123
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' lemma.`, qualifiedStatementNode);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
return
|
|
127
|
+
return qualifiedStatementUnifiedAgainstLemma;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
function
|
|
131
|
-
let
|
|
130
|
+
function unifyQualifiedStatementAAgainstTheorem(qualifiedStatementNode, substitutions, localContext) {
|
|
131
|
+
let qualifiedStatementUnifiedAgainstTheorem = false;
|
|
132
132
|
|
|
133
133
|
const metavariableNode = metavariableNodeQuery(qualifiedStatementNode),
|
|
134
134
|
theorem = localContext.findTheoremByMetavariableNode(metavariableNode);
|
|
@@ -138,22 +138,22 @@ function verifyQualifiedStatementAAgainstTheorem(qualifiedStatementNode, substit
|
|
|
138
138
|
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
139
139
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
140
140
|
|
|
141
|
-
localContext.trace(`
|
|
141
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' theorem...`, qualifiedStatementNode);
|
|
142
142
|
|
|
143
143
|
const theoremMatchesStatement = theorem.unifyStatement(statementNode, localContext);
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
qualifiedStatementUnifiedAgainstTheorem = theoremMatchesStatement; ///
|
|
146
146
|
|
|
147
|
-
if (
|
|
148
|
-
localContext.debug(`...
|
|
147
|
+
if (qualifiedStatementUnifiedAgainstTheorem) {
|
|
148
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' theorem.`, qualifiedStatementNode);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
return
|
|
152
|
+
return qualifiedStatementUnifiedAgainstTheorem;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
function
|
|
156
|
-
let
|
|
155
|
+
function unifyQualifiedStatementAAgainstConjecture(qualifiedStatementNode, substitutions, localContext) {
|
|
156
|
+
let qualifiedStatementUnifiedAgainstConjecture = false;
|
|
157
157
|
|
|
158
158
|
const metavariableNode = metavariableNodeQuery(qualifiedStatementNode),
|
|
159
159
|
conjecture = localContext.findConjectureByMetavariableNode(metavariableNode);
|
|
@@ -163,29 +163,29 @@ function verifyQualifiedStatementAAgainstConjecture(qualifiedStatementNode, subs
|
|
|
163
163
|
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
164
164
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
165
165
|
|
|
166
|
-
localContext.trace(`
|
|
166
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' conjecture...`, qualifiedStatementNode);
|
|
167
167
|
|
|
168
168
|
const conjectureMatchesStatement = conjecture.unifyStatement(statementNode, localContext);
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
qualifiedStatementUnifiedAgainstConjecture = conjectureMatchesStatement; ///
|
|
171
171
|
|
|
172
|
-
if (
|
|
173
|
-
localContext.debug(`...
|
|
172
|
+
if (qualifiedStatementUnifiedAgainstConjecture) {
|
|
173
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' conjecture.`, qualifiedStatementNode);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
return
|
|
177
|
+
return qualifiedStatementUnifiedAgainstConjecture;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
function
|
|
181
|
-
let
|
|
180
|
+
function unifyQualifiedStatementAAgainstReference(qualifiedStatementNode, substitutions, localContext) {
|
|
181
|
+
let qualifiedStatementUnifiedAgainstReference = false;
|
|
182
182
|
|
|
183
183
|
const metavariableNode = metavariableNodeQuery(qualifiedStatementNode),
|
|
184
184
|
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
185
185
|
metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode),
|
|
186
186
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
187
187
|
|
|
188
|
-
localContext.trace(`
|
|
188
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' reference...`, qualifiedStatementNode);
|
|
189
189
|
|
|
190
190
|
if (metavariablePresent) {
|
|
191
191
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
@@ -200,14 +200,14 @@ function verifyQualifiedStatementAAgainstReference(qualifiedStatementNode, subst
|
|
|
200
200
|
return verifiedAhead;
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
qualifiedStatementUnifiedAgainstReference = metavariableVerifiedAgainstStatement; ///
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
if (
|
|
207
|
-
localContext.debug(`...
|
|
206
|
+
if (qualifiedStatementUnifiedAgainstReference) {
|
|
207
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement against the '${metavariableString}' reference.`, qualifiedStatementNode);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
return
|
|
210
|
+
return qualifiedStatementUnifiedAgainstReference;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
function verifyStatedStatement(statementNode, assignments, derived, localContext) {
|
|
@@ -250,11 +250,7 @@ function verifyStatedStatementAsEquality(statementNode, assignments, derived, lo
|
|
|
250
250
|
|
|
251
251
|
localContext.trace(`Verifying the '${statementString}' stated statement as an equality...`, statementNode);
|
|
252
252
|
|
|
253
|
-
const equalityVerified = verifyEquality(equalityNode, assignments, derived, localContext
|
|
254
|
-
const verifiedAhead = true;
|
|
255
|
-
|
|
256
|
-
return verifiedAhead;
|
|
257
|
-
});
|
|
253
|
+
const equalityVerified = verifyEquality(equalityNode, assignments, derived, localContext);
|
|
258
254
|
|
|
259
255
|
statedStatementVerifiedAsEquality = equalityVerified; ///
|
|
260
256
|
|
|
@@ -48,7 +48,7 @@ function verifyDerivedUnqualifiedStatement(unqualifiedStatementNode, assignments
|
|
|
48
48
|
|
|
49
49
|
localContext.trace(`Verifying the '${unqualifiedStatementString}' derived unqualified statement...`, unqualifiedStatementNode);
|
|
50
50
|
|
|
51
|
-
const statementUnified = localContext.unifyStatement(statementNode);
|
|
51
|
+
const statementUnified = localContext.unifyStatement(statementNode, localContext);
|
|
52
52
|
|
|
53
53
|
if (statementUnified) {
|
|
54
54
|
derivedUnqualifiedStatementVerified = true;
|
|
@@ -126,11 +126,7 @@ function verifyDerivedStatementAsEquality(statementNode, assignments, derived, l
|
|
|
126
126
|
|
|
127
127
|
localContext.trace(`Verifying the '${statementString}' derived statement as an equality...`, statementNode);
|
|
128
128
|
|
|
129
|
-
const equalityVerified = verifyEquality(equalityNode, assignments, derived, localContext
|
|
130
|
-
const verifiedAhead = true;
|
|
131
|
-
|
|
132
|
-
return verifiedAhead;
|
|
133
|
-
});
|
|
129
|
+
const equalityVerified = verifyEquality(equalityNode, assignments, derived, localContext);
|
|
134
130
|
|
|
135
131
|
derivedStatementVerifiedAsEquality = equalityVerified; ///
|
|
136
132
|
|
package/src/verify/statement.js
CHANGED
|
@@ -28,24 +28,30 @@ function verifyStatement(statementNode, assignments, derived, localContext) {
|
|
|
28
28
|
|
|
29
29
|
localContext.trace(`Verifying the '${statementString}' statement...`, statementNode);
|
|
30
30
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
const statementUnifiedAgainstCombinators = unifyStatementAgainstCombinators(statementNode, assignments, derived, localContext);
|
|
32
|
+
|
|
33
|
+
if (statementUnifiedAgainstCombinators) {
|
|
34
|
+
statementVerified = true;
|
|
35
|
+
} else {
|
|
36
|
+
const verifyStatementFunctions = [
|
|
37
|
+
verifyStatementAsMetavariable,
|
|
38
|
+
verifyStatementAsEquality,
|
|
39
|
+
verifyStatementAsJudgement,
|
|
40
|
+
verifyStatementAsTypeAssertion,
|
|
41
|
+
verifyStatementAsDefinedAssertion,
|
|
42
|
+
verifyStatementAsSubproofAssertion,
|
|
43
|
+
verifyStatementAsContainedAssertion,
|
|
44
|
+
unifyStatementAgainstCombinators
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
statementVerified = verifyStatementFunctions.some((verifyStatementFunction) => {
|
|
48
|
+
const statementVerified = verifyStatementFunction(statementNode, assignments, derived, localContext);
|
|
49
|
+
|
|
50
|
+
if (statementVerified) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
49
55
|
|
|
50
56
|
if (statementVerified) {
|
|
51
57
|
localContext.debug(`...verified the '${statementString}' statement.`, statementNode);
|
|
@@ -92,11 +98,7 @@ function verifyStatementAsEquality(statementNode, assignments, derived, localCon
|
|
|
92
98
|
|
|
93
99
|
localContext.trace(`Verifying the '${statementString}' statement as an equality...`, statementNode);
|
|
94
100
|
|
|
95
|
-
const equalityVerified = verifyEquality(equalityNode, assignments, derived, localContext
|
|
96
|
-
const verifiedAhead = true;
|
|
97
|
-
|
|
98
|
-
return verifiedAhead;
|
|
99
|
-
});
|
|
101
|
+
const equalityVerified = verifyEquality(equalityNode, assignments, derived, localContext);
|
|
100
102
|
|
|
101
103
|
statementVerifiedAsEquality = equalityVerified; ///
|
|
102
104
|
|
|
@@ -218,8 +220,8 @@ function verifyStatementAsContainedAssertion(statementNode, assignments, derived
|
|
|
218
220
|
return statementVerifiedAsContainedAssertion;
|
|
219
221
|
}
|
|
220
222
|
|
|
221
|
-
function
|
|
222
|
-
let
|
|
223
|
+
function unifyStatementAgainstCombinators(statementNode, assignments, derived, localContext) {
|
|
224
|
+
let statementUnifiedAgainstCombinators = false;
|
|
223
225
|
|
|
224
226
|
const equalityNode = equalityNodeQuery(statementNode),
|
|
225
227
|
judgementNode = judgementNodeQuery(statementNode),
|
|
@@ -244,33 +246,33 @@ function verifyStatementAgainstCombinators(statementNode, assignments, derived,
|
|
|
244
246
|
...combinators
|
|
245
247
|
];
|
|
246
248
|
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
+
statementUnifiedAgainstCombinators = combinators.some((combinator) => {
|
|
250
|
+
const statementUnifiedAgainstCombinator = unifyStatementAgainstCombinator(statementNode, combinator, localContext);
|
|
249
251
|
|
|
250
|
-
if (
|
|
252
|
+
if (statementUnifiedAgainstCombinator) {
|
|
251
253
|
return true;
|
|
252
254
|
}
|
|
253
255
|
});
|
|
254
256
|
}
|
|
255
257
|
|
|
256
|
-
return
|
|
258
|
+
return statementUnifiedAgainstCombinators;
|
|
257
259
|
}
|
|
258
260
|
|
|
259
|
-
function
|
|
260
|
-
let
|
|
261
|
+
function unifyStatementAgainstCombinator(statementNode, combinator, localContext) {
|
|
262
|
+
let statementUnifiedAgainstCombinator;
|
|
261
263
|
|
|
262
264
|
const statementString = localContext.nodeAsString(statementNode),
|
|
263
265
|
combinatorString = combinator.getString();
|
|
264
266
|
|
|
265
|
-
localContext.trace(`
|
|
267
|
+
localContext.trace(`Unifying the '${statementString}' statement against the '${combinatorString}' combinator...`, statementNode);
|
|
266
268
|
|
|
267
269
|
const combinatorStatementNode = combinator.getStatementNode();
|
|
268
270
|
|
|
269
|
-
|
|
271
|
+
statementUnifiedAgainstCombinator = statementAgainstCombinatorUnifier.unify(statementNode, combinatorStatementNode, localContext);
|
|
270
272
|
|
|
271
|
-
if (
|
|
272
|
-
localContext.debug(`...
|
|
273
|
+
if (statementUnifiedAgainstCombinator) {
|
|
274
|
+
localContext.debug(`...unified the '${statementString}' statement against the '${combinatorString}' combinator.`, statementNode);
|
|
273
275
|
}
|
|
274
276
|
|
|
275
|
-
return
|
|
277
|
+
return statementUnifiedAgainstCombinator;
|
|
276
278
|
}
|
package/src/verify/term.js
CHANGED
|
@@ -20,8 +20,8 @@ function verifyTerm(termNode, terms, localContext, verifyAhead) {
|
|
|
20
20
|
|
|
21
21
|
const verifyTermFunctions = [
|
|
22
22
|
verifyTermAsVariable,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
unifyTermAgainstConstructors,
|
|
24
|
+
unifyTermAgainstBracketedConstructor
|
|
25
25
|
];
|
|
26
26
|
|
|
27
27
|
termVerified = verifyTermFunctions.some((verifyTermFunction) => {
|
|
@@ -67,9 +67,7 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
|
|
|
67
67
|
|
|
68
68
|
verifiedAhead = verifyAhead();
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
terms.pop();
|
|
72
|
-
}
|
|
70
|
+
terms.pop();
|
|
73
71
|
|
|
74
72
|
termVerifiedAsVariable = verifiedAhead; ///
|
|
75
73
|
}
|
|
@@ -82,33 +80,33 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
|
|
|
82
80
|
return termVerifiedAsVariable;
|
|
83
81
|
}
|
|
84
82
|
|
|
85
|
-
function
|
|
86
|
-
let
|
|
83
|
+
function unifyTermAgainstConstructors(termNode, terms, localContext, verifyAhead) {
|
|
84
|
+
let termUnifiedAgainstConstructors = false;
|
|
87
85
|
|
|
88
86
|
const variableNode = variableNodeQuery(termNode);
|
|
89
87
|
|
|
90
88
|
if (variableNode === null) {
|
|
91
89
|
const constructors = localContext.getConstructors();
|
|
92
90
|
|
|
93
|
-
|
|
94
|
-
const
|
|
91
|
+
termUnifiedAgainstConstructors = constructors.some((constructor) => {
|
|
92
|
+
const termUnifiedAgainstConstructor = unifyTermAgainstConstructor(termNode, terms, constructor, localContext, verifyAhead);
|
|
95
93
|
|
|
96
|
-
if (
|
|
94
|
+
if (termUnifiedAgainstConstructor) {
|
|
97
95
|
return true;
|
|
98
96
|
}
|
|
99
97
|
});
|
|
100
98
|
}
|
|
101
99
|
|
|
102
|
-
return
|
|
100
|
+
return termUnifiedAgainstConstructors;
|
|
103
101
|
}
|
|
104
102
|
|
|
105
|
-
function
|
|
106
|
-
let
|
|
103
|
+
function unifyTermAgainstBracketedConstructor(termNode, terms, localContext, verifyAhead) {
|
|
104
|
+
let termUnifiedAgainstBracketedConstructor;
|
|
107
105
|
|
|
108
106
|
const termString = localContext.nodeAsString(termNode),
|
|
109
107
|
bracketedConstructorString = bracketedConstructor.getString();
|
|
110
108
|
|
|
111
|
-
localContext.trace(`
|
|
109
|
+
localContext.trace(`Unifying the '${termString}' term against the '${bracketedConstructorString}' bracketed constructor...`, termNode);
|
|
112
110
|
|
|
113
111
|
const bracketedConstructorTermNode = bracketedConstructor.getTermNode(),
|
|
114
112
|
termNodeA = termNode, ///
|
|
@@ -148,30 +146,28 @@ function verifyTermAgainstBracketedConstructor(termNode, terms, localContext, ve
|
|
|
148
146
|
|
|
149
147
|
verifiedAhead = verifyAhead();
|
|
150
148
|
|
|
151
|
-
|
|
152
|
-
terms.pop();
|
|
153
|
-
}
|
|
149
|
+
terms.pop();
|
|
154
150
|
}
|
|
155
151
|
|
|
156
152
|
return verifiedAhead;
|
|
157
153
|
});
|
|
158
154
|
|
|
159
|
-
|
|
155
|
+
termUnifiedAgainstBracketedConstructor = unified; ///
|
|
160
156
|
|
|
161
|
-
if (
|
|
162
|
-
localContext.debug(`...
|
|
157
|
+
if (termUnifiedAgainstBracketedConstructor) {
|
|
158
|
+
localContext.debug(`...unified the '${termString}' term against the '${bracketedConstructorString}' constructor.`, termNode);
|
|
163
159
|
}
|
|
164
160
|
|
|
165
|
-
return
|
|
161
|
+
return termUnifiedAgainstBracketedConstructor;
|
|
166
162
|
}
|
|
167
163
|
|
|
168
|
-
function
|
|
169
|
-
let
|
|
164
|
+
function unifyTermAgainstConstructor(termNode, terms, constructor, localContext, verifyAhead) {
|
|
165
|
+
let termUnifiedAgainstConstructor;
|
|
170
166
|
|
|
171
167
|
const termString = localContext.nodeAsString(termNode),
|
|
172
168
|
constructorString = constructor.getString();
|
|
173
169
|
|
|
174
|
-
localContext.trace(`
|
|
170
|
+
localContext.trace(`Unifying the '${termString}' term against the '${constructorString}' constructor...`, termNode);
|
|
175
171
|
|
|
176
172
|
const constructorTermNode = constructor.getTermNode(),
|
|
177
173
|
termNodeA = termNode, ///
|
|
@@ -186,19 +182,17 @@ function verifyTermAgainstConstructor(termNode, terms, constructor, localContext
|
|
|
186
182
|
|
|
187
183
|
verifiedAhead = verifyAhead();
|
|
188
184
|
|
|
189
|
-
|
|
190
|
-
terms.pop();
|
|
191
|
-
}
|
|
185
|
+
terms.pop();
|
|
192
186
|
|
|
193
187
|
return verifiedAhead;
|
|
194
188
|
});
|
|
195
189
|
|
|
196
|
-
|
|
190
|
+
termUnifiedAgainstConstructor = unified; ///
|
|
197
191
|
|
|
198
|
-
if (
|
|
199
|
-
localContext.debug(`...
|
|
192
|
+
if (termUnifiedAgainstConstructor) {
|
|
193
|
+
localContext.debug(`...unified the '${termString}' term against the '${constructorString}' constructor.`, termNode);
|
|
200
194
|
}
|
|
201
195
|
|
|
202
|
-
return
|
|
196
|
+
return termUnifiedAgainstConstructor;
|
|
203
197
|
}
|
|
204
198
|
|