occam-verify-cli 0.0.880 → 0.0.882
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/assignment/judgement.js +62 -0
- package/lib/axiomLemmaTheoremConjecture.js +4 -10
- package/lib/context/file.js +47 -41
- package/lib/context/local.js +19 -7
- package/lib/context/localMeta.js +58 -16
- package/lib/declaration.js +90 -0
- package/lib/frame.js +105 -0
- package/lib/judgement.js +87 -0
- package/lib/label.js +3 -3
- package/lib/metaLemmaMetatheorem.js +4 -4
- package/lib/metaType/{label.js → frame.js} +12 -12
- package/lib/metaType/{context.js → reference.js} +12 -12
- package/lib/metaTypeNames.js +7 -7
- package/lib/metaTypes.js +5 -5
- package/lib/mixins/context.js +32 -24
- package/lib/premise.js +2 -26
- package/lib/rule.js +4 -10
- package/lib/supposition.js +1 -53
- package/lib/utilities/name.js +3 -11
- package/lib/verify/declaration.js +36 -18
- package/lib/verify/frame.js +75 -0
- package/lib/verify/judgement.js +95 -20
- package/lib/verify/label.js +8 -8
- package/lib/verify/labels.js +4 -4
- package/lib/verify/metastatement/qualified.js +12 -8
- package/lib/verify/metastatement.js +5 -21
- package/lib/verify/metavariable.js +3 -3
- package/lib/verify/statement/qualified.js +6 -6
- package/package.json +2 -2
- package/src/assignment/judgement.js +30 -0
- package/src/axiomLemmaTheoremConjecture.js +3 -12
- package/src/context/file.js +38 -33
- package/src/context/local.js +6 -2
- package/src/context/localMeta.js +62 -15
- package/src/declaration.js +58 -0
- package/src/frame.js +69 -0
- package/src/judgement.js +38 -0
- package/src/label.js +2 -2
- package/src/metaLemmaMetatheorem.js +3 -3
- package/src/metaType/frame.js +18 -0
- package/src/metaType/reference.js +18 -0
- package/src/metaTypeNames.js +2 -2
- package/src/metaTypes.js +4 -4
- package/src/mixins/context.js +21 -15
- package/src/premise.js +0 -41
- package/src/rule.js +3 -12
- package/src/supposition.js +0 -45
- package/src/utilities/name.js +5 -15
- package/src/verify/declaration.js +48 -21
- package/src/verify/frame.js +91 -0
- package/src/verify/judgement.js +142 -21
- package/src/verify/label.js +7 -8
- package/src/verify/labels.js +4 -3
- package/src/verify/metastatement/qualified.js +14 -11
- package/src/verify/metastatement.js +4 -30
- package/src/verify/metavariable.js +2 -2
- package/src/verify/statement/qualified.js +10 -10
- package/lib/assignment/metaEquality.js +0 -62
- package/lib/metaEquality.js +0 -101
- package/lib/verify/context.js +0 -34
- package/lib/verify/metaEquality.js +0 -69
- package/src/assignment/metaEquality.js +0 -30
- package/src/metaEquality.js +0 -84
- package/src/metaType/context.js +0 -18
- package/src/metaType/label.js +0 -18
- package/src/verify/context.js +0 -30
- package/src/verify/metaEquality.js +0 -83
package/src/frame.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { push, first } from "./utilities/array";
|
|
4
|
+
|
|
5
|
+
export default class Frame {
|
|
6
|
+
constructor(declarations) {
|
|
7
|
+
this.declarations = declarations;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getDeclarations() {
|
|
11
|
+
return this.declarations;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getDeclaration() {
|
|
15
|
+
let declaration = null;
|
|
16
|
+
|
|
17
|
+
const singular = this.isSingular();
|
|
18
|
+
|
|
19
|
+
if (singular) {
|
|
20
|
+
const firstDeclaration = first(this.declarations);
|
|
21
|
+
|
|
22
|
+
declaration = firstDeclaration; ///
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return declaration;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
isSingular() {
|
|
29
|
+
const declarationsLength = this.declarations.length,
|
|
30
|
+
singular = (declarationsLength === 1);
|
|
31
|
+
|
|
32
|
+
return singular;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
addDeclarations(declarations) {
|
|
36
|
+
push(this.declarations, declarations);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
matchSubstitution(substitution) {
|
|
40
|
+
const substitutionMatches = this.declarations.some((declaration) => {
|
|
41
|
+
const declarationMatchesSubstitution = declaration.matchSubstitution(substitution);
|
|
42
|
+
|
|
43
|
+
if (declarationMatchesSubstitution) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return substitutionMatches;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem) {
|
|
52
|
+
const substitutions = metaLemmaMetatheorem.getSubstitutions(),
|
|
53
|
+
metaLemmaOrMetaTheoremMatches = substitutions.every((substitution) => {
|
|
54
|
+
const frameMatchesSubstitution = this.matchSubstitution(substitution);
|
|
55
|
+
|
|
56
|
+
if (frameMatchesSubstitution) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return metaLemmaOrMetaTheoremMatches;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static fromDeclarations(declarations) {
|
|
65
|
+
const frame = new Frame(declarations);
|
|
66
|
+
|
|
67
|
+
return frame;
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/judgement.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default class Judgement {
|
|
4
|
+
constructor(node, frame, metavariableNode) {
|
|
5
|
+
this.node = node;
|
|
6
|
+
this.frame = frame;
|
|
7
|
+
this.metavariableNode = metavariableNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getNode() {
|
|
11
|
+
return this.node;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getFrame() {
|
|
15
|
+
return this.frame;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getMetavariableNode() {
|
|
19
|
+
return this.metavariableNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getDeclarations() { return this.frame.getDeclarations(); }
|
|
23
|
+
|
|
24
|
+
matchMetavariableNode(metavariableNode) {
|
|
25
|
+
const metavariableNodeMatches = this.metavariableNode.match(metavariableNode);
|
|
26
|
+
|
|
27
|
+
return metavariableNodeMatches;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem) { return this.frame.matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem); }
|
|
31
|
+
|
|
32
|
+
static fromJudgementNodeFrameAndMetavariableNode(judgementNode, frame, metavariableNode) {
|
|
33
|
+
const node = judgementNode,
|
|
34
|
+
judgement = new Judgement(node, frame, metavariableNode);
|
|
35
|
+
|
|
36
|
+
return judgement;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/label.js
CHANGED
|
@@ -33,9 +33,9 @@ export default class Label {
|
|
|
33
33
|
|
|
34
34
|
static fromMetavariableNode(metavariableNode) {
|
|
35
35
|
const node = metavariableNode, ///
|
|
36
|
-
|
|
36
|
+
label = new Label(node);
|
|
37
37
|
|
|
38
|
-
return
|
|
38
|
+
return label;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
static fromJSONAndFileContext(json, fileContext) {
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import Label from "./label";
|
|
4
4
|
import MetaConsequent from "./metaConsequent";
|
|
5
5
|
import MetaSupposition from "./metaSupposition";
|
|
6
|
+
import MetastatementForMetavariableSubstitution from "./substitution/metastatementForMetavariable";
|
|
6
7
|
|
|
7
8
|
import { prune } from "./utilities/array";
|
|
8
9
|
import { someSubArray } from "./utilities/array";
|
|
9
|
-
import MetastatementForMetavariableSubstitution from "./substitution/metastatementForMetavariable";
|
|
10
10
|
|
|
11
11
|
export default class MetaLemmaMetatheorem {
|
|
12
12
|
constructor(labels, metaSuppositions, metaConsequent, substitutions, fileContext) {
|
|
@@ -71,9 +71,9 @@ export default class MetaLemmaMetatheorem {
|
|
|
71
71
|
return metastatementNatches;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
matchLabelMetavariableNode(
|
|
74
|
+
matchLabelMetavariableNode(metavariableNode) {
|
|
75
75
|
const labelMetavariableNodeMatches = this.labels.some((label) => {
|
|
76
|
-
const node =
|
|
76
|
+
const node = metavariableNode, ///
|
|
77
77
|
labelMatchesNode = label.matchNode(node);
|
|
78
78
|
|
|
79
79
|
if (labelMatchesNode) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetaType from "../metaType";
|
|
4
|
+
|
|
5
|
+
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
6
|
+
|
|
7
|
+
class FrameMetaType extends MetaType {
|
|
8
|
+
static fromNothing() {
|
|
9
|
+
const name = FRAME_META_TYPE_NAME,
|
|
10
|
+
frameMetaType = new FrameMetaType(name);
|
|
11
|
+
|
|
12
|
+
return frameMetaType;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const frameMetaType = FrameMetaType.fromNothing();
|
|
17
|
+
|
|
18
|
+
export default frameMetaType;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetaType from "../metaType";
|
|
4
|
+
|
|
5
|
+
import { REFERENCE_META_TYPE_NAME } from "../metaTypeNames";
|
|
6
|
+
|
|
7
|
+
class ReferenceMetaType extends MetaType {
|
|
8
|
+
static fromNothing() {
|
|
9
|
+
const name = REFERENCE_META_TYPE_NAME,
|
|
10
|
+
referenceMetaType = new ReferenceMetaType(name);
|
|
11
|
+
|
|
12
|
+
return referenceMetaType;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const referenceMetaType = ReferenceMetaType.fromNothing();
|
|
17
|
+
|
|
18
|
+
export default referenceMetaType;
|
package/src/metaTypeNames.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
export const FRAME_META_TYPE_NAME = "Frame";
|
|
4
|
+
export const REFERENCE_META_TYPE_NAME = "Reference";
|
|
3
5
|
export const STATEMENT_META_TYPE_NAME = "Statement";
|
|
4
|
-
export const CONTEXT_META_TYPE_NAME = "Context";
|
|
5
|
-
export const LABEL_META_TYPE_NAME = "Label";
|
package/src/metaTypes.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import frameMetaType from "./metaType/frame";
|
|
4
|
+
import referenceMetaType from "./metaType/reference";
|
|
5
5
|
import statementMetaType from "./metaType/statement";
|
|
6
6
|
|
|
7
7
|
const metaTypes = [
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
frameMetaType,
|
|
9
|
+
referenceMetaType,
|
|
10
10
|
statementMetaType
|
|
11
11
|
];
|
|
12
12
|
|
package/src/mixins/context.js
CHANGED
|
@@ -26,7 +26,7 @@ function getConstructors() { return this.context.getConstructors(); }
|
|
|
26
26
|
|
|
27
27
|
function findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
28
28
|
|
|
29
|
-
function findTypeByTypeNode(
|
|
29
|
+
function findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
30
30
|
|
|
31
31
|
function findMetavariableByName(name) { return this.context.findMetavariableByName(name); }
|
|
32
32
|
|
|
@@ -36,19 +36,23 @@ function isTypePresentByTypeNode(typeNode) { return this.context.isTypePresentBy
|
|
|
36
36
|
|
|
37
37
|
function isMetavariablePresentByName(name) { return this.context.isMetavariablePresentByName(name); }
|
|
38
38
|
|
|
39
|
-
function
|
|
39
|
+
function isLabelPresentByMetavariableNode(metavariableNode) { return this.context.isLabelPresentByMetavariableNode(metavariableNode); }
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
function findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
42
42
|
|
|
43
|
-
function
|
|
43
|
+
function findRuleByMetavariableNode(metavariableNode) { return this.context.findRuleByMetavariableNode(metavariableNode); }
|
|
44
44
|
|
|
45
|
-
function
|
|
45
|
+
function findAxiomByMetavariableNode(metavariableNode) { return this.context.findAxiomByMetavariableNode(metavariableNode); }
|
|
46
46
|
|
|
47
|
-
function
|
|
47
|
+
function findLemmaByMetavariableNode(metavariableNode) { return this.context.findLemmaByMetavariableNode(metavariableNode); }
|
|
48
48
|
|
|
49
|
-
function
|
|
49
|
+
function findTheoremByMetavariableNode(metavariableNode) { return this.context.findTheoremByMetavariableNode(metavariableNode); }
|
|
50
50
|
|
|
51
|
-
function
|
|
51
|
+
function findMetaLemmaByMetavariableNode(metavariableNode) { return this.context.findMetaLemmaByMetavariableNode(metavariableNode); }
|
|
52
|
+
|
|
53
|
+
function findConjectureByMetavariableNode(metavariableNode) { return this.context.findConjectureByMetavariableNode(metavariableNode); }
|
|
54
|
+
|
|
55
|
+
function findMetatheoremByMetavariableNode(metavariableNode) { return this.context.findMetatheoremByMetavariableNode(metavariableNode); }
|
|
52
56
|
|
|
53
57
|
function nodeAsString(node) { return this.context.nodeAsString(node); }
|
|
54
58
|
|
|
@@ -73,13 +77,15 @@ const contextMixins = {
|
|
|
73
77
|
isTypePresentByTypeName,
|
|
74
78
|
isTypePresentByTypeNode,
|
|
75
79
|
isMetavariablePresentByName,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
isLabelPresentByMetavariableNode,
|
|
81
|
+
findLabelByMetavariableNode,
|
|
82
|
+
findRuleByMetavariableNode,
|
|
83
|
+
findAxiomByMetavariableNode,
|
|
84
|
+
findLemmaByMetavariableNode,
|
|
85
|
+
findTheoremByMetavariableNode,
|
|
86
|
+
findMetaLemmaByMetavariableNode,
|
|
87
|
+
findConjectureByMetavariableNode,
|
|
88
|
+
findMetatheoremByMetavariableNode,
|
|
83
89
|
nodeAsString,
|
|
84
90
|
nodesAsString
|
|
85
91
|
};
|
package/src/premise.js
CHANGED
|
@@ -11,8 +11,6 @@ import { metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
|
11
11
|
|
|
12
12
|
const ruleSubproofAssertionNodeQuery = nodeQuery("/metastatement/ruleSubproofAssertion!"),
|
|
13
13
|
ruleSubproofPremiseMetastatementQuery = nodesQuery("/ruleSubproof/premise/unqualifiedMetastatement!/metastatement!"),
|
|
14
|
-
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement!/statement!"),
|
|
15
|
-
subproofSubDerivationLastStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!"),
|
|
16
14
|
ruleSubproofAssertionMetastatementNodesQuery = nodesQuery("/ruleSubproofAssertion/metastatement"),
|
|
17
15
|
ruleSubproofSubDerivationLastMetastatementQuery = nodeQuery("/ruleSubproof/ruleSubDerivation/qualifiedMetastatement|unqualifiedMetastatement[-1]/metastatement!");
|
|
18
16
|
|
|
@@ -25,45 +23,6 @@ export default class Premise {
|
|
|
25
23
|
return this.metastatementNode;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
matchSubproofNode(subproofNode, substitutions, fileContext, statementLocalContext) {
|
|
29
|
-
let subproofNodeMatches = false;
|
|
30
|
-
|
|
31
|
-
const subproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
32
|
-
|
|
33
|
-
if (subproofAssertionNode !== null) {
|
|
34
|
-
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
35
|
-
subproofSubDerivationLastStatementNode = subproofSubDerivationLastStatementNodeQuery(subproofNode),
|
|
36
|
-
subproofStatementNodes = [
|
|
37
|
-
...subproofSuppositionStatementNodes,
|
|
38
|
-
subproofSubDerivationLastStatementNode
|
|
39
|
-
],
|
|
40
|
-
ruleSubproofAssertionMetastatementNodes = ruleSubproofAssertionMetastatementNodesQuery(subproofAssertionNode),
|
|
41
|
-
subproofStatementNodesLength = subproofStatementNodes.length,
|
|
42
|
-
ruleSubproofAssertionMetastatementNodesLength = ruleSubproofAssertionMetastatementNodes.length;
|
|
43
|
-
|
|
44
|
-
if (subproofStatementNodesLength === ruleSubproofAssertionMetastatementNodesLength) {
|
|
45
|
-
subproofNodeMatches = match(ruleSubproofAssertionMetastatementNodes, subproofStatementNodes, (ruleSubproofAssertionMetastatementNode, subproofStatementNode) => {
|
|
46
|
-
const nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
47
|
-
nonTerminalNodeB = subproofStatementNode, ///
|
|
48
|
-
fileContextA = fileContext, ///
|
|
49
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
50
|
-
localContextB = statementLocalContext, ///
|
|
51
|
-
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
52
|
-
const verifiedAhead = true;
|
|
53
|
-
|
|
54
|
-
return verifiedAhead;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (nonTerminalNodeVerified) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return subproofNodeMatches;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
26
|
matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext) {
|
|
68
27
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
69
28
|
nonTerminalNodeB = statementNode, ///
|
package/src/rule.js
CHANGED
|
@@ -99,9 +99,9 @@ export default class Rule {
|
|
|
99
99
|
return metastatementNatches;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
matchLabelMetavariableNode(
|
|
102
|
+
matchLabelMetavariableNode(metavariableNode) {
|
|
103
103
|
const labelMetavariableNodeMatches = this.labels.some((label) => {
|
|
104
|
-
const node =
|
|
104
|
+
const node = metavariableNode, ///
|
|
105
105
|
labelMatchesNode = label.matchNode(node);
|
|
106
106
|
|
|
107
107
|
if (labelMatchesNode) {
|
|
@@ -183,16 +183,7 @@ export default class Rule {
|
|
|
183
183
|
|
|
184
184
|
function matchPremise(premise, proofSteps, substitutions, fileContext, statementLocalContext) {
|
|
185
185
|
const proofStep = prune(proofSteps, (proofStep) => {
|
|
186
|
-
const
|
|
187
|
-
statementNode = proofStep.getStatementNode()
|
|
188
|
-
|
|
189
|
-
if (subproofNode !== null) {
|
|
190
|
-
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, statementLocalContext);
|
|
191
|
-
|
|
192
|
-
if (!subProofNodeMatches) { ///
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
186
|
+
const statementNode = proofStep.getStatementNode()
|
|
196
187
|
|
|
197
188
|
if (statementNode !== null) {
|
|
198
189
|
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext);
|
package/src/supposition.js
CHANGED
|
@@ -2,16 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import intrinsicLevelNodesVerifier from "./verifier/nodes/intrinsicLevel";
|
|
4
4
|
|
|
5
|
-
import { match } from "./utilities/array";
|
|
6
5
|
import { nodeAsString } from "./utilities/string";
|
|
7
|
-
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
6
|
import { statementNodeFromStatementString } from "./utilities/node";
|
|
9
7
|
|
|
10
|
-
const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
11
|
-
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
12
|
-
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
13
|
-
subproofSubDerivationLastStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!");
|
|
14
|
-
|
|
15
8
|
export default class Supposition {
|
|
16
9
|
constructor(statementNode) {
|
|
17
10
|
this.statementNode = statementNode;
|
|
@@ -21,44 +14,6 @@ export default class Supposition {
|
|
|
21
14
|
return this.statementNode;
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
matchSubproofNode(subproofNode, substitutions, localContext, statementLocalContext) {
|
|
25
|
-
let subproofNodeMatches = false;
|
|
26
|
-
|
|
27
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
28
|
-
|
|
29
|
-
if (subproofAssertionNode !== null) {
|
|
30
|
-
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
31
|
-
subproofSubDerivationLastStatementNode = subproofSubDerivationLastStatementNodeQuery(subproofNode),
|
|
32
|
-
subproofStatementNodes = [
|
|
33
|
-
...subproofSuppositionStatementNodes,
|
|
34
|
-
subproofSubDerivationLastStatementNode
|
|
35
|
-
],
|
|
36
|
-
subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode),
|
|
37
|
-
subproofStatementNodesLength = subproofStatementNodes.length,
|
|
38
|
-
subproofAssertionStatementNodesLength = subproofAssertionStatementNodes.length;
|
|
39
|
-
|
|
40
|
-
if (subproofStatementNodesLength === subproofAssertionStatementNodesLength) {
|
|
41
|
-
subproofNodeMatches = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, subproofStatementNode) => {
|
|
42
|
-
const nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
43
|
-
nonTerminalNodeB = subproofStatementNode, ///
|
|
44
|
-
localContextA = localContext, ///
|
|
45
|
-
localContextB = statementLocalContext, ///
|
|
46
|
-
nonTerminalNodeVerified = intrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
47
|
-
const verifiedAhead = true;
|
|
48
|
-
|
|
49
|
-
return verifiedAhead;
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (nonTerminalNodeVerified) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return subproofNodeMatches;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
17
|
matchStatementNode(statementNode, substitutions, localContext, statementLocalContext) {
|
|
63
18
|
const nonTerminalNodeA = this.statementNode, ///
|
|
64
19
|
nonTerminalNodeB = statementNode, ///
|
package/src/utilities/name.js
CHANGED
|
@@ -7,14 +7,9 @@ const typeTerminalNodeQuery = nodeQuery("/type/@type"),
|
|
|
7
7
|
metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type");
|
|
8
8
|
|
|
9
9
|
export function typeNameFromTypeNode(typeNode) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const typeTerminalNode = typeTerminalNodeQuery(typeNode),
|
|
14
|
-
typeTerminalNodeContent = typeTerminalNode.getContent();
|
|
15
|
-
|
|
16
|
-
typeName = typeTerminalNodeContent; ///
|
|
17
|
-
}
|
|
10
|
+
const typeTerminalNode = typeTerminalNodeQuery(typeNode),
|
|
11
|
+
typeTerminalNodeContent = typeTerminalNode.getContent(),
|
|
12
|
+
typeName = typeTerminalNodeContent; ///
|
|
18
13
|
|
|
19
14
|
return typeName;
|
|
20
15
|
}
|
|
@@ -28,14 +23,9 @@ export function nameFromMetavariableNode(metavariableNode) {
|
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
export function metaTypeNameFromMetaTypeNode(metaTypeNode) {
|
|
31
|
-
let metaTypeName = null;
|
|
32
|
-
|
|
33
|
-
if (metaTypeNode !== null) {
|
|
34
26
|
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
35
|
-
metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent()
|
|
36
|
-
|
|
37
|
-
metaTypeName = metaTypeTerminalNodeContent; ///
|
|
38
|
-
}
|
|
27
|
+
metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent(),
|
|
28
|
+
metaTypeName = metaTypeTerminalNodeContent; ///
|
|
39
29
|
|
|
40
30
|
return metaTypeName;
|
|
41
31
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Declaration from "../declaration"
|
|
4
|
+
import referenceMetaType from "../metaType/reference";
|
|
4
5
|
import metastatementNodeVerifier from "../verifier/node/metastatement";
|
|
5
6
|
|
|
6
7
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -8,7 +9,7 @@ import { nodeQuery } from "../utilities/query";
|
|
|
8
9
|
const metavariableNodeQuery = nodeQuery("/declaration/metavariable!"),
|
|
9
10
|
metastatementNodeQuery = nodeQuery("/declaration/metastatement!");
|
|
10
11
|
|
|
11
|
-
export default function verifyDeclaration(declarationNode,
|
|
12
|
+
export default function verifyDeclaration(declarationNode, declarations, localMetaContext) {
|
|
12
13
|
let declarationVerified = false;
|
|
13
14
|
|
|
14
15
|
const declarationString = localMetaContext.nodeAsString(declarationNode);
|
|
@@ -16,31 +17,26 @@ export default function verifyDeclaration(declarationNode, derived, localMetaCon
|
|
|
16
17
|
localMetaContext.trace(`Verifying the '${declarationString}' declaration...`, declarationNode);
|
|
17
18
|
|
|
18
19
|
const metavariableNode = metavariableNodeQuery(declarationNode),
|
|
19
|
-
|
|
20
|
+
metavariableVerified = verifyMetavariable(metavariableNode, localMetaContext);
|
|
20
21
|
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
22
|
+
if (metavariableVerified) {
|
|
23
|
+
const metastatementNode = metastatementNodeQuery(declarationNode);
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const { verifyMetastatement } = metastatementNodeVerifier,
|
|
26
|
+
derived = false,
|
|
27
|
+
assignments = [],
|
|
28
|
+
metastatementVerified = verifyMetastatement(metastatementNode, assignments, derived, localMetaContext, () => {
|
|
29
|
+
const verifiedAhead = true;
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
assignments = [],
|
|
30
|
-
metastatementVerified = verifyMetastatement(metastatementNode, assignments, derived, localMetaContext, () => {
|
|
31
|
-
const verifiedAhead = true;
|
|
31
|
+
return verifiedAhead;
|
|
32
|
+
});
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
if (metastatementVerified) {
|
|
35
|
+
const declaration = Declaration.fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
39
|
-
const metavariableString = localMetaContext.nodeAsString(metavariableNode),
|
|
40
|
-
labelMetaTypeName = labelMetaType.getName(),
|
|
41
|
-
metaTypeString = metaType.asString();
|
|
37
|
+
declarations.push(declaration);
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
declarationVerified = true;
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
|
|
@@ -49,4 +45,35 @@ export default function verifyDeclaration(declarationNode, derived, localMetaCon
|
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
return declarationVerified;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function verifyMetavariable(metavariableNode, localMetaContext) {
|
|
51
|
+
let metavariableVerified = false;
|
|
52
|
+
|
|
53
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
54
|
+
|
|
55
|
+
localMetaContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
56
|
+
|
|
57
|
+
const metavariable = localMetaContext.findMetavariableByMetavariableNode(metavariableNode, localMetaContext);
|
|
58
|
+
|
|
59
|
+
if (metavariable !== null) {
|
|
60
|
+
const metaType = metavariable.getMetaType();
|
|
61
|
+
|
|
62
|
+
if (metaType === referenceMetaType) {
|
|
63
|
+
metavariableVerified = true;
|
|
64
|
+
} else {
|
|
65
|
+
const referenceMetaTypeName = referenceMetaType.getName(),
|
|
66
|
+
metaTypeString = metaType.asString();
|
|
67
|
+
|
|
68
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${referenceMetaTypeName}'.`, metavariableNode);
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (metavariableVerified) {
|
|
75
|
+
localMetaContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return metavariableVerified;
|
|
52
79
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Frame from "../frame";
|
|
4
|
+
import frameMetaType from "../metaType/frame";
|
|
5
|
+
import verifyDeclaration from "../verify/declaration";
|
|
6
|
+
|
|
7
|
+
import { push } from "../utilities/array";
|
|
8
|
+
import { nodesQuery } from "../utilities/query";
|
|
9
|
+
|
|
10
|
+
const declarationNodesQuery = nodesQuery("/frame/declaration"),
|
|
11
|
+
metavariableNodesQuery = nodesQuery("/frame/metavariable");
|
|
12
|
+
|
|
13
|
+
export default function verifyFrame(frameNode, frames, derived, localMetaContext) {
|
|
14
|
+
let frameVerified;
|
|
15
|
+
|
|
16
|
+
const frameString = localMetaContext.nodeAsString(frameNode);
|
|
17
|
+
|
|
18
|
+
localMetaContext.trace(`Verifying the '${frameString}' frame...`, frameNode);
|
|
19
|
+
|
|
20
|
+
const declarations = [],
|
|
21
|
+
declarationNodes = declarationNodesQuery(frameNode),
|
|
22
|
+
declarationsVerified = declarationNodes.every((declarationNode) => {
|
|
23
|
+
const declarationVerified = verifyDeclaration(declarationNode, declarations, localMetaContext);
|
|
24
|
+
|
|
25
|
+
return declarationVerified;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (declarationsVerified) {
|
|
29
|
+
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
30
|
+
metavariablesVerified = metavariableNodes.every((metavariableNode) => {
|
|
31
|
+
const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localMetaContext);
|
|
32
|
+
|
|
33
|
+
return metavariableVerified;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (metavariablesVerified) {
|
|
37
|
+
const frame = Frame.fromDeclarations(declarations);
|
|
38
|
+
|
|
39
|
+
frames.push(frame);
|
|
40
|
+
|
|
41
|
+
frameVerified = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (frameVerified) {
|
|
46
|
+
localMetaContext.debug(`...verified the '${frameString}' frame.`, frameNode);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return frameVerified;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function verifyMetavariable(metavariableNode, declarations, localMetaContext) {
|
|
53
|
+
let metavariableVerified = false;
|
|
54
|
+
|
|
55
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
56
|
+
|
|
57
|
+
localMetaContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
58
|
+
|
|
59
|
+
const metavariable = localMetaContext.findMetavariableByMetavariableNode(metavariableNode, localMetaContext);
|
|
60
|
+
|
|
61
|
+
if (metavariable !== null) {
|
|
62
|
+
const metaType = metavariable.getMetaType();
|
|
63
|
+
|
|
64
|
+
if (metaType === frameMetaType) {
|
|
65
|
+
const judgement = localMetaContext.findJudgementByMetavariableNode(metavariableNode);
|
|
66
|
+
|
|
67
|
+
if (judgement !== null) {
|
|
68
|
+
const judgementDeclarations = judgement.getDeclarations();
|
|
69
|
+
|
|
70
|
+
push(declarations, judgementDeclarations);
|
|
71
|
+
|
|
72
|
+
metavariableVerified = true;
|
|
73
|
+
} else {
|
|
74
|
+
localMetaContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
const frameMetaTypeName = frameMetaType.getName(),
|
|
78
|
+
metaTypeString = metaType.asString();
|
|
79
|
+
|
|
80
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${frameMetaTypeName}'.`, metavariableNode);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (metavariableVerified) {
|
|
87
|
+
localMetaContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return metavariableVerified;
|
|
91
|
+
}
|