occam-verify-cli 0.0.959 → 0.0.961
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 +16 -5
- package/bin/utilities/releaseContext.js +5 -8
- package/lib/context/file.js +38 -14
- package/lib/context/local.js +3 -9
- package/lib/context/release.js +82 -52
- package/lib/frame.js +3 -3
- package/lib/index.js +5 -5
- package/lib/metavariable.js +9 -9
- package/lib/proofStep.js +21 -18
- package/lib/releaseContext/create.js +8 -9
- package/lib/releaseContext/initialise.js +67 -0
- package/lib/rule.js +5 -5
- package/lib/substitution/statementForMetavariable.js +8 -8
- package/lib/substitution/termForVariable.js +29 -30
- package/lib/substitution.js +7 -7
- package/lib/substitutions.js +7 -7
- package/lib/topLevelAssertion.js +5 -5
- package/lib/unifier/equality.js +7 -7
- package/lib/unifier/intrinsicLevel.js +4 -4
- package/lib/unifier/metaLevel.js +10 -10
- package/lib/unifier/statementWithCombinator.js +147 -0
- package/lib/unifier/{termAgainstConstructor.js → termWithConstructor.js} +17 -17
- package/lib/unify/conclusionWithStatement.js +34 -0
- package/lib/unify/consequentWithStatement.js +34 -0
- package/lib/unify/metavariableWithStatement.js +74 -0
- package/lib/unify/premiseWithProofStep.js +41 -0
- package/lib/unify/premisesWithProofSteps.js +31 -0
- package/lib/unify/statementAtainstStatement.js +18 -18
- package/lib/unify/statementWithBracketedCombinator.js +30 -0
- package/lib/unify/statementWithCombinators.js +40 -0
- package/lib/unify/statementWithMetaType.js +24 -0
- package/lib/unify/suppositionWithProffStep.js +41 -0
- package/lib/unify/suppositionsWithProofSteps.js +31 -0
- package/lib/unify/termWithBracketedConstructor.js +37 -0
- package/lib/unify/termWithConstructors.js +53 -0
- package/lib/unify/termWithTerm.js +21 -0
- package/lib/unify/termWithType.js +24 -0
- package/lib/unify/variableWithTerm.js +54 -0
- package/lib/utilities/assignments.js +9 -12
- package/lib/verifier/intrinsicLevel.js +140 -0
- package/lib/verifier/metaLevel.js +11 -20
- package/lib/verifier/statementAsCombinator.js +9 -9
- package/lib/verifier/termAsConstructor.js +5 -5
- package/lib/verify/assertion/contained.js +2 -3
- package/lib/verify/assertion/defined.js +2 -4
- package/lib/verify/assertion/subproof.js +20 -18
- package/lib/verify/assertion/type.js +1 -2
- package/lib/verify/declaration.js +27 -9
- package/lib/verify/error.js +2 -2
- package/lib/verify/frame.js +25 -6
- package/lib/verify/judgement.js +3 -3
- package/lib/verify/metavariable.js +4 -4
- package/lib/verify/premise.js +3 -3
- package/lib/verify/proofStep.js +23 -30
- package/lib/verify/statement/qualified.js +93 -137
- package/lib/verify/statement/unqualified.js +18 -104
- package/lib/verify/statement.js +95 -76
- package/lib/verify/statementAsCombinator.js +3 -3
- package/lib/verify/statementGivenMetaType.js +41 -0
- package/lib/verify/supposition.js +3 -3
- package/lib/verify/term.js +36 -64
- package/lib/verify/termAsConstructor.js +2 -2
- package/lib/verify/termGivenType.js +34 -0
- package/package.json +1 -1
- package/src/context/file.js +42 -17
- package/src/context/local.js +4 -13
- package/src/context/release.js +84 -45
- package/src/frame.js +2 -2
- package/src/index.js +1 -1
- package/src/metavariable.js +6 -6
- package/src/proofStep.js +24 -19
- package/src/releaseContext/create.js +8 -16
- package/src/releaseContext/{verify.js → initialise.js} +32 -23
- package/src/rule.js +4 -4
- package/src/substitution/statementForMetavariable.js +7 -7
- package/src/substitution/termForVariable.js +37 -34
- package/src/substitution.js +5 -5
- package/src/substitutions.js +5 -5
- package/src/topLevelAssertion.js +4 -4
- package/src/unifier/equality.js +6 -6
- package/src/unifier/intrinsicLevel.js +3 -3
- package/src/unifier/metaLevel.js +9 -9
- package/src/unifier/statementWithCombinator.js +55 -0
- package/src/unifier/{termAgainstConstructor.js → termWithConstructor.js} +9 -9
- package/src/unify/{conclusionAgainstStatement.js → conclusionWithStatement.js} +3 -3
- package/src/unify/{consequentAgainstStatement.js → consequentWithStatement.js} +3 -3
- package/src/unify/{metavariableAgainstStatement.js → metavariableWithStatement.js} +12 -12
- package/src/unify/{premiseAgainstProofStep.js → premiseWithProofStep.js} +5 -5
- package/src/unify/{premisesAgainstProofSteps.js → premisesWithProofSteps.js} +3 -3
- package/src/unify/statementAtainstStatement.js +14 -14
- package/src/unify/statementWithBracketedCombinator.js +22 -0
- package/src/unify/statementWithCombinators.js +38 -0
- package/src/unify/statementWithMetaType.js +14 -0
- package/src/unify/{suppositionAgainstProofStep.js → suppositionWithProffStep.js} +5 -5
- package/src/unify/{suppositionsAgainstProofSteps.js → suppositionsWithProofSteps.js} +3 -3
- package/src/unify/termWithBracketedConstructor.js +36 -0
- package/src/unify/termWithConstructors.js +63 -0
- package/src/unify/{termAgainstTerm.js → termWithTerm.js} +4 -4
- package/src/unify/termWithType.js +15 -0
- package/src/unify/{variableAgainstTerm.js → variableWithTerm.js} +5 -5
- package/src/utilities/assignments.js +6 -13
- package/src/verifier/intrinsicLevel.js +42 -0
- package/src/verifier/metaLevel.js +13 -21
- package/src/verifier/statementAsCombinator.js +11 -7
- package/src/verifier/termAsConstructor.js +4 -3
- package/src/verify/assertion/contained.js +1 -3
- package/src/verify/assertion/defined.js +1 -4
- package/src/verify/assertion/subproof.js +22 -18
- package/src/verify/assertion/type.js +0 -1
- package/src/verify/declaration.js +34 -11
- package/src/verify/error.js +1 -1
- package/src/verify/frame.js +32 -5
- package/src/verify/judgement.js +3 -3
- package/src/verify/metavariable.js +3 -3
- package/src/verify/premise.js +3 -3
- package/src/verify/proofStep.js +26 -38
- package/src/verify/statement/qualified.js +104 -184
- package/src/verify/statement/unqualified.js +19 -149
- package/src/verify/statement.js +126 -72
- package/src/verify/statementAsCombinator.js +2 -2
- package/src/verify/statementGivenMetaType.js +37 -0
- package/src/verify/supposition.js +3 -3
- package/src/verify/term.js +38 -93
- package/src/verify/termAsConstructor.js +1 -1
- package/src/verify/termGivenType.js +32 -0
- package/lib/releaseContext/verify.js +0 -66
- package/lib/unifier/statementAgainstCombinator.js +0 -147
- package/lib/unify/conclusionAgainstStatement.js +0 -34
- package/lib/unify/consequentAgainstStatement.js +0 -34
- package/lib/unify/metavariableAgainstStatement.js +0 -74
- package/lib/unify/premiseAgainstProofStep.js +0 -41
- package/lib/unify/premisesAgainstProofSteps.js +0 -31
- package/lib/unify/statementAgainstMetaType.js +0 -48
- package/lib/unify/suppositionAgainstProofStep.js +0 -41
- package/lib/unify/suppositionsAgainstProofSteps.js +0 -31
- package/lib/unify/termAgainstTerm.js +0 -21
- package/lib/unify/termAgainstType.js +0 -32
- package/lib/unify/variableAgainstTerm.js +0 -54
- package/src/unifier/statementAgainstCombinator.js +0 -55
- package/src/unify/statementAgainstMetaType.js +0 -50
- package/src/unify/termAgainstType.js +0 -31
package/src/index.js
CHANGED
|
@@ -4,6 +4,6 @@ export { default as Log } from "./log";
|
|
|
4
4
|
export { default as verifyRelease } from "./verify/release";
|
|
5
5
|
export { default as ReleaseContext } from "./context/release";
|
|
6
6
|
export { default as createReleaseContext } from "./releaseContext/create";
|
|
7
|
-
export { default as verifyReleaseContext } from "./releaseContext/verify";
|
|
8
7
|
export { default as customGrammarUtilities } from "./utilities/customGrammar";
|
|
8
|
+
export { default as initialiseReleaseContext } from "./releaseContext/initialise";
|
|
9
9
|
|
package/src/metavariable.js
CHANGED
|
@@ -63,9 +63,9 @@ export default class Metavariable {
|
|
|
63
63
|
} else if ((termNode === null) && (this.termType === null)) {
|
|
64
64
|
matchesNode = true;
|
|
65
65
|
} else if ((termNode !== null) && (this.termType !== null)) {
|
|
66
|
-
const
|
|
66
|
+
const termUnifiedWithTermType = unifyTermWithTermType(termNode, this.termType, localContext);
|
|
67
67
|
|
|
68
|
-
matchesNode =
|
|
68
|
+
matchesNode = termUnifiedWithTermType; ///
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -90,8 +90,8 @@ export default class Metavariable {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
export function
|
|
94
|
-
let
|
|
93
|
+
export function unifyTermWithTermType(termNode, termType, localContext) {
|
|
94
|
+
let termUnifiedWithTermType;
|
|
95
95
|
|
|
96
96
|
const type = termType, ///
|
|
97
97
|
terms = [],
|
|
@@ -110,9 +110,9 @@ export function unifyTermAgainstTermType(termNode, termType, localContext) {
|
|
|
110
110
|
return verifiedAhead;
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
termUnifiedWithTermType = termVerified; ///
|
|
114
114
|
|
|
115
|
-
return
|
|
115
|
+
return termUnifiedWithTermType;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
function termTypeFromMetavariableNode(metavariableNode, fileContext) {
|
package/src/proofStep.js
CHANGED
|
@@ -17,27 +17,32 @@ export default class ProofStep {
|
|
|
17
17
|
return this.statementNode;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
unifyStatement(
|
|
20
|
+
unifyStatement(statementNodeB, equivalences, localContextA, localContextB) {
|
|
21
21
|
let statementUnified = false;
|
|
22
22
|
|
|
23
23
|
if (this.statementNode !== null) {
|
|
24
|
-
let
|
|
24
|
+
let statementUnifiedWithStatement = false;
|
|
25
25
|
|
|
26
|
-
if (!
|
|
27
|
-
const statementNodeA = statementNode
|
|
28
|
-
statementNodeB = this.statementNode; ///
|
|
26
|
+
if (!statementUnifiedWithStatement) {
|
|
27
|
+
const statementNodeA = this.statementNode; ///
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
statementUnifiedWithStatement = unifyStatementWithStatement(statementNodeA, statementNodeB, equivalences, localContextA, localContextB);
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
if (!
|
|
34
|
-
const statementNodeA =
|
|
35
|
-
|
|
32
|
+
if (!statementUnifiedWithStatement) {
|
|
33
|
+
const statementNodeA = statementNodeB, ///
|
|
34
|
+
localContext = localContextA; ///
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
statementNodeB = this.statementNode; ///
|
|
37
|
+
|
|
38
|
+
localContextA = localContextB; ///
|
|
39
|
+
|
|
40
|
+
localContextB = localContext; ///
|
|
41
|
+
|
|
42
|
+
statementUnifiedWithStatement = unifyStatementWithStatement(statementNodeA, statementNodeB, equivalences, localContextA, localContextB);
|
|
38
43
|
}
|
|
39
44
|
|
|
40
|
-
statementUnified =
|
|
45
|
+
statementUnified = statementUnifiedWithStatement; ///
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
return statementUnified;
|
|
@@ -58,13 +63,13 @@ export default class ProofStep {
|
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
function
|
|
62
|
-
let
|
|
66
|
+
function unifyStatementWithStatement(statementNodeA, statementNodeB, equivalences, localContextA, localContextB) {
|
|
67
|
+
let statementUnifiedWithStatement = false;
|
|
63
68
|
|
|
64
69
|
const statementStringA = localContextA.nodeAsString(statementNodeA),
|
|
65
70
|
statementStringB = localContextB.nodeAsString(statementNodeB);
|
|
66
71
|
|
|
67
|
-
localContextB.trace(`Unifying the '${statementStringB}' statement
|
|
72
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement with the '${statementStringA}' statement...`, statementNodeB);
|
|
68
73
|
|
|
69
74
|
const substitutions = Substitutions.fromNothing(),
|
|
70
75
|
nodeA = statementNodeA, ///
|
|
@@ -72,14 +77,14 @@ function unifyStatementAgainstStatement(statementNodeA, statementNodeB, equivale
|
|
|
72
77
|
unified = intrinsicLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
73
78
|
|
|
74
79
|
if (unified) {
|
|
75
|
-
const
|
|
80
|
+
const substitutionsUnifiedWithEquivalences = substitutions.unifyWithEquivalences(equivalences, localContextA, localContextB);
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
statementUnifiedWithStatement = substitutionsUnifiedWithEquivalences; ///
|
|
78
83
|
}
|
|
79
84
|
|
|
80
|
-
if (
|
|
81
|
-
localContextB.debug(`...unified the '${statementStringB}' statement
|
|
85
|
+
if (statementUnifiedWithStatement) {
|
|
86
|
+
localContextB.debug(`...unified the '${statementStringB}' statement with the '${statementStringA}' statement.`, statementNodeB);
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
return
|
|
89
|
+
return statementUnifiedWithStatement;
|
|
85
90
|
}
|
|
@@ -12,11 +12,9 @@ export default function createReleaseContext(dependency, dependentNames, context
|
|
|
12
12
|
log.debug(`Creating the '${releaseName}' context given the '${dependencyString}' dependency...`);
|
|
13
13
|
|
|
14
14
|
if (releaseContext !== null) {
|
|
15
|
-
const error = null
|
|
16
|
-
version = releaseContext.getVersion(),
|
|
17
|
-
versionString = version.toString();
|
|
15
|
+
const error = null;
|
|
18
16
|
|
|
19
|
-
log.debug(`...already created the '${releaseName}
|
|
17
|
+
log.debug(`...already created the '${releaseName}' context.`);
|
|
20
18
|
|
|
21
19
|
callback(error);
|
|
22
20
|
|
|
@@ -52,20 +50,17 @@ export default function createReleaseContext(dependency, dependentNames, context
|
|
|
52
50
|
return;
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
const version = releaseContext.getVersion(),
|
|
56
|
-
versionString = version.toString();
|
|
57
|
-
|
|
58
53
|
releaseContextMap[releaseName] = releaseContext;
|
|
59
54
|
|
|
60
|
-
|
|
55
|
+
log.info(`...created the '${releaseName}' context.`);
|
|
56
|
+
|
|
57
|
+
createDependencyReleaseContexts(dependency, releaseContext, dependentNames, context, (error) => {
|
|
61
58
|
if (error) {
|
|
62
59
|
callback(error);
|
|
63
60
|
|
|
64
61
|
return;
|
|
65
62
|
}
|
|
66
63
|
|
|
67
|
-
log.info(`...created the '${releaseName}@${versionString}' context.`);
|
|
68
|
-
|
|
69
64
|
callback(error);
|
|
70
65
|
});
|
|
71
66
|
}, context);
|
|
@@ -122,7 +117,7 @@ function checkReleaseMatchesDependency(releaseContext, dependency, dependentName
|
|
|
122
117
|
versionString = version.toString(),
|
|
123
118
|
dependencyString = dependency.asString();
|
|
124
119
|
|
|
125
|
-
log.
|
|
120
|
+
log.warning(`Version mismatch: The '${dependentName}' dependent requires the '${dependencyString}' dependency but a context with version '${versionString}' was provided.`);
|
|
126
121
|
|
|
127
122
|
releaseMatchesDependency = false;
|
|
128
123
|
}
|
|
@@ -131,11 +126,8 @@ function checkReleaseMatchesDependency(releaseContext, dependency, dependentName
|
|
|
131
126
|
return releaseMatchesDependency;
|
|
132
127
|
}
|
|
133
128
|
|
|
134
|
-
function createDependencyReleaseContexts(dependency, dependentNames, context, callback) {
|
|
135
|
-
const
|
|
136
|
-
dependencyName = dependency.getName(),
|
|
137
|
-
releaseName = dependencyName, ///
|
|
138
|
-
releaseContext = releaseContextMap[releaseName],
|
|
129
|
+
function createDependencyReleaseContexts(dependency, releaseContext, dependentNames, context, callback) {
|
|
130
|
+
const dependencyName = dependency.getName(),
|
|
139
131
|
dependencies = releaseContext.getDependencies();
|
|
140
132
|
|
|
141
133
|
dependentNames = [ ...dependentNames, dependencyName ]; ///
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export default function
|
|
4
|
-
let
|
|
3
|
+
export default function initialiseReleaseContext(dependency, dependentName, dependentReleased, context) {
|
|
4
|
+
let releaseContextInitialised = false;
|
|
5
5
|
|
|
6
6
|
const { releaseContextMap } = context,
|
|
7
7
|
dependencyName = dependency.getName(),
|
|
@@ -11,44 +11,37 @@ export default function verifyReleaseContext(dependency, dependentName, dependen
|
|
|
11
11
|
if (releaseContext === null) {
|
|
12
12
|
const { log } = context;
|
|
13
13
|
|
|
14
|
-
log.
|
|
14
|
+
log.warning(`Unable to initialise the '${dependencyName}' ontext because it has not been created.`);
|
|
15
15
|
} else {
|
|
16
|
-
|
|
16
|
+
releaseContextInitialised = releaseContext.isInitialised();
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
releaseContextVerified = true;
|
|
20
|
-
} else {
|
|
18
|
+
if (!releaseContextInitialised) {
|
|
21
19
|
const released = releaseContext.isReleased();
|
|
22
20
|
|
|
23
21
|
if (!released && dependentReleased) {
|
|
24
22
|
const { log } = context;
|
|
25
23
|
|
|
26
|
-
log.
|
|
24
|
+
log.warning(`Unable to initialise the '${dependencyName}' dependency's context because its '${dependentName}' dependent is a package.`);
|
|
27
25
|
} else {
|
|
28
|
-
const
|
|
26
|
+
const dependencyReleaseContextsInitialised = initialiseDependencyReleaseContexts(dependency, releaseContext, released, context);
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
if (dependencyReleaseContextsInitialised) {
|
|
29
|
+
const { log } = context,
|
|
30
|
+
releaseContexts = retrieveReleaseContexts(releaseContext, releaseContextMap);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
log.debug(`Initialising the '${dependencyName}' context...`);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
const releaseContextVerified = verifyReleaseContext(dependency, dependentName, dependentReleased, context);
|
|
34
|
+
releaseContextInitialised = releaseContext.initialise(releaseContexts);
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
if (releaseContextVerified) {
|
|
43
|
-
const releaseContexts = retrieveReleaseContexts(releaseContext, releaseContextMap);
|
|
44
|
-
|
|
45
|
-
releaseContext.verify(releaseContexts);
|
|
36
|
+
releaseContextInitialised ?
|
|
37
|
+
log.info(`...initialised the '${dependencyName}' context.`) :
|
|
38
|
+
log.warning(`...unable to initialise the '${dependencyName}' context.`);
|
|
46
39
|
}
|
|
47
40
|
}
|
|
48
41
|
}
|
|
49
42
|
}
|
|
50
43
|
|
|
51
|
-
return
|
|
44
|
+
return releaseContextInitialised;
|
|
52
45
|
}
|
|
53
46
|
|
|
54
47
|
function retrieveReleaseContexts(releaseContext, releaseContextMap) {
|
|
@@ -87,3 +80,19 @@ function retrieveReleaseContexts(releaseContext, releaseContextMap) {
|
|
|
87
80
|
|
|
88
81
|
return releaseContexts;
|
|
89
82
|
}
|
|
83
|
+
|
|
84
|
+
function initialiseDependencyReleaseContexts(dependency, releaseContext, released, context) {
|
|
85
|
+
const dependencyName = dependency.getName(),
|
|
86
|
+
dependentName = dependencyName, ///
|
|
87
|
+
dependencies = releaseContext.getDependencies(),
|
|
88
|
+
dependentReleased = released, ///
|
|
89
|
+
dependencyReleaseContextsInitialised = dependencies.everyDependency((dependency) => { ///
|
|
90
|
+
const releaseContextInitialised = initialiseReleaseContext(dependency, dependentName, dependentReleased, context);
|
|
91
|
+
|
|
92
|
+
if (releaseContextInitialised) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return dependencyReleaseContextsInitialised;
|
|
98
|
+
}
|
package/src/rule.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Substitutions from "./substitutions";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import unifyPremisesWithProofSteps from "./unify/premisesWithProofSteps";
|
|
5
|
+
import unifyConclusionWithStatement from "./unify/conclusionWithStatement";
|
|
6
6
|
|
|
7
7
|
export default class Rule {
|
|
8
8
|
constructor(labels, premises, conclusion, fileContext) {
|
|
@@ -37,11 +37,11 @@ export default class Rule {
|
|
|
37
37
|
proofStepsB = proofSteps, ///
|
|
38
38
|
fileContextA = this.fileContext, ///
|
|
39
39
|
localContextB = localContext, ///
|
|
40
|
-
premisesUnified =
|
|
40
|
+
premisesUnified = unifyPremisesWithProofSteps(premisesA, proofStepsB, substitutions, fileContextA, localContextB);
|
|
41
41
|
|
|
42
42
|
if (premisesUnified) {
|
|
43
43
|
const conclusionA = this.conclusion, ///
|
|
44
|
-
conclusionUnified =
|
|
44
|
+
conclusionUnified = unifyConclusionWithStatement(conclusionA, statementNode, substitutions, fileContextA, localContextB);
|
|
45
45
|
|
|
46
46
|
statementUnified = conclusionUnified; ///
|
|
47
47
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Substitution from "../substitution";
|
|
5
5
|
import TermForVariableSubstitution from "./termForVariable";
|
|
6
|
-
import
|
|
6
|
+
import unifyStatementWithStatement from "../unify/statementAtainstStatement";
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "../utilities/query";
|
|
9
9
|
import { matchStatementModuloBrackets, bracketedStatementChildNodeFromStatementNode } from "../utilities/match";
|
|
@@ -74,8 +74,8 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
74
74
|
return statementNodeMatches;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
let
|
|
77
|
+
unifyWithEquivalence(equivalence, substitutions, localContextA, localContextB) {
|
|
78
|
+
let unifiedWithEquivalence = false; ///
|
|
79
79
|
|
|
80
80
|
const metavariableNode = metavariableNodeQuery(this.statementNode);
|
|
81
81
|
|
|
@@ -89,10 +89,10 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
89
89
|
nodeB = metavariableNode, ///
|
|
90
90
|
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
unifiedWithEquivalence = unified; ///
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
return
|
|
95
|
+
return unifiedWithEquivalence;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
asString(localContextA, localContextB) {
|
|
@@ -156,9 +156,9 @@ function unifyStatement(statementNodeA, statementNodeB, substitution, substituti
|
|
|
156
156
|
|
|
157
157
|
statementUnified = statementNodeAMatchesStatementNodeB; ///
|
|
158
158
|
} else {
|
|
159
|
-
const
|
|
159
|
+
const statementUnifiedWithStatement = unifyStatementWithStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
160
160
|
|
|
161
|
-
statementUnified =
|
|
161
|
+
statementUnified = statementUnifiedWithStatement; ///
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
return statementUnified;
|
|
@@ -29,14 +29,21 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
29
29
|
return node;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
transformed(substitutions) {
|
|
33
|
+
let transformedSubstitution = null;
|
|
34
|
+
|
|
35
|
+
const transformedTermNode = transformTermNode(this.termNode, substitutions),
|
|
36
|
+
transformedVariableNode = transformVariableNode(this.variableNode, substitutions);
|
|
37
|
+
|
|
38
|
+
if ((transformedTermNode !== null) && (transformedVariableNode !== null)) {
|
|
39
|
+
const termNode = transformedTermNode, ///
|
|
40
|
+
variableNode = transformedVariableNode,
|
|
41
|
+
termForVariableSubstitution = new TermForVariableSubstitution(termNode, variableNode);
|
|
42
|
+
|
|
43
|
+
transformedSubstitution = termForVariableSubstitution; ///
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return transformedSubstitution;
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
matchTermNode(termNode) {
|
|
@@ -51,8 +58,8 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
51
58
|
return matchesVariableNode;
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
let
|
|
61
|
+
unifyWithEquivalence(equivalence, substitutions, localContextA, localContextB) {
|
|
62
|
+
let unifiedWithEquivalence;
|
|
56
63
|
|
|
57
64
|
const equivalenceMatchesVariableNode = equivalence.matchVariableNode(this.variableNode);
|
|
58
65
|
|
|
@@ -60,11 +67,11 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
60
67
|
const equivalenceMatchesTermNode = equivalence.matchTermNode(this.termNode);
|
|
61
68
|
|
|
62
69
|
if (equivalenceMatchesTermNode) {
|
|
63
|
-
|
|
70
|
+
unifiedWithEquivalence = true;
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
return
|
|
74
|
+
return unifiedWithEquivalence;
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
asString(localContextA, localContextB) {
|
|
@@ -95,22 +102,12 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
95
102
|
let termNode = substitution.getTermNode(),
|
|
96
103
|
variableNode = substitution.getVariableNode();
|
|
97
104
|
|
|
98
|
-
|
|
105
|
+
const transformedTermNode = transformTermNode(termNode, substitutions),
|
|
106
|
+
transformedVariableNode = transformVariableNode(variableNode, substitutions); ///
|
|
99
107
|
|
|
100
|
-
|
|
108
|
+
termNode = transformedTermNode; ///
|
|
101
109
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return termForVariableSubstitution;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
static fromSubstitutionNodeAndSubstitutions(substitutionNode, substitutions) {
|
|
108
|
-
let termNode = termNodeQuery(substitutionNode),
|
|
109
|
-
variableNode = variableNodeQuery(substitutionNode);
|
|
110
|
-
|
|
111
|
-
termNode = substituteTermNode(termNode, substitutions); ///
|
|
112
|
-
|
|
113
|
-
variableNode = substituteVariableNode(variableNode, substitutions); ///
|
|
110
|
+
variableNode = transformedVariableNode; ///
|
|
114
111
|
|
|
115
112
|
const termForVariableSubstitution = new TermForVariableSubstitution(variableNode, termNode);
|
|
116
113
|
|
|
@@ -118,7 +115,9 @@ export default class TermForVariableSubstitution extends Substitution {
|
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
|
|
121
|
-
function
|
|
118
|
+
function transformTermNode(termNode, substitutions) {
|
|
119
|
+
let transformedTermNode = null;
|
|
120
|
+
|
|
122
121
|
const termVariableNode = variableNodeQuery(termNode);
|
|
123
122
|
|
|
124
123
|
if (termVariableNode !== null) {
|
|
@@ -126,31 +125,35 @@ function substituteTermNode(termNode, substitutions) {
|
|
|
126
125
|
const substitutionMatchesVariableNode = substitution.matchVariableNode(termVariableNode);
|
|
127
126
|
|
|
128
127
|
if (substitutionMatchesVariableNode) {
|
|
129
|
-
termNode = substitution.getTermNode();
|
|
128
|
+
const termNode = substitution.getTermNode();
|
|
129
|
+
|
|
130
|
+
transformedTermNode = termNode; ////
|
|
130
131
|
|
|
131
132
|
return true;
|
|
132
133
|
}
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
return
|
|
137
|
+
return transformedTermNode;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
function
|
|
140
|
+
function transformVariableNode(variableNode, substitutions) {
|
|
141
|
+
let transformedVariableNode = null;
|
|
142
|
+
|
|
140
143
|
substitutions.someSubstitution((substitution) => {
|
|
141
144
|
const substitutionMatchesVariableNode = substitution.matchVariableNode(variableNode);
|
|
142
145
|
|
|
143
146
|
if (substitutionMatchesVariableNode) {
|
|
144
147
|
const termNode = substitution.getTermNode(),
|
|
145
|
-
|
|
148
|
+
variableNode = variableNodeQuery(termNode);
|
|
146
149
|
|
|
147
|
-
if (
|
|
148
|
-
|
|
150
|
+
if (variableNode !== null) {
|
|
151
|
+
transformedVariableNode = variableNode; ///
|
|
149
152
|
|
|
150
153
|
return true;
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
});
|
|
154
157
|
|
|
155
|
-
return
|
|
158
|
+
return transformedVariableNode;
|
|
156
159
|
}
|
package/src/substitution.js
CHANGED
|
@@ -25,15 +25,15 @@ export default class Substitution {
|
|
|
25
25
|
return matchesMetavariableNode;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
28
|
+
unifyWithEquivalences(equivalences, substitutions, localContextA, localContextB) {
|
|
29
|
+
const unifiedWithEquivalences = equivalences.some((equivalence) => {
|
|
30
|
+
const substitutionUnifiedWithEquivalence = this.unifyWithEquivalence(equivalence, substitutions, localContextA, localContextB);
|
|
31
31
|
|
|
32
|
-
if (
|
|
32
|
+
if (substitutionUnifiedWithEquivalence) {
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
return
|
|
37
|
+
return unifiedWithEquivalences;
|
|
38
38
|
}
|
|
39
39
|
}
|
package/src/substitutions.js
CHANGED
|
@@ -55,17 +55,17 @@ export default class Substitutions {
|
|
|
55
55
|
localContextB.trace(`Removed the '${substitutionString}' substitution.`, substitutionNode);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
const
|
|
58
|
+
unifyWithEquivalences(equivalences, localContextA, localContextB) {
|
|
59
|
+
const unifiedWithEquivalences = this.everySubstitution((substitution) => {
|
|
60
60
|
const substitutions = this, ///
|
|
61
|
-
|
|
61
|
+
substitutionUnifiedWithEquivalence = substitution.unifyWithEquivalences(equivalences, substitutions, localContextA, localContextB);
|
|
62
62
|
|
|
63
|
-
if (
|
|
63
|
+
if (substitutionUnifiedWithEquivalence) {
|
|
64
64
|
return true;
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
return
|
|
68
|
+
return unifiedWithEquivalences;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
snapshot() {
|
package/src/topLevelAssertion.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Substitutions from "./substitutions";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import unifyConsequentWithStatement from "./unify/consequentWithStatement";
|
|
5
|
+
import unifySuppositionsWithProofSteps from "./unify/suppositionsWithProofSteps";
|
|
6
6
|
|
|
7
7
|
export default class TopLevelAssertion {
|
|
8
8
|
constructor(labels, suppositions, consequent, substitutions, fileContext) {
|
|
@@ -42,11 +42,11 @@ export default class TopLevelAssertion {
|
|
|
42
42
|
fileContextA = this.fileContext, ///
|
|
43
43
|
suppositionsA = this.suppositions, ///
|
|
44
44
|
localContextB = localContext, ///
|
|
45
|
-
suppositionsUnified =
|
|
45
|
+
suppositionsUnified = unifySuppositionsWithProofSteps(suppositionsA, proofStepsB, substitutions, fileContextA, localContextB);
|
|
46
46
|
|
|
47
47
|
if (suppositionsUnified) {
|
|
48
48
|
const consequentA = this.consequent, ///
|
|
49
|
-
consequentUnified =
|
|
49
|
+
consequentUnified = unifyConsequentWithStatement(consequentA, statementNode, substitutions, fileContextA, localContext);
|
|
50
50
|
|
|
51
51
|
statementUnified = consequentUnified; ///
|
|
52
52
|
}
|
package/src/unifier/equality.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Unifier from "../unifier";
|
|
4
|
-
import
|
|
4
|
+
import unifyTermWithTerm from "../unify/termWithTerm";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
|
|
@@ -25,14 +25,14 @@ class EqualityUnifier extends Unifier {
|
|
|
25
25
|
nodeQueryA: termNodeQuery,
|
|
26
26
|
nodeQueryB: termNodeQuery,
|
|
27
27
|
unify: (termNodeA, termNodeB, localContext) => {
|
|
28
|
-
let
|
|
28
|
+
let termUnifiedWithTerm;
|
|
29
29
|
|
|
30
30
|
const leftTermNode = termNodeA, ///
|
|
31
31
|
rightTermNode = termNodeB; ///
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
termUnifiedWithTerm = unifyTermWithTerm(leftTermNode, rightTermNode, localContext);
|
|
34
34
|
|
|
35
|
-
if (!
|
|
35
|
+
if (!termUnifiedWithTerm) {
|
|
36
36
|
const nonTerminalNodeA = termNodeA, ///
|
|
37
37
|
nonTerminalNodeB = termNodeB, ///
|
|
38
38
|
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
@@ -41,10 +41,10 @@ class EqualityUnifier extends Unifier {
|
|
|
41
41
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
42
42
|
childNodesVerified = equalityUnifier.unifyChildNodes(childNodesA, childNodesB, localContext);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
termUnifiedWithTerm = childNodesVerified; ///
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
return
|
|
47
|
+
return termUnifiedWithTerm;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Unifier from "../unifier";
|
|
5
|
-
import
|
|
5
|
+
import unifyVariableWithTerm from "../unify/variableWithTerm";
|
|
6
6
|
|
|
7
7
|
import { nodeQuery } from "../utilities/query";
|
|
8
8
|
|
|
@@ -28,9 +28,9 @@ class IntrinsicLevelUnifier extends Unifier {
|
|
|
28
28
|
nodeQueryB: termNodeQuery,
|
|
29
29
|
unify: (termVariableNodeA, termNodeB, substitutions, localContextA, localContextB) => {
|
|
30
30
|
const variableNodeA = termVariableNodeA, ///
|
|
31
|
-
|
|
31
|
+
variableUnifiedWithTerm = unifyVariableWithTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB);
|
|
32
32
|
|
|
33
|
-
return
|
|
33
|
+
return variableUnifiedWithTerm;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
];
|