occam-verify-cli 0.0.1094 → 0.0.1096
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 +21 -5
- package/lib/assertion/defined.js +11 -4
- package/lib/assertion/subproof.js +16 -10
- package/lib/axiom.js +4 -4
- package/lib/combinator/bracketed.js +5 -28
- package/lib/conclusion.js +7 -1
- package/lib/conjecture.js +4 -4
- package/lib/consequent.js +7 -1
- package/lib/constructor/bracketed.js +5 -28
- package/lib/context/bracketed/combinator.js +118 -0
- package/lib/context/bracketed/constructor.js +118 -0
- package/lib/context/bracketted.js +98 -0
- package/lib/context/file.js +44 -40
- package/lib/context/local.js +13 -13
- package/lib/declaration.js +122 -7
- package/lib/frame.js +26 -16
- package/lib/judgement.js +8 -23
- package/lib/label.js +8 -9
- package/lib/lemma.js +4 -4
- package/lib/metaLemma.js +41 -7
- package/lib/metatheorem.js +37 -2
- package/lib/metavariable.js +13 -13
- package/lib/mixins/statement/qualified/unify.js +2 -2
- package/lib/nodeAndTokens/metavariable.js +5 -6
- package/lib/nodeAndTokens/statement.js +7 -20
- package/lib/nodeAndTokens/substitution/frame.js +4 -5
- package/lib/nodeAndTokens/substitution/statement.js +4 -5
- package/lib/nodeAndTokens/substitution/term.js +4 -5
- package/lib/nodeAndTokens/term.js +5 -6
- package/lib/nodeAndTokens/variable.js +5 -6
- package/lib/premise.js +9 -3
- package/lib/reference.js +23 -9
- package/lib/rule.js +13 -7
- package/lib/statement/qualified.js +4 -3
- package/lib/statement/unqualified.js +29 -23
- package/lib/statement.js +9 -7
- package/lib/substitution/frame.js +2 -2
- package/lib/substitution/statement.js +4 -4
- package/lib/substitution/term.js +2 -2
- package/lib/substitutions.js +9 -2
- package/lib/topLevelAssertion.js +13 -25
- package/lib/unifier/equality.js +5 -5
- package/lib/unifier/label.js +146 -0
- package/lib/unifier/metaLevel.js +7 -7
- package/lib/unifier.js +4 -4
- package/lib/variable.js +8 -5
- package/package.json +1 -1
- package/src/assertion/contained.js +22 -6
- package/src/assertion/defined.js +11 -5
- package/src/assertion/subproof.js +17 -12
- package/src/axiom.js +3 -2
- package/src/combinator/bracketed.js +5 -41
- package/src/conclusion.js +2 -0
- package/src/conjecture.js +3 -2
- package/src/consequent.js +2 -0
- package/src/constructor/bracketed.js +5 -40
- package/src/context/bracketed/combinator.js +23 -0
- package/src/context/bracketed/constructor.js +23 -0
- package/src/context/bracketted.js +61 -0
- package/src/context/file.js +57 -48
- package/src/context/local.js +4 -4
- package/src/declaration.js +130 -6
- package/src/frame.js +30 -15
- package/src/judgement.js +7 -35
- package/src/label.js +3 -14
- package/src/lemma.js +3 -2
- package/src/metaLemma.js +60 -12
- package/src/metatheorem.js +56 -2
- package/src/metavariable.js +19 -13
- package/src/mixins/statement/qualified/unify.js +3 -1
- package/src/nodeAndTokens/metavariable.js +3 -7
- package/src/nodeAndTokens/statement.js +1 -13
- package/src/nodeAndTokens/substitution/frame.js +1 -6
- package/src/nodeAndTokens/substitution/statement.js +1 -6
- package/src/nodeAndTokens/substitution/term.js +1 -6
- package/src/nodeAndTokens/term.js +3 -7
- package/src/nodeAndTokens/variable.js +3 -7
- package/src/premise.js +15 -3
- package/src/reference.js +30 -19
- package/src/rule.js +7 -5
- package/src/statement/qualified.js +3 -3
- package/src/statement/unqualified.js +32 -30
- package/src/statement.js +9 -9
- package/src/substitution/frame.js +1 -2
- package/src/substitution/statement.js +3 -6
- package/src/substitution/term.js +1 -2
- package/src/substitutions.js +7 -1
- package/src/topLevelAssertion.js +10 -22
- package/src/unifier/equality.js +14 -16
- package/src/unifier/label.js +57 -0
- package/src/unifier/metaLevel.js +6 -6
- package/src/unifier.js +4 -4
- package/src/variable.js +13 -7
- package/lib/unifier/intrinsicLevel.js +0 -149
- package/src/unifier/intrinsicLevel.js +0 -61
package/src/metaLemma.js
CHANGED
|
@@ -1,31 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
+
import LocalContext from "./context/local";
|
|
4
5
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
5
6
|
|
|
6
|
-
import { EMPTY_STRING } from "./constants";
|
|
7
|
-
|
|
8
7
|
class MetaLemma extends TopLevelAssertion {
|
|
8
|
+
unifyReference(reference, substitutions, context) {
|
|
9
|
+
let referenceUnified;
|
|
10
|
+
|
|
11
|
+
const metaLemma = this, ///
|
|
12
|
+
referenceString = reference.getString(),
|
|
13
|
+
metaLemmaString = metaLemma.getString();
|
|
14
|
+
|
|
15
|
+
context.trace(`Unifying the '${referenceString}' reference with the '${metaLemmaString}' meta-lemma...`);
|
|
16
|
+
|
|
17
|
+
const fileContext = this.getFileContext(),
|
|
18
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
19
|
+
generalContext = localContext, ///
|
|
20
|
+
specificContext = context, ///
|
|
21
|
+
labelUnified = this.labels.some((label) => {
|
|
22
|
+
substitutions.clear();
|
|
23
|
+
|
|
24
|
+
const referenceUnified = reference.unifyLabel(label, substitutions, generalContext, specificContext);
|
|
25
|
+
|
|
26
|
+
if (referenceUnified) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
referenceUnified = labelUnified; ///
|
|
32
|
+
|
|
33
|
+
if (referenceUnified) {
|
|
34
|
+
context.debug(`...unified the '${referenceString}' reference with the '${metaLemmaString}' meta-lemma.`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return referenceUnified;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
unifyStatement(statement, substitutions, context) {
|
|
41
|
+
let statementUnified;
|
|
42
|
+
|
|
43
|
+
const metaLemma = this, ///
|
|
44
|
+
statementString = statement.getString(),
|
|
45
|
+
metaLemmaString = metaLemma.getString();
|
|
46
|
+
|
|
47
|
+
context.trace(`Unifying the '${statementString}' reference with the '${metaLemmaString}' meta-lemma...`);
|
|
48
|
+
|
|
49
|
+
const consequent = this.getConsequent();
|
|
50
|
+
|
|
51
|
+
statementUnified = consequent.unifyStatement(statement, substitutions, context);
|
|
52
|
+
|
|
53
|
+
if (statementUnified) {
|
|
54
|
+
context.debug(`...unified the '${statementString}' reference with the '${metaLemmaString}' meta-lemma.`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return statementUnified;
|
|
58
|
+
}
|
|
59
|
+
|
|
9
60
|
verify() {
|
|
10
61
|
let verified;
|
|
11
62
|
|
|
12
|
-
const
|
|
13
|
-
|
|
63
|
+
const metaLemma = this, ///
|
|
64
|
+
fileContext = this.getFileContext(),
|
|
65
|
+
metaLemmaString = metaLemma.getString();
|
|
14
66
|
|
|
15
|
-
(metaLemmaString
|
|
16
|
-
fileContext.trace(`Verifying a meta-lemma...`) :
|
|
17
|
-
fileContext.trace(`Verifying the '${metaLemmaString}' meta-lemma...`);
|
|
67
|
+
fileContext.trace(`Verifying the '${metaLemmaString}' meta-lemma...`);
|
|
18
68
|
|
|
19
69
|
verified = super.verify();
|
|
20
70
|
|
|
21
71
|
if (verified) {
|
|
22
|
-
const
|
|
72
|
+
const metaTheorem = this; ///
|
|
23
73
|
|
|
24
|
-
fileContext.
|
|
74
|
+
fileContext.addMetatheorem(metaTheorem);
|
|
25
75
|
|
|
26
|
-
(metaLemmaString
|
|
27
|
-
fileContext.debug(`...verified a meta-lemma.`) :
|
|
28
|
-
fileContext.debug(`...verified the '${metaLemmaString}' meta-lemma.`);
|
|
76
|
+
fileContext.debug(`...verified the '${metaLemmaString}' meta-lemma.`);
|
|
29
77
|
}
|
|
30
78
|
|
|
31
79
|
return verified;
|
package/src/metatheorem.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
+
import LocalContext from "./context/local";
|
|
4
5
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
5
6
|
|
|
6
7
|
import { stringFromLabels } from "./topLevelAssertion";
|
|
@@ -14,11 +15,64 @@ import { labelsFromJSON,
|
|
|
14
15
|
substitutionsToSubstitutionsJSON } from "./utilities/json";
|
|
15
16
|
|
|
16
17
|
class Metatheorem extends TopLevelAssertion {
|
|
18
|
+
unifyReference(reference, substitutions, context) {
|
|
19
|
+
let referenceUnified;
|
|
20
|
+
|
|
21
|
+
const metatheorem = this, ///
|
|
22
|
+
referenceString = reference.getString(),
|
|
23
|
+
metatheoremString = metatheorem.getString();
|
|
24
|
+
|
|
25
|
+
context.trace(`Unifying the '${referenceString}' reference with the '${metatheoremString}' metatheorem...`);
|
|
26
|
+
|
|
27
|
+
const fileContext = this.getFileContext(),
|
|
28
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
29
|
+
generalContext = localContext, ///
|
|
30
|
+
specificContext = context, ///
|
|
31
|
+
labelUnified = this.labels.some((label) => {
|
|
32
|
+
substitutions.clear();
|
|
33
|
+
|
|
34
|
+
const referenceUnified = reference.unifyLabel(label, substitutions, generalContext, specificContext);
|
|
35
|
+
|
|
36
|
+
if (referenceUnified) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
referenceUnified = labelUnified; ///
|
|
42
|
+
|
|
43
|
+
if (referenceUnified) {
|
|
44
|
+
context.debug(`...unified the '${referenceString}' reference with the '${metatheoremString}' metatheorem.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return referenceUnified;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
unifyStatement(statement, substitutions, context) {
|
|
51
|
+
let statementUnified;
|
|
52
|
+
|
|
53
|
+
const metatheorem = this, ///
|
|
54
|
+
statementString = statement.getString(),
|
|
55
|
+
metatheoremString = metatheorem.getString();
|
|
56
|
+
|
|
57
|
+
context.trace(`Unifying the '${statementString}' reference with the '${metatheoremString}' metatheorem...`);
|
|
58
|
+
|
|
59
|
+
const consequent = this.getConsequent();
|
|
60
|
+
|
|
61
|
+
statementUnified = consequent.unifyStatement(statement, substitutions, context);
|
|
62
|
+
|
|
63
|
+
if (statementUnified) {
|
|
64
|
+
context.debug(`...unified the '${statementString}' reference with the '${metatheoremString}' metatheorem.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return statementUnified;
|
|
68
|
+
}
|
|
69
|
+
|
|
17
70
|
verify() {
|
|
18
71
|
let verified;
|
|
19
72
|
|
|
20
|
-
const
|
|
21
|
-
|
|
73
|
+
const metatheorem = this, ///
|
|
74
|
+
fileContext = this.getFileContext(),
|
|
75
|
+
metatheoremString = metatheorem.getString();
|
|
22
76
|
|
|
23
77
|
fileContext.trace(`Verifying the '${metatheoremString}' metatheorem...`);
|
|
24
78
|
|
package/src/metavariable.js
CHANGED
|
@@ -71,14 +71,14 @@ class Metavariable {
|
|
|
71
71
|
return metavariableNodeMatches;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
unifyFrame(frame, substitutions,
|
|
74
|
+
unifyFrame(frame, substitutions, context) {
|
|
75
75
|
let frameUnified = false;
|
|
76
76
|
|
|
77
77
|
const frameNode = frame.getNode(),
|
|
78
78
|
frameString = frame.getString(),
|
|
79
79
|
metavariableString = this.string; ///
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
context.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
82
82
|
|
|
83
83
|
const metavariableNode = this.node, ///
|
|
84
84
|
simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableNode(metavariableNode);
|
|
@@ -92,7 +92,10 @@ class Metavariable {
|
|
|
92
92
|
frameUnified = true;
|
|
93
93
|
}
|
|
94
94
|
} else {
|
|
95
|
-
const
|
|
95
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
96
|
+
generalContext = localContext, ///
|
|
97
|
+
specificContext = context, ///
|
|
98
|
+
metavariableNode = this.node, ///
|
|
96
99
|
metavariable = metavariableFromMetavariableNode(metavariableNode, generalContext, specificContext),
|
|
97
100
|
frameMetavariable = frameMetavariableFromStatementNode(frameNode, generalContext, specificContext);
|
|
98
101
|
|
|
@@ -100,7 +103,6 @@ class Metavariable {
|
|
|
100
103
|
frameUnified = true;
|
|
101
104
|
} else {
|
|
102
105
|
const metavariable = this, ///
|
|
103
|
-
context = specificContext, ///
|
|
104
106
|
frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, context),
|
|
105
107
|
substitution = frameSubstitution; ///
|
|
106
108
|
|
|
@@ -111,13 +113,13 @@ class Metavariable {
|
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
if (frameUnified) {
|
|
114
|
-
|
|
116
|
+
context.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
return frameUnified;
|
|
118
120
|
}
|
|
119
121
|
|
|
120
|
-
unifyStatement(statement, substitution, substitutions,
|
|
122
|
+
unifyStatement(statement, substitution, substitutions, context) {
|
|
121
123
|
let statementUnified = false;
|
|
122
124
|
|
|
123
125
|
const statementString = statement.getString(),
|
|
@@ -126,7 +128,7 @@ class Metavariable {
|
|
|
126
128
|
substitution.getString() :
|
|
127
129
|
EMPTY_STRING;
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
context.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
|
|
130
132
|
|
|
131
133
|
const statementNode = statement.getNode(),
|
|
132
134
|
metavariableNode = this.node, ///
|
|
@@ -143,15 +145,17 @@ class Metavariable {
|
|
|
143
145
|
statementUnified = true;
|
|
144
146
|
}
|
|
145
147
|
} else {
|
|
146
|
-
const
|
|
148
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
149
|
+
generalContext = localContext, ///
|
|
150
|
+
specificContext = context, ///
|
|
151
|
+
metavariableNode = this.node, ///
|
|
147
152
|
metavariable = metavariableFromMetavariableNode(metavariableNode, generalContext, specificContext),
|
|
148
153
|
statementMetavariable = statementMetavariableFromStatementNode(statementNode, generalContext, specificContext);
|
|
149
154
|
|
|
150
155
|
if ((metavariable !== null) && (metavariable === statementMetavariable)) {
|
|
151
156
|
statementUnified = true;
|
|
152
157
|
} else {
|
|
153
|
-
const
|
|
154
|
-
metavariable = this, ///
|
|
158
|
+
const metavariable = this, ///
|
|
155
159
|
statementSubstitution = StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context);
|
|
156
160
|
|
|
157
161
|
substitution = statementSubstitution; ///
|
|
@@ -163,7 +167,7 @@ class Metavariable {
|
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
if (statementUnified) {
|
|
166
|
-
|
|
170
|
+
context.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
return statementUnified;
|
|
@@ -201,7 +205,9 @@ class Metavariable {
|
|
|
201
205
|
context.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
202
206
|
|
|
203
207
|
const metavariableNode = this.node,
|
|
204
|
-
|
|
208
|
+
generalContext = context, ///
|
|
209
|
+
specificContext = context, ///
|
|
210
|
+
metavariablePresent = generalContext.isMetavariablePresentByMetavariableNode(metavariableNode, specificContext);
|
|
205
211
|
|
|
206
212
|
verified = metavariablePresent; ///
|
|
207
213
|
|
|
@@ -374,7 +380,7 @@ function statementMetavariableFromStatementNode(statementNode, generalContext, s
|
|
|
374
380
|
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
|
|
375
381
|
|
|
376
382
|
if (statementMetavariableNode !== null) {
|
|
377
|
-
const context = generalContext;
|
|
383
|
+
const context = generalContext; ///
|
|
378
384
|
|
|
379
385
|
statementMetavariable = context.findMetavariableByMetavariableNode(statementMetavariableNode, specificContext);
|
|
380
386
|
}
|
|
@@ -33,8 +33,10 @@ function unifyAWithReference(qualifiedStatement, substitutions, context) {
|
|
|
33
33
|
let unifiedWithReference = false;
|
|
34
34
|
|
|
35
35
|
const reference = qualifiedStatement.getReference(),
|
|
36
|
+
generalContext = context, ///
|
|
37
|
+
specificContext = context, ///
|
|
36
38
|
metavariableNode = reference.getMetavariableNode(),
|
|
37
|
-
metavariablePresent =
|
|
39
|
+
metavariablePresent = generalContext.isMetavariablePresentByMetavariableNode(metavariableNode, specificContext);
|
|
38
40
|
|
|
39
41
|
if (metavariablePresent) {
|
|
40
42
|
const statement = qualifiedStatement.getStatement(),
|
|
@@ -33,16 +33,12 @@ export default class MetavariableNodeAndTokens extends NodeAndTokens {
|
|
|
33
33
|
return metavariableNodeAndTokens;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
static
|
|
37
|
-
const string = metavariableString, ///
|
|
38
|
-
metavariableNodeAndTokens = NodeAndTokens.fromString(MetavariableNodeAndTokens, string, context);
|
|
39
|
-
|
|
40
|
-
return metavariableNodeAndTokens;
|
|
41
|
-
}
|
|
36
|
+
static fromString(string, context) { return NodeAndTokens.fromString(MetavariableNodeAndTokens, string, context); }
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
export function metavariableNodeFromMetavariableString(metavariableString, context) {
|
|
45
|
-
const
|
|
40
|
+
const string = metavariableString, ///
|
|
41
|
+
metavariableNodeAndTokens = MetavariableNodeAndTokens.fromString(string, context),
|
|
46
42
|
metavariableNode = metavariableNodeAndTokens.getMetavariableNode();
|
|
47
43
|
|
|
48
44
|
return metavariableNode;
|
|
@@ -33,17 +33,5 @@ export default class StatementNodeAndTokens extends NodeAndTokens {
|
|
|
33
33
|
return statementNodeAndTokens;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
static
|
|
37
|
-
const string = statementString, ///
|
|
38
|
-
statementNodeAndTokens = NodeAndTokens.fromString(StatementNodeAndTokens, string, context);
|
|
39
|
-
|
|
40
|
-
return statementNodeAndTokens;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function statementNodeFromStatementString(statementString, context) {
|
|
45
|
-
const statementNodeAndTokens = StatementNodeAndTokens.fromStatementString(statementString, context),
|
|
46
|
-
statementNode = statementNodeAndTokens.getStatementNode();
|
|
47
|
-
|
|
48
|
-
return statementNode;
|
|
36
|
+
static fromString(string, context) { return NodeAndTokens.fromString(StatementNodeAndTokens, string, context); }
|
|
49
37
|
}
|
|
@@ -14,10 +14,5 @@ const bnf = `
|
|
|
14
14
|
export default class FrameSubstitutionNodeAndTokens extends NodeAndTokens {
|
|
15
15
|
static rule = rule;
|
|
16
16
|
|
|
17
|
-
static
|
|
18
|
-
const string = frameSubstitutionString, ///
|
|
19
|
-
frameSubstitutionNodeAndTokens = NodeAndTokens.fromString(FrameSubstitutionNodeAndTokens, string, context);
|
|
20
|
-
|
|
21
|
-
return frameSubstitutionNodeAndTokens;
|
|
22
|
-
}
|
|
17
|
+
static fromString(string, context) { return NodeAndTokens.fromString(FrameSubstitutionNodeAndTokens, string, context); }
|
|
23
18
|
}
|
|
@@ -14,10 +14,5 @@ const bnf = `
|
|
|
14
14
|
export default class StatementSubstitutionNodeAndTokens extends NodeAndTokens {
|
|
15
15
|
static rule = rule;
|
|
16
16
|
|
|
17
|
-
static
|
|
18
|
-
const string = statementSubstitutionString, ///
|
|
19
|
-
statementSubstitutionNodeAndTokens = NodeAndTokens.fromString(StatementSubstitutionNodeAndTokens, string, context);
|
|
20
|
-
|
|
21
|
-
return statementSubstitutionNodeAndTokens;
|
|
22
|
-
}
|
|
17
|
+
static fromString(string, context) { return NodeAndTokens.fromString(StatementSubstitutionNodeAndTokens, string, context); }
|
|
23
18
|
}
|
|
@@ -14,10 +14,5 @@ const bnf = `
|
|
|
14
14
|
export default class TermSubstitutionNodeAndTokens extends NodeAndTokens {
|
|
15
15
|
static rule = rule;
|
|
16
16
|
|
|
17
|
-
static
|
|
18
|
-
const string = termSubstitutionString, ///
|
|
19
|
-
termSubstitutionNodeAndTokens = NodeAndTokens.fromString(TermSubstitutionNodeAndTokens, string, context);
|
|
20
|
-
|
|
21
|
-
return termSubstitutionNodeAndTokens;
|
|
22
|
-
}
|
|
17
|
+
static fromString(string, context) { return NodeAndTokens.fromString(TermSubstitutionNodeAndTokens, string, context); }
|
|
23
18
|
}
|
|
@@ -33,16 +33,12 @@ export default class TermNodeAndTokens extends NodeAndTokens {
|
|
|
33
33
|
return termNodeAndTokens;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
static
|
|
37
|
-
const string = termString, ///
|
|
38
|
-
termNodeAndTokens = NodeAndTokens.fromString(TermNodeAndTokens, string, context);
|
|
39
|
-
|
|
40
|
-
return termNodeAndTokens;
|
|
41
|
-
}
|
|
36
|
+
static fromString(string, context) { return NodeAndTokens.fromString(TermNodeAndTokens, string, context); }
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
export function termNodeFromTermString(termString, context) {
|
|
45
|
-
const
|
|
40
|
+
const string = termString, ///
|
|
41
|
+
termNodeAndTokens = TermNodeAndTokens.fromString(string, context),
|
|
46
42
|
termNode = termNodeAndTokens.getTermNode();
|
|
47
43
|
|
|
48
44
|
return termNode;
|
|
@@ -33,16 +33,12 @@ export default class VariableNodeAndTokens extends NodeAndTokens {
|
|
|
33
33
|
return variableNodeAndTokens;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
static
|
|
37
|
-
const string = variableString, ///
|
|
38
|
-
variableNodeAndTokens = NodeAndTokens.fromString(VariableNodeAndTokens, string, context);
|
|
39
|
-
|
|
40
|
-
return variableNodeAndTokens;
|
|
41
|
-
}
|
|
36
|
+
static fromString(string, context) { return NodeAndTokens.fromString(VariableNodeAndTokens, string, context); }
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
export function variableNodeFromVariableString(variableString, context) {
|
|
45
|
-
const
|
|
40
|
+
const string = variableString, ///
|
|
41
|
+
variableNodeAndTokens = VariableNodeAndTokens.fromString(string, context),
|
|
46
42
|
variableNode = variableNodeAndTokens.getVariableNode();
|
|
47
43
|
|
|
48
44
|
return variableNode;
|
package/src/premise.js
CHANGED
|
@@ -119,12 +119,24 @@ class Premise {
|
|
|
119
119
|
premiseStatementString = premiseStatement.getString();
|
|
120
120
|
|
|
121
121
|
const statement = this.unqualifiedStatement.getStatement(),
|
|
122
|
-
statementNode = statement.getNode()
|
|
122
|
+
statementNode = statement.getNode(),
|
|
123
|
+
statementTokens = statement.getTokens();
|
|
123
124
|
|
|
124
125
|
specificContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
let context;
|
|
128
|
+
|
|
129
|
+
const tokens = statementTokens; ///
|
|
130
|
+
|
|
131
|
+
context = generalContext; ///
|
|
132
|
+
|
|
133
|
+
const localContext = LocalContext.fromContextAndTokens(context, tokens);
|
|
134
|
+
|
|
135
|
+
generalContext = localContext; ///
|
|
136
|
+
|
|
137
|
+
context = generalContext; ///
|
|
138
|
+
|
|
139
|
+
const subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, context);
|
|
128
140
|
|
|
129
141
|
if (subproofAssertion !== null) {
|
|
130
142
|
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
|
package/src/reference.js
CHANGED
|
@@ -6,7 +6,7 @@ import LocalContext from "./context/local";
|
|
|
6
6
|
import { nodeQuery } from "./utilities/query";
|
|
7
7
|
import { referenceMetaType } from "./metaType";
|
|
8
8
|
import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
|
|
9
|
-
import
|
|
9
|
+
import labelUnifier from "./unifier/label";
|
|
10
10
|
|
|
11
11
|
const metavariableNodeQuery = nodeQuery("//reference/metavariable");
|
|
12
12
|
|
|
@@ -23,12 +23,41 @@ export default class Reference {
|
|
|
23
23
|
|
|
24
24
|
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
25
25
|
|
|
26
|
+
getMetavariableName() {
|
|
27
|
+
const metavariableName = this.metavariable.getName();
|
|
28
|
+
|
|
29
|
+
return metavariableName;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
getMetavariableNode() {
|
|
27
33
|
const metavariableNode = this.metavariable.getNode();
|
|
28
34
|
|
|
29
35
|
return metavariableNode;
|
|
30
36
|
}
|
|
31
37
|
|
|
38
|
+
unifyLabel(label, substitutions, generalContext, specificContext) {
|
|
39
|
+
let labelUnified;
|
|
40
|
+
|
|
41
|
+
const reference = this,
|
|
42
|
+
labelString = label.getString(),
|
|
43
|
+
referenceString = reference.getString();
|
|
44
|
+
|
|
45
|
+
specificContext.trace(`Unifying the '${labelString}' label with the '${referenceString}' reference...`);
|
|
46
|
+
|
|
47
|
+
const labelMetavariable = label.getMetavariable(),
|
|
48
|
+
referenceMetavariable = reference.getMetavariable(),
|
|
49
|
+
labelMetavariableNode = labelMetavariable.getNode(),
|
|
50
|
+
referenceMetavariableNode = referenceMetavariable.getNode();
|
|
51
|
+
|
|
52
|
+
labelUnified = labelUnifier.unify(labelMetavariableNode, referenceMetavariableNode, substitutions, generalContext, specificContext);
|
|
53
|
+
|
|
54
|
+
if (labelUnified) {
|
|
55
|
+
specificContext.debug(`...unified the '${labelString}' label with the '${referenceString}' reference.`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return labelUnified;
|
|
59
|
+
}
|
|
60
|
+
|
|
32
61
|
verify(context) {
|
|
33
62
|
let verified = false;
|
|
34
63
|
|
|
@@ -43,24 +72,6 @@ export default class Reference {
|
|
|
43
72
|
verified = metavariableVerifiedGivenMetaType; ///
|
|
44
73
|
}
|
|
45
74
|
|
|
46
|
-
if (!verified) {
|
|
47
|
-
const reference = this, ///
|
|
48
|
-
metaLemmaPresent = context.isMetaLemmaPresentByReference(reference),
|
|
49
|
-
metatheoremPresent = context.isMetatheoremPresentByReference(reference);
|
|
50
|
-
|
|
51
|
-
verified = (metaLemmaPresent || metatheoremPresent);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (!verified) {
|
|
55
|
-
const reference = this, ///
|
|
56
|
-
axiomPresent = context.isAxiomPresentByReference(reference),
|
|
57
|
-
lemmaPresent = context.isLemmaPresentByReference(reference),
|
|
58
|
-
theoremPresent = context.isTheoremPresentByReference(reference),
|
|
59
|
-
conjecturePresent = context.isConjecturePresentByReference(reference);
|
|
60
|
-
|
|
61
|
-
verified = (axiomPresent || lemmaPresent || theoremPresent || conjecturePresent);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
75
|
if (verified) {
|
|
65
76
|
context.debug(`...verified the '${referenceString}' reference.`);
|
|
66
77
|
}
|
package/src/rule.js
CHANGED
|
@@ -55,16 +55,18 @@ class Rule {
|
|
|
55
55
|
return this.proof;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
const metavariableNodeMatches = this.labels.some((label) => {
|
|
60
|
-
const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
|
|
58
|
+
matchStatementNode(statementNode) { return this.conclusion.matchStatementNode(statementNode); }
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
matchMetavariableName(metavariableName) {
|
|
61
|
+
const metavariableNameMatches = this.labels.some((label) => {
|
|
62
|
+
const metavariableNameMatches = label.matchMetavariableName(metavariableName);
|
|
63
|
+
|
|
64
|
+
if (metavariableNameMatches) {
|
|
63
65
|
return true;
|
|
64
66
|
}
|
|
65
67
|
});
|
|
66
68
|
|
|
67
|
-
return
|
|
69
|
+
return metavariableNameMatches;
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
unifyStatement(statement, context) {
|
|
@@ -36,13 +36,13 @@ class QualifiedStatement {
|
|
|
36
36
|
unify(substitutions, context) {
|
|
37
37
|
let unified;
|
|
38
38
|
|
|
39
|
-
const
|
|
40
|
-
qualifiedStatementString = this.string; ///
|
|
39
|
+
const qualifiedStatementString = this.string; ///
|
|
41
40
|
|
|
42
41
|
context.trace(`Unifying the '${qualifiedStatementString}' qualified statement...`);
|
|
43
42
|
|
|
44
43
|
unified = unifyMixins.some((unifyMixin) => {
|
|
45
|
-
const
|
|
44
|
+
const qualifiedStatement = this, ///
|
|
45
|
+
unified = unifyMixin(qualifiedStatement, substitutions, context);
|
|
46
46
|
|
|
47
47
|
return unified;
|
|
48
48
|
});
|
|
@@ -27,36 +27,7 @@ class UnqualifiedStatement {
|
|
|
27
27
|
return this.statement;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
let verified;
|
|
32
|
-
|
|
33
|
-
const unqualifiedStatement = this, ///
|
|
34
|
-
unqualifiedStatementString = unqualifiedStatement.getString(); ///
|
|
35
|
-
|
|
36
|
-
if (this.statement !== null) {
|
|
37
|
-
context.trace(`Verifying the '${unqualifiedStatementString}' unqualified statement...`);
|
|
38
|
-
|
|
39
|
-
const statementVerified = this.statement.verify(assignments, stated, context);
|
|
40
|
-
|
|
41
|
-
if (statementVerified) {
|
|
42
|
-
verified = true;
|
|
43
|
-
} else {
|
|
44
|
-
const statementUnifiedWithProofSteps = this.unifyStatementWithProofSteps(this.statement, assignments, stated, context);
|
|
45
|
-
|
|
46
|
-
if (statementUnifiedWithProofSteps) {
|
|
47
|
-
verified = true;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (verified) {
|
|
52
|
-
context.debug(`...verified the '${unqualifiedStatementString}' unqualified statement.`);
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
context.debug(`Cannot verify the '${unqualifiedStatementString}' unqualified statement because it is nonsense.`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return verified;
|
|
59
|
-
}
|
|
30
|
+
matchStatementNode(statementNode) { return this.statement.matchStatementNode(statementNode); }
|
|
60
31
|
|
|
61
32
|
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
62
33
|
let statementUnified;
|
|
@@ -113,6 +84,37 @@ class UnqualifiedStatement {
|
|
|
113
84
|
return statementUnifiedWithProofSteps;
|
|
114
85
|
}
|
|
115
86
|
|
|
87
|
+
verify(assignments, stated, context) {
|
|
88
|
+
let verified;
|
|
89
|
+
|
|
90
|
+
const unqualifiedStatement = this, ///
|
|
91
|
+
unqualifiedStatementString = unqualifiedStatement.getString(); ///
|
|
92
|
+
|
|
93
|
+
if (this.statement !== null) {
|
|
94
|
+
context.trace(`Verifying the '${unqualifiedStatementString}' unqualified statement...`);
|
|
95
|
+
|
|
96
|
+
const statementVerified = this.statement.verify(assignments, stated, context);
|
|
97
|
+
|
|
98
|
+
if (statementVerified) {
|
|
99
|
+
verified = true;
|
|
100
|
+
} else {
|
|
101
|
+
const statementUnifiedWithProofSteps = this.unifyStatementWithProofSteps(this.statement, assignments, stated, context);
|
|
102
|
+
|
|
103
|
+
if (statementUnifiedWithProofSteps) {
|
|
104
|
+
verified = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (verified) {
|
|
109
|
+
context.debug(`...verified the '${unqualifiedStatementString}' unqualified statement.`);
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
context.debug(`Cannot verify the '${unqualifiedStatementString}' unqualified statement because it is nonsense.`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return verified;
|
|
116
|
+
}
|
|
117
|
+
|
|
116
118
|
toJSON() {
|
|
117
119
|
const statementJSON = statementToStatementJSON(this.statement),
|
|
118
120
|
statement = statementJSON, ///
|