occam-verify-cli 0.0.972 → 0.0.975
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/bin/action/verify.js +30 -0
- package/bin/main.js +0 -27
- package/lib/context/file.js +1 -8
- package/lib/frame.js +3 -3
- package/lib/judgement.js +4 -4
- package/lib/metavariable.js +4 -28
- package/lib/resolve/complexSubstitutionAgainstSimpleSubstitution.js +76 -0
- package/lib/resolve/substitution.js +27 -0
- package/lib/resolve/substitutions.js +8 -70
- package/lib/rule.js +11 -1
- package/lib/substitution/statementForMetavariable.js +2 -2
- package/lib/substitution.js +8 -1
- package/lib/substitutions.js +19 -7
- package/lib/topLevelAssertion.js +11 -1
- package/lib/type.js +3 -3
- package/lib/unifier/metavariable.js +142 -0
- package/lib/unify/complexSubstitutionStatementWithSimpleSubstitutionStatement.js +26 -0
- package/lib/unify/qualifiedStatement.js +136 -0
- package/lib/unify/statementWithCombinator.js +29 -0
- package/lib/unify/statementWithCombinators.js +5 -14
- package/lib/unify/termWithBracketedConstructor.js +3 -3
- package/lib/unify/termWithConstructor.js +37 -0
- package/lib/unify/termWithConstructors.js +6 -33
- package/lib/unify/unqualifiedStatement.js +25 -0
- package/lib/verifier/statementAsCombinator.js +2 -2
- package/lib/verify/assertion/contained.js +2 -2
- package/lib/verify/assertion/defined.js +7 -4
- package/lib/verify/assertion/type.js +5 -3
- package/lib/verify/conclusion.js +2 -2
- package/lib/verify/consequent.js +2 -2
- package/lib/verify/declaration.js +14 -26
- package/lib/verify/equality.js +11 -7
- package/lib/verify/frame.js +39 -32
- package/lib/verify/judgement.js +28 -49
- package/lib/verify/metavariableGivenMetaType.js +44 -0
- package/lib/verify/premise.js +3 -3
- package/lib/verify/statement/qualified.js +3 -3
- package/lib/verify/statement/unqualified.js +9 -53
- package/lib/verify/statement.js +27 -62
- package/lib/verify/statementGivenMetaType.js +3 -2
- package/lib/verify/term.js +11 -5
- package/package.json +4 -4
- package/src/context/file.js +0 -6
- package/src/frame.js +1 -1
- package/src/judgement.js +1 -1
- package/src/metavariable.js +3 -32
- package/src/resolve/complexSubstitutionAgainstSimpleSubstitution.js +94 -0
- package/src/resolve/substitution.js +19 -0
- package/src/resolve/substitutions.js +9 -112
- package/src/rule.js +10 -0
- package/src/substitution/statementForMetavariable.js +1 -1
- package/src/substitution.js +6 -0
- package/src/substitutions.js +17 -6
- package/src/topLevelAssertion.js +10 -0
- package/src/type.js +3 -3
- package/src/unifier/metavariable.js +46 -0
- package/src/unify/complexSubstitutionStatementWithSimpleSubstitutionStatement.js +18 -0
- package/src/unify/{statement/qualified.js → qualifiedStatement.js} +61 -31
- package/src/unify/statementWithCombinator.js +22 -0
- package/src/unify/statementWithCombinators.js +5 -20
- package/src/unify/termWithBracketedConstructor.js +1 -1
- package/src/unify/termWithConstructor.js +39 -0
- package/src/unify/termWithConstructors.js +1 -37
- package/src/unify/{statement/unqualified.js → unqualifiedStatement.js} +1 -1
- package/src/verifier/statementAsCombinator.js +2 -2
- package/src/verify/assertion/contained.js +1 -1
- package/src/verify/assertion/defined.js +10 -3
- package/src/verify/assertion/type.js +6 -4
- package/src/verify/conclusion.js +1 -1
- package/src/verify/consequent.js +1 -1
- package/src/verify/declaration.js +25 -36
- package/src/verify/equality.js +12 -8
- package/src/verify/frame.js +52 -39
- package/src/verify/judgement.js +43 -75
- package/src/verify/metavariableGivenMetaType.js +45 -0
- package/src/verify/premise.js +3 -3
- package/src/verify/statement/qualified.js +1 -1
- package/src/verify/statement/unqualified.js +8 -13
- package/src/verify/statement.js +25 -69
- package/src/verify/statementGivenMetaType.js +3 -1
- package/src/verify/term.js +13 -6
- package/lib/unify/statement/qualified.js +0 -117
- package/lib/unify/statement/unqualified.js +0 -25
- package/lib/verify/metavariable.js +0 -51
- package/src/verify/metavariable.js +0 -58
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import termWithConstructorUnifier from "../unifier/termWithConstructor";
|
|
3
|
+
import unifyTermWithConstructor from "../unify/termWithConstructor";
|
|
5
4
|
|
|
6
5
|
import { nodeQuery } from "../utilities/query";
|
|
7
6
|
|
|
@@ -26,38 +25,3 @@ export default function unifyTermWithConstructors(termNode, terms, localContext,
|
|
|
26
25
|
|
|
27
26
|
return termUnifiedWithConstructors;
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
export function unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead) {
|
|
31
|
-
let termUnifiedWithConstructor = false;
|
|
32
|
-
|
|
33
|
-
const termString = localContext.nodeAsString(termNode),
|
|
34
|
-
constructorString = constructor.getString(),
|
|
35
|
-
constructorTermNode = constructor.getTermNode();
|
|
36
|
-
|
|
37
|
-
localContext.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`, termNode);
|
|
38
|
-
|
|
39
|
-
const termNodeA = termNode, ///
|
|
40
|
-
constructorTermNodeB = constructorTermNode, ///
|
|
41
|
-
unified = termWithConstructorUnifier.unify(termNodeA, constructorTermNodeB, localContext);
|
|
42
|
-
|
|
43
|
-
if (unified) {
|
|
44
|
-
let verifiedAhead;
|
|
45
|
-
|
|
46
|
-
const type = constructor.getType(),
|
|
47
|
-
term = Term.fromTermNodeAndType(termNode, type);
|
|
48
|
-
|
|
49
|
-
terms.push(term);
|
|
50
|
-
|
|
51
|
-
verifiedAhead = verifyAhead();
|
|
52
|
-
|
|
53
|
-
terms.pop();
|
|
54
|
-
|
|
55
|
-
termUnifiedWithConstructor = verifiedAhead; ///
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (termUnifiedWithConstructor) {
|
|
59
|
-
localContext.debug(`...unified the '${termString}' term with the '${constructorString}' constructor.`, termNode);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return termUnifiedWithConstructor;
|
|
63
|
-
}
|
|
@@ -29,8 +29,8 @@ class StatementAsCombinatorVerifier extends Verifier {
|
|
|
29
29
|
nodeQuery: statementNodeQuery,
|
|
30
30
|
verify: (statementNode, fileContext) => {
|
|
31
31
|
const { verifyStatement } = shim,
|
|
32
|
-
stated = false,
|
|
33
|
-
assignments =
|
|
32
|
+
stated = false,
|
|
33
|
+
assignments = null,
|
|
34
34
|
localContext = LocalContext.fromFileContext(fileContext),
|
|
35
35
|
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
36
36
|
|
|
@@ -23,7 +23,7 @@ export default function verifyContainedAssertion(containedAssertionNode, assignm
|
|
|
23
23
|
|
|
24
24
|
localContext.trace(`Verifying the '${containedAssertionString}' contained assertion...`, containedAssertionNode);
|
|
25
25
|
|
|
26
|
-
assignments =
|
|
26
|
+
assignments = null; ///
|
|
27
27
|
|
|
28
28
|
stated = true; ///
|
|
29
29
|
|
|
@@ -6,6 +6,7 @@ import metaLevelVerifier from "../../verifier/metaLevel";
|
|
|
6
6
|
import { first } from "../../utilities/array";
|
|
7
7
|
import { nodeQuery } from "../../utilities/query";
|
|
8
8
|
import { isAssertionNegated } from "../../utilities/assertion";
|
|
9
|
+
import { metavariableNameFromMetavariableNode } from "../../utilities/name";
|
|
9
10
|
|
|
10
11
|
const variableNodeQuery = nodeQuery("/definedAssertion/term/variable!"),
|
|
11
12
|
metavariableNodeQuery = nodeQuery("/definedAssertion/statement[-1]/metavariable!");
|
|
@@ -18,14 +19,19 @@ const verifyDefinedAssertionFunctions = [
|
|
|
18
19
|
export default function verifyDefinedAssertion(definedAssertionNode, assignments, stated, localContext) {
|
|
19
20
|
let definedAssertionVerified;
|
|
20
21
|
|
|
21
|
-
const definedAssertionString = localContext.nodeAsString(definedAssertionNode)
|
|
22
|
+
const definedAssertionString = localContext.nodeAsString(definedAssertionNode),
|
|
23
|
+
savedStated = stated; ///;
|
|
22
24
|
|
|
23
25
|
localContext.trace(`Verifying the '${definedAssertionString}' defined assertion...`, definedAssertionNode);
|
|
24
26
|
|
|
25
|
-
assignments =
|
|
27
|
+
assignments = null; ///
|
|
28
|
+
|
|
29
|
+
stated = true; ///
|
|
26
30
|
|
|
27
31
|
const verified = metaLevelVerifier.verify(definedAssertionNode, assignments, stated, localContext);
|
|
28
32
|
|
|
33
|
+
stated = savedStated; ///
|
|
34
|
+
|
|
29
35
|
if (verified) {
|
|
30
36
|
definedAssertionVerified = verifyDefinedAssertionFunctions.some((verifyDefinedAssertionFunction) => {
|
|
31
37
|
const definedAssertionVerified = verifyDefinedAssertionFunction(definedAssertionNode, assignments, stated, localContext);
|
|
@@ -58,7 +64,8 @@ function verifyDerivedDefinedAssertion(definedAssertionNode, assignments, stated
|
|
|
58
64
|
if (false) {
|
|
59
65
|
///
|
|
60
66
|
} else if (metavariableNode !== null) {
|
|
61
|
-
const
|
|
67
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
68
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName),
|
|
62
69
|
metavariableDefined = localContext.isMetavariableDefined(metavariable);
|
|
63
70
|
|
|
64
71
|
if (!assertionNegated) {
|
|
@@ -112,11 +112,13 @@ function verifyStatedTypeAssertion(typeAssertionNode, assignments, stated, local
|
|
|
112
112
|
const variableNode = variableNodeQuery(termNode);
|
|
113
113
|
|
|
114
114
|
if (variableNode !== null) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
if (assignments !== null) {
|
|
116
|
+
const variable = Variable.fromVariableNodeAndType(variableNode, type),
|
|
117
|
+
variableAssignment = VariableAssignment.fromVariable(variable),
|
|
118
|
+
assignment = variableAssignment; ///
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
assignments.push(assignment);
|
|
121
|
+
}
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
verifiedAhead = true;
|
package/src/verify/conclusion.js
CHANGED
|
@@ -19,7 +19,7 @@ export default function verifyConclusion(conclusionNode, conclusions, localConte
|
|
|
19
19
|
|
|
20
20
|
if (unqualifiedStatementNode !== null) {
|
|
21
21
|
const stated = true,
|
|
22
|
-
assignments =
|
|
22
|
+
assignments = null,
|
|
23
23
|
statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
24
24
|
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
25
25
|
|
package/src/verify/consequent.js
CHANGED
|
@@ -19,7 +19,7 @@ export default function verifyConsequent(consequentNode, consequents, localConte
|
|
|
19
19
|
|
|
20
20
|
if (unqualifiedStatementNode !== null) {
|
|
21
21
|
const stated = true,
|
|
22
|
-
assignments =
|
|
22
|
+
assignments = null,
|
|
23
23
|
statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
24
24
|
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
25
25
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Declaration from "../declaration"
|
|
5
5
|
import referenceMetaType from "../metaType/reference";
|
|
6
|
+
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
6
7
|
|
|
7
8
|
import { nodeQuery } from "../utilities/query";
|
|
8
9
|
|
|
@@ -44,7 +45,25 @@ function verifyDerivedDeclaration(declarationNode, declarations, stated, localCo
|
|
|
44
45
|
|
|
45
46
|
localContext.trace(`Verifying the '${declarationString}' derived declaration...`, declarationNode);
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
const metaType = referenceMetaType, ///
|
|
49
|
+
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
50
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
51
|
+
|
|
52
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
53
|
+
const { verifyStatement } = shim,
|
|
54
|
+
stated = true,
|
|
55
|
+
assignments = null,
|
|
56
|
+
statementNode = statementNodeQuery(declarationNode),
|
|
57
|
+
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
58
|
+
|
|
59
|
+
if (statementVerified) {
|
|
60
|
+
const declaration = Declaration.fromMetavariableNodeAndStatementNode(metavariableNode, statementNode);
|
|
61
|
+
|
|
62
|
+
declarations.push(declaration);
|
|
63
|
+
|
|
64
|
+
derivedDeclarationVerified = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
48
67
|
|
|
49
68
|
if (derivedDeclarationVerified) {
|
|
50
69
|
localContext.debug(`...verified the '${declarationString}' derived declaration.`, declarationNode);
|
|
@@ -62,13 +81,14 @@ function verifyStatedDeclaration(declarationNode, declarations, stated, localCon
|
|
|
62
81
|
|
|
63
82
|
localContext.trace(`Verifying the '${declarationString}' stated declaration...`, declarationNode);
|
|
64
83
|
|
|
65
|
-
const
|
|
66
|
-
|
|
84
|
+
const metaType = referenceMetaType, ///
|
|
85
|
+
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
86
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
67
87
|
|
|
68
|
-
if (
|
|
88
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
69
89
|
const { verifyStatement } = shim,
|
|
70
90
|
stated = true,
|
|
71
|
-
assignments =
|
|
91
|
+
assignments = null,
|
|
72
92
|
statementNode = statementNodeQuery(declarationNode),
|
|
73
93
|
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
74
94
|
|
|
@@ -88,34 +108,3 @@ function verifyStatedDeclaration(declarationNode, declarations, stated, localCon
|
|
|
88
108
|
|
|
89
109
|
return statedDeclarationVerified;
|
|
90
110
|
}
|
|
91
|
-
|
|
92
|
-
function verifyMetavariable(metavariableNode, localContext) {
|
|
93
|
-
let metavariableVerified = false;
|
|
94
|
-
|
|
95
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
96
|
-
|
|
97
|
-
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
98
|
-
|
|
99
|
-
const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
100
|
-
|
|
101
|
-
if (metavariable !== null) {
|
|
102
|
-
const metaType = metavariable.getMetaType();
|
|
103
|
-
|
|
104
|
-
if (metaType === referenceMetaType) {
|
|
105
|
-
metavariableVerified = true;
|
|
106
|
-
} else {
|
|
107
|
-
const referenceMetaTypeName = referenceMetaType.getName(),
|
|
108
|
-
metaTypeString = metaType.asString();
|
|
109
|
-
|
|
110
|
-
localContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${referenceMetaTypeName}'.`, metavariableNode);
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (metavariableVerified) {
|
|
117
|
-
localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return metavariableVerified;
|
|
121
|
-
}
|
package/src/verify/equality.js
CHANGED
|
@@ -41,7 +41,7 @@ function verifyDerivedEquality(equalityNode, assignments, stated, localContext)
|
|
|
41
41
|
if (!stated) {
|
|
42
42
|
const equalityString = localContext.nodeAsString(equalityNode);
|
|
43
43
|
|
|
44
|
-
localContext.trace(`Verifying the '${equalityString}'
|
|
44
|
+
localContext.trace(`Verifying the '${equalityString}' derived equality...`, equalityNode);
|
|
45
45
|
|
|
46
46
|
const terms = [],
|
|
47
47
|
termNodes = termNodesQuery(equalityNode),
|
|
@@ -54,10 +54,12 @@ function verifyDerivedEquality(equalityNode, assignments, stated, localContext)
|
|
|
54
54
|
const equalityEqual = equality.isEqual(localContext);
|
|
55
55
|
|
|
56
56
|
if (equalityEqual) {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
if (assignments !== null) {
|
|
58
|
+
const equalityAssignment = EqualityAssignment.fromEquality(equality),
|
|
59
|
+
assignment = equalityAssignment; ///
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
assignments.push(assignment);
|
|
62
|
+
}
|
|
61
63
|
|
|
62
64
|
verifiedAhead = true;
|
|
63
65
|
}
|
|
@@ -69,7 +71,7 @@ function verifyDerivedEquality(equalityNode, assignments, stated, localContext)
|
|
|
69
71
|
derivedEqualityVerified = termsVerified; ///
|
|
70
72
|
|
|
71
73
|
if (derivedEqualityVerified) {
|
|
72
|
-
localContext.debug(`...verified the '${equalityString}'
|
|
74
|
+
localContext.debug(`...verified the '${equalityString}' derived equality.`, equalityNode);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
|
|
@@ -92,10 +94,12 @@ function verifyStatedEquality(equalityNode, assignments, stated, localContext) {
|
|
|
92
94
|
const equality = Equality.fromTermsAndEqualityNode(terms, equalityNode);
|
|
93
95
|
|
|
94
96
|
if (equality !== null) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
if (assignments !== null) {
|
|
98
|
+
const equalityAssignment = EqualityAssignment.fromEquality(equality),
|
|
99
|
+
assignment = equalityAssignment; ///
|
|
97
100
|
|
|
98
|
-
|
|
101
|
+
assignments.push(assignment);
|
|
102
|
+
}
|
|
99
103
|
|
|
100
104
|
verifiedAhead = true;
|
|
101
105
|
}
|
package/src/verify/frame.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
import Frame from "../frame";
|
|
4
4
|
import frameMetaType from "../metaType/frame";
|
|
5
5
|
import verifyDeclaration from "../verify/declaration";
|
|
6
|
+
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
6
7
|
|
|
7
|
-
import { push } from "../utilities/array";
|
|
8
8
|
import { nodesQuery } from "../utilities/query";
|
|
9
|
+
import { first, push } from "../utilities/array";
|
|
9
10
|
|
|
10
11
|
const declarationNodesQuery = nodesQuery("/frame/declaration"),
|
|
11
12
|
metavariableNodesQuery = nodesQuery("/frame/metavariable");
|
|
@@ -45,7 +46,32 @@ function verifyDerivedFrame(frameNode, frames, stated, localContext) {
|
|
|
45
46
|
|
|
46
47
|
localContext.trace(`Verifying the '${frameString}' derived frame...`, frameNode);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
const declarationNodes = declarationNodesQuery(frameNode),
|
|
50
|
+
declarationNodesLength = declarationNodes.length;
|
|
51
|
+
|
|
52
|
+
if (declarationNodesLength === 1) {
|
|
53
|
+
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
54
|
+
metavariableNodesLength = metavariableNodes.length;
|
|
55
|
+
|
|
56
|
+
if (metavariableNodesLength === 0) {
|
|
57
|
+
const firstDeclarationNode = first(declarationNodes),
|
|
58
|
+
declarationNode = firstDeclarationNode, ///
|
|
59
|
+
declarations = [],
|
|
60
|
+
declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
61
|
+
|
|
62
|
+
if (declarationVerified) {
|
|
63
|
+
const frame = Frame.fromDeclarations(declarations);
|
|
64
|
+
|
|
65
|
+
frames.push(frame);
|
|
66
|
+
|
|
67
|
+
derivedFrameVerified = true; ///
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
localContext.debug(`The '${frameString}' derived frame must no spread metavariables.`, frameNode);
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
localContext.debug(`The '${frameString}' derived frame must have one and only one declaration.`, frameNode);
|
|
74
|
+
}
|
|
49
75
|
|
|
50
76
|
if (derivedFrameVerified) {
|
|
51
77
|
localContext.debug(`...verified the '${frameString}' derived frame.`, frameNode);
|
|
@@ -65,25 +91,28 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
|
|
|
65
91
|
|
|
66
92
|
const declarations = [],
|
|
67
93
|
declarationNodes = declarationNodesQuery(frameNode),
|
|
68
|
-
metavariableNodes = metavariableNodesQuery(frameNode),
|
|
69
94
|
declarationsVerified = declarationNodes.every((declarationNode) => {
|
|
70
95
|
const declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
71
96
|
|
|
72
97
|
return declarationVerified;
|
|
73
|
-
}),
|
|
74
|
-
metavariablesVerified = metavariableNodes.every((metavariableNode) => {
|
|
75
|
-
const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localContext);
|
|
76
|
-
|
|
77
|
-
return metavariableVerified;
|
|
78
98
|
});
|
|
79
99
|
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
if (declarationsVerified) {
|
|
101
|
+
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
102
|
+
metavariablesVerified = metavariableNodes.every((metavariableNode) => {
|
|
103
|
+
const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localContext);
|
|
82
104
|
|
|
83
|
-
|
|
105
|
+
return metavariableVerified;
|
|
106
|
+
});
|
|
84
107
|
|
|
85
|
-
|
|
86
|
-
|
|
108
|
+
if (metavariablesVerified) {
|
|
109
|
+
const frame = Frame.fromDeclarations(declarations);
|
|
110
|
+
|
|
111
|
+
frames.push(frame);
|
|
112
|
+
|
|
113
|
+
statedFrameVerified = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
87
116
|
|
|
88
117
|
if (statedFrameVerified) {
|
|
89
118
|
localContext.debug(`...verified the '${frameString}' stated frame.`, frameNode);
|
|
@@ -96,39 +125,23 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
|
|
|
96
125
|
function verifyMetavariable(metavariableNode, declarations, localContext) {
|
|
97
126
|
let metavariableVerified = false;
|
|
98
127
|
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
102
|
-
|
|
103
|
-
const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
128
|
+
const metaType = frameMetaType, ///
|
|
129
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
104
130
|
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
131
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
132
|
+
const judgement = localContext.findJudgementByMetavariableNode(metavariableNode);
|
|
107
133
|
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
134
|
+
if (judgement !== null) {
|
|
135
|
+
const judgementDeclarations = judgement.getDeclarations();
|
|
110
136
|
|
|
111
|
-
|
|
112
|
-
const judgementDeclarations = judgement.getDeclarations();
|
|
137
|
+
push(declarations, judgementDeclarations);
|
|
113
138
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
metavariableVerified = true;
|
|
117
|
-
} else {
|
|
118
|
-
localContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode);
|
|
119
|
-
}
|
|
139
|
+
metavariableVerified = true;
|
|
120
140
|
} else {
|
|
121
|
-
const
|
|
122
|
-
metaTypeString = metaType.asString();
|
|
141
|
+
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
123
142
|
|
|
124
|
-
localContext.debug(`
|
|
143
|
+
localContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode)
|
|
125
144
|
}
|
|
126
|
-
} else {
|
|
127
|
-
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (metavariableVerified) {
|
|
131
|
-
localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
132
145
|
}
|
|
133
146
|
|
|
134
147
|
return metavariableVerified;
|
package/src/verify/judgement.js
CHANGED
|
@@ -4,6 +4,7 @@ import Judgement from "../judgement";
|
|
|
4
4
|
import verifyFrame from "../verify/frame";
|
|
5
5
|
import frameMetaType from "../metaType/frame";
|
|
6
6
|
import JudgementAssignment from "../assignment/judgement";
|
|
7
|
+
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
7
8
|
|
|
8
9
|
import { first } from "../utilities/array";
|
|
9
10
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -46,49 +47,41 @@ function verifyDerivedJudgement(judgementNode, assignments, stated, localContext
|
|
|
46
47
|
|
|
47
48
|
localContext.trace(`Verifying the '${judgementString}' derived judgement...`, judgementNode);
|
|
48
49
|
|
|
49
|
-
const metavariableNode = metavariableNodeQuery(judgementNode)
|
|
50
|
-
metavariableVerified = verifyMetavariable(metavariableNode, localContext);
|
|
50
|
+
const metavariableNode = metavariableNodeQuery(judgementNode);
|
|
51
51
|
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
52
|
+
if (metavariableNode !== null) {
|
|
53
|
+
const metaType = frameMetaType, ///
|
|
54
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
54
55
|
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
frameNode = frameNodeQuery(judgementNode),
|
|
58
|
-
frameVerified = verifyFrame(frameNode, frames, assignments, stated, localContext);
|
|
56
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
57
|
+
const judgement = localContext.findJudgementByMetavariableNode(metavariableNode);
|
|
59
58
|
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
if (judgement !== null) {
|
|
60
|
+
const frames = [],
|
|
61
|
+
frameNode = frameNodeQuery(judgementNode),
|
|
62
|
+
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
64
63
|
|
|
65
|
-
if (
|
|
66
|
-
const
|
|
64
|
+
if (frameVerified) {
|
|
65
|
+
const firstFrame = first(frames),
|
|
66
|
+
frame = firstFrame, ///
|
|
67
|
+
declaration = frame.getDeclaration(),
|
|
67
68
|
metavariableNode = declaration.getMetavariableNode(),
|
|
68
|
-
metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
|
|
69
69
|
metatheorem = localContext.findMetatheoremByMetavariableNode(metavariableNode),
|
|
70
|
+
metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
|
|
70
71
|
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
71
72
|
|
|
72
73
|
if (metaLemmaMetatheorem !== null) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
derivedJudgementVerified = (metaLemmaMetatheoremUnifiedWithDeclaration && metaLemmaMetatheoremUnifiedWithJudgement);
|
|
77
|
-
} else {
|
|
78
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
74
|
+
const metaLemmaMetatheoremUnifiedWithJudgement = judgement.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem),
|
|
75
|
+
metaLemmaMetatheoremUnifiedWithDeclaration = declaration.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem);
|
|
79
76
|
|
|
80
|
-
|
|
77
|
+
derivedJudgementVerified = (metaLemmaMetatheoremUnifiedWithJudgement && metaLemmaMetatheoremUnifiedWithDeclaration);
|
|
81
78
|
}
|
|
82
|
-
} else {
|
|
83
|
-
const frameString = localContext.nodeAsString(frameNode);
|
|
84
|
-
|
|
85
|
-
localContext.debug(`The '${frameString}' is not singular.`, judgementNode);
|
|
86
79
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
80
|
+
} else {
|
|
81
|
+
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
90
82
|
|
|
91
|
-
|
|
83
|
+
localContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode)
|
|
84
|
+
}
|
|
92
85
|
}
|
|
93
86
|
}
|
|
94
87
|
|
|
@@ -108,24 +101,30 @@ function verifyStatedJudgement(judgementNode, assignments, stated, localContext)
|
|
|
108
101
|
|
|
109
102
|
localContext.trace(`Verifying the '${judgementString}' stated judgement...`, judgementNode);
|
|
110
103
|
|
|
111
|
-
const metavariableNode = metavariableNodeQuery(judgementNode)
|
|
112
|
-
metavariableVerified = verifyMetavariable(metavariableNode, localContext);
|
|
104
|
+
const metavariableNode = metavariableNodeQuery(judgementNode);
|
|
113
105
|
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
106
|
+
if (metavariableNode !== null) {
|
|
107
|
+
const metaType = frameMetaType, ///
|
|
108
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
118
109
|
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
judgementAssignment = JudgementAssignment.fromJudgement(judgement),
|
|
124
|
-
assignment = judgementAssignment;
|
|
110
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
111
|
+
const frames = [],
|
|
112
|
+
frameNode = frameNodeQuery(judgementNode),
|
|
113
|
+
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
125
114
|
|
|
126
|
-
|
|
115
|
+
if (frameVerified) {
|
|
116
|
+
if (assignments !== null) {
|
|
117
|
+
const firstFrame = first(frames),
|
|
118
|
+
frame = firstFrame, ///
|
|
119
|
+
judgement = Judgement.fromJudgementNodeFrameAndMetavariableNode(judgementNode, frame, metavariableNode),
|
|
120
|
+
judgementAssignment = JudgementAssignment.fromJudgement(judgement),
|
|
121
|
+
assignment = judgementAssignment;
|
|
122
|
+
|
|
123
|
+
assignments.push(assignment);
|
|
124
|
+
}
|
|
127
125
|
|
|
128
|
-
|
|
126
|
+
statedJudgementVerified = true;
|
|
127
|
+
}
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
|
|
@@ -136,34 +135,3 @@ function verifyStatedJudgement(judgementNode, assignments, stated, localContext)
|
|
|
136
135
|
|
|
137
136
|
return statedJudgementVerified;
|
|
138
137
|
}
|
|
139
|
-
|
|
140
|
-
function verifyMetavariable(metavariableNode, localContext) {
|
|
141
|
-
let metavariableVerified = false;
|
|
142
|
-
|
|
143
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
144
|
-
|
|
145
|
-
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
146
|
-
|
|
147
|
-
const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
148
|
-
|
|
149
|
-
if (metavariable !== null) {
|
|
150
|
-
const metaType = metavariable.getMetaType();
|
|
151
|
-
|
|
152
|
-
if (metaType === frameMetaType) {
|
|
153
|
-
metavariableVerified = true;
|
|
154
|
-
} else {
|
|
155
|
-
const frameMetaTypeName = frameMetaType.getName(),
|
|
156
|
-
metaTypeString = metaType.asString();
|
|
157
|
-
|
|
158
|
-
localContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${frameMetaTypeName}'.`, metavariableNode);
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (metavariableVerified) {
|
|
165
|
-
localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return metavariableVerified;
|
|
169
|
-
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import metavariableUnifier from "../unifier/metavariable";
|
|
4
|
+
|
|
5
|
+
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
6
|
+
|
|
7
|
+
export default function verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext) {
|
|
8
|
+
let metavariableVerifiedGivenMetaType = false;
|
|
9
|
+
|
|
10
|
+
const metaTypeName = metaType.getName(),
|
|
11
|
+
metavariableString = localContext.nodeAsString(metavariableNode);
|
|
12
|
+
|
|
13
|
+
localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeName}' meta-type...`, metavariableNode);
|
|
14
|
+
|
|
15
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
16
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
17
|
+
|
|
18
|
+
if (metavariable !== null) {
|
|
19
|
+
const metavariableMetaType = metavariable.getMetaType();
|
|
20
|
+
|
|
21
|
+
if (metavariableMetaType === metaType) {
|
|
22
|
+
const metavariableNodeA = metavariableNode; ///
|
|
23
|
+
|
|
24
|
+
metavariableNode = metavariable.getNode();
|
|
25
|
+
|
|
26
|
+
const metavariableNodeB = metavariableNode; ///
|
|
27
|
+
|
|
28
|
+
const unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
29
|
+
|
|
30
|
+
metavariableVerifiedGivenMetaType = unified; ///
|
|
31
|
+
} else {
|
|
32
|
+
const metavariableMetaTypeName = metavariableMetaType.getName();
|
|
33
|
+
|
|
34
|
+
localContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metavariableMetaTypeName}' when it should be '${metaTypeName}'.`, metavariableNode);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
41
|
+
localContext.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeName}' meta-type.`, metavariableNode);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return metavariableVerifiedGivenMetaType;
|
|
45
|
+
}
|
package/src/verify/premise.js
CHANGED
|
@@ -29,12 +29,12 @@ export default function verifyPremise(premiseNode, premises, localContext) {
|
|
|
29
29
|
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
30
30
|
|
|
31
31
|
if (assignmentsAssigned) {
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const premise = Premise.fromStatementNode(statementNode),
|
|
33
|
+
proofStep = ProofStep.fromStatementNode(statementNode);
|
|
34
34
|
|
|
35
35
|
premises.push(premise);
|
|
36
36
|
|
|
37
|
-
localContext.addProofStep(
|
|
37
|
+
localContext.addProofStep(proofStep);
|
|
38
38
|
|
|
39
39
|
premiseVerified = true;
|
|
40
40
|
}
|