occam-verify-cli 0.0.1003 → 0.0.1006
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/README.md +0 -2
- package/bin/abbreviations.js +1 -3
- package/bin/action/help.js +0 -2
- package/bin/action/verify.js +4 -24
- package/bin/defaults.js +0 -2
- package/bin/main.js +3 -4
- package/bin/options.js +0 -2
- package/bin/utilities/releaseContext.js +9 -2
- package/lib/assertion/subproof.js +106 -0
- package/lib/assignment/metavariable.js +2 -2
- package/lib/combinator.js +50 -16
- package/lib/conclusion.js +74 -14
- package/lib/context/file.js +191 -31
- package/lib/context/local.js +37 -49
- package/lib/context/release.js +25 -81
- package/lib/declaration/combinator.js +83 -0
- package/lib/derivation.js +86 -0
- package/lib/equality.js +3 -11
- package/lib/index.js +1 -1
- package/lib/judgement.js +3 -10
- package/lib/label.js +58 -16
- package/lib/log.js +3 -11
- package/lib/metaType.js +31 -19
- package/lib/metavariable.js +39 -12
- package/lib/mixins/statement/qualified/unify.js +118 -0
- package/lib/mixins/statement/unify.js +57 -0
- package/lib/mixins/statement/verify.js +184 -0
- package/lib/node/statement/combinator/bracketed.js +15 -11
- package/lib/ocmbinator/bracketed.js +52 -8
- package/lib/premise.js +109 -55
- package/lib/proof.js +91 -0
- package/lib/proofStep.js +78 -25
- package/lib/reference.js +62 -16
- package/lib/rule.js +146 -26
- package/lib/ruleNames.js +5 -5
- package/lib/statement/qualified.js +127 -0
- package/lib/statement/unqualified.js +89 -0
- package/lib/statement.js +176 -0
- package/lib/subDerivation.js +86 -0
- package/lib/subproof.js +155 -0
- package/lib/substitution/frameForMetavariable.js +14 -15
- package/lib/substitution/statementForMetavariable.js +23 -24
- package/lib/substitution/termForVariable.js +11 -12
- package/lib/substitution.js +9 -2
- package/lib/substitutions.js +14 -14
- package/lib/supposition.js +92 -61
- package/lib/unifier/statementWithCombinator.js +3 -3
- package/lib/unify/metavariableWithFrame.js +2 -2
- package/lib/unify/metavariableWithStatement.js +2 -2
- package/lib/unify/metavariableWithStatementGivenSubstitution.js +2 -2
- package/lib/unify/variableWithTerm.js +2 -2
- package/lib/utilities/node.js +13 -11
- package/lib/utilities/releaseContext.js +5 -6
- package/lib/utilities/string.js +8 -2
- package/lib/utilities/subproof.js +5 -5
- package/lib/utilities/tokens.js +10 -10
- package/lib/variable.js +1 -10
- package/lib/verifier/metaLevel.js +2 -2
- package/lib/verifier/topLevel.js +5 -5
- package/lib/verify/axiom.js +3 -5
- package/lib/verify/conjecture.js +4 -7
- package/lib/verify/consequent.js +2 -3
- package/lib/verify/declaration/combinator.js +2 -14
- package/lib/verify/declaration/metavariable.js +9 -10
- package/lib/verify/files.js +4 -4
- package/lib/verify/frame.js +12 -12
- package/lib/verify/lemma.js +4 -7
- package/lib/verify/metaLemma.js +4 -7
- package/lib/verify/metatheorem.js +4 -7
- package/lib/verify/proofStep.js +2 -31
- package/lib/verify/theorem.js +4 -7
- package/package.json +1 -1
- package/src/assertion/subproof.js +84 -0
- package/src/assignment/metavariable.js +2 -2
- package/src/combinator.js +45 -15
- package/src/conclusion.js +85 -13
- package/src/context/file.js +223 -11
- package/src/context/local.js +12 -16
- package/src/context/release.js +31 -100
- package/src/declaration/combinator.js +44 -0
- package/src/derivation.js +50 -0
- package/src/equality.js +2 -9
- package/src/index.js +0 -1
- package/src/judgement.js +2 -8
- package/src/label.js +56 -13
- package/src/log.js +2 -9
- package/src/metaType.js +26 -14
- package/src/metavariable.js +57 -9
- package/src/mixins/statement/qualified/unify.js +186 -0
- package/src/mixins/statement/unify.js +70 -0
- package/src/mixins/statement/verify.js +274 -0
- package/src/node/statement/combinator/bracketed.js +4 -3
- package/src/ocmbinator/bracketed.js +15 -12
- package/src/premise.js +138 -44
- package/src/proof.js +58 -0
- package/src/proofStep.js +92 -22
- package/src/reference.js +58 -12
- package/src/rule.js +199 -30
- package/src/ruleNames.js +1 -1
- package/src/statement/qualified.js +104 -0
- package/src/statement/unqualified.js +60 -0
- package/src/statement.js +179 -0
- package/src/subDerivation.js +52 -0
- package/src/subproof.js +99 -0
- package/src/substitution/frameForMetavariable.js +20 -17
- package/src/substitution/statementForMetavariable.js +31 -29
- package/src/substitution/termForVariable.js +15 -14
- package/src/substitution.js +8 -0
- package/src/substitutions.js +12 -13
- package/src/supposition.js +96 -51
- package/src/unifier/statementWithCombinator.js +6 -3
- package/src/unify/metavariableWithFrame.js +1 -1
- package/src/unify/metavariableWithStatement.js +1 -1
- package/src/unify/metavariableWithStatementGivenSubstitution.js +1 -1
- package/src/unify/variableWithTerm.js +1 -1
- package/src/utilities/node.js +18 -12
- package/src/utilities/releaseContext.js +5 -8
- package/src/utilities/string.js +6 -2
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/tokens.js +7 -7
- package/src/variable.js +0 -10
- package/src/verifier/metaLevel.js +3 -2
- package/src/verifier/topLevel.js +6 -4
- package/src/verify/axiom.js +1 -2
- package/src/verify/conjecture.js +2 -3
- package/src/verify/consequent.js +1 -1
- package/src/verify/declaration/combinator.js +0 -20
- package/src/verify/declaration/metavariable.js +8 -12
- package/src/verify/files.js +3 -3
- package/src/verify/frame.js +11 -11
- package/src/verify/lemma.js +2 -3
- package/src/verify/metaLemma.js +2 -3
- package/src/verify/metatheorem.js +2 -3
- package/src/verify/proofStep.js +0 -41
- package/src/verify/theorem.js +2 -3
- package/lib/tokens/combinatorStatement/bracketed.js +0 -17
- package/lib/unify/premiseWithProofStep.js +0 -41
- package/lib/unify/premisesWithProofSteps.js +0 -31
- package/lib/unify/qualifiedStatement.js +0 -136
- package/lib/unify/statementWithBracketedCombinator.js +0 -30
- package/lib/unify/statementWithCombinator.js +0 -29
- package/lib/unify/statementWithCombinators.js +0 -31
- package/lib/unify/statementWithMetaType.js +0 -24
- package/lib/verify/conclusion.js +0 -39
- package/lib/verify/derivation.js +0 -31
- package/lib/verify/label.js +0 -37
- package/lib/verify/labels.js +0 -28
- package/lib/verify/premise.js +0 -45
- package/lib/verify/premises.js +0 -28
- package/lib/verify/proof.js +0 -34
- package/lib/verify/rule.js +0 -56
- package/lib/verify/statement/qualified.js +0 -41
- package/lib/verify/statement/unqualified.js +0 -45
- package/lib/verify/statement.js +0 -219
- package/lib/verify/statementAsCombinator.js +0 -33
- package/lib/verify/statementGivenMetaType.js +0 -52
- package/lib/verify/subproof.js +0 -34
- package/lib/verify/supposition.js +0 -45
- package/lib/verify/suppositions.js +0 -28
- package/src/tokens/combinatorStatement/bracketed.js +0 -10
- package/src/unify/premiseWithProofStep.js +0 -54
- package/src/unify/premisesWithProofSteps.js +0 -23
- package/src/unify/qualifiedStatement.js +0 -208
- package/src/unify/statementWithBracketedCombinator.js +0 -22
- package/src/unify/statementWithCombinator.js +0 -22
- package/src/unify/statementWithCombinators.js +0 -23
- package/src/unify/statementWithMetaType.js +0 -14
- package/src/verify/conclusion.js +0 -40
- package/src/verify/derivation.js +0 -23
- package/src/verify/label.js +0 -34
- package/src/verify/labels.js +0 -17
- package/src/verify/premise.js +0 -49
- package/src/verify/premises.js +0 -17
- package/src/verify/proof.js +0 -31
- package/src/verify/rule.js +0 -71
- package/src/verify/statement/qualified.js +0 -40
- package/src/verify/statement/unqualified.js +0 -49
- package/src/verify/statement.js +0 -312
- package/src/verify/statementAsCombinator.js +0 -27
- package/src/verify/statementGivenMetaType.js +0 -52
- package/src/verify/subproof.js +0 -32
- package/src/verify/supposition.js +0 -49
- package/src/verify/suppositions.js +0 -17
package/src/metavariable.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { metaTypeFromJSON } from "./metaType";
|
|
4
|
+
import { metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
4
5
|
|
|
5
6
|
export default class Metavariable {
|
|
6
|
-
constructor(node, name, termType, metaType) {
|
|
7
|
+
constructor(string, node, name, termType, metaType) {
|
|
8
|
+
this.string = string;
|
|
7
9
|
this.node = node;
|
|
8
10
|
this.name = name;
|
|
9
11
|
this.termType = termType;
|
|
10
12
|
this.metaType = metaType;
|
|
11
13
|
}
|
|
12
14
|
|
|
15
|
+
getString() {
|
|
16
|
+
return this.string;
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
getNode() {
|
|
14
20
|
return this.node;
|
|
15
21
|
}
|
|
@@ -44,18 +50,60 @@ export default class Metavariable {
|
|
|
44
50
|
return metavariableNodeMatches;
|
|
45
51
|
}
|
|
46
52
|
|
|
47
|
-
|
|
48
|
-
const
|
|
53
|
+
toJSON() {
|
|
54
|
+
const metaTypeJSON = (this.metaType !== null) ?
|
|
55
|
+
this.metaType.toJSON() :
|
|
56
|
+
null,
|
|
57
|
+
string = this.string,
|
|
58
|
+
metaType = metaTypeJSON, ///
|
|
59
|
+
json = {
|
|
60
|
+
string,
|
|
61
|
+
metaType
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return json;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static fromJSON(json, fileContext) {
|
|
68
|
+
const { string } = json,
|
|
69
|
+
lexer = fileContext.getLexer(),
|
|
70
|
+
parser = fileContext.getParser(),
|
|
71
|
+
metavariableString = string, ///
|
|
72
|
+
metavariableNode = metavariableNodeFromMetavariableString(metavariableString, lexer, parser),
|
|
73
|
+
node = metavariableNode; ///
|
|
74
|
+
|
|
75
|
+
let { metaType } = json;
|
|
49
76
|
|
|
50
|
-
|
|
77
|
+
json = metaType; ///
|
|
51
78
|
|
|
52
|
-
|
|
79
|
+
metaType = metaTypeFromJSON(json, fileContext);
|
|
53
80
|
|
|
54
|
-
|
|
81
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
82
|
+
name = metavariableName, ///
|
|
83
|
+
termType = termTypeFromMetavariableNode(metavariableNode, fileContext),
|
|
84
|
+
metavariable = new Metavariable(string, node, name, termType, metaType);
|
|
85
|
+
|
|
86
|
+
return metavariable;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static fromMetavariableNode(metavariableNode, fileContext) {
|
|
90
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
91
|
+
name = metavariableName, ///
|
|
92
|
+
node = metavariableNode, ///
|
|
93
|
+
string = fileContext.nodeAsString(node),
|
|
94
|
+
termType = null,
|
|
95
|
+
metaType = null,
|
|
96
|
+
metavariable = new Metavariable(string, node, name, termType, metaType);
|
|
97
|
+
|
|
98
|
+
return metavariable;
|
|
55
99
|
}
|
|
56
100
|
|
|
57
|
-
static
|
|
58
|
-
const
|
|
101
|
+
static fromMetavariableNodeNameTermTypeAndMetaType(metavariableNode, termType, metaType, fileContext) {
|
|
102
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
103
|
+
name = metavariableName, ///
|
|
104
|
+
node = metavariableNode, ///
|
|
105
|
+
string = fileContext.nodeAsString(node),
|
|
106
|
+
metavariable = new Metavariable(string, node, name, termType, metaType);
|
|
59
107
|
|
|
60
108
|
return metavariable;
|
|
61
109
|
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import metavariableUnifier from "../../../unifier/metavariable";
|
|
4
|
+
import StatementForMetavariableSubstitution from "../../../substitution/statementForMetavariable";
|
|
5
|
+
|
|
6
|
+
import { trim } from "../../../utilities/string";
|
|
7
|
+
import { metavariableNameFromMetavariableNode } from "../../../utilities/name";
|
|
8
|
+
|
|
9
|
+
function unifyAWithRule(qualifiedStatement, substitutions, localContext) {
|
|
10
|
+
let unifiedWithRule = false;
|
|
11
|
+
|
|
12
|
+
const reference = qualifiedStatement.getReference(),
|
|
13
|
+
rule = localContext.findRuleByReference(reference);
|
|
14
|
+
|
|
15
|
+
if (rule !== null) {
|
|
16
|
+
const referenceString = reference.getString(),
|
|
17
|
+
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
18
|
+
|
|
19
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' rule...`);
|
|
20
|
+
|
|
21
|
+
const statement = qualifiedStatement.getStatement(),
|
|
22
|
+
statementUnified = rule.unifyStatement(statement, localContext);
|
|
23
|
+
|
|
24
|
+
unifiedWithRule = statementUnified; ///
|
|
25
|
+
|
|
26
|
+
if (unifiedWithRule) {
|
|
27
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' rule.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return unifiedWithRule;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function unifyAWithAxiom(qualifiedStatement, substitutions, localContext) {
|
|
35
|
+
let unifiedWithAxiom = false;
|
|
36
|
+
|
|
37
|
+
const reference = qualifiedStatement.getReference(),
|
|
38
|
+
axiom = localContext.findAxiomByReference(reference);
|
|
39
|
+
|
|
40
|
+
if (axiom !== null) {
|
|
41
|
+
const referenceString = reference.getString(),
|
|
42
|
+
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
43
|
+
|
|
44
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom...`);
|
|
45
|
+
|
|
46
|
+
const statement = qualifiedStatement.getStatement(),
|
|
47
|
+
statementUnified = axiom.unifyStatement(statement, localContext);
|
|
48
|
+
|
|
49
|
+
unifiedWithAxiom = statementUnified; ///
|
|
50
|
+
|
|
51
|
+
if (unifiedWithAxiom) {
|
|
52
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' axiom.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return unifiedWithAxiom;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function unifyAWithLemma(qualifiedStatement, substitutions, localContext) {
|
|
60
|
+
let unifiedWithLemma = false;
|
|
61
|
+
|
|
62
|
+
const reference = qualifiedStatement.getReference(),
|
|
63
|
+
lemma = localContext.findLemmaByReference(reference);
|
|
64
|
+
|
|
65
|
+
if (lemma !== null) {
|
|
66
|
+
const referenceString = reference.getString(),
|
|
67
|
+
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
68
|
+
|
|
69
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' lemma...`);
|
|
70
|
+
|
|
71
|
+
const statement = qualifiedStatement.getStatement(),
|
|
72
|
+
statementUnified = lemma.unifyStatement(statement, localContext);
|
|
73
|
+
|
|
74
|
+
unifiedWithLemma = statementUnified; ///
|
|
75
|
+
|
|
76
|
+
if (unifiedWithLemma) {
|
|
77
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' lemma.`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return unifiedWithLemma;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function unifyAWithTheorem(qualifiedStatement, substitutions, localContext) {
|
|
85
|
+
let unifiedWithTheorem = false;
|
|
86
|
+
|
|
87
|
+
const reference = qualifiedStatement.getReference(),
|
|
88
|
+
theorem = localContext.findTheoremByReference(reference);
|
|
89
|
+
|
|
90
|
+
if (theorem !== null) {
|
|
91
|
+
const referenceString = reference.getString(),
|
|
92
|
+
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
93
|
+
|
|
94
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' theorem...`);
|
|
95
|
+
|
|
96
|
+
const statement = qualifiedStatement.getStatement(),
|
|
97
|
+
statementUnified = theorem.unifyStatement(statement, localContext);
|
|
98
|
+
|
|
99
|
+
unifiedWithTheorem = statementUnified; ///
|
|
100
|
+
|
|
101
|
+
if (unifiedWithTheorem) {
|
|
102
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' theorem.`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return unifiedWithTheorem;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function unifyAWithConjecture(qualifiedStatement, substitutions, localContext) {
|
|
110
|
+
let unifiedWithConjecture = false;
|
|
111
|
+
|
|
112
|
+
const reference = qualifiedStatement.getReference(),
|
|
113
|
+
conjecture = localContext.findConjectureByReference(reference);
|
|
114
|
+
|
|
115
|
+
if (conjecture !== null) {
|
|
116
|
+
const referenceString = reference.getString(),
|
|
117
|
+
qualifiedStatementString = trim(qualifiedStatement.getString()); ///
|
|
118
|
+
|
|
119
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${referenceString}' conjecture...`);
|
|
120
|
+
|
|
121
|
+
const statement = qualifiedStatement.getStatement(),
|
|
122
|
+
statementUnified = conjecture.unifyStatement(statement, localContext);
|
|
123
|
+
|
|
124
|
+
unifiedWithConjecture = statementUnified; ///
|
|
125
|
+
|
|
126
|
+
if (unifiedWithConjecture) {
|
|
127
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${referenceString}' conjecture.`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return unifiedWithConjecture;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
|
|
135
|
+
let unifiedWithReference = false;
|
|
136
|
+
|
|
137
|
+
const reference = qualifiedStatement.getReference(),
|
|
138
|
+
metavariableNode = reference.getMetavariableNode(),
|
|
139
|
+
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
140
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
141
|
+
|
|
142
|
+
if (metavariable !== null) {
|
|
143
|
+
const statement = qualifiedStatement.getStatement(),
|
|
144
|
+
statementString = statement.getString(),
|
|
145
|
+
referenceString = reference.getString();
|
|
146
|
+
|
|
147
|
+
localContext.trace(`Unifying the '${statementString}' qualified statement with the '${referenceString}' reference...`);
|
|
148
|
+
|
|
149
|
+
const metavariableNode = metavariable.getNode(),
|
|
150
|
+
referenceMetavariableNode = reference.getMetavariableNode(),
|
|
151
|
+
metavariableNodeA = referenceMetavariableNode, ///
|
|
152
|
+
metavariableNodeB = metavariableNode, ///
|
|
153
|
+
unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
154
|
+
|
|
155
|
+
if (unified) {
|
|
156
|
+
const statementNode = statement.getNode(),
|
|
157
|
+
metavariableNode = metavariableNodeA, ///
|
|
158
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeAndMetavariableNode(statementNode, metavariableNode, localContextA, localContextB),
|
|
159
|
+
substitution = statementForMetavariableSubstitution, ///
|
|
160
|
+
localContextA = localContext, ///
|
|
161
|
+
localContextB = localContext; ///
|
|
162
|
+
|
|
163
|
+
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
164
|
+
|
|
165
|
+
unifiedWithReference = true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (unifiedWithReference) {
|
|
169
|
+
localContext.debug(`...unified the '${statementString}' qualified statement with the '${referenceString}' reference.`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return unifiedWithReference;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const unifyMixins = [
|
|
177
|
+
unifyAWithRule,
|
|
178
|
+
unifyAWithAxiom,
|
|
179
|
+
unifyAWithLemma,
|
|
180
|
+
unifyAWithTheorem,
|
|
181
|
+
unifyAWithConjecture,
|
|
182
|
+
unifyAWithReference
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
export default unifyMixins;
|
|
186
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import BracketedCombinator from "../../ocmbinator/bracketed";
|
|
4
|
+
import statementWithCombinatorUnifier from "../../unifier/statementWithCombinator";
|
|
5
|
+
|
|
6
|
+
function unifyWithBracketedCombinator(statement, assignments, stated, localContext) {
|
|
7
|
+
let unifiedWithBracketedCombinator;
|
|
8
|
+
|
|
9
|
+
const statementNode = statement.getNode(),
|
|
10
|
+
statementString = statement.getString(),
|
|
11
|
+
bracketedCombinator = BracketedCombinator.fromNothing(),
|
|
12
|
+
bracketedCombinatorStatementNode = bracketedCombinator.getStatementNode(),
|
|
13
|
+
combinatorStatementNode = bracketedCombinatorStatementNode; ///
|
|
14
|
+
|
|
15
|
+
localContext.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`);
|
|
16
|
+
|
|
17
|
+
unifiedWithBracketedCombinator = statementWithCombinatorUnifier.unify(statementNode, combinatorStatementNode, assignments, stated, localContext);
|
|
18
|
+
|
|
19
|
+
if (unifiedWithBracketedCombinator) {
|
|
20
|
+
localContext.debug(`...unified the '${statementString}' statement with the bracketed combinator.`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return unifiedWithBracketedCombinator;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function unifyWithCombinators(statement, assignments, stated, localContext) {
|
|
27
|
+
let unifiedWithCombinators;
|
|
28
|
+
|
|
29
|
+
const combinators = localContext.getCombinators();
|
|
30
|
+
|
|
31
|
+
assignments = null; ///
|
|
32
|
+
|
|
33
|
+
stated = true; ///
|
|
34
|
+
|
|
35
|
+
unifiedWithCombinators = combinators.some((combinator) => {
|
|
36
|
+
const unifiedWithCombinator = unifyStatementWithCombinator(statement, combinator, assignments, stated, localContext);
|
|
37
|
+
|
|
38
|
+
if (unifiedWithCombinator) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return unifiedWithCombinators;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const unifyMixins = [
|
|
47
|
+
unifyWithBracketedCombinator,
|
|
48
|
+
unifyWithCombinators
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
export default unifyMixins;
|
|
52
|
+
|
|
53
|
+
function unifyStatementWithCombinator(statement, combinator, assignments, stated, localContext) {
|
|
54
|
+
let unifiedWithCombinator;
|
|
55
|
+
|
|
56
|
+
const statementNode = statement.getNode(),
|
|
57
|
+
statementString = statement.getString(),
|
|
58
|
+
combinatorString = combinator.getString(),
|
|
59
|
+
combinatorStatementNode = combinator.getStatementNode();
|
|
60
|
+
|
|
61
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${combinatorString}' combinator...`);
|
|
62
|
+
|
|
63
|
+
unifiedWithCombinator = statementWithCombinatorUnifier.unify(statementNode, combinatorStatementNode, assignments, stated, localContext);
|
|
64
|
+
|
|
65
|
+
if (unifiedWithCombinator) {
|
|
66
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${combinatorString}' combinator.`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return unifiedWithCombinator;
|
|
70
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifyFrame from "../../verify/frame";
|
|
4
|
+
import verifyEquality from "../../verify/equality";
|
|
5
|
+
import verifyJudgement from "../../verify/judgement";
|
|
6
|
+
import verifyDeclaration from "../../verify/declaration";
|
|
7
|
+
import verifyTypeAssertion from "../../verify/assertion/type";
|
|
8
|
+
import metavariableUnifier from "../../unifier/metavariable";
|
|
9
|
+
import verifyDefinedAssertion from "../../verify/assertion/defined";
|
|
10
|
+
import verifySubproofAssertion from "../../verify/assertion/subproof";
|
|
11
|
+
import verifyContainedAssertion from "../../verify/assertion/contained";
|
|
12
|
+
|
|
13
|
+
import { nodeQuery } from "../../utilities/query";
|
|
14
|
+
import { metavariableNameFromMetavariableNode } from "../../utilities/name";
|
|
15
|
+
|
|
16
|
+
const frameNodeQuery = nodeQuery("/statement/frame!"),
|
|
17
|
+
equalityNodeQuery = nodeQuery("/statement/equality!"),
|
|
18
|
+
judgementNodeQuery = nodeQuery("/statement/judgement!"),
|
|
19
|
+
declarationNodeQuery = nodeQuery("/statement/declaration!"),
|
|
20
|
+
metavariableNodeQuery = nodeQuery("/statement/metavariable!"),
|
|
21
|
+
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!"),
|
|
22
|
+
definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion!"),
|
|
23
|
+
subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
24
|
+
containedAssertionNodeQuery = nodeQuery("/statement/containedAssertion!");
|
|
25
|
+
|
|
26
|
+
function verifyAsMetavariable(statement, assignments, stated, localContext) {
|
|
27
|
+
let verifiedAsMetavariable = false;
|
|
28
|
+
|
|
29
|
+
const statementNode = statement.getNode(),
|
|
30
|
+
metavariableNode = metavariableNodeQuery(statementNode);
|
|
31
|
+
|
|
32
|
+
if (metavariableNode !== null) {
|
|
33
|
+
const statementString = statement.getString();
|
|
34
|
+
|
|
35
|
+
localContext.trace(`Verifying the '${statementString}' statement as a metavariable...`);
|
|
36
|
+
|
|
37
|
+
const metavariableUnified = unifyMetavariable(metavariableNode, localContext);
|
|
38
|
+
|
|
39
|
+
verifiedAsMetavariable = metavariableUnified; ///
|
|
40
|
+
|
|
41
|
+
if (verifiedAsMetavariable) {
|
|
42
|
+
localContext.debug(`...verified the '${statementString}' statement as a metavariable.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return verifiedAsMetavariable;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function verifyAsEquality(statement, assignments, stated, localContext) {
|
|
50
|
+
let verifiedAsEquality = false;
|
|
51
|
+
|
|
52
|
+
const statementNode = statement.getNode(),
|
|
53
|
+
equalityNode = equalityNodeQuery(statementNode);
|
|
54
|
+
|
|
55
|
+
if (equalityNode !== null) {
|
|
56
|
+
const statementString = statement.getString();
|
|
57
|
+
|
|
58
|
+
localContext.trace(`Verifying the '${statementString}' statement as an equality...`);
|
|
59
|
+
|
|
60
|
+
const equalityVerified = verifyEquality(equalityNode, assignments, stated, localContext);
|
|
61
|
+
|
|
62
|
+
verifiedAsEquality = equalityVerified; ///
|
|
63
|
+
|
|
64
|
+
if (verifiedAsEquality) {
|
|
65
|
+
localContext.debug(`...verified the '${statementString}' statement as an equality.`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return verifiedAsEquality;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function verifyAsFrame(statement, assignments, stated, localContext) {
|
|
73
|
+
let verifiedAsFrame = false;
|
|
74
|
+
|
|
75
|
+
const statementNode = statement.getNode(),
|
|
76
|
+
frameNode = frameNodeQuery(statementNode);
|
|
77
|
+
|
|
78
|
+
if (frameNode !== null) {
|
|
79
|
+
const statementString = statement.getString();
|
|
80
|
+
|
|
81
|
+
localContext.trace(`Verifying the '${statementString}' statement as a frame...`);
|
|
82
|
+
|
|
83
|
+
const frameVerified = verifyFrame(frameNode, assignments, stated, localContext);
|
|
84
|
+
|
|
85
|
+
verifiedAsFrame = frameVerified; ///
|
|
86
|
+
|
|
87
|
+
if (verifiedAsFrame) {
|
|
88
|
+
localContext.debug(`...verified the '${statementString}' statement as a frame.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return verifiedAsFrame;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
96
|
+
let verifiedAsJudgement = false;
|
|
97
|
+
|
|
98
|
+
const statementNode = statement.getNode(),
|
|
99
|
+
judgementNode = judgementNodeQuery(statementNode);
|
|
100
|
+
|
|
101
|
+
if (judgementNode !== null) {
|
|
102
|
+
const statementString = statement.getString();
|
|
103
|
+
|
|
104
|
+
localContext.trace(`Verifying the '${statementString}' statement as a judgement...`);
|
|
105
|
+
|
|
106
|
+
const judgementVerified = verifyJudgement(judgementNode, assignments, stated, localContext);
|
|
107
|
+
|
|
108
|
+
verifiedAsJudgement = judgementVerified; ///
|
|
109
|
+
|
|
110
|
+
if (verifiedAsJudgement) {
|
|
111
|
+
localContext.debug(`...verified the '${statementString}' statement as a judgement.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return verifiedAsJudgement;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function verifyAsDeclaration(statement, assignments, stated, localContext) {
|
|
119
|
+
let verifiedAsDeclaration = false;
|
|
120
|
+
|
|
121
|
+
const statementNode = statement.getNode(),
|
|
122
|
+
declarationNode = declarationNodeQuery(statementNode);
|
|
123
|
+
|
|
124
|
+
if (declarationNode !== null) {
|
|
125
|
+
const statementString = statement.getString();
|
|
126
|
+
|
|
127
|
+
localContext.trace(`Verifying the '${statementString}' statement as a declaration...`);
|
|
128
|
+
|
|
129
|
+
const declarationVerified = verifyDeclaration(declarationNode, assignments, stated, localContext);
|
|
130
|
+
|
|
131
|
+
verifiedAsDeclaration = declarationVerified; ///
|
|
132
|
+
|
|
133
|
+
if (verifiedAsDeclaration) {
|
|
134
|
+
localContext.debug(`...verified the '${statementString}' statement as a declaration.`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return verifiedAsDeclaration;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function verifyAsTypeAssertion(statement, assignments, stated, localContext) {
|
|
142
|
+
let verifiedAsTypeAssertion = false;
|
|
143
|
+
|
|
144
|
+
const statementNode = statement.getNode(),
|
|
145
|
+
typeAssertionNode = typeAssertionNodeQuery(statementNode);
|
|
146
|
+
|
|
147
|
+
if (typeAssertionNode !== null) {
|
|
148
|
+
const statementString = statement.getString();
|
|
149
|
+
|
|
150
|
+
localContext.trace(`Verifying the '${statementString}' statement as a type assertion...`);
|
|
151
|
+
|
|
152
|
+
const typeAssertionVerified = verifyTypeAssertion(typeAssertionNode, assignments, stated, localContext);
|
|
153
|
+
|
|
154
|
+
verifiedAsTypeAssertion = typeAssertionVerified; ///
|
|
155
|
+
|
|
156
|
+
if (verifiedAsTypeAssertion) {
|
|
157
|
+
localContext.debug(`...verified the '${statementString}' statement as a type assertion.`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return verifiedAsTypeAssertion;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function verifyAsDefinedAssertion(statement, assignments, stated, localContext) {
|
|
165
|
+
let verifiedAsDefinedAssertion = false;
|
|
166
|
+
|
|
167
|
+
const statementNode = statement.getNode(),
|
|
168
|
+
definedAssertionNode = definedAssertionNodeQuery(statementNode);
|
|
169
|
+
|
|
170
|
+
if (definedAssertionNode !== null) {
|
|
171
|
+
const statementString = statement.getString();
|
|
172
|
+
|
|
173
|
+
localContext.trace(`Verifying the '${statementString}' statement as a defined assertion...`);
|
|
174
|
+
|
|
175
|
+
const definedAssertionVerified = verifyDefinedAssertion(definedAssertionNode, assignments, stated, localContext);
|
|
176
|
+
|
|
177
|
+
verifiedAsDefinedAssertion = definedAssertionVerified; ///
|
|
178
|
+
|
|
179
|
+
if (verifiedAsDefinedAssertion) {
|
|
180
|
+
localContext.debug(`...verified the '${statementString}' statement as a defined assertion.`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return verifiedAsDefinedAssertion;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function verifyAsSubproofAssertion(statement, assignments, stated, localContext) {
|
|
188
|
+
let verifiedAsSubproofAssertion = false;
|
|
189
|
+
|
|
190
|
+
const statementNode = statement.getNode(),
|
|
191
|
+
subproofAssertionNode = subproofAssertionNodeQuery(statementNode);
|
|
192
|
+
|
|
193
|
+
if (subproofAssertionNode !== null) {
|
|
194
|
+
const statementString = statement.getString();
|
|
195
|
+
|
|
196
|
+
localContext.trace(`Verifying the '${statementString}' statement as a subproof assertion...`);
|
|
197
|
+
|
|
198
|
+
const subproofAssertionVerified = verifySubproofAssertion(subproofAssertionNode, assignments, stated, localContext);
|
|
199
|
+
|
|
200
|
+
verifiedAsSubproofAssertion = subproofAssertionVerified; ///
|
|
201
|
+
|
|
202
|
+
if (verifiedAsSubproofAssertion) {
|
|
203
|
+
localContext.debug(`...verified the '${statementString}' statement as a subproof assertion.`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return verifiedAsSubproofAssertion;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function verifyAsContainedAssertion(statement, assignments, stated, localContext) {
|
|
211
|
+
let verifiedAsContainedAssertion = false;
|
|
212
|
+
|
|
213
|
+
const statementNode = statement.getNode(),
|
|
214
|
+
containedAssertionNode = containedAssertionNodeQuery(statementNode);
|
|
215
|
+
|
|
216
|
+
if (containedAssertionNode !== null) {
|
|
217
|
+
const statementString = statement.getString();
|
|
218
|
+
|
|
219
|
+
localContext.trace(`Verifying the '${statementString}' statement as a contained assertion...`);
|
|
220
|
+
|
|
221
|
+
const containedAssertionVerified = verifyContainedAssertion(containedAssertionNode, assignments, stated, localContext);
|
|
222
|
+
|
|
223
|
+
verifiedAsContainedAssertion = containedAssertionVerified; ///
|
|
224
|
+
|
|
225
|
+
if (verifiedAsContainedAssertion) {
|
|
226
|
+
localContext.debug(`...verified the '${statementString}' statement as a contained assertion.`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return verifiedAsContainedAssertion;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const verifyMixins = [
|
|
234
|
+
verifyAsMetavariable,
|
|
235
|
+
verifyAsEquality,
|
|
236
|
+
verifyAsFrame,
|
|
237
|
+
verifyAsJudgement,
|
|
238
|
+
verifyAsDeclaration,
|
|
239
|
+
verifyAsTypeAssertion,
|
|
240
|
+
verifyAsDefinedAssertion,
|
|
241
|
+
verifyAsSubproofAssertion,
|
|
242
|
+
verifyAsContainedAssertion
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
export default verifyMixins;
|
|
246
|
+
|
|
247
|
+
function unifyMetavariable(metavariableNode, localContext) {
|
|
248
|
+
let metavariableUnified;
|
|
249
|
+
|
|
250
|
+
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
251
|
+
|
|
252
|
+
localContext.trace(`Unifying the '${metavariableString}' metavariable...`);
|
|
253
|
+
|
|
254
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
255
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
256
|
+
|
|
257
|
+
if (metavariable !== null) {
|
|
258
|
+
const metavariableNodeA = metavariableNode; ///
|
|
259
|
+
|
|
260
|
+
metavariableNode = metavariable.getNode();
|
|
261
|
+
|
|
262
|
+
const metavariableNodeB = metavariableNode; ///
|
|
263
|
+
|
|
264
|
+
const unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
265
|
+
|
|
266
|
+
metavariableUnified = unified; ///
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (metavariableUnified) {
|
|
270
|
+
localContext.debug(`...unified the '${metavariableString}' metavariable.`);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return metavariableUnified;
|
|
274
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { STATEMENT_META_TYPE_NAME } from "../../../metaTypeNames";
|
|
4
|
+
import { statementNodeFromStatementString } from "../../../utilities/node";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
export const bracketedCombinatorStatementString = `(${STATEMENT_META_TYPE_NAME})`;
|
|
6
7
|
|
|
7
|
-
const bracketedCombinatorStatementNode =
|
|
8
|
+
const bracketedCombinatorStatementNode = statementNodeFromStatementString(bracketedCombinatorStatementString)
|
|
8
9
|
|
|
9
10
|
export default bracketedCombinatorStatementNode;
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "../shim";
|
|
3
4
|
import Combinator from "../combinator";
|
|
4
5
|
import bracketedCombinatorStatementNode from "../node/statement/combinator/bracketed";
|
|
5
|
-
import bracketedCombinatorStatementTokens from "../tokens/combinatorStatement/bracketed";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { bracketedCombinatorStatementString } from "../node/statement/combinator/bracketed";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const localContext = {
|
|
10
|
+
nodeAsString: (node) => {
|
|
11
|
+
const string = bracketedCombinatorStatementString; ///
|
|
12
|
+
|
|
13
|
+
return string;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default class BracketedCombinator extends Combinator {
|
|
10
18
|
static fromNothing() {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
bracketedCombinator = new BracketedCombinator(statementNode, string);
|
|
19
|
+
const { Statement } = shim,
|
|
20
|
+
statementNode = bracketedCombinatorStatementNode, ///
|
|
21
|
+
statement = Statement.fromStatementNode(statementNode, localContext),
|
|
22
|
+
bracketedCombinator = new BracketedCombinator(statement);
|
|
16
23
|
|
|
17
24
|
return bracketedCombinator;
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
|
-
|
|
21
|
-
const bracketedCombinator = BracketedCombinator.fromNothing();
|
|
22
|
-
|
|
23
|
-
export default bracketedCombinator;
|