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/unifier/metaLevel.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Unifier from "../unifier";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import unifyVariableWithTerm from "../unify/variableWithTerm";
|
|
6
|
+
import unifyMetavariableWithStatement from "../unify/metavariableWithStatement";
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "../utilities/query";
|
|
9
9
|
|
|
@@ -31,15 +31,15 @@ class MetaLevelUnifier extends Unifier {
|
|
|
31
31
|
nodeQueryA: statementNodeQuery,
|
|
32
32
|
nodeQueryB: statementNodeQuery,
|
|
33
33
|
unify: (statementNodeA, statementNodeB, substitutions, localContextA, localContextB) => {
|
|
34
|
-
let
|
|
34
|
+
let statementUnifiedWithStatement;
|
|
35
35
|
|
|
36
36
|
const metavariableNodeA = metavariableNodeQuery(statementNodeA);
|
|
37
37
|
|
|
38
38
|
if (metavariableNodeA !== null) {
|
|
39
39
|
const substitutionNodeA = substitutionNodeQuery(statementNodeA),
|
|
40
|
-
|
|
40
|
+
metavariableUnifiedWithStatement = unifyMetavariableWithStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB);
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
statementUnifiedWithStatement = metavariableUnifiedWithStatement; ///
|
|
43
43
|
} else {
|
|
44
44
|
const nonTerminalNodeA = statementNodeA, ///
|
|
45
45
|
nonTerminalNodeB = statementNodeB, ///
|
|
@@ -49,10 +49,10 @@ class MetaLevelUnifier extends Unifier {
|
|
|
49
49
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
50
50
|
childNodesVerified = metaLevelUnifier.unifyChildNodes(childNodesA, childNodesB, substitutions, localContextA, localContextB);
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
statementUnifiedWithStatement = childNodesVerified; ///
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
return
|
|
55
|
+
return statementUnifiedWithStatement;
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
{
|
|
@@ -60,9 +60,9 @@ class MetaLevelUnifier extends Unifier {
|
|
|
60
60
|
nodeQueryB: termNodeQuery,
|
|
61
61
|
unify: (termVariableNodeA, termNodeB, substitutions, localContextA, localContextB) => {
|
|
62
62
|
const variableNodeA = termVariableNodeA, ///
|
|
63
|
-
|
|
63
|
+
variableUnifiedWithTerm = unifyVariableWithTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB);
|
|
64
64
|
|
|
65
|
-
return
|
|
65
|
+
return variableUnifiedWithTerm;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Unifier from "../unifier";
|
|
4
|
+
import unifyTermWithType from "../unify/termWithType";
|
|
5
|
+
import unifyStatementWithMetaType from "../unify/statementWithMetaType";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "../utilities/query";
|
|
8
|
+
|
|
9
|
+
const termNodeQuery = nodeQuery("/term!"),
|
|
10
|
+
typeNodeQuery = nodeQuery("/type!"),
|
|
11
|
+
metaTypeNodeQuery = nodeQuery("/metaType!"),
|
|
12
|
+
statementNodeQuery = nodeQuery("/statement!");
|
|
13
|
+
|
|
14
|
+
class StatementWithCombinatorUnifier extends Unifier {
|
|
15
|
+
unify(statementNode, combinatorStatementNode, assignments, derived, localContext) {
|
|
16
|
+
let statementUnifiedWithCombinator;
|
|
17
|
+
|
|
18
|
+
const nonTerminalNodeA = statementNode, ///
|
|
19
|
+
nonTerminalNodeB = combinatorStatementNode, ///
|
|
20
|
+
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, assignments, derived, localContext);
|
|
21
|
+
|
|
22
|
+
statementUnifiedWithCombinator = nonTerminalNodeUnified; ///
|
|
23
|
+
|
|
24
|
+
return statementUnifiedWithCombinator;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
static maps = [
|
|
28
|
+
{
|
|
29
|
+
nodeQueryA: statementNodeQuery,
|
|
30
|
+
nodeQueryB: metaTypeNodeQuery,
|
|
31
|
+
unify: (statementNodeA, metaTypeNodeB, assignments, derived, localContext) => {
|
|
32
|
+
const metaTypeNode = metaTypeNodeB, ///
|
|
33
|
+
statementNode = statementNodeA, ///
|
|
34
|
+
statementUnifiedWithMetaType = unifyStatementWithMetaType(statementNode, metaTypeNode, assignments, derived, localContext);
|
|
35
|
+
|
|
36
|
+
return statementUnifiedWithMetaType;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
nodeQueryA: termNodeQuery,
|
|
41
|
+
nodeQueryB: typeNodeQuery,
|
|
42
|
+
unify: (termNodeA, typeNodeB, assignments, derived, localContext) => {
|
|
43
|
+
const termNode = termNodeA, ///
|
|
44
|
+
typeNode = typeNodeB, ///
|
|
45
|
+
termUnifiedWithType = unifyTermWithType(termNode, typeNode, localContext);
|
|
46
|
+
|
|
47
|
+
return termUnifiedWithType;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const statementWithCombinatorUnifier = new StatementWithCombinatorUnifier();
|
|
54
|
+
|
|
55
|
+
export default statementWithCombinatorUnifier;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Unifier from "../unifier";
|
|
4
|
-
import
|
|
4
|
+
import unifyTermWithType from "../unify/termWithType";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
|
|
8
8
|
const termNodeQuery = nodeQuery("/term"),
|
|
9
9
|
typeNodeQuery = nodeQuery("/type");
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class TermWithConstructorUnifier extends Unifier {
|
|
12
12
|
unify(termNode, constructorTermNode, localContext) {
|
|
13
|
-
let
|
|
13
|
+
let termUnifiedWithConstructor;
|
|
14
14
|
|
|
15
15
|
const nonTerminalNodeA = termNode, ///
|
|
16
16
|
nonTerminalNodeB = constructorTermNode, ///
|
|
17
17
|
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext);
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
termUnifiedWithConstructor = nonTerminalNodeUnified; ///
|
|
20
20
|
|
|
21
|
-
return
|
|
21
|
+
return termUnifiedWithConstructor;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
static maps = [
|
|
@@ -28,14 +28,14 @@ class TermAgainstConstructorUnifier extends Unifier {
|
|
|
28
28
|
unify: (termNodeA, typeNodeB, localContext) => {
|
|
29
29
|
const termNode = termNodeA, ///
|
|
30
30
|
typeNode = typeNodeB, ///
|
|
31
|
-
|
|
31
|
+
termUnifiedWithType = unifyTermWithType(termNode, typeNode, localContext);
|
|
32
32
|
|
|
33
|
-
return
|
|
33
|
+
return termUnifiedWithType;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const termWithConstructorUnifier = new TermWithConstructorUnifier();
|
|
40
40
|
|
|
41
|
-
export default
|
|
41
|
+
export default termWithConstructorUnifier;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import LocalContext from "../context/local";
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function unifyConclusionWithStatement(conclusionA, statementNodeB, substitutions, fileContextA, localContextB) {
|
|
6
6
|
let conclusionUnified = false;
|
|
7
7
|
|
|
8
8
|
const conclusionAStatementNode = conclusionA.getStatementNode();
|
|
@@ -15,7 +15,7 @@ export default function unifyConclusionAgainstStatement(conclusionA, statementNo
|
|
|
15
15
|
|
|
16
16
|
substitutions.snapshot();
|
|
17
17
|
|
|
18
|
-
localContextB.trace(`Unifying the '${statementStringB}' statement
|
|
18
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement with the conclusion's '${statementStringA}' statement...`, statementNodeB);
|
|
19
19
|
|
|
20
20
|
const statementUnified = conclusionA.unifyStatement(statementNodeB, substitutions, localContextA, localContextB);
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@ export default function unifyConclusionAgainstStatement(conclusionA, statementNo
|
|
|
26
26
|
substitutions.rollback(localContextA, localContextB);
|
|
27
27
|
|
|
28
28
|
if (conclusionUnified) {
|
|
29
|
-
localContextB.debug(`...unified the '${statementStringB}' statement
|
|
29
|
+
localContextB.debug(`...unified the '${statementStringB}' statement with the conclusion's '${statementStringA}' statement.`, statementNodeB);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import LocalContext from "../context/local";
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function unifyConsequentWithStatement(consequentA, statementNodeB, substitutions, fileContextA, localContextB) {
|
|
6
6
|
let consequentUnified = false;
|
|
7
7
|
|
|
8
8
|
const consequentAStatementNode = consequentA.getStatementNode();
|
|
@@ -15,7 +15,7 @@ export default function unifyConsequentAgainstStatement(consequentA, statementNo
|
|
|
15
15
|
|
|
16
16
|
substitutions.snapshot();
|
|
17
17
|
|
|
18
|
-
localContextB.trace(`Unifying the '${statementStringB}' statement
|
|
18
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement with the consequent's '${statementStringA}' statement...`, statementNodeB);
|
|
19
19
|
|
|
20
20
|
const statementUnified = consequentA.unifyStatement(statementNodeB, substitutions, localContextA, localContextB);
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@ export default function unifyConsequentAgainstStatement(consequentA, statementNo
|
|
|
26
26
|
substitutions.rollback(localContextA, localContextB);
|
|
27
27
|
|
|
28
28
|
if (consequentUnified) {
|
|
29
|
-
localContextB.debug(`...unified the '${statementStringB}' statement
|
|
29
|
+
localContextB.debug(`...unified the '${statementStringB}' statement with the consequent's '${statementStringA}' statement.`, statementNodeB);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
4
|
-
import
|
|
4
|
+
import unifyStatementWithStatement from "../unify/statementAtainstStatement";
|
|
5
5
|
import StatementForMetavariableSubstitution from "../substitution/statementForMetavariable";
|
|
6
6
|
|
|
7
7
|
import { nodeQuery } from "../utilities/query";
|
|
8
8
|
|
|
9
9
|
const metavariableNodeQuery = nodeQuery("/statement/metavariable");
|
|
10
10
|
|
|
11
|
-
export default function
|
|
12
|
-
let
|
|
11
|
+
export default function unifyMetavariableWithStatement(metavariableNodeA, statementNodeB, substitutionNodeA, substitutions, localContextA, localContextB) {
|
|
12
|
+
let metavariableUnifiedWithStatement = false;
|
|
13
13
|
|
|
14
14
|
const substitution = substitutions.findSubstitution((substitution) => {
|
|
15
15
|
const substitutionMatchesMetavariableNodeA = substitution.matchMetavariableNode(metavariableNodeA);
|
|
@@ -28,10 +28,10 @@ export default function unifyMetavariableAgainstStatement(metavariableNodeA, sta
|
|
|
28
28
|
localContext = localContextB, ///
|
|
29
29
|
substitution = termForVariableSubstitution, ///
|
|
30
30
|
statementNodeA = substitutionStatementNode, ///
|
|
31
|
-
|
|
31
|
+
statementUnifiedWithStatement = unifyStatementWithStatement(statementNodeA, statementNodeB, substitution, substitutions, localContext, localContext);
|
|
32
32
|
|
|
33
|
-
if (
|
|
34
|
-
|
|
33
|
+
if (statementUnifiedWithStatement) {
|
|
34
|
+
metavariableUnifiedWithStatement = true;
|
|
35
35
|
}
|
|
36
36
|
} else {
|
|
37
37
|
const substitutionSubstitution = substitution.getSubstitution();
|
|
@@ -43,16 +43,16 @@ export default function unifyMetavariableAgainstStatement(metavariableNodeA, sta
|
|
|
43
43
|
|
|
44
44
|
const localContext = localContextB, ///
|
|
45
45
|
substitution = substitutionSubstitution,
|
|
46
|
-
|
|
46
|
+
statementUnifiedWithStatement = unifyStatementWithStatement(statementNodeA, statementNodeB, substitution, substitutions, localContext, localContext);
|
|
47
47
|
|
|
48
|
-
if (
|
|
49
|
-
|
|
48
|
+
if (statementUnifiedWithStatement) {
|
|
49
|
+
metavariableUnifiedWithStatement = true;
|
|
50
50
|
}
|
|
51
51
|
} else {
|
|
52
52
|
const substitutionMatchesStatementNodeB = substitution.matchStatementNode(statementNodeB);
|
|
53
53
|
|
|
54
54
|
if (substitutionMatchesStatementNodeB) {
|
|
55
|
-
|
|
55
|
+
metavariableUnifiedWithStatement = true;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -72,11 +72,11 @@ export default function unifyMetavariableAgainstStatement(metavariableNodeA, sta
|
|
|
72
72
|
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
metavariableUnifiedWithStatement = true;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
return
|
|
79
|
+
return metavariableUnifiedWithStatement;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
function metavariableFromStatementNode(statementNode, localContext) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { subproofNodeAsSubproofString } from "../utilities/unify";
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function unifyPremiseWithProofStep(premiseA, proofStepB, substitutions, localContextA, localContextB) {
|
|
6
6
|
let premiseUnified = false;
|
|
7
7
|
|
|
8
8
|
const premiseAStatementNode = premiseA.getStatementNode();
|
|
@@ -20,12 +20,12 @@ export default function unifyPremiseAgainstProofStep(premiseA, proofStepB, subst
|
|
|
20
20
|
if (subproofNodeB !== null) {
|
|
21
21
|
const subproofStringB = subproofNodeAsSubproofString(subproofNodeB, localContextB);
|
|
22
22
|
|
|
23
|
-
localContextB.trace(`Unifying the '${subproofStringB}' subproof
|
|
23
|
+
localContextB.trace(`Unifying the '${subproofStringB}' subproof with the premise's '${statementStringA}' statement...`, subproofNodeB);
|
|
24
24
|
|
|
25
25
|
const subproofUnified = premiseA.unifySubproof(subproofNodeB, substitutions, localContextA, localContextB);
|
|
26
26
|
|
|
27
27
|
if (subproofUnified) {
|
|
28
|
-
localContextB.debug(`...unified the '${subproofStringB}' subproof
|
|
28
|
+
localContextB.debug(`...unified the '${subproofStringB}' subproof with the premise's '${statementStringA}' statement.`, subproofNodeB);
|
|
29
29
|
|
|
30
30
|
premiseUnified = true;
|
|
31
31
|
}
|
|
@@ -34,12 +34,12 @@ export default function unifyPremiseAgainstProofStep(premiseA, proofStepB, subst
|
|
|
34
34
|
if (statementNodeB !== null) {
|
|
35
35
|
const statementStringB = localContextB.nodeAsString(statementNodeB);
|
|
36
36
|
|
|
37
|
-
localContextB.trace(`Unifying the '${statementStringB}' statement
|
|
37
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement with the premise's '${statementStringA}' statement...`, statementNodeB);
|
|
38
38
|
|
|
39
39
|
const statementUnified = premiseA.unifyStatement(statementNodeB, substitutions, localContextA, localContextB);
|
|
40
40
|
|
|
41
41
|
if (statementUnified) {
|
|
42
|
-
localContextB.debug(`...unified the '${statementStringB}' statement
|
|
42
|
+
localContextB.debug(`...unified the '${statementStringB}' statement with the premise's '${statementStringA}' statement.`, statementNodeB);
|
|
43
43
|
|
|
44
44
|
premiseUnified = true;
|
|
45
45
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import LocalContext from "../context/local";
|
|
4
|
-
import
|
|
4
|
+
import unifyPremiseWithProofStep from "../unify/premiseWithProofStep";
|
|
5
5
|
|
|
6
6
|
import { reverse, correlate } from "../utilities/array";
|
|
7
7
|
|
|
8
|
-
export default function
|
|
8
|
+
export default function unifyPremisesWithProofSteps(premisesA, proofStepsB, substitutions, fileContextA, localContextB) {
|
|
9
9
|
premisesA = reverse(premisesA); ///
|
|
10
10
|
|
|
11
11
|
proofStepsB = reverse(proofStepsB); ///
|
|
12
12
|
|
|
13
13
|
const premisesUnified = correlate(premisesA, proofStepsB, (premiseA, proofStepB) => {
|
|
14
14
|
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
15
|
-
premiseUnified =
|
|
15
|
+
premiseUnified = unifyPremiseWithProofStep(premiseA, proofStepB, substitutions, localContextA, localContextB);
|
|
16
16
|
|
|
17
17
|
if (premiseUnified) {
|
|
18
18
|
return true;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Substitutions from "../substitutions";
|
|
3
4
|
import metaLevelUnifier from "../unifier/metaLevel";
|
|
4
5
|
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
5
6
|
|
|
6
7
|
import { push } from "../utilities/array";
|
|
7
8
|
|
|
8
|
-
export default function
|
|
9
|
-
let
|
|
9
|
+
export default function unifyStatementWithStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB) {
|
|
10
|
+
let statementUnifiedWithStatement = false;
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const transformedSubstitutions = Substitutions.fromNothing(),
|
|
13
|
+
transformedSubstitution = substitution.transformed(substitutions);
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (transformed) {
|
|
17
|
-
const substitutionA = termForVariableSubstitution; ///
|
|
18
|
-
|
|
19
|
-
substitutionsA.push(substitutionA);
|
|
15
|
+
if (transformedSubstitution !== null) {
|
|
16
|
+
transformedSubstitutions.addSubstitution(transformedSubstitution, localContextA, localContextB);
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
const nodeA = statementNodeA, ///
|
|
23
20
|
nodeB = statementNodeB, ///
|
|
24
|
-
unified = metaLevelUnifier.unify(nodeA, nodeB,
|
|
21
|
+
unified = metaLevelUnifier.unify(nodeA, nodeB, transformedSubstitutions, localContextA, localContextB);
|
|
25
22
|
|
|
26
23
|
if (unified) {
|
|
27
|
-
if (
|
|
24
|
+
if (transformedSubstitution === null) {
|
|
25
|
+
|
|
26
|
+
debugger
|
|
27
|
+
|
|
28
28
|
const substitutionB = termForVariableSubstitution, ///
|
|
29
29
|
substitutionsB = [
|
|
30
30
|
substitutionB
|
|
@@ -35,10 +35,10 @@ export default function unifyStatementAgainstStatement(statementNodeA, statement
|
|
|
35
35
|
push(substitutions, substitutionsA);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
statementUnifiedWithStatement = true;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
return
|
|
41
|
+
return statementUnifiedWithStatement;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function transformSubstitutions(substitutionsA, substitutionsB) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import bracketedCombinator from "../ocmbinator/bracketed";
|
|
4
|
+
import statementWithCombinatorUnifier from "../unifier/statementWithCombinator";
|
|
5
|
+
|
|
6
|
+
export default function unifyStatementWithBracketedCombinator(statementNode, assignments, derived, localContext) {
|
|
7
|
+
let statementUnifiedWithBracketedCombinator;
|
|
8
|
+
|
|
9
|
+
const statementString = localContext.nodeAsString(statementNode);
|
|
10
|
+
|
|
11
|
+
localContext.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`, statementNode);
|
|
12
|
+
|
|
13
|
+
const bracketedCombinatorStatementNode = bracketedCombinator.getStatementNode();
|
|
14
|
+
|
|
15
|
+
statementUnifiedWithBracketedCombinator = statementWithCombinatorUnifier.unify(statementNode, bracketedCombinatorStatementNode, assignments, derived, localContext);
|
|
16
|
+
|
|
17
|
+
if (statementUnifiedWithBracketedCombinator) {
|
|
18
|
+
localContext.debug(`...unified the '${statementString}' statement with the bracketed combinator.`, statementNode);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return statementUnifiedWithBracketedCombinator;
|
|
22
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import statementWithCombinatorUnifier from "../unifier/statementWithCombinator";
|
|
4
|
+
|
|
5
|
+
export default function unifyStatementWithCombinators(statementNode, assignments, derived, localContext) {
|
|
6
|
+
let statementUnifiedWithCombinators;
|
|
7
|
+
|
|
8
|
+
const combinators = localContext.getCombinators();
|
|
9
|
+
|
|
10
|
+
statementUnifiedWithCombinators = combinators.some((combinator) => {
|
|
11
|
+
const statementUnifiedWithCombinator = unifyStatementWithCombinator(statementNode, combinator, assignments, derived, localContext);
|
|
12
|
+
|
|
13
|
+
if (statementUnifiedWithCombinator) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return statementUnifiedWithCombinators;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function unifyStatementWithCombinator(statementNode, combinator, assignments, derived, localContext) {
|
|
22
|
+
let statementUnifiedWithCombinator;
|
|
23
|
+
|
|
24
|
+
const statementString = localContext.nodeAsString(statementNode),
|
|
25
|
+
combinatorString = combinator.getString();
|
|
26
|
+
|
|
27
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${combinatorString}' combinator...`, statementNode);
|
|
28
|
+
|
|
29
|
+
const combinatorStatementNode = combinator.getStatementNode();
|
|
30
|
+
|
|
31
|
+
statementUnifiedWithCombinator = statementWithCombinatorUnifier.unify(statementNode, combinatorStatementNode, assignments, derived, localContext);
|
|
32
|
+
|
|
33
|
+
if (statementUnifiedWithCombinator) {
|
|
34
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${combinatorString}' combinator.`, statementNode);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return statementUnifiedWithCombinator;
|
|
38
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifyStatementGivenMetaType from "../verify/statementGivenMetaType";
|
|
4
|
+
|
|
5
|
+
export default function unifyStatementWithMetaType(statementNode, metaTypeNode, assignments, derived, localContext) {
|
|
6
|
+
let statementUnifiedWithMetaType;
|
|
7
|
+
|
|
8
|
+
const metaType = localContext.findMetaTypeByMetaTypeNode(metaTypeNode),
|
|
9
|
+
statementVerifiedGivenMetaType = verifyStatementGivenMetaType(statementNode, metaType, assignments, derived, localContext);
|
|
10
|
+
|
|
11
|
+
statementUnifiedWithMetaType = statementVerifiedGivenMetaType; ///
|
|
12
|
+
|
|
13
|
+
return statementUnifiedWithMetaType;
|
|
14
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { subproofNodeAsSubproofString } from "../utilities/unify";
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function unifySuppositionWithProofStep(suppositionA, proofStepB, substitutions, localContextA, localContextB) {
|
|
6
6
|
let suppositionUnified = false;
|
|
7
7
|
|
|
8
8
|
const suppositionAStatementNode = suppositionA.getStatementNode();
|
|
@@ -20,12 +20,12 @@ export default function unifySuppositionAgainstProofStep(suppositionA, proofStep
|
|
|
20
20
|
if (subproofNodeB !== null) {
|
|
21
21
|
const subproofStringB = subproofNodeAsSubproofString(subproofNodeB, localContextB);
|
|
22
22
|
|
|
23
|
-
localContextB.trace(`Unifying the '${subproofStringB}' subproof
|
|
23
|
+
localContextB.trace(`Unifying the '${subproofStringB}' subproof with the supposition's '${statementStringA}' statement...`, subproofNodeB);
|
|
24
24
|
|
|
25
25
|
const subproofUnified = suppositionA.unifySubproof(subproofNodeB, substitutions, localContextA, localContextB);
|
|
26
26
|
|
|
27
27
|
if (subproofUnified) {
|
|
28
|
-
localContextB.debug(`...unified the '${subproofStringB}' subproof
|
|
28
|
+
localContextB.debug(`...unified the '${subproofStringB}' subproof with the supposition's '${statementStringA}' statement.`, subproofNodeB);
|
|
29
29
|
|
|
30
30
|
suppositionUnified = true;
|
|
31
31
|
}
|
|
@@ -34,12 +34,12 @@ export default function unifySuppositionAgainstProofStep(suppositionA, proofStep
|
|
|
34
34
|
if (statementNodeB !== null) {
|
|
35
35
|
const statementStringB = localContextB.nodeAsString(statementNodeB);
|
|
36
36
|
|
|
37
|
-
localContextB.trace(`Unifying the '${statementStringB}' statement
|
|
37
|
+
localContextB.trace(`Unifying the '${statementStringB}' statement with the supposition's '${statementStringA}' statement...`, statementNodeB);
|
|
38
38
|
|
|
39
39
|
const statementUnified = suppositionA.unifyStatement(statementNodeB, substitutions, localContextA, localContextB);
|
|
40
40
|
|
|
41
41
|
if (statementUnified) {
|
|
42
|
-
localContextB.debug(`...unified the '${statementStringB}' statement
|
|
42
|
+
localContextB.debug(`...unified the '${statementStringB}' statement with the supposition's '${statementStringA}' statement.`, statementNodeB);
|
|
43
43
|
|
|
44
44
|
suppositionUnified = true;
|
|
45
45
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import LocalContext from "../context/local";
|
|
4
|
-
import
|
|
4
|
+
import unifySuppositionWithProofStep from "./suppositionWithProffStep";
|
|
5
5
|
|
|
6
6
|
import { reverse, correlate } from "../utilities/array";
|
|
7
7
|
|
|
8
|
-
export default function
|
|
8
|
+
export default function unifySuppositionsWithProofSteps(suppositionsA, proofStepsB, substitutions, fileContextA, localContextB) {
|
|
9
9
|
suppositionsA = reverse(suppositionsA); ///
|
|
10
10
|
|
|
11
11
|
proofStepsB = reverse(proofStepsB); ///
|
|
12
12
|
|
|
13
13
|
const suppositionsUnified = correlate(suppositionsA, proofStepsB, (suppositionA, proofStepB) => {
|
|
14
14
|
const localContextA = LocalContext.fromFileContext(fileContextA),
|
|
15
|
-
suppositionUnified =
|
|
15
|
+
suppositionUnified = unifySuppositionWithProofStep(suppositionA, proofStepB, substitutions, localContextA, localContextB);
|
|
16
16
|
|
|
17
17
|
if (suppositionUnified) {
|
|
18
18
|
return true;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import bracketedConstructor from "../constructor/bracketed";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "../utilities/query";
|
|
6
|
+
|
|
7
|
+
const termNodeQuery = nodeQuery("/term/argument/term");
|
|
8
|
+
|
|
9
|
+
export default function unifyTermWithBracketedConstructor(termNode, terms, localContext, verifyAhead) {
|
|
10
|
+
let termUnifiedWithBracketedConstructor;
|
|
11
|
+
|
|
12
|
+
const termString = localContext.nodeAsString(termNode),
|
|
13
|
+
bracketedTerms = [];
|
|
14
|
+
|
|
15
|
+
localContext.trace(`Unifying the '${termString}' term with the bracketed constructor...`, termNode);
|
|
16
|
+
|
|
17
|
+
termUnifiedWithBracketedConstructor = unifyTermWithConstructor(termNode, bracketedTerms, bracketedConstructor, localContext, () => {
|
|
18
|
+
let verifiedAhead;
|
|
19
|
+
|
|
20
|
+
const bracketedTermNode = termNode; ///
|
|
21
|
+
|
|
22
|
+
termNode = termNodeQuery(bracketedTermNode); ///
|
|
23
|
+
|
|
24
|
+
const termVVerified = verifyTerm(termNode, terms, localContext, verifyAhead);
|
|
25
|
+
|
|
26
|
+
verifiedAhead = termVVerified; ///
|
|
27
|
+
|
|
28
|
+
return verifiedAhead;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (termUnifiedWithBracketedConstructor) {
|
|
32
|
+
localContext.debug(`...unified the '${termString}' term with the bracketed constructor.`, termNode);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return termUnifiedWithBracketedConstructor;
|
|
36
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Term from "../term";
|
|
4
|
+
import termWithConstructorUnifier from "../unifier/termWithConstructor";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
|
|
8
|
+
const variableNodeQuery = nodeQuery("/term/variable!");
|
|
9
|
+
|
|
10
|
+
export default function unifyTermWithConstructors(termNode, terms, localContext, verifyAhead) {
|
|
11
|
+
let termUnifiedWithConstructors = false;
|
|
12
|
+
|
|
13
|
+
const variableNode = variableNodeQuery(termNode);
|
|
14
|
+
|
|
15
|
+
if (variableNode === null) {
|
|
16
|
+
const constructors = localContext.getConstructors();
|
|
17
|
+
|
|
18
|
+
termUnifiedWithConstructors = constructors.some((constructor) => {
|
|
19
|
+
const termUnifiedWithConstructor = unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead);
|
|
20
|
+
|
|
21
|
+
if (termUnifiedWithConstructor) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return termUnifiedWithConstructors;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function unifyTermWithConstructor(termNode, terms, constructor, localContext, verifyAhead) {
|
|
31
|
+
let termUnifiedWithConstructor = false;
|
|
32
|
+
|
|
33
|
+
const termString = localContext.nodeAsString(termNode),
|
|
34
|
+
constructorString = constructor.getString(),
|
|
35
|
+
constructorTermNode = constructor.getTermNode();
|
|
36
|
+
|
|
37
|
+
localContext.trace(`Unifying the '${termString}' term with the '${constructorString}' constructor...`, termNode);
|
|
38
|
+
|
|
39
|
+
const termNodeA = termNode, ///
|
|
40
|
+
constructorTermNodeB = constructorTermNode, ///
|
|
41
|
+
unified = termWithConstructorUnifier.unify(termNodeA, constructorTermNodeB, localContext);
|
|
42
|
+
|
|
43
|
+
if (unified) {
|
|
44
|
+
let verifiedAhead;
|
|
45
|
+
|
|
46
|
+
const type = constructor.getType(),
|
|
47
|
+
term = Term.fromTermNodeAndType(termNode, type);
|
|
48
|
+
|
|
49
|
+
terms.push(term);
|
|
50
|
+
|
|
51
|
+
verifiedAhead = verifyAhead();
|
|
52
|
+
|
|
53
|
+
terms.pop();
|
|
54
|
+
|
|
55
|
+
termUnifiedWithConstructor = verifiedAhead; ///
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (termUnifiedWithConstructor) {
|
|
59
|
+
localContext.debug(`...unified the '${termString}' term with the '${constructorString}' constructor.`, termNode);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return termUnifiedWithConstructor;
|
|
63
|
+
}
|