occam-verify-cli 0.0.1002 → 0.0.1005
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/lib/assertion/subproof.js +106 -0
- package/lib/assignment/metavariable.js +2 -2
- package/lib/combinator.js +50 -16
- package/lib/conclusion.js +73 -14
- package/lib/context/file.js +191 -31
- package/lib/context/local.js +37 -49
- package/lib/context/release.js +42 -35
- package/lib/context/release.other.js +605 -0
- 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 -56
- 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 -60
- 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 +3 -3
- 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 +4 -4
- package/src/assertion/subproof.js +84 -0
- package/src/assignment/metavariable.js +2 -2
- package/src/combinator.js +45 -15
- package/src/conclusion.js +83 -13
- package/src/context/file.js +223 -11
- package/src/context/local.js +12 -16
- package/src/context/release.js +57 -39
- package/src/context/release.other.js +547 -0
- 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 +136 -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 +94 -44
- 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 +2 -2
- 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/label.js
CHANGED
|
@@ -1,30 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Metavariable from "./metavariable";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "./utilities/query";
|
|
6
|
+
|
|
7
|
+
const metavariableNodeQuery = nodeQuery("//label/metavariable");
|
|
4
8
|
|
|
5
9
|
export default class Label {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
10
|
+
constructor(metavariable) {
|
|
11
|
+
this.metavariable = metavariable;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getMetavariable() {
|
|
15
|
+
return this.metavariable;
|
|
8
16
|
}
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
getString() { return this.metavariable.getString(); }
|
|
19
|
+
|
|
20
|
+
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
21
|
+
|
|
22
|
+
verify(fileContext) {
|
|
23
|
+
let verified = false;
|
|
24
|
+
|
|
25
|
+
const labelString = this.getString(); ///
|
|
26
|
+
|
|
27
|
+
fileContext.trace(`Verifying the '${labelString}' label...`);
|
|
28
|
+
|
|
29
|
+
const metavariableNode = this.metavariable.getNode(),
|
|
30
|
+
labelPresent = fileContext.isLabelPresentByMetavariableNode(metavariableNode);
|
|
31
|
+
|
|
32
|
+
if (labelPresent) {
|
|
33
|
+
fileContext.debug(`The '${labelString}' label is already present.`);
|
|
34
|
+
} else {
|
|
35
|
+
verified = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (verified) {
|
|
39
|
+
fileContext.debug(`...verified the '${labelString}' label.`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return verified;
|
|
12
43
|
}
|
|
13
44
|
|
|
14
|
-
|
|
15
|
-
const
|
|
45
|
+
toJSON() {
|
|
46
|
+
const metavariableJSON = this.metavariable.toJSON(),
|
|
47
|
+
metavariable = metavariableJSON, ///
|
|
48
|
+
json = {
|
|
49
|
+
metavariable
|
|
50
|
+
};
|
|
16
51
|
|
|
17
|
-
return
|
|
52
|
+
return json;
|
|
18
53
|
}
|
|
19
54
|
|
|
20
|
-
|
|
21
|
-
|
|
55
|
+
static fromJSON(json, fileContext) {
|
|
56
|
+
let { metavariable } = json;
|
|
22
57
|
|
|
23
|
-
|
|
58
|
+
json = metavariable; ///
|
|
59
|
+
|
|
60
|
+
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
61
|
+
|
|
62
|
+
const label = new Label(metavariable);
|
|
63
|
+
|
|
64
|
+
return label;
|
|
24
65
|
}
|
|
25
66
|
|
|
26
|
-
static
|
|
27
|
-
const
|
|
67
|
+
static fromLabelNode(labelNode, fileContext) {
|
|
68
|
+
const metavariableNode = metavariableNodeQuery(labelNode),
|
|
69
|
+
metavariable = Metavariable.fromMetavariableNode(metavariableNode, fileContext),
|
|
70
|
+
label = new Label(metavariable);
|
|
28
71
|
|
|
29
72
|
return label;
|
|
30
73
|
}
|
package/src/log.js
CHANGED
|
@@ -4,7 +4,7 @@ import { levels } from "necessary";
|
|
|
4
4
|
|
|
5
5
|
import { leastLineIndexFromNodeAndTokens, greatestLineIndexFromNodeAndTokens } from "./utilities/message";
|
|
6
6
|
|
|
7
|
-
const { TRACE_LEVEL, DEBUG_LEVEL, INFO_LEVEL, WARNING_LEVEL, ERROR_LEVEL
|
|
7
|
+
const { TRACE_LEVEL, DEBUG_LEVEL, INFO_LEVEL, WARNING_LEVEL, ERROR_LEVEL } = levels;
|
|
8
8
|
|
|
9
9
|
export default class Log {
|
|
10
10
|
constructor(messages, logLevel, follow) {
|
|
@@ -55,20 +55,13 @@ export default class Log {
|
|
|
55
55
|
this.write(level, message, node, tokens, filePath);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
fatal(message, node, tokens, filePath) {
|
|
59
|
-
const level = FATAL_LEVEL;
|
|
60
|
-
|
|
61
|
-
this.write(level, message, node, tokens, filePath);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
58
|
write(level, message, node, tokens, filePath) {
|
|
65
59
|
const levels = [
|
|
66
60
|
TRACE_LEVEL,
|
|
67
61
|
DEBUG_LEVEL,
|
|
68
62
|
INFO_LEVEL,
|
|
69
63
|
WARNING_LEVEL,
|
|
70
|
-
ERROR_LEVEL
|
|
71
|
-
FATAL_LEVEL,
|
|
64
|
+
ERROR_LEVEL
|
|
72
65
|
],
|
|
73
66
|
levelIndex = levels.indexOf(level),
|
|
74
67
|
logLevelIndex = levels.indexOf(this.logLevel);
|
package/src/metaType.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
|
|
3
5
|
import { metaTypeNameFromMetaTypeNode } from "./utilities/name";
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
class MetaType {
|
|
6
8
|
constructor(name) {
|
|
7
9
|
this.name = name;
|
|
8
10
|
}
|
|
@@ -17,13 +19,6 @@ export default class MetaType {
|
|
|
17
19
|
return equalTo;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
match(metaType) {
|
|
21
|
-
const equalToMetaType = this.isEqualTo(metaType),
|
|
22
|
-
matches = equalToMetaType; ///
|
|
23
|
-
|
|
24
|
-
return matches;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
22
|
matchName(name) {
|
|
28
23
|
const nameMatches = (this.name === name);
|
|
29
24
|
|
|
@@ -44,21 +39,38 @@ export default class MetaType {
|
|
|
44
39
|
return metaTypeNodeMatches;
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
const
|
|
42
|
+
toJSON() {
|
|
43
|
+
const name = this.name,
|
|
44
|
+
json = {
|
|
45
|
+
name
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return json;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static fromJSON(json, fileContext) {
|
|
52
|
+
const { name } = json,
|
|
53
|
+
metaType = new MetaType(name);
|
|
49
54
|
|
|
50
|
-
return
|
|
55
|
+
return metaType;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
static
|
|
54
|
-
const
|
|
58
|
+
static fromMetaTypeNode(metaTypeNode, localContext) {
|
|
59
|
+
const metaTypeName = metaTypeNameFromMetaTypeNode(metaTypeNode),
|
|
60
|
+
name = metaTypeName, ///
|
|
55
61
|
metaType = new MetaType(name);
|
|
56
62
|
|
|
57
63
|
return metaType;
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
Object.assign(shim, {
|
|
68
|
+
MetaType
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export default MetaType;
|
|
72
|
+
|
|
73
|
+
export function metaTypeFromJSON(json, fileContext) {
|
|
62
74
|
let metaType;
|
|
63
75
|
|
|
64
76
|
const { name } = json;
|
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
|
+
}
|