occam-verify-cli 0.0.1066 → 0.0.1068
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 +3 -2
- package/lib/assertion/defined.js +3 -2
- package/lib/assignment/judgement.js +3 -3
- package/lib/conclusion.js +8 -4
- package/lib/consequent.js +8 -4
- package/lib/context/file.js +7 -7
- package/lib/context/local.js +12 -25
- package/lib/declaration.js +90 -3
- package/lib/frame.js +109 -48
- package/lib/judgement.js +84 -5
- package/lib/metaType.js +24 -3
- package/lib/metavariable.js +94 -65
- package/lib/mixins/statement/unify.js +1 -1
- package/lib/mixins/statement/verify.js +14 -23
- package/lib/premise.js +14 -6
- package/lib/proofStep.js +22 -13
- package/lib/reference.js +11 -9
- package/lib/rule.js +9 -2
- package/lib/ruleNames.js +5 -1
- package/lib/statement/qualified.js +30 -17
- package/lib/statement/unqualified.js +30 -6
- package/lib/statement.js +20 -9
- package/lib/subproof.js +1 -1
- package/lib/substitution/frameForMetavariable.js +80 -71
- package/lib/substitution/statementForMetavariable.js +118 -56
- package/lib/substitution/termForVariable.js +75 -75
- package/lib/substitution.js +68 -33
- package/lib/substitutions.js +58 -49
- package/lib/supposition.js +8 -4
- package/lib/unifier/intrinsicLevel.js +4 -4
- package/lib/unifier/metaLevel.js +23 -16
- package/lib/unifier/statementWithCombinator.js +2 -2
- package/lib/utilities/node.js +24 -10
- package/lib/utilities/tokens.js +8 -1
- package/lib/variable.js +17 -13
- package/package.json +2 -2
- package/src/assertion/contained.js +3 -1
- package/src/assertion/defined.js +3 -1
- package/src/assignment/judgement.js +3 -4
- package/src/conclusion.js +10 -3
- package/src/consequent.js +10 -3
- package/src/context/file.js +6 -8
- package/src/context/local.js +12 -33
- package/src/declaration.js +57 -4
- package/src/frame.js +149 -90
- package/src/judgement.js +109 -3
- package/src/metaType.js +29 -3
- package/src/metavariable.js +140 -87
- package/src/mixins/statement/unify.js +1 -0
- package/src/mixins/statement/verify.js +16 -28
- package/src/premise.js +19 -5
- package/src/proofStep.js +28 -12
- package/src/reference.js +11 -7
- package/src/rule.js +13 -1
- package/src/ruleNames.js +1 -0
- package/src/statement/qualified.js +38 -21
- package/src/statement/unqualified.js +35 -5
- package/src/statement.js +20 -12
- package/src/subproof.js +0 -1
- package/src/substitution/frameForMetavariable.js +90 -104
- package/src/substitution/statementForMetavariable.js +133 -61
- package/src/substitution/termForVariable.js +83 -113
- package/src/substitution.js +55 -26
- package/src/substitutions.js +59 -47
- package/src/supposition.js +10 -3
- package/src/unifier/intrinsicLevel.js +4 -3
- package/src/unifier/metaLevel.js +42 -24
- package/src/unifier/statementWithCombinator.js +1 -1
- package/src/utilities/node.js +26 -10
- package/src/utilities/tokens.js +7 -0
- package/src/variable.js +20 -11
- package/lib/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -62
- package/lib/resolve/substitution.js +0 -27
- package/lib/resolve/substitutions.js +0 -37
- package/lib/unify/metavariableWithFrame.js +0 -40
- package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -31
- package/lib/verify/declaration.js +0 -83
- package/lib/verify/frame.js +0 -120
- package/lib/verify/judgement.js +0 -88
- package/lib/verify/metavariableGivenMetaType.js +0 -44
- package/src/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -79
- package/src/resolve/substitution.js +0 -19
- package/src/resolve/substitutions.js +0 -31
- package/src/unify/metavariableWithFrame.js +0 -40
- package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -27
- package/src/verify/declaration.js +0 -113
- package/src/verify/frame.js +0 -157
- package/src/verify/judgement.js +0 -127
- package/src/verify/metavariableGivenMetaType.js +0 -45
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import resolveComplexSubstitutionAgainstSimpleSubstitution from "../resolve/complexSubstitutionAgainstSimpleSubstitution";
|
|
4
|
-
|
|
5
|
-
export default function resolveSubstitution(substitution, substitutions, localContextA, localContextB) {
|
|
6
|
-
let complexSubstitutionResolved = false;
|
|
7
|
-
|
|
8
|
-
const metavariableNode = substitution.getMetavariableNode(),
|
|
9
|
-
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode);
|
|
10
|
-
|
|
11
|
-
if (simpleSubstitution !== null) {
|
|
12
|
-
const complexSubstitution = substitution, ///
|
|
13
|
-
complexSubstitutionResolvedAgainstSimpleSubstitution = resolveComplexSubstitutionAgainstSimpleSubstitution(complexSubstitution, simpleSubstitution, substitutions, localContextA, localContextB);
|
|
14
|
-
|
|
15
|
-
complexSubstitutionResolved = complexSubstitutionResolvedAgainstSimpleSubstitution; ///
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return complexSubstitutionResolved;
|
|
19
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import LocalContext from "../context/local";
|
|
4
|
-
import resolveSubstitution from "../resolve/substitution";
|
|
5
|
-
|
|
6
|
-
export default function resolveSubstitutions(substitutions, fileContextA, localContextB) {
|
|
7
|
-
let substitutionsResolved = substitutions.areResolved();
|
|
8
|
-
|
|
9
|
-
if (!substitutionsResolved) {
|
|
10
|
-
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
11
|
-
metavariableNodes = substitutions.getMetavariableNodes();
|
|
12
|
-
|
|
13
|
-
substitutionsResolved = metavariableNodes.every((metavariableNode) => {
|
|
14
|
-
const complexSubstitutions = substitutions.findComplexSubstitutionsByMetavariableNode(metavariableNode),
|
|
15
|
-
complexSubstitutionsResolved = complexSubstitutions.everySubstitution((complexSubstitution) => {
|
|
16
|
-
const substitution = complexSubstitution, ///
|
|
17
|
-
complexSubstitutionResolved = resolveSubstitution(substitution, substitutions, localContextA, localContextB);
|
|
18
|
-
|
|
19
|
-
if (complexSubstitutionResolved) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (complexSubstitutionsResolved) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return substitutionsResolved;
|
|
31
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import FrameForMetavariableSubstitution from "../substitution/frameForMetavariable";
|
|
4
|
-
|
|
5
|
-
import { metavariableFromFrameNode } from "../utilities/unify";
|
|
6
|
-
import {metavariableNameFromMetavariableNode} from "../utilities/name";
|
|
7
|
-
|
|
8
|
-
export default function unifyMetavariableWithFrame(metavariableNodeA, frameNodeB, substitutions, localContextA, localContextB) {
|
|
9
|
-
let metavariableUnifiedWithFrame = false;
|
|
10
|
-
|
|
11
|
-
const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNodeA),
|
|
12
|
-
substitution = simpleSubstitution; ///
|
|
13
|
-
|
|
14
|
-
if (substitution !== null) {
|
|
15
|
-
const frameNodeMatches = substitution.matchFrameNode(frameNodeB);
|
|
16
|
-
|
|
17
|
-
if (frameNodeMatches) {
|
|
18
|
-
metavariableUnifiedWithFrame = true;
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
const metavariableNameA = metavariableNameFromMetavariableNode(metavariableNodeA),
|
|
22
|
-
metavariableA = localContextA.findMetavariableByMetavariableName(metavariableNameA),
|
|
23
|
-
metavariableB = metavariableFromFrameNode(frameNodeB, localContextB);
|
|
24
|
-
|
|
25
|
-
if (metavariableA === metavariableB) {
|
|
26
|
-
metavariableUnifiedWithFrame = true;
|
|
27
|
-
} else {
|
|
28
|
-
const frameNode = frameNodeB, ///
|
|
29
|
-
metavariableNode = metavariableNodeA, ///
|
|
30
|
-
frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameNodeAndMetavariableNode(frameNode, metavariableNode, localContextA, localContextB),
|
|
31
|
-
substitution = frameForMetavariableSubstitution; ///
|
|
32
|
-
|
|
33
|
-
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
34
|
-
|
|
35
|
-
metavariableUnifiedWithFrame = true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return metavariableUnifiedWithFrame;
|
|
40
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import metaLevelUnifier from "../unifier/metaLevel";
|
|
4
|
-
|
|
5
|
-
export default function unifyComplexSubstitutionStatementWithSimpleSubstitutionStatement(simpleSubstitutionStatementNode, complexSubstitutionStatementNode, substitutions, localContextA, localContextB) {
|
|
6
|
-
let simpleSubstitutionStatementUnifiedWithComplexSubstitutionStatement;
|
|
7
|
-
|
|
8
|
-
const simpleSubstitutionStatementString = localContextB.nodeAsString(simpleSubstitutionStatementNode),
|
|
9
|
-
complexSubstitutionStatementString = localContextB.nodeAsString(complexSubstitutionStatementNode);
|
|
10
|
-
|
|
11
|
-
localContextB.trace(`Unifying the simple substitution's '${simpleSubstitutionStatementString}' statement with the complex substitution's '${complexSubstitutionStatementString}' statement...`, simpleSubstitutionStatementNode);
|
|
12
|
-
|
|
13
|
-
const nodeA = complexSubstitutionStatementNode, ///
|
|
14
|
-
nodeB = simpleSubstitutionStatementNode; ///
|
|
15
|
-
|
|
16
|
-
localContextA = localContextB; ///
|
|
17
|
-
|
|
18
|
-
const unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
19
|
-
|
|
20
|
-
simpleSubstitutionStatementUnifiedWithComplexSubstitutionStatement = unifiedAtMetaLevel; ///
|
|
21
|
-
|
|
22
|
-
if (simpleSubstitutionStatementUnifiedWithComplexSubstitutionStatement) {
|
|
23
|
-
localContextB.trace(`...unified the simple substitution's '${simpleSubstitutionStatementString}' statement with the complex substitution's '${complexSubstitutionStatementString}' statement.`, simpleSubstitutionStatementNode);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return simpleSubstitutionStatementUnifiedWithComplexSubstitutionStatement;
|
|
27
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import shim from "../shim";
|
|
4
|
-
import Reference from "../reference";
|
|
5
|
-
import Declaration from "../declaration"
|
|
6
|
-
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
7
|
-
|
|
8
|
-
import { nodeQuery } from "../utilities/query";
|
|
9
|
-
import { referenceMetaType } from "../metaType";
|
|
10
|
-
|
|
11
|
-
const statementNodeQuery = nodeQuery("/declaration/statement"),
|
|
12
|
-
metavariableNodeQuery = nodeQuery("/declaration/reference/metavariable"); ///
|
|
13
|
-
|
|
14
|
-
const verifyDeclarationFunctions = [
|
|
15
|
-
verifyDerivedDeclaration,
|
|
16
|
-
verifyStatedDeclaration
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
export default function verifyDeclaration(declarationNode, declarations, stated, localContext) {
|
|
20
|
-
let declarationVerified;
|
|
21
|
-
|
|
22
|
-
const declarationString = localContext.nodeAsString(declarationNode);
|
|
23
|
-
|
|
24
|
-
localContext.trace(`Verifying the '${declarationString}' declaration...`, declarationNode);
|
|
25
|
-
|
|
26
|
-
declarationVerified = verifyDeclarationFunctions.some((verifyDeclarationFunction) => {
|
|
27
|
-
const declarationVerified = verifyDeclarationFunction(declarationNode, declarations, stated, localContext);
|
|
28
|
-
|
|
29
|
-
if (declarationVerified) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (declarationVerified) {
|
|
35
|
-
localContext.debug(`...verified the '${declarationString}' declaration.`, declarationNode);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return declarationVerified;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function verifyDerivedDeclaration(declarationNode, declarations, stated, localContext) {
|
|
42
|
-
let derivedDeclarationVerified;
|
|
43
|
-
|
|
44
|
-
if (!stated) {
|
|
45
|
-
const declarationString = localContext.nodeAsString(declarationNode);
|
|
46
|
-
|
|
47
|
-
localContext.trace(`Verifying the '${declarationString}' derived declaration...`, declarationNode);
|
|
48
|
-
|
|
49
|
-
const metaType = referenceMetaType, ///
|
|
50
|
-
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
51
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
52
|
-
|
|
53
|
-
if (metavariableVerifiedGivenMetaType) {
|
|
54
|
-
const { verifyStatement } = shim,
|
|
55
|
-
stated = true,
|
|
56
|
-
assignments = null,
|
|
57
|
-
statementNode = statementNodeQuery(declarationNode),
|
|
58
|
-
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
59
|
-
|
|
60
|
-
if (statementVerified) {
|
|
61
|
-
const reference = Reference.fromMetavariableNode(metavariableNode),
|
|
62
|
-
declaration = Declaration.fromReferenceAndStatementNode(reference, statementNode);
|
|
63
|
-
|
|
64
|
-
declarations.push(declaration);
|
|
65
|
-
|
|
66
|
-
derivedDeclarationVerified = true;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (derivedDeclarationVerified) {
|
|
71
|
-
localContext.debug(`...verified the '${declarationString}' derived declaration.`, declarationNode);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return derivedDeclarationVerified;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function verifyStatedDeclaration(declarationNode, declarations, stated, localContext) {
|
|
79
|
-
let statedDeclarationVerified = false;
|
|
80
|
-
|
|
81
|
-
if (stated) {
|
|
82
|
-
const declarationString = localContext.nodeAsString(declarationNode);
|
|
83
|
-
|
|
84
|
-
localContext.trace(`Verifying the '${declarationString}' stated declaration...`, declarationNode);
|
|
85
|
-
|
|
86
|
-
const metaType = referenceMetaType, ///
|
|
87
|
-
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
88
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
89
|
-
|
|
90
|
-
if (metavariableVerifiedGivenMetaType) {
|
|
91
|
-
const { verifyStatement } = shim,
|
|
92
|
-
stated = true,
|
|
93
|
-
assignments = null,
|
|
94
|
-
statementNode = statementNodeQuery(declarationNode),
|
|
95
|
-
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
96
|
-
|
|
97
|
-
if (statementVerified) {
|
|
98
|
-
const reference = Reference.fromMetavariableNode(metavariableNode),
|
|
99
|
-
declaration = Declaration.fromReferenceAndStatementNode(reference, statementNode);
|
|
100
|
-
|
|
101
|
-
declarations.push(declaration);
|
|
102
|
-
|
|
103
|
-
statedDeclarationVerified = true;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (statedDeclarationVerified) {
|
|
108
|
-
localContext.debug(`...verified the '${declarationString}' stated declaration.`, declarationNode);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return statedDeclarationVerified;
|
|
113
|
-
}
|
package/src/verify/frame.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import Frame from "../frame";
|
|
4
|
-
import verifyDeclaration from "../verify/declaration";
|
|
5
|
-
import verifyMetavariableGivenMetaType from "./metavariableGivenMetaType";
|
|
6
|
-
|
|
7
|
-
import { frameMetaType } from "../metaType";
|
|
8
|
-
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
9
|
-
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
10
|
-
|
|
11
|
-
const metavariableNodeQuery = nodeQuery("/frame/metavariable"),
|
|
12
|
-
declarationNodesQuery = nodesQuery("/frame/declaration"),
|
|
13
|
-
metavariableNodesQuery = nodesQuery("/frame/metavariable");
|
|
14
|
-
|
|
15
|
-
const verifyFrameFunctions = [
|
|
16
|
-
verifyDerivedFrame,
|
|
17
|
-
verifyStatedFrame
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export default function verifyFrame(frameNode, frames, stated, localContext) {
|
|
21
|
-
let frameVerified;
|
|
22
|
-
|
|
23
|
-
const frameString = localContext.nodeAsString(frameNode);
|
|
24
|
-
|
|
25
|
-
localContext.trace(`Verifying the '${frameString}' frame...`);
|
|
26
|
-
|
|
27
|
-
frameVerified = verifyFrameFunctions.some((verifyFrameFunction) => {
|
|
28
|
-
const frameVerified = verifyFrameFunction(frameNode, frames, stated, localContext);
|
|
29
|
-
|
|
30
|
-
if (frameVerified) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (frameVerified) {
|
|
36
|
-
localContext.debug(`...verified the '${frameString}' frame.`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return frameVerified;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function verifyDerivedFrame(frameNode, frames, stated, localContext) {
|
|
43
|
-
let derivedFrameVerified;
|
|
44
|
-
|
|
45
|
-
if (!stated) {
|
|
46
|
-
const frameString = localContext.nodeAsString(frameNode);
|
|
47
|
-
|
|
48
|
-
localContext.trace(`Verifying the '${frameString}' derived frame...`);
|
|
49
|
-
|
|
50
|
-
const declarations = [],
|
|
51
|
-
declarationNodes = declarationNodesQuery(frameNode),
|
|
52
|
-
declarationsVerified = declarationNodes.every((declarationNode) => {
|
|
53
|
-
const declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
54
|
-
|
|
55
|
-
if (declarationVerified) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
if (declarationsVerified) {
|
|
61
|
-
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
62
|
-
metavariablesVerified = metavariableNodes.every((metavariableNode) => {
|
|
63
|
-
const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localContext);
|
|
64
|
-
|
|
65
|
-
if (metavariableVerified) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (metavariablesVerified) {
|
|
71
|
-
const frame = Frame.fromDeclarations(declarations);
|
|
72
|
-
|
|
73
|
-
frames.push(frame);
|
|
74
|
-
|
|
75
|
-
derivedFrameVerified = true; ///
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (derivedFrameVerified) {
|
|
80
|
-
localContext.debug(`...verified the '${frameString}' derived frame.`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return derivedFrameVerified;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function verifyStatedFrame(frameNode, frames, stated, localContext) {
|
|
88
|
-
let statedFrameVerified;
|
|
89
|
-
|
|
90
|
-
if (stated) {
|
|
91
|
-
const frameString = localContext.nodeAsString(frameNode);
|
|
92
|
-
|
|
93
|
-
localContext.trace(`Verifying the '${frameString}' stated frame...`);
|
|
94
|
-
|
|
95
|
-
const declarationNodes = declarationNodesQuery(frameNode),
|
|
96
|
-
declarationNodesLength = declarationNodes.length;
|
|
97
|
-
|
|
98
|
-
if (declarationNodesLength === 0) {
|
|
99
|
-
const metavariableNode = metavariableNodeQuery(frameNode);
|
|
100
|
-
|
|
101
|
-
if (metavariableNode !== null) {
|
|
102
|
-
const metaType = frameMetaType, ///
|
|
103
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
104
|
-
|
|
105
|
-
if (metavariableVerifiedGivenMetaType) {
|
|
106
|
-
const frame = Frame.fromMetavariableNode(metavariableNode);
|
|
107
|
-
|
|
108
|
-
frames.push(frame);
|
|
109
|
-
|
|
110
|
-
statedFrameVerified = true;
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
localContext.trace(`The '${frameString}' stated frame cannot have more than one metavariable.`);
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
localContext.trace(`The '${frameString}' stated frame cannot have declarations.`);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (statedFrameVerified) {
|
|
120
|
-
localContext.debug(`...verified the '${frameString}' stated frame.`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return statedFrameVerified;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function verifyMetavariable(metavariableNode, declarations, localContext) {
|
|
128
|
-
let metavariableVerified = false;
|
|
129
|
-
|
|
130
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
131
|
-
|
|
132
|
-
localContext.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
133
|
-
|
|
134
|
-
const metaType = frameMetaType, ///
|
|
135
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
136
|
-
|
|
137
|
-
if (metavariableVerifiedGivenMetaType) {
|
|
138
|
-
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
139
|
-
judgement = localContext.findJudgementByMetavariableName(metavariableName);
|
|
140
|
-
|
|
141
|
-
if (judgement !== null) {
|
|
142
|
-
const declaration = judgement.getDeclaration();
|
|
143
|
-
|
|
144
|
-
declarations.push(declaration);
|
|
145
|
-
|
|
146
|
-
metavariableVerified = true;
|
|
147
|
-
} else {
|
|
148
|
-
localContext.trace(`There is no judgement for the '${metavariableString}' metavariable.`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (metavariableVerified) {
|
|
153
|
-
localContext.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return metavariableVerified;
|
|
157
|
-
}
|
package/src/verify/judgement.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
|
-
import Judgement from "../judgement";
|
|
6
|
-
import verifyFrame from "../verify/frame";
|
|
7
|
-
import verifyDeclaration from "./declaration";
|
|
8
|
-
import JudgementAssignment from "../assignment/judgement";
|
|
9
|
-
|
|
10
|
-
import { nodeQuery } from "../utilities/query";
|
|
11
|
-
|
|
12
|
-
const { first } = arrayUtilities;
|
|
13
|
-
|
|
14
|
-
const frameNodeQuery = nodeQuery("/judgement/frame"),
|
|
15
|
-
declarationNodeQuery = nodeQuery("/judgement/declaration");
|
|
16
|
-
|
|
17
|
-
const verifyJudgementFunctions = [
|
|
18
|
-
verifyDerivedJudgement,
|
|
19
|
-
verifyStatedJudgement
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
export default function verifyJudgement(judgementNode, assignments, stated, localContext) {
|
|
23
|
-
let judgementVerified;
|
|
24
|
-
|
|
25
|
-
const judgementString = localContext.nodeAsString(judgementNode);
|
|
26
|
-
|
|
27
|
-
localContext.trace(`Verifying the '${judgementString}' judgement...`, judgementNode);
|
|
28
|
-
|
|
29
|
-
judgementVerified = verifyJudgementFunctions.some((verifyJudgementFunction) => {
|
|
30
|
-
const judgementVerified = verifyJudgementFunction(judgementNode, assignments, stated, localContext);
|
|
31
|
-
|
|
32
|
-
if (judgementVerified) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if (judgementVerified) {
|
|
38
|
-
localContext.debug(`...verified the '${judgementString}' judgement.`, judgementNode);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return judgementVerified;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function verifyDerivedJudgement(judgementNode, assignments, stated, localContext) {
|
|
45
|
-
let derivedJudgementVerified = false;
|
|
46
|
-
|
|
47
|
-
if (!stated) {
|
|
48
|
-
const judgementString = localContext.nodeAsString(judgementNode);
|
|
49
|
-
|
|
50
|
-
localContext.trace(`Verifying the '${judgementString}' derived judgement...`, judgementNode);
|
|
51
|
-
|
|
52
|
-
const declarations = [],
|
|
53
|
-
declarationNode = declarationNodeQuery(judgementNode),
|
|
54
|
-
declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
55
|
-
|
|
56
|
-
if (declarationVerified) {
|
|
57
|
-
const firstDeclaration = first(declarations),
|
|
58
|
-
declaration = firstDeclaration, ///
|
|
59
|
-
metavariableNode = declaration.getMetavariableNode(),
|
|
60
|
-
metatheorem = localContext.findMetatheoremByMetavariableNode(metavariableNode),
|
|
61
|
-
metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
|
|
62
|
-
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
63
|
-
|
|
64
|
-
if (metaLemmaMetatheorem !== null) {
|
|
65
|
-
const frames = [],
|
|
66
|
-
frameNode = frameNodeQuery(judgementNode),
|
|
67
|
-
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
68
|
-
|
|
69
|
-
if (frameVerified) {
|
|
70
|
-
const firstFrame = first(frames),
|
|
71
|
-
frame = firstFrame, ///
|
|
72
|
-
metaLemmaMetatheoremUnified = frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem);
|
|
73
|
-
|
|
74
|
-
derivedJudgementVerified = metaLemmaMetatheoremUnified; ///
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (derivedJudgementVerified) {
|
|
80
|
-
localContext.debug(`...verified the '${judgementString}' derived judgement.`, judgementNode);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return derivedJudgementVerified;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function verifyStatedJudgement(judgementNode, assignments, stated, localContext) {
|
|
88
|
-
let statedJudgementVerified = false;
|
|
89
|
-
|
|
90
|
-
if (stated) {
|
|
91
|
-
const judgementString = localContext.nodeAsString(judgementNode);
|
|
92
|
-
|
|
93
|
-
localContext.trace(`Verifying the '${judgementString}' stated judgement...`, judgementNode);
|
|
94
|
-
|
|
95
|
-
const frames = [],
|
|
96
|
-
frameNode = frameNodeQuery(judgementNode),
|
|
97
|
-
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
98
|
-
|
|
99
|
-
if (frameVerified) {
|
|
100
|
-
const declarations = [],
|
|
101
|
-
declarationNode = declarationNodeQuery(judgementNode),
|
|
102
|
-
declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
103
|
-
|
|
104
|
-
if (declarationVerified) {
|
|
105
|
-
if (assignments !== null) {
|
|
106
|
-
const firstDeclaration = first(declarations),
|
|
107
|
-
firstFrame = first(frames),
|
|
108
|
-
frame = firstFrame,
|
|
109
|
-
declaration = firstDeclaration, ///
|
|
110
|
-
judgement = Judgement.fromJudgementNodeFrameAndDeclaration(judgementNode, frame, declaration),
|
|
111
|
-
judgementAssignment = JudgementAssignment.fromJudgement(judgement),
|
|
112
|
-
assignment = judgementAssignment;
|
|
113
|
-
|
|
114
|
-
assignments.push(assignment);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
statedJudgementVerified = true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (statedJudgementVerified) {
|
|
122
|
-
localContext.debug(`...verified the '${judgementString}' stated judgement.`, judgementNode);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return statedJudgementVerified;
|
|
127
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import metavariableUnifier from "../unifier/metavariable";
|
|
4
|
-
|
|
5
|
-
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
6
|
-
|
|
7
|
-
export default function verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext) {
|
|
8
|
-
let metavariableVerifiedGivenMetaType = false;
|
|
9
|
-
|
|
10
|
-
const metaTypeName = metaType.getName(),
|
|
11
|
-
metavariableString = localContext.nodeAsString(metavariableNode);
|
|
12
|
-
|
|
13
|
-
localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeName}' meta-type...`, metavariableNode);
|
|
14
|
-
|
|
15
|
-
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
16
|
-
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
17
|
-
|
|
18
|
-
if (metavariable !== null) {
|
|
19
|
-
const metavariableMetaType = metavariable.getMetaType();
|
|
20
|
-
|
|
21
|
-
if (metavariableMetaType === metaType) {
|
|
22
|
-
const metavariableNodeA = metavariableNode; ///
|
|
23
|
-
|
|
24
|
-
metavariableNode = metavariable.getNode();
|
|
25
|
-
|
|
26
|
-
const metavariableNodeB = metavariableNode; ///
|
|
27
|
-
|
|
28
|
-
const metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
29
|
-
|
|
30
|
-
metavariableVerifiedGivenMetaType = metavariableUnified; ///
|
|
31
|
-
} else {
|
|
32
|
-
const metavariableMetaTypeName = metavariableMetaType.getName();
|
|
33
|
-
|
|
34
|
-
localContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metavariableMetaTypeName}' when it should be '${metaTypeName}'.`, metavariableNode);
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (metavariableVerifiedGivenMetaType) {
|
|
41
|
-
localContext.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeName}' meta-type.`, metavariableNode);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return metavariableVerifiedGivenMetaType;
|
|
45
|
-
}
|