occam-verify-cli 0.0.1074 → 0.0.1077
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/assertion/contained.js +6 -4
- package/lib/assertion/defined.js +2 -2
- package/lib/assertion/subproof.js +46 -30
- package/lib/assertion/type.js +4 -5
- package/lib/assignment/variable.js +2 -2
- package/lib/axiom.js +9 -12
- package/lib/combinator/bracketed.js +3 -2
- package/lib/combinator.js +6 -6
- package/lib/conclusion.js +2 -3
- package/lib/conjecture.js +10 -15
- package/lib/consequent.js +2 -3
- package/lib/constructor/bracketed.js +3 -2
- package/lib/constructor.js +6 -6
- package/lib/context/file.js +48 -102
- package/lib/context/local.js +21 -20
- package/lib/declaration/combinator.js +5 -5
- package/lib/declaration/constructor.js +5 -5
- package/lib/declaration/metavariable.js +4 -5
- package/lib/declaration/type.js +3 -3
- package/lib/declaration/variable.js +5 -5
- package/lib/declaration.js +10 -9
- package/lib/derivation.js +6 -2
- package/lib/equality.js +6 -2
- package/lib/frame.js +11 -13
- package/lib/index.js +13 -1
- package/lib/judgement.js +11 -8
- package/lib/label.js +6 -7
- package/lib/lemma.js +10 -15
- package/lib/metaLemma.js +15 -15
- package/lib/metatheorem.js +9 -14
- package/lib/metavariable.js +22 -27
- package/lib/mixins/statement/qualified/unify.js +2 -2
- package/lib/mixins/statement/unify.js +2 -2
- package/lib/mixins/statement/verify.js +20 -54
- package/lib/mixins/term/verify.js +3 -3
- package/lib/premise.js +24 -21
- package/lib/proof.js +8 -4
- package/lib/proofStep.js +62 -28
- package/lib/reference.js +3 -3
- package/lib/rule.js +17 -24
- package/lib/statement/qualified.js +8 -4
- package/lib/statement.js +5 -5
- package/lib/subDerivation.js +6 -2
- package/lib/subproof.js +10 -7
- package/lib/substitution/statementForMetavariable.js +36 -27
- package/lib/substitution.js +13 -13
- package/lib/substitutions.js +73 -49
- package/lib/supposition.js +30 -23
- package/lib/term.js +5 -5
- package/lib/theorem.js +10 -15
- package/lib/topLevelAssertion.js +12 -6
- package/lib/type.js +5 -5
- package/lib/unifier/equality.js +2 -2
- package/lib/unifier/metaLevel.js +6 -6
- package/lib/unifier/metavariable.js +5 -5
- package/lib/unifier/statementWithCombinator.js +2 -2
- package/lib/utilities/brackets.js +2 -2
- package/lib/utilities/node.js +2 -7
- package/lib/utilities/nominal.js +26 -0
- package/lib/utilities/subproof.js +2 -2
- package/lib/utilities/tokens.js +3 -7
- package/lib/variable.js +6 -6
- package/lib/verifier/statementAsCombinator.js +4 -11
- package/lib/verifier/termAsConstructor.js +4 -4
- package/lib/verifier/topLevel.js +9 -15
- package/package.json +1 -1
- package/src/assertion/contained.js +7 -5
- package/src/assertion/defined.js +2 -2
- package/src/assertion/subproof.js +61 -42
- package/src/assertion/type.js +2 -2
- package/src/assignment/variable.js +2 -1
- package/src/axiom.js +6 -8
- package/src/combinator/bracketed.js +6 -3
- package/src/combinator.js +4 -4
- package/src/conclusion.js +2 -2
- package/src/conjecture.js +8 -11
- package/src/consequent.js +2 -2
- package/src/constructor/bracketed.js +6 -3
- package/src/constructor.js +4 -4
- package/src/context/file.js +46 -84
- package/src/context/local.js +15 -17
- package/src/declaration/combinator.js +5 -4
- package/src/declaration/constructor.js +5 -4
- package/src/declaration/metavariable.js +3 -4
- package/src/declaration/type.js +2 -2
- package/src/declaration/variable.js +5 -4
- package/src/declaration.js +12 -9
- package/src/derivation.js +7 -1
- package/src/equality.js +7 -1
- package/src/frame.js +10 -9
- package/src/index.js +12 -0
- package/src/judgement.js +11 -5
- package/src/label.js +5 -5
- package/src/lemma.js +8 -11
- package/src/metaLemma.js +13 -11
- package/src/metatheorem.js +6 -10
- package/src/metavariable.js +23 -42
- package/src/mixins/statement/qualified/unify.js +1 -2
- package/src/mixins/statement/unify.js +2 -2
- package/src/mixins/statement/verify.js +35 -88
- package/src/mixins/term/verify.js +3 -2
- package/src/premise.js +41 -33
- package/src/proof.js +10 -3
- package/src/proofStep.js +91 -32
- package/src/reference.js +3 -2
- package/src/rule.js +17 -24
- package/src/statement/qualified.js +9 -5
- package/src/statement.js +3 -3
- package/src/subDerivation.js +8 -2
- package/src/subproof.js +12 -5
- package/src/substitution/statementForMetavariable.js +45 -30
- package/src/substitution.js +9 -9
- package/src/substitutions.js +75 -45
- package/src/supposition.js +50 -35
- package/src/term.js +3 -3
- package/src/theorem.js +8 -11
- package/src/topLevelAssertion.js +16 -7
- package/src/type.js +3 -3
- package/src/unifier/equality.js +1 -1
- package/src/unifier/metaLevel.js +8 -10
- package/src/unifier/metavariable.js +5 -5
- package/src/unifier/statementWithCombinator.js +5 -5
- package/src/utilities/brackets.js +2 -2
- package/src/utilities/node.js +1 -10
- package/src/utilities/nominal.js +14 -0
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/tokens.js +2 -9
- package/src/variable.js +4 -4
- package/src/verifier/statementAsCombinator.js +4 -18
- package/src/verifier/termAsConstructor.js +4 -4
- package/src/verifier/topLevel.js +15 -14
- package/lib/assignment/metavariable.js +0 -62
- package/lib/unifier/intrinsicLevel.js +0 -144
- package/lib/utilities/unify.js +0 -24
- package/lib/verifier/intrinsicLevel.js +0 -140
- package/lib/verifier/metaLevel.js +0 -147
- package/src/assignment/metavariable.js +0 -30
- package/src/unifier/intrinsicLevel.js +0 -54
- package/src/utilities/unify.js +0 -23
- package/src/verifier/intrinsicLevel.js +0 -42
- package/src/verifier/metaLevel.js +0 -54
|
@@ -45,13 +45,13 @@ export default class ContainedAssertion {
|
|
|
45
45
|
|
|
46
46
|
localContext.trace(`Verifying the '${containedAssertionString}' contained assertion...`);
|
|
47
47
|
|
|
48
|
-
stated = true;
|
|
48
|
+
stated = true; ///
|
|
49
49
|
|
|
50
50
|
assignments = null; ///
|
|
51
51
|
|
|
52
|
-
let termVerified = true,
|
|
53
|
-
frameVerified = true,
|
|
54
|
-
statementVerified;
|
|
52
|
+
let termVerified = true,
|
|
53
|
+
frameVerified = true,
|
|
54
|
+
statementVerified = true;
|
|
55
55
|
|
|
56
56
|
if (this.term !== null) {
|
|
57
57
|
termVerified = this.term.verify(localContext, () => {
|
|
@@ -65,7 +65,9 @@ export default class ContainedAssertion {
|
|
|
65
65
|
frameVerified = this.frame.verify(assignments, stated, localContext);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
if (this.statement !== null) {
|
|
69
|
+
statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
70
|
+
}
|
|
69
71
|
|
|
70
72
|
if (termVerified && frameVerified && statementVerified) {
|
|
71
73
|
let verifiedWhenStated = false,
|
package/src/assertion/defined.js
CHANGED
|
@@ -44,8 +44,8 @@ export default class DefinedAssertion {
|
|
|
44
44
|
|
|
45
45
|
assignments = null; ///
|
|
46
46
|
|
|
47
|
-
let termVerified = true,
|
|
48
|
-
frameVerified = true;
|
|
47
|
+
let termVerified = true,
|
|
48
|
+
frameVerified = true;
|
|
49
49
|
|
|
50
50
|
if (this.term !== null) {
|
|
51
51
|
termVerified = this.term.verify(localContext, () => {
|
|
@@ -5,7 +5,6 @@ import { arrayUtilities } from "necessary";
|
|
|
5
5
|
import shim from "../shim";
|
|
6
6
|
import LocalContext from "../context/local";
|
|
7
7
|
import metaLevelUnifier from "../unifier/metaLevel";
|
|
8
|
-
import metaLevelVerifier from "../verifier/metaLevel";
|
|
9
8
|
|
|
10
9
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
10
|
|
|
@@ -33,6 +32,39 @@ export default class SubproofAssertion {
|
|
|
33
32
|
return this.statements;
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
unifySubproof(subproof, substitutions, fileContext, localContext) {
|
|
36
|
+
let subproofUnified;
|
|
37
|
+
|
|
38
|
+
const subproofString = subproof.getString(),
|
|
39
|
+
subproofAssertionString = this.string; ///
|
|
40
|
+
|
|
41
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion...`);
|
|
42
|
+
|
|
43
|
+
const subproofStatements = subproof.getStatements(),
|
|
44
|
+
subproofAssertionStatements = this.statements; ///
|
|
45
|
+
|
|
46
|
+
subproofUnified = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
|
|
47
|
+
const subproofAssertionStatementNode = subproofAssertionStatement.getNode(),
|
|
48
|
+
subproofStatementNode = subproofStatement.getNode(),
|
|
49
|
+
nodeA = subproofAssertionStatementNode, ///
|
|
50
|
+
nodeB = subproofStatementNode, ///
|
|
51
|
+
fileContextA = fileContext, ///
|
|
52
|
+
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
53
|
+
localContextB = localContext, ///
|
|
54
|
+
unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
55
|
+
|
|
56
|
+
if (unifiedAtMetaLevel) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
if (subproofUnified) {
|
|
62
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion.`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return subproofUnified;
|
|
66
|
+
}
|
|
67
|
+
|
|
36
68
|
verify(assignments, stated, localContext) {
|
|
37
69
|
let verified;
|
|
38
70
|
|
|
@@ -40,24 +72,31 @@ export default class SubproofAssertion {
|
|
|
40
72
|
|
|
41
73
|
localContext.trace(`Verifying the '${subproofAssertionString}' subproof assertion...`);
|
|
42
74
|
|
|
43
|
-
|
|
44
|
-
verifiedWhenDerived = false;
|
|
75
|
+
stated = true; ///
|
|
45
76
|
|
|
46
|
-
|
|
47
|
-
verifiedWhenStated = this.verifyWhenStated(localContext);
|
|
48
|
-
} else {
|
|
49
|
-
verifiedWhenDerived = this.verifyWhenDerived(localContext);
|
|
50
|
-
}
|
|
77
|
+
assignments = null; ///
|
|
51
78
|
|
|
52
|
-
|
|
53
|
-
|
|
79
|
+
const statementsVerified = this.statements.map((statement) => {
|
|
80
|
+
const statementVerified = statement.verify(assignments, stated, localContext);
|
|
54
81
|
|
|
55
|
-
|
|
82
|
+
if (statementVerified) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (statementsVerified) {
|
|
88
|
+
let verifiedWhenStated = false,
|
|
89
|
+
verifiedWhenDerived = false;
|
|
56
90
|
|
|
57
|
-
|
|
58
|
-
|
|
91
|
+
if (stated) {
|
|
92
|
+
verifiedWhenStated = this.verifyWhenStated(localContext);
|
|
93
|
+
} else {
|
|
94
|
+
verifiedWhenDerived = this.verifyWhenDerived(localContext);
|
|
95
|
+
}
|
|
59
96
|
|
|
60
|
-
|
|
97
|
+
if (verifiedWhenStated || verifiedWhenDerived) {
|
|
98
|
+
verified = true; ///
|
|
99
|
+
}
|
|
61
100
|
}
|
|
62
101
|
|
|
63
102
|
if (verified) {
|
|
@@ -90,42 +129,22 @@ export default class SubproofAssertion {
|
|
|
90
129
|
|
|
91
130
|
localContext.trace(`Verifying the '${subproofAssertionString}' derived subproof assertion...`);
|
|
92
131
|
|
|
93
|
-
|
|
132
|
+
const proofSteps = localContext.getProofSteps();
|
|
94
133
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
unifySubproof(subproof, substitutions, fileContext, localContext) {
|
|
101
|
-
let subproofUnified;
|
|
102
|
-
|
|
103
|
-
const subproofString = subproof.getString(),
|
|
104
|
-
subproofStatements = subproof.getStatements(),
|
|
105
|
-
subproofAssertionString = this.string; ///
|
|
134
|
+
derivedSubproofAssertionVerified = proofSteps.some((proofStep) => {
|
|
135
|
+
const subproofAssertion = this,
|
|
136
|
+
subproofAssertionUnified = proofStep.unifySubproofAssertion(subproofAssertion, localContext);
|
|
106
137
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
subproofUnified = match(this.statements, subproofStatements, (statement, subproofStatement) => {
|
|
110
|
-
const statementNode = statement.getNode(),
|
|
111
|
-
subproofStatementNode = subproofStatement.getNode(),
|
|
112
|
-
nodeA = statementNode, ///
|
|
113
|
-
nodeB = subproofStatementNode, ///
|
|
114
|
-
fileContextA = fileContext, ///
|
|
115
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
116
|
-
localContextB = localContext, ///
|
|
117
|
-
unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
118
|
-
|
|
119
|
-
if (unifiedAtMetaLevel) {
|
|
138
|
+
if (subproofAssertionUnified) {
|
|
120
139
|
return true;
|
|
121
140
|
}
|
|
122
141
|
});
|
|
123
142
|
|
|
124
|
-
if (
|
|
125
|
-
localContext.debug(`...
|
|
143
|
+
if (derivedSubproofAssertionVerified) {
|
|
144
|
+
localContext.debug(`...verified the '${subproofAssertionString}' derived subproof assertion.`);
|
|
126
145
|
}
|
|
127
146
|
|
|
128
|
-
return
|
|
147
|
+
return derivedSubproofAssertionVerified;
|
|
129
148
|
}
|
|
130
149
|
|
|
131
150
|
static fromStatementNode(statementNode, localContext) {
|
package/src/assertion/type.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "../shim";
|
|
4
|
-
import Variable from "../variable";
|
|
5
4
|
import VariableAssignment from "../assignment/variable";
|
|
6
5
|
|
|
7
6
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -111,7 +110,8 @@ export default class TypeAssertion {
|
|
|
111
110
|
|
|
112
111
|
if (termVerified) {
|
|
113
112
|
if (assignments !== null) {
|
|
114
|
-
const
|
|
113
|
+
const { Variable } = shim,
|
|
114
|
+
termNode = this.term.getNode(),
|
|
115
115
|
variableNode = variableNodeQuery(termNode),
|
|
116
116
|
variable = Variable.fromVariableNodeAndType(variableNode, this.type, localContext);
|
|
117
117
|
|
|
@@ -10,7 +10,8 @@ export default class VariableAssignment {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
assign(localContext) {
|
|
13
|
-
const
|
|
13
|
+
const nested = false,
|
|
14
|
+
variableAdded = localContext.addVariable(this.variable, nested),
|
|
14
15
|
variableType = this.variable.getType(),
|
|
15
16
|
variableString = this.variable.getString(),
|
|
16
17
|
variableTypeName = variableType.getName(),
|
package/src/axiom.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import Label from "./label";
|
|
5
|
-
import Consequent from "./consequent";
|
|
6
|
-
import Supposition from "./supposition";
|
|
7
4
|
import LocalContext from "./context/local";
|
|
8
5
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
9
6
|
|
|
@@ -22,15 +19,15 @@ class Axiom extends TopLevelAssertion {
|
|
|
22
19
|
|
|
23
20
|
this.fileContext.trace(`Verifying the '${axiomString}' axiom...`);
|
|
24
21
|
|
|
25
|
-
const
|
|
26
|
-
const
|
|
22
|
+
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
23
|
+
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
27
24
|
|
|
28
|
-
if (
|
|
25
|
+
if (labelVVerifiedWhenDeclared) {
|
|
29
26
|
return true;
|
|
30
27
|
}
|
|
31
28
|
});
|
|
32
29
|
|
|
33
|
-
if (
|
|
30
|
+
if (labelsVerifiedWhenDeclared) {
|
|
34
31
|
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
35
32
|
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
36
33
|
const suppositionVerified = supposition.verify(localContext);
|
|
@@ -63,7 +60,8 @@ class Axiom extends TopLevelAssertion {
|
|
|
63
60
|
static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Axiom, json, fileContext); }
|
|
64
61
|
|
|
65
62
|
static fromAxiomNode(axiomNode, fileContext) {
|
|
66
|
-
const
|
|
63
|
+
const { Label, Supposition, Consequent } = shim,
|
|
64
|
+
labelNodes = labelNodesQuery(axiomNode),
|
|
67
65
|
consequentNode = consequentNodeQuery(axiomNode),
|
|
68
66
|
suppositionNodes = suppositionNodesQuery(axiomNode),
|
|
69
67
|
labels = labelNodes.map((labelNode) => {
|
|
@@ -4,15 +4,18 @@ import shim from "../shim";
|
|
|
4
4
|
import Combinator from "../combinator";
|
|
5
5
|
|
|
6
6
|
import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
|
|
7
|
+
import { nominalLexer, nominalParser } from "../utilities/nominal";
|
|
7
8
|
import { statementTokensFromUnqualifiedStatementTokens, unqualifiedStatementTokensFromUnqualifiedStatementString } from "../utilities/tokens";
|
|
8
9
|
import { statementNodeFromUnqualifiedStatementNode,
|
|
9
10
|
unqualifiedStatementStringFromStatementString,
|
|
10
11
|
unqualifiedStatementNodeFromUnqualifiedStatementTokens } from "../utilities/node";
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
+
const lexer = nominalLexer, ///
|
|
14
|
+
parser = nominalParser, ///
|
|
15
|
+
statementString = `(${STATEMENT_META_TYPE_NAME})`,
|
|
13
16
|
unqualifiedStatementString = unqualifiedStatementStringFromStatementString(statementString),
|
|
14
|
-
unqualifiedStatementTokens = unqualifiedStatementTokensFromUnqualifiedStatementString(unqualifiedStatementString),
|
|
15
|
-
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens),
|
|
17
|
+
unqualifiedStatementTokens = unqualifiedStatementTokensFromUnqualifiedStatementString(unqualifiedStatementString, lexer),
|
|
18
|
+
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser),
|
|
16
19
|
statementTokens = statementTokensFromUnqualifiedStatementTokens(unqualifiedStatementTokens),
|
|
17
20
|
statementNode = statementNodeFromUnqualifiedStatementNode(unqualifiedStatementNode),
|
|
18
21
|
nodeAsTokens = (node) => {
|
package/src/combinator.js
CHANGED
|
@@ -25,19 +25,19 @@ class Combinator {
|
|
|
25
25
|
return statementNode;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
verifyWhenDeclared(fileContext) {
|
|
29
29
|
let verifiedAtTopLevel;
|
|
30
30
|
|
|
31
31
|
const combinatorString = this.getString(); ///
|
|
32
32
|
|
|
33
|
-
fileContext.trace(`Verifying the '${combinatorString}' combinator
|
|
33
|
+
fileContext.trace(`Verifying the '${combinatorString}' combinator when declared...`);
|
|
34
34
|
|
|
35
|
-
const statementVerifiedAtTopLevel = this.statement.
|
|
35
|
+
const statementVerifiedAtTopLevel = this.statement.verifyWhenDeclared(fileContext);
|
|
36
36
|
|
|
37
37
|
verifiedAtTopLevel = statementVerifiedAtTopLevel; ///
|
|
38
38
|
|
|
39
39
|
if (verifiedAtTopLevel) {
|
|
40
|
-
fileContext.debug(`...verified the '${combinatorString}' combinator
|
|
40
|
+
fileContext.debug(`...verified the '${combinatorString}' combinator when declared.`);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
return verifiedAtTopLevel;
|
package/src/conclusion.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
|
-
import UnqualifiedStatement from "./statement/unqualified";
|
|
6
5
|
|
|
7
6
|
import { nodeQuery } from "./utilities/query";
|
|
8
7
|
import { unqualifiedStatementFromJSON, unqualifiedStatementToUnqualifiedStatementJSON } from "./utilities/json";
|
|
@@ -90,7 +89,8 @@ class Conclusion {
|
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
static fromConclusionNode(conclusionNode, fileContext) {
|
|
93
|
-
const
|
|
92
|
+
const { UnqualifiedStatement } = shim,
|
|
93
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(conclusionNode),
|
|
94
94
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
95
95
|
conclusion = new Conclusion(fileContext, unqualifiedStatement);
|
|
96
96
|
|
package/src/conjecture.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import Label from "./label";
|
|
5
|
-
import Proof from "./proof";
|
|
6
|
-
import Consequent from "./consequent";
|
|
7
|
-
import Supposition from "./supposition";
|
|
8
4
|
import LocalContext from "./context/local";
|
|
9
|
-
import Substitutions from "./substitutions";
|
|
10
5
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
11
6
|
|
|
12
7
|
import { stringFromLabels } from "./topLevelAssertion";
|
|
@@ -25,15 +20,15 @@ class Conjecture extends TopLevelAssertion {
|
|
|
25
20
|
|
|
26
21
|
this.fileContext.trace(`Verifying the '${conjectureString}' conjecture...`);
|
|
27
22
|
|
|
28
|
-
const
|
|
29
|
-
const
|
|
23
|
+
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
24
|
+
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
30
25
|
|
|
31
|
-
if (
|
|
26
|
+
if (labelVVerifiedWhenDeclared) {
|
|
32
27
|
return true;
|
|
33
28
|
}
|
|
34
29
|
});
|
|
35
30
|
|
|
36
|
-
if (
|
|
31
|
+
if (labelsVerifiedWhenDeclared) {
|
|
37
32
|
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
38
33
|
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
39
34
|
const suppositionVerified = supposition.verify(localContext);
|
|
@@ -48,7 +43,8 @@ class Conjecture extends TopLevelAssertion {
|
|
|
48
43
|
|
|
49
44
|
if (consequentVerified) {
|
|
50
45
|
if (this.proof !== null) {
|
|
51
|
-
const
|
|
46
|
+
const { Substitutions } = shim,
|
|
47
|
+
substitutions = Substitutions.fromNothing();
|
|
52
48
|
|
|
53
49
|
this.proof.verify(substitutions, this.consequent, localContext);
|
|
54
50
|
}
|
|
@@ -72,7 +68,8 @@ class Conjecture extends TopLevelAssertion {
|
|
|
72
68
|
static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Conjecture, json, fileContext); }
|
|
73
69
|
|
|
74
70
|
static fromConjectureNode(conjectureNode, fileContext) {
|
|
75
|
-
const
|
|
71
|
+
const { Label, Proof, Supposition, Consequent } = shim,
|
|
72
|
+
proofNode = proofNodeQuery(conjectureNode),
|
|
76
73
|
labelNodes = labelNodesQuery(conjectureNode),
|
|
77
74
|
consequentNode = consequentNodeQuery(conjectureNode),
|
|
78
75
|
suppositionNodes = suppositionNodesQuery(conjectureNode),
|
package/src/consequent.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
|
-
import UnqualifiedStatement from "./statement/unqualified";
|
|
6
5
|
|
|
7
6
|
import { nodeQuery } from "./utilities/query";
|
|
8
7
|
import { unqualifiedStatementFromJSON, unqualifiedStatementToUnqualifiedStatementJSON } from "./utilities/json";
|
|
@@ -90,7 +89,8 @@ class Consequent {
|
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
static fromConsequentNode(consequentNode, fileContext) {
|
|
93
|
-
const
|
|
92
|
+
const { UnqualifiedStatement } = shim,
|
|
93
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(consequentNode),
|
|
94
94
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
95
95
|
consequent = new Consequent(fileContext, unqualifiedStatement);
|
|
96
96
|
|
|
@@ -5,15 +5,18 @@ import Constructor from "../constructor";
|
|
|
5
5
|
|
|
6
6
|
import { OBJECT_TYPE_NAME } from "../typeNames";
|
|
7
7
|
import { stringFromTermAndType } from "../constructor";
|
|
8
|
+
import { nominalLexer, nominalParser } from "../utilities/nominal";
|
|
8
9
|
import { termTokensFromConstructorDeclarationTokens, constructorDeclarationTokensFromConstructorDeclarationString } from "../utilities/tokens";
|
|
9
10
|
import { termNodeFromConstructorDeclarationNode,
|
|
10
11
|
constructorDeclarationStringFromTermString,
|
|
11
12
|
constructorDeclarationNodeFromConstructorDeclarationTokens } from "../utilities/node";
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
+
const lexer = nominalLexer, ///
|
|
15
|
+
parser = nominalParser, ///
|
|
16
|
+
termString = `(${OBJECT_TYPE_NAME})`, ///
|
|
14
17
|
constructorDeclarationString = constructorDeclarationStringFromTermString(termString),
|
|
15
|
-
constructorDeclarationTokens = constructorDeclarationTokensFromConstructorDeclarationString(constructorDeclarationString),
|
|
16
|
-
constructorDeclarationNode = constructorDeclarationNodeFromConstructorDeclarationTokens(constructorDeclarationTokens),
|
|
18
|
+
constructorDeclarationTokens = constructorDeclarationTokensFromConstructorDeclarationString(constructorDeclarationString, lexer),
|
|
19
|
+
constructorDeclarationNode = constructorDeclarationNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser),
|
|
17
20
|
termNode = termNodeFromConstructorDeclarationNode(constructorDeclarationNode),
|
|
18
21
|
termTokens = termTokensFromConstructorDeclarationTokens(constructorDeclarationTokens),
|
|
19
22
|
nodeAsTokens = (node) => {
|
package/src/constructor.js
CHANGED
|
@@ -25,21 +25,21 @@ class Constructor {
|
|
|
25
25
|
|
|
26
26
|
getType() { return this.term.getType(); }
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
verifyWhenDeclared(fileContext) {
|
|
29
29
|
let verifiedAtTopLevel;
|
|
30
30
|
|
|
31
31
|
const constructorString = this.string; ///
|
|
32
32
|
|
|
33
|
-
fileContext.trace(`Verifying the '${constructorString}' constructor
|
|
33
|
+
fileContext.trace(`Verifying the '${constructorString}' constructor when declared...`);
|
|
34
34
|
|
|
35
|
-
const termVerifiedAtTopLevel = this.term.
|
|
35
|
+
const termVerifiedAtTopLevel = this.term.verifyWhenDeclared(fileContext);
|
|
36
36
|
|
|
37
37
|
if (termVerifiedAtTopLevel) {
|
|
38
38
|
verifiedAtTopLevel = true; ///
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (verifiedAtTopLevel) {
|
|
42
|
-
fileContext.debug(`...verified the '${constructorString}' constructor
|
|
42
|
+
fileContext.debug(`...verified the '${constructorString}' constructor when declared.`);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return verifiedAtTopLevel;
|
package/src/context/file.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
+
import metavariableUnifier from "../unifier/metavariable";
|
|
6
|
+
|
|
5
7
|
import { objectType } from "../type";
|
|
6
8
|
import { frameMetaType, referenceMetaType, statementMetaType } from "../metaType";
|
|
7
9
|
import { nodeAsTokens, nodeAsString, nodesAsString, tokensAsString } from "../utilities/string";
|
|
@@ -302,6 +304,16 @@ export default class FileContext {
|
|
|
302
304
|
return this.metavariables;
|
|
303
305
|
}
|
|
304
306
|
|
|
307
|
+
getMetavariableNames(includeRelease = true) {
|
|
308
|
+
const metavariableNames = this.metavariables.map((metavariable) => {
|
|
309
|
+
const metavariableName = metavariable.getName();
|
|
310
|
+
|
|
311
|
+
return metavariableName;
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
return metavariableNames;
|
|
315
|
+
}
|
|
316
|
+
|
|
305
317
|
setReleaseContext(releaseContext) {
|
|
306
318
|
this.releaseContext = releaseContext;
|
|
307
319
|
}
|
|
@@ -314,58 +326,6 @@ export default class FileContext {
|
|
|
314
326
|
this.tokens = tokens;
|
|
315
327
|
}
|
|
316
328
|
|
|
317
|
-
setNode(node) {
|
|
318
|
-
this.node = node;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
setTypes(types) {
|
|
322
|
-
this.types = types;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
setRules(rules) {
|
|
326
|
-
this.rules = rules;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
setAxioms(axioms) {
|
|
330
|
-
this.axioms = axioms;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
setLemmas(lemmas) {
|
|
334
|
-
this.lemmas = lemmas;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
setTheorems(theorems) {
|
|
338
|
-
this.theorems = theorems;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
setVariables(variables) {
|
|
342
|
-
this.variables = variables;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
setMetaLemmas(metaLemmas) {
|
|
346
|
-
this.metaLemmas = metaLemmas;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
setConjectures(conjectures) {
|
|
350
|
-
this.conjectures = conjectures;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
setCombinators(combinators) {
|
|
354
|
-
this.combinators = combinators;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
setConstructors(constructors) {
|
|
358
|
-
this.constructors = constructors;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
setMetatheorems(metatheorems) {
|
|
362
|
-
this.metatheorems = metatheorems;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
setMetavariables(metavariables) {
|
|
366
|
-
this.metavariables = metavariables;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
329
|
findTypeByTypeName(typeName) {
|
|
370
330
|
let types = this.getTypes();
|
|
371
331
|
|
|
@@ -436,6 +396,13 @@ export default class FileContext {
|
|
|
436
396
|
return metavariablePresent;
|
|
437
397
|
}
|
|
438
398
|
|
|
399
|
+
isMetavariablePresentByMetavariableNode(metavariableNode, localContext) {
|
|
400
|
+
const metavariable = this.findMetavariableByMetavariableNode(metavariableNode, localContext),
|
|
401
|
+
metavariablePresent = (metavariable !== null);
|
|
402
|
+
|
|
403
|
+
return metavariablePresent;
|
|
404
|
+
}
|
|
405
|
+
|
|
439
406
|
findRuleByReference(reference) {
|
|
440
407
|
const rules = this.getRules(),
|
|
441
408
|
metavariableNode = reference.getMetavariableNode(),
|
|
@@ -537,9 +504,9 @@ export default class FileContext {
|
|
|
537
504
|
findVariableByVariableName(variableName) {
|
|
538
505
|
const variables = this.getVariables(),
|
|
539
506
|
variable = variables.find((variable) => {
|
|
540
|
-
const
|
|
507
|
+
const variableNameMatches = variable.matchVariableName(variableName);
|
|
541
508
|
|
|
542
|
-
if (
|
|
509
|
+
if (variableNameMatches) {
|
|
543
510
|
return true;
|
|
544
511
|
}
|
|
545
512
|
}) || null;
|
|
@@ -547,12 +514,12 @@ export default class FileContext {
|
|
|
547
514
|
return variable;
|
|
548
515
|
}
|
|
549
516
|
|
|
550
|
-
|
|
517
|
+
findJudgementByMetavariableNode(metavariableNode) {
|
|
551
518
|
const judgements = this.getJudgements(),
|
|
552
519
|
judgement = judgements.find((judgement) => {
|
|
553
|
-
const
|
|
520
|
+
const judgementMatchesMetavariableNode = judgement.matchMetavariableNode(metavariableNode);
|
|
554
521
|
|
|
555
|
-
if (
|
|
522
|
+
if (judgementMatchesMetavariableNode) {
|
|
556
523
|
return true;
|
|
557
524
|
}
|
|
558
525
|
}) || null;
|
|
@@ -561,11 +528,28 @@ export default class FileContext {
|
|
|
561
528
|
}
|
|
562
529
|
|
|
563
530
|
findMetavariableByMetavariableName(metavariableName) {
|
|
564
|
-
const
|
|
531
|
+
const metavariableNameB = metavariableName, ///
|
|
532
|
+
metavariableNames = this.getMetavariableNames(),
|
|
533
|
+
metavariable = metavariableNames.find((metavariableName) => {
|
|
534
|
+
const metavariableNameA = metavariableName; ///
|
|
535
|
+
|
|
536
|
+
if (metavariableNameA === metavariableNameB) {
|
|
537
|
+
return true;
|
|
538
|
+
}
|
|
539
|
+
}) || null;
|
|
540
|
+
|
|
541
|
+
return metavariable;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
findMetavariableByMetavariableNode(metavariableNode, localContext) {
|
|
545
|
+
const metavariableNodeB = metavariableNode, ///
|
|
546
|
+
metavariables = this.getMetavariables(),
|
|
565
547
|
metavariable = metavariables.find((metavariable) => {
|
|
566
|
-
const
|
|
548
|
+
const metavariableA = metavariable, ///
|
|
549
|
+
metavariableNodeA = metavariableA.getNode(), ///
|
|
550
|
+
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
567
551
|
|
|
568
|
-
if (
|
|
552
|
+
if (metavariableUnified) {
|
|
569
553
|
return true;
|
|
570
554
|
}
|
|
571
555
|
}) || null;
|
|
@@ -636,18 +620,7 @@ export default class FileContext {
|
|
|
636
620
|
}
|
|
637
621
|
|
|
638
622
|
addVariable(variable) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
const variableName = variable.getName(),
|
|
642
|
-
variablePresent = this.isVariablePresentByVariableName(variableName);
|
|
643
|
-
|
|
644
|
-
if (!variablePresent) {
|
|
645
|
-
this.variables.push(variable);
|
|
646
|
-
|
|
647
|
-
variableAdded = true;
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
return variableAdded;
|
|
623
|
+
this.variables.push(variable);
|
|
651
624
|
}
|
|
652
625
|
|
|
653
626
|
addMetaLemma(metaLemma) {
|
|
@@ -671,18 +644,7 @@ export default class FileContext {
|
|
|
671
644
|
}
|
|
672
645
|
|
|
673
646
|
addMetavariable(metavariable) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
const metavariableName = metavariable.getName(),
|
|
677
|
-
metavariablePresent = this.isMetavariablePresentByMetavariableName(metavariableName);
|
|
678
|
-
|
|
679
|
-
if (!metavariablePresent) {
|
|
680
|
-
this.metavariables.push(metavariable);
|
|
681
|
-
|
|
682
|
-
metavariableAdded = true;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
return metavariableAdded;
|
|
647
|
+
this.metavariables.push(metavariable);
|
|
686
648
|
}
|
|
687
649
|
|
|
688
650
|
trace(message) { this.releaseContext.trace(message, this.filePath); }
|