occam-verify-cli 0.0.968 → 0.0.971
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/bin/action/verify.js +6 -8
- package/lib/constants.js +5 -1
- package/lib/context/file.js +48 -53
- package/lib/context/local.js +45 -39
- package/lib/context/release.js +3 -3
- package/lib/declaration.js +9 -7
- package/lib/equivalence.js +23 -21
- package/lib/judgement.js +3 -3
- package/lib/label.js +3 -3
- package/lib/log.js +3 -3
- package/lib/metaType.js +7 -7
- package/lib/metavariable.js +7 -7
- package/lib/node/term/bracketed.js +16 -0
- package/lib/proofStep.js +3 -29
- package/lib/releaseContext/initialise.js +11 -17
- package/lib/resolve/substitutions.js +99 -0
- package/lib/rule.js +10 -6
- package/lib/substitution/statementForMetavariable.js +93 -98
- package/lib/substitution/termForVariable.js +45 -54
- package/lib/substitution.js +51 -9
- package/lib/substitutions.js +165 -12
- package/lib/term.js +8 -1
- package/lib/topLevelAssertion.js +10 -6
- package/lib/type.js +5 -5
- package/lib/unifier/metaLevel.js +10 -3
- package/lib/unifier/statementWithCombinator.js +6 -6
- package/lib/unifier.js +2 -2
- package/lib/unify/metavariableWithStatement.js +13 -48
- package/lib/unify/metavariableWithStatementGivenSubstitution.js +39 -0
- package/lib/unify/premiseWithProofStep.js +3 -3
- package/lib/unify/statement/qualified.js +117 -0
- package/lib/unify/statement/unqualified.js +25 -0
- package/lib/unify/statementWithBracketedCombinator.js +3 -3
- package/lib/unify/statementWithCombinators.js +5 -5
- package/lib/unify/statementWithMetaType.js +3 -3
- package/lib/unify/statementWithSttaemetnGivenEquivalences.js +45 -0
- package/lib/unify/suppositionWithProffStep.js +3 -3
- package/lib/unify/variableWithTerm.js +11 -26
- package/lib/utilities/array.js +5 -14
- package/lib/utilities/assertion.js +24 -0
- package/lib/utilities/brackets.js +60 -0
- package/lib/utilities/message.js +52 -0
- package/lib/utilities/name.js +7 -7
- package/lib/utilities/node.js +10 -17
- package/lib/utilities/string.js +1 -7
- package/lib/utilities/subproof.js +19 -0
- package/lib/utilities/unify.js +30 -11
- package/lib/variable.js +8 -8
- package/lib/verifier/metaLevel.js +6 -6
- package/lib/verifier/statementAsCombinator.js +2 -2
- package/lib/verify/assertion/contained.js +66 -32
- package/lib/verify/assertion/defined.js +51 -46
- package/lib/verify/assertion/subproof.js +9 -9
- package/lib/verify/assertion/type.js +11 -11
- package/lib/verify/conclusion.js +6 -6
- package/lib/verify/consequent.js +6 -6
- package/lib/verify/declaration/metavariable.js +2 -2
- package/lib/verify/declaration.js +34 -20
- package/lib/verify/equality.js +13 -13
- package/lib/verify/frame.js +38 -24
- package/lib/verify/judgement.js +13 -13
- package/lib/verify/metavariable.js +2 -2
- package/lib/verify/premise.js +5 -5
- package/lib/verify/proofStep.js +15 -24
- package/lib/verify/statement/qualified.js +15 -124
- package/lib/verify/statement/unqualified.js +23 -24
- package/lib/verify/statement.js +24 -24
- package/lib/verify/statementGivenMetaType.js +3 -3
- package/lib/verify/supposition.js +5 -5
- package/package.json +2 -2
- package/src/constants.js +1 -0
- package/src/context/file.js +49 -55
- package/src/context/local.js +34 -31
- package/src/context/release.js +2 -2
- package/src/declaration.js +12 -10
- package/src/equivalence.js +27 -26
- package/src/judgement.js +2 -2
- package/src/label.js +2 -2
- package/src/log.js +1 -1
- package/src/metaType.js +7 -7
- package/src/metavariable.js +7 -7
- package/src/node/term/bracketed.js +9 -0
- package/src/proofStep.js +3 -48
- package/src/releaseContext/initialise.js +13 -24
- package/src/resolve/substitutions.js +134 -0
- package/src/rule.js +10 -5
- package/src/substitution/statementForMetavariable.js +99 -85
- package/src/substitution/termForVariable.js +50 -65
- package/src/substitution.js +46 -8
- package/src/substitutions.js +176 -10
- package/src/term.js +6 -0
- package/src/topLevelAssertion.js +10 -5
- package/src/type.js +4 -4
- package/src/unifier/metaLevel.js +11 -3
- package/src/unifier/statementWithCombinator.js +5 -5
- package/src/unifier.js +1 -1
- package/src/unify/metavariableWithStatement.js +17 -71
- package/src/unify/metavariableWithStatementGivenSubstitution.js +39 -0
- package/src/unify/premiseWithProofStep.js +1 -1
- package/src/unify/statement/qualified.js +183 -0
- package/src/unify/statement/unqualified.js +24 -0
- package/src/unify/statementWithBracketedCombinator.js +2 -2
- package/src/unify/statementWithCombinators.js +4 -4
- package/src/unify/statementWithMetaType.js +2 -2
- package/src/unify/statementWithSttaemetnGivenEquivalences.js +51 -0
- package/src/unify/suppositionWithProffStep.js +1 -1
- package/src/unify/variableWithTerm.js +14 -35
- package/src/utilities/array.js +1 -16
- package/src/utilities/assertion.js +19 -0
- package/src/utilities/brackets.js +56 -0
- package/src/utilities/name.js +8 -8
- package/src/utilities/node.js +14 -17
- package/src/utilities/string.js +2 -2
- package/src/utilities/subproof.js +18 -0
- package/src/utilities/unify.js +24 -12
- package/src/variable.js +11 -11
- package/src/verifier/metaLevel.js +5 -5
- package/src/verifier/statementAsCombinator.js +2 -2
- package/src/verify/assertion/contained.js +80 -38
- package/src/verify/assertion/defined.js +64 -55
- package/src/verify/assertion/subproof.js +8 -8
- package/src/verify/assertion/type.js +11 -11
- package/src/verify/conclusion.js +8 -8
- package/src/verify/consequent.js +8 -8
- package/src/verify/declaration/metavariable.js +4 -3
- package/src/verify/declaration.js +46 -23
- package/src/verify/equality.js +13 -13
- package/src/verify/frame.js +48 -28
- package/src/verify/judgement.js +13 -13
- package/src/verify/metavariable.js +3 -3
- package/src/verify/premise.js +6 -6
- package/src/verify/proofStep.js +14 -31
- package/src/verify/statement/qualified.js +18 -199
- package/src/verify/statement/unqualified.js +25 -31
- package/src/verify/statement.js +23 -23
- package/src/verify/statementGivenMetaType.js +2 -2
- package/src/verify/supposition.js +6 -6
- package/lib/unify/statementAtainstStatement.js +0 -49
- package/lib/utilities/lineIndex.js +0 -52
- package/lib/utilities/match.js +0 -59
- package/lib/utilities/verify.js +0 -19
- package/src/unify/statementAtainstStatement.js +0 -56
- package/src/utilities/match.js +0 -53
- package/src/utilities/verify.js +0 -14
- /package/src/utilities/{lineIndex.js → message.js} +0 -0
package/src/proofStep.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import intrinsicLevelUnifier from "./unifier/intrinsicLevel";
|
|
3
|
+
import unifyStatementWithStatementGivenEquivalences from "./unify/statementWithSttaemetnGivenEquivalences";
|
|
5
4
|
|
|
6
5
|
export default class ProofStep {
|
|
7
6
|
constructor(subproofNode, statementNode) {
|
|
@@ -21,26 +20,8 @@ export default class ProofStep {
|
|
|
21
20
|
let statementUnified = false;
|
|
22
21
|
|
|
23
22
|
if (this.statementNode !== null) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!statementUnifiedWithStatement) {
|
|
27
|
-
const statementNodeA = this.statementNode; ///
|
|
28
|
-
|
|
29
|
-
statementUnifiedWithStatement = unifyStatementWithStatement(statementNodeA, statementNodeB, equivalences, localContextA, localContextB);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!statementUnifiedWithStatement) {
|
|
33
|
-
const statementNodeA = statementNodeB, ///
|
|
34
|
-
localContext = localContextA; ///
|
|
35
|
-
|
|
36
|
-
statementNodeB = this.statementNode; ///
|
|
37
|
-
|
|
38
|
-
localContextA = localContextB; ///
|
|
39
|
-
|
|
40
|
-
localContextB = localContext; ///
|
|
41
|
-
|
|
42
|
-
statementUnifiedWithStatement = unifyStatementWithStatement(statementNodeA, statementNodeB, equivalences, localContextA, localContextB);
|
|
43
|
-
}
|
|
23
|
+
const statementNodeA = this.statementNode, ///
|
|
24
|
+
statementUnifiedWithStatement = unifyStatementWithStatementGivenEquivalences(statementNodeA, statementNodeB, equivalences, localContextA, localContextB);
|
|
44
25
|
|
|
45
26
|
statementUnified = statementUnifiedWithStatement; ///
|
|
46
27
|
}
|
|
@@ -62,29 +43,3 @@ export default class ProofStep {
|
|
|
62
43
|
return proofStep;
|
|
63
44
|
}
|
|
64
45
|
}
|
|
65
|
-
|
|
66
|
-
function unifyStatementWithStatement(statementNodeA, statementNodeB, equivalences, localContextA, localContextB) {
|
|
67
|
-
let statementUnifiedWithStatement = false;
|
|
68
|
-
|
|
69
|
-
const statementStringA = localContextA.nodeAsString(statementNodeA),
|
|
70
|
-
statementStringB = localContextB.nodeAsString(statementNodeB);
|
|
71
|
-
|
|
72
|
-
localContextB.trace(`Unifying the '${statementStringB}' statement with the '${statementStringA}' statement...`, statementNodeB);
|
|
73
|
-
|
|
74
|
-
const substitutions = Substitutions.fromNothing(),
|
|
75
|
-
nodeA = statementNodeA, ///
|
|
76
|
-
nodeB = statementNodeB, ///
|
|
77
|
-
unified = intrinsicLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
78
|
-
|
|
79
|
-
if (unified) {
|
|
80
|
-
const substitutionsUnifiedWithEquivalences = substitutions.unifyWithEquivalences(equivalences, localContextA, localContextB);
|
|
81
|
-
|
|
82
|
-
statementUnifiedWithStatement = substitutionsUnifiedWithEquivalences; ///
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (statementUnifiedWithStatement) {
|
|
86
|
-
localContextB.debug(`...unified the '${statementStringB}' statement with the '${statementStringA}' statement.`, statementNodeB);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return statementUnifiedWithStatement;
|
|
90
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export default function initialiseReleaseContext(dependency,
|
|
3
|
+
export default function initialiseReleaseContext(dependency, context) {
|
|
4
4
|
let releaseContextInitialised = false;
|
|
5
5
|
|
|
6
6
|
const { releaseContextMap } = context,
|
|
@@ -16,27 +16,19 @@ export default function initialiseReleaseContext(dependency, dependentName, depe
|
|
|
16
16
|
releaseContextInitialised = releaseContext.isInitialised();
|
|
17
17
|
|
|
18
18
|
if (!releaseContextInitialised) {
|
|
19
|
-
const
|
|
19
|
+
const dependencyReleaseContextsInitialised = initialiseDependencyReleaseContexts(dependency, releaseContext, context);
|
|
20
20
|
|
|
21
|
-
if (
|
|
22
|
-
const { log } = context
|
|
21
|
+
if (dependencyReleaseContextsInitialised) {
|
|
22
|
+
const { log } = context,
|
|
23
|
+
releaseContexts = retrieveReleaseContexts(releaseContext, releaseContextMap);
|
|
23
24
|
|
|
24
|
-
log.
|
|
25
|
-
} else {
|
|
26
|
-
const dependencyReleaseContextsInitialised = initialiseDependencyReleaseContexts(dependency, releaseContext, released, context);
|
|
25
|
+
log.debug(`Initialising the '${dependencyName}' context...`);
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
const { log } = context,
|
|
30
|
-
releaseContexts = retrieveReleaseContexts(releaseContext, releaseContextMap);
|
|
27
|
+
releaseContextInitialised = releaseContext.initialise(releaseContexts);
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
releaseContextInitialised ?
|
|
37
|
-
log.info(`...initialised the '${dependencyName}' context.`) :
|
|
38
|
-
log.warning(`...unable to initialise the '${dependencyName}' context.`);
|
|
39
|
-
}
|
|
29
|
+
releaseContextInitialised ?
|
|
30
|
+
log.info(`...initialised the '${dependencyName}' context.`) :
|
|
31
|
+
log.warning(`...unable to initialise the '${dependencyName}' context.`);
|
|
40
32
|
}
|
|
41
33
|
}
|
|
42
34
|
}
|
|
@@ -81,13 +73,10 @@ function retrieveReleaseContexts(releaseContext, releaseContextMap) {
|
|
|
81
73
|
return releaseContexts;
|
|
82
74
|
}
|
|
83
75
|
|
|
84
|
-
function initialiseDependencyReleaseContexts(dependency, releaseContext,
|
|
85
|
-
const
|
|
86
|
-
dependentName = dependencyName, ///
|
|
87
|
-
dependencies = releaseContext.getDependencies(),
|
|
88
|
-
dependentReleased = released, ///
|
|
76
|
+
function initialiseDependencyReleaseContexts(dependency, releaseContext, context) {
|
|
77
|
+
const dependencies = releaseContext.getDependencies(),
|
|
89
78
|
dependencyReleaseContextsInitialised = dependencies.everyDependency((dependency) => { ///
|
|
90
|
-
const releaseContextInitialised = initialiseReleaseContext(dependency,
|
|
79
|
+
const releaseContextInitialised = initialiseReleaseContext(dependency, context);
|
|
91
80
|
|
|
92
81
|
if (releaseContextInitialised) {
|
|
93
82
|
return true;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import LocalContext from "../context/local";
|
|
4
|
+
import Substitutions from "../substitutions";
|
|
5
|
+
import metaLevelUnifier from "../unifier/metaLevel";
|
|
6
|
+
|
|
7
|
+
export default function resolveSubstitutions(substitutions, fileContextA, localContextB) {
|
|
8
|
+
let substitutionsResolved = substitutions.areResolved();
|
|
9
|
+
|
|
10
|
+
if (!substitutionsResolved) {
|
|
11
|
+
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
12
|
+
metavariableNodes = substitutions.getMetavariableNodes();
|
|
13
|
+
|
|
14
|
+
substitutionsResolved = metavariableNodes.every((metavariableNode) => {
|
|
15
|
+
const complexSubstitutions = substitutions.findComplexSubstitutionsByMetavariableNode(metavariableNode),
|
|
16
|
+
complexSubstitutionsResolved = resolveComplexSubstitutions(complexSubstitutions, substitutions, localContextA, localContextB);
|
|
17
|
+
|
|
18
|
+
if (complexSubstitutionsResolved) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return substitutionsResolved;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function resolveComplexSubstitution(complexSubstitution, substitutions, localContextA, localContextB) {
|
|
28
|
+
let complexSubstitutionResolved = false;
|
|
29
|
+
|
|
30
|
+
const metavariableNode = complexSubstitution.getMetavariableNode(),
|
|
31
|
+
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode);
|
|
32
|
+
|
|
33
|
+
if (simpleSubstitution !== null) {
|
|
34
|
+
const complexSubstitutionResolvedAgainstSimpleSubstitution = resolveComplexSubstitutionAgainstSimpleSubstitution(complexSubstitution, simpleSubstitution, substitutions, localContextA, localContextB);
|
|
35
|
+
|
|
36
|
+
complexSubstitutionResolved = complexSubstitutionResolvedAgainstSimpleSubstitution; ///
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return complexSubstitutionResolved;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function resolveComplexSubstitutions(complexSubstitutions, substitutions, localContextA, localContextB) {
|
|
43
|
+
const complexSubstitutionsResolved = complexSubstitutions.everySubstitution((complexSubstitution) => {
|
|
44
|
+
const complexSubstitutionResolved = resolveComplexSubstitution(complexSubstitution, substitutions, localContextA, localContextB);
|
|
45
|
+
|
|
46
|
+
if (complexSubstitutionResolved) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return complexSubstitutionsResolved;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function resolveComplexSubstitutionAgainstSimpleSubstitution(complexSubstitution, simpleSubstitution, substitutions, localContextA, localContextB) {
|
|
55
|
+
let complexSubstitutionResolvedAgainstSimpleSubstitution = false;
|
|
56
|
+
|
|
57
|
+
const statementNode = complexSubstitution.getStatementNode(),
|
|
58
|
+
simpleSubstitutionString = simpleSubstitution.asString(localContextA, localContextB),
|
|
59
|
+
complexSubstitutionString = complexSubstitution.asString(localContextA, localContextB);
|
|
60
|
+
|
|
61
|
+
localContextB.trace(`Resolving the complex ${complexSubstitutionString} substitution against the simple ${simpleSubstitutionString} substitution...`, statementNode);
|
|
62
|
+
|
|
63
|
+
const transformedSubstitution = transformedSubstitutionFromComplexSubstitutionSimpleSubstitutionAndSubstitutions(complexSubstitution, simpleSubstitution, substitutions, localContextA, localContextB);
|
|
64
|
+
|
|
65
|
+
if (transformedSubstitution !== null) {
|
|
66
|
+
const variableNode = transformedSubstitution.getVariableNode(),
|
|
67
|
+
substitution = substitutions.findSubstitutionByVariableNode(variableNode);
|
|
68
|
+
|
|
69
|
+
if (substitution === null) {
|
|
70
|
+
simpleSubstitution = transformedSubstitution; ///
|
|
71
|
+
|
|
72
|
+
substitutions.addSubstitution(simpleSubstitution, localContextA, localContextB);
|
|
73
|
+
|
|
74
|
+
substitutions.removeSubstitution(complexSubstitution, localContextA, localContextB);
|
|
75
|
+
|
|
76
|
+
complexSubstitutionResolvedAgainstSimpleSubstitution = true;
|
|
77
|
+
} else {
|
|
78
|
+
const termNode = transformedSubstitution.getTermNode(),
|
|
79
|
+
termNodeMatches = substitution.matchTermNode(termNode);
|
|
80
|
+
|
|
81
|
+
if (termNodeMatches) {
|
|
82
|
+
substitutions.removeSubstitution(complexSubstitution, localContextA, localContextB);
|
|
83
|
+
|
|
84
|
+
complexSubstitutionResolvedAgainstSimpleSubstitution = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (complexSubstitutionResolvedAgainstSimpleSubstitution) {
|
|
90
|
+
localContextB.debug(`...resolved the complex ${complexSubstitutionString} substitution against the simple ${simpleSubstitutionString} substitution.`, statementNode);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return complexSubstitutionResolvedAgainstSimpleSubstitution;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function unifyComplexSubstitutionStatementWithSimpleSubstitutionStatement(complexSubstitutionStatementNode, simpleSubstitutionStatementNode, substitutions, localContextA, localContextB) {
|
|
97
|
+
let complexSubstitutionStatementWithSimpleSubstitutionStatement;
|
|
98
|
+
|
|
99
|
+
const nodeA = complexSubstitutionStatementNode, ///
|
|
100
|
+
nodeB = simpleSubstitutionStatementNode; ///
|
|
101
|
+
|
|
102
|
+
localContextA = localContextB; ///
|
|
103
|
+
|
|
104
|
+
const unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
105
|
+
|
|
106
|
+
complexSubstitutionStatementWithSimpleSubstitutionStatement = unified; ///
|
|
107
|
+
|
|
108
|
+
return complexSubstitutionStatementWithSimpleSubstitutionStatement;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function transformedSubstitutionFromComplexSubstitutionSimpleSubstitutionAndSubstitutions(complexSubstitution, simpleSubstitution, substitutions, localContextA, localContextB) {
|
|
112
|
+
let transformedSubstitution;
|
|
113
|
+
|
|
114
|
+
const substitution = complexSubstitution.getSubstitution();
|
|
115
|
+
|
|
116
|
+
transformedSubstitution = substitution.transformed(substitutions);
|
|
117
|
+
|
|
118
|
+
if (transformedSubstitution !== null) {
|
|
119
|
+
const simpleSubstitutionStatementNode = simpleSubstitution.getStatementNode(),
|
|
120
|
+
complexSubstitutionStatementNode = complexSubstitution.getStatementNode();
|
|
121
|
+
|
|
122
|
+
substitutions = Substitutions.fromNothing(); ///
|
|
123
|
+
|
|
124
|
+
const complexSubstitutionStatementWithSimpleSubstitutionStatement = unifyComplexSubstitutionStatementWithSimpleSubstitutionStatement(complexSubstitutionStatementNode, simpleSubstitutionStatementNode, substitutions, localContextA, localContextB);
|
|
125
|
+
|
|
126
|
+
if (complexSubstitutionStatementWithSimpleSubstitutionStatement) {
|
|
127
|
+
const substitution = transformedSubstitution; ///
|
|
128
|
+
|
|
129
|
+
transformedSubstitution = substitution.transformed(substitutions);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return transformedSubstitution;
|
|
134
|
+
}
|
package/src/rule.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Substitutions from "./substitutions";
|
|
4
|
+
import resolveSubstitutions from "./resolve/substitutions";
|
|
4
5
|
import unifyPremisesWithProofSteps from "./unify/premisesWithProofSteps";
|
|
5
6
|
import unifyConclusionWithStatement from "./unify/conclusionWithStatement";
|
|
6
7
|
|
|
@@ -43,22 +44,26 @@ export default class Rule {
|
|
|
43
44
|
const conclusionA = this.conclusion, ///
|
|
44
45
|
conclusionUnified = unifyConclusionWithStatement(conclusionA, statementNode, substitutions, fileContextA, localContextB);
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
if (conclusionUnified) {
|
|
48
|
+
const substitutionsResolved = resolveSubstitutions(substitutions, fileContextA, localContextB);
|
|
49
|
+
|
|
50
|
+
statementUnified = substitutionsResolved; ///
|
|
51
|
+
}
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
return statementUnified;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
matchMetavariableNode(metavariableNode) {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
58
|
+
const metavariableNodeMatches = this.labels.some((label) => {
|
|
59
|
+
const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
|
|
55
60
|
|
|
56
|
-
if (
|
|
61
|
+
if (metavariableNodeMatches) {
|
|
57
62
|
return true;
|
|
58
63
|
}
|
|
59
64
|
});
|
|
60
65
|
|
|
61
|
-
return
|
|
66
|
+
return metavariableNodeMatches;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
static fromLabelsPremisesConclusionAndFileContext(labels, premises, conclusion, fileContext) {
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import shim from "../shim";
|
|
4
3
|
import Substitution from "../substitution";
|
|
5
|
-
import TermForVariableSubstitution from "
|
|
6
|
-
import unifyStatementWithStatement from "../unify/statementAtainstStatement";
|
|
4
|
+
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
7
5
|
|
|
8
6
|
import { nodeQuery } from "../utilities/query";
|
|
9
|
-
import {
|
|
7
|
+
import { stripBracketsFromStatement } from "../utilities/brackets";
|
|
10
8
|
|
|
11
|
-
const
|
|
9
|
+
const statementNodeQuery = nodeQuery("/substitution/statement!"),
|
|
10
|
+
metavariableNodeQuery = nodeQuery("/*/metavariable!");
|
|
12
11
|
|
|
13
12
|
export default class StatementForMetavariableSubstitution extends Substitution {
|
|
14
|
-
constructor(
|
|
13
|
+
constructor(statementNode, metavariableNode, substitution) {
|
|
15
14
|
super();
|
|
16
15
|
|
|
17
|
-
this.metavariableNode = metavariableNode;
|
|
18
16
|
this.statementNode = statementNode;
|
|
17
|
+
this.metavariableNode = metavariableNode;
|
|
19
18
|
this.substitution = substitution;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
getMetavariableNode() {
|
|
23
|
-
return this.metavariableNode;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
21
|
getStatementNode() {
|
|
27
22
|
return this.statementNode;
|
|
28
23
|
}
|
|
29
24
|
|
|
25
|
+
getMetavariableNode() {
|
|
26
|
+
return this.metavariableNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
30
29
|
getSubstitution() {
|
|
31
30
|
return this.substitution;
|
|
32
31
|
}
|
|
@@ -37,129 +36,144 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
37
36
|
return node;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
statementNodeB = this.statementNode, ///
|
|
43
|
-
statementNodesMatch = matchStatementModuloBrackets(statementNodeA, statementNodeB),
|
|
44
|
-
statementNodeMatches = statementNodesMatch; ///
|
|
39
|
+
isSimple() {
|
|
40
|
+
const simple = (this.substitution === null);
|
|
45
41
|
|
|
46
|
-
return
|
|
42
|
+
return simple;
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return metavariableNodeMatches;
|
|
53
|
-
}
|
|
45
|
+
transformed(substitutions) {
|
|
46
|
+
let transformedSubstitution = null;
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
let statementNodeMatches;
|
|
48
|
+
const transformedStatementNode = transformStatementNode(this.statementNode, substitutions);
|
|
57
49
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
if (transformedStatementNode !== null) {
|
|
51
|
+
const substitution = null,
|
|
52
|
+
statementNode = transformedStatementNode, ///
|
|
53
|
+
metavariableNode = this.metavariableNode, ///
|
|
54
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode, substitution);
|
|
61
55
|
|
|
62
|
-
|
|
56
|
+
transformedSubstitution = statementForMetavariableSubstitution; ///
|
|
57
|
+
}
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
return transformedSubstitution;
|
|
60
|
+
}
|
|
66
61
|
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
matchStatementNode(statementNode) {
|
|
63
|
+
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
69
64
|
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
}
|
|
65
|
+
const statementNodeMatches = this.statementNode.match(statementNode);
|
|
73
66
|
|
|
74
67
|
return statementNodeMatches;
|
|
75
68
|
}
|
|
76
69
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const metavariableNode = metavariableNodeQuery(this.statementNode);
|
|
70
|
+
matchMetavariableNode(metavariableNode) {
|
|
71
|
+
const metavariableNodeMatches = this.metavariableNode.match(metavariableNode);
|
|
81
72
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
...substitutions
|
|
85
|
-
];
|
|
73
|
+
return metavariableNodeMatches;
|
|
74
|
+
}
|
|
86
75
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
nodeB = metavariableNode, ///
|
|
90
|
-
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
76
|
+
matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
77
|
+
const metavariableNodeAndSubstitutionNodeMatches = false;
|
|
91
78
|
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return unifiedWithEquivalence;
|
|
79
|
+
return metavariableNodeAndSubstitutionNodeMatches;
|
|
96
80
|
}
|
|
97
81
|
|
|
98
82
|
asString(localContextA, localContextB) {
|
|
83
|
+
let string;
|
|
84
|
+
|
|
99
85
|
const statementNodeB = this.statementNode, ///
|
|
100
86
|
statementStringB = localContextB.nodeAsString(statementNodeB),
|
|
101
87
|
metavariableNodeA = this.metavariableNode, ///
|
|
102
|
-
metavariableStringA = localContextA.nodeAsString(metavariableNodeA)
|
|
103
|
-
|
|
88
|
+
metavariableStringA = localContextA.nodeAsString(metavariableNodeA);
|
|
89
|
+
|
|
90
|
+
if (this.substitution === null) {
|
|
91
|
+
string = `[${statementStringB} for ${metavariableStringA}]`;
|
|
92
|
+
} else {
|
|
93
|
+
const substitutionString = this.substitution.asString(localContextA, localContextA);
|
|
94
|
+
|
|
95
|
+
string = `[${statementStringB} for ${metavariableStringA}${substitutionString}]`;
|
|
96
|
+
}
|
|
104
97
|
|
|
105
98
|
return string;
|
|
106
99
|
}
|
|
107
100
|
|
|
108
|
-
static
|
|
109
|
-
let statementForMetavariableSubstitution;
|
|
110
|
-
|
|
111
|
-
const substitution = null;
|
|
101
|
+
static fromSubstitutionNode(substitutionNode) {
|
|
102
|
+
let statementForMetavariableSubstitution = null;
|
|
112
103
|
|
|
113
|
-
|
|
104
|
+
let statementNode = statementNodeQuery(substitutionNode),
|
|
105
|
+
metavariableNode = metavariableNodeQuery(substitutionNode);
|
|
114
106
|
|
|
115
|
-
|
|
107
|
+
if (statementNode !== null) {
|
|
108
|
+
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
116
109
|
|
|
117
|
-
|
|
118
|
-
const statementNode = bracketedStatementChildNode; ///
|
|
110
|
+
const substitution = null;
|
|
119
111
|
|
|
120
|
-
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(
|
|
112
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode, substitution);
|
|
121
113
|
}
|
|
122
114
|
|
|
123
115
|
return statementForMetavariableSubstitution;
|
|
124
116
|
}
|
|
125
117
|
|
|
126
|
-
static
|
|
127
|
-
|
|
118
|
+
static fromStatementNodeAndMetavariableNode(statementNode, metavariableNode) {
|
|
119
|
+
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
128
120
|
|
|
129
|
-
|
|
121
|
+
const substitution = null,
|
|
122
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode, substitution);
|
|
130
123
|
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
return statementForMetavariableSubstitution;
|
|
125
|
+
}
|
|
133
126
|
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
static fromStatementNodeMetavariableNodeAndSubstitutionNode(statementNode, metavariableNode, substitutionNode) {
|
|
128
|
+
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
136
129
|
|
|
137
|
-
|
|
130
|
+
const substitution = substitutionFromSubstitutionNode(substitutionNode),
|
|
131
|
+
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode, substitution);
|
|
138
132
|
|
|
139
|
-
|
|
133
|
+
return statementForMetavariableSubstitution;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
140
136
|
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
function substitutionFromSubstitutionNode(substitutionNode) {
|
|
138
|
+
let substitution = null;
|
|
143
139
|
|
|
144
|
-
|
|
140
|
+
if (substitution === null) {
|
|
141
|
+
const termForVariableSubstitution = TermForVariableSubstitution.fromSubstitutionNode(substitutionNode);
|
|
142
|
+
|
|
143
|
+
if (termForVariableSubstitution !== null) {
|
|
144
|
+
substitution = termForVariableSubstitution; ///
|
|
145
145
|
}
|
|
146
|
+
}
|
|
146
147
|
|
|
147
|
-
|
|
148
|
+
if (substitution === null) {
|
|
149
|
+
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromSubstitutionNode(substitutionNode);
|
|
150
|
+
|
|
151
|
+
if (statementForMetavariableSubstitution !== null) {
|
|
152
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
153
|
+
}
|
|
148
154
|
}
|
|
155
|
+
|
|
156
|
+
return substitution;
|
|
149
157
|
}
|
|
150
158
|
|
|
151
|
-
function
|
|
152
|
-
let
|
|
159
|
+
function transformStatementNode(statementNode, substitutions) {
|
|
160
|
+
let transformedStatementNode = null;
|
|
153
161
|
|
|
154
|
-
|
|
155
|
-
|
|
162
|
+
const metavariableNode = metavariableNodeQuery(statementNode);
|
|
163
|
+
|
|
164
|
+
if (metavariableNode !== null) {
|
|
165
|
+
substitutions.someSubstitution((substitution) => {
|
|
166
|
+
const substitutionMatchesVariableNode = substitution.matchVariableNode(metavariableNode);
|
|
156
167
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const statementUnifiedWithStatement = unifyStatementWithStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
168
|
+
if (substitutionMatchesVariableNode) {
|
|
169
|
+
const statementNode = substitution.getStatementNode();
|
|
160
170
|
|
|
161
|
-
|
|
171
|
+
transformedStatementNode = statementNode; ////
|
|
172
|
+
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
162
176
|
}
|
|
163
177
|
|
|
164
|
-
return
|
|
165
|
-
}
|
|
178
|
+
return transformedStatementNode;
|
|
179
|
+
}
|