occam-verify-cli 0.0.958 → 0.0.960
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/axiom.js +1 -7
- package/lib/combinator.js +1 -19
- package/lib/conclusion.js +1 -19
- package/lib/conjecture.js +1 -7
- package/lib/consequent.js +1 -19
- package/lib/constructor.js +1 -28
- package/lib/context/file.js +38 -14
- package/lib/context/local.js +1 -14
- package/lib/context/release.js +82 -52
- package/lib/frame.js +3 -3
- package/lib/index.js +5 -5
- package/lib/label.js +1 -16
- package/lib/lemma.js +1 -7
- package/lib/metaLemma.js +1 -7
- package/lib/metaType.js +1 -10
- package/lib/metatheorem.js +1 -7
- package/lib/metavariable.js +9 -34
- package/lib/premise.js +1 -18
- package/lib/proofStep.js +15 -15
- package/lib/releaseContext/create.js +8 -9
- package/lib/releaseContext/initialise.js +67 -0
- package/lib/rule.js +5 -49
- package/lib/ruleNames.js +1 -9
- package/lib/substitution/statementForMetavariable.js +8 -16
- package/lib/substitution/termForVariable.js +6 -6
- package/lib/substitution.js +7 -7
- package/lib/substitutions.js +7 -33
- package/lib/supposition.js +1 -18
- package/lib/theorem.js +1 -7
- package/lib/topLevelAssertion.js +5 -50
- package/lib/type.js +2 -38
- 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 +6 -6
- package/lib/unify/statementWithMetaType.js +48 -0
- package/lib/unify/suppositionWithProffStep.js +41 -0
- package/lib/unify/suppositionsWithProofSteps.js +31 -0
- package/lib/unify/termWithTerm.js +21 -0
- package/lib/unify/termWithType.js +32 -0
- package/lib/unify/variableWithTerm.js +54 -0
- package/lib/utilities/node.js +3 -42
- package/lib/utilities/tokens.js +1 -15
- package/lib/variable.js +1 -26
- package/lib/verify/error.js +2 -2
- package/lib/verify/judgement.js +3 -3
- package/lib/verify/metavariable.js +4 -4
- package/lib/verify/statement/qualified.js +51 -51
- package/lib/verify/statement.js +18 -18
- package/lib/verify/statementAsCombinator.js +2 -2
- package/lib/verify/term.js +25 -25
- package/package.json +1 -1
- package/src/axiom.js +0 -2
- package/src/combinator.js +0 -26
- package/src/conclusion.js +0 -24
- package/src/conjecture.js +0 -2
- package/src/consequent.js +0 -24
- package/src/constructor.js +0 -43
- package/src/context/file.js +42 -17
- package/src/context/local.js +0 -22
- package/src/context/release.js +84 -45
- package/src/frame.js +2 -2
- package/src/index.js +1 -1
- package/src/label.js +0 -18
- package/src/lemma.js +0 -2
- package/src/metaLemma.js +0 -2
- package/src/metaType.js +0 -9
- package/src/metatheorem.js +0 -2
- package/src/metavariable.js +6 -44
- package/src/premise.js +0 -22
- package/src/proofStep.js +14 -14
- package/src/releaseContext/create.js +8 -16
- package/src/releaseContext/{verify.js → initialise.js} +32 -23
- package/src/rule.js +4 -69
- package/src/ruleNames.js +0 -2
- package/src/substitution/statementForMetavariable.js +7 -21
- package/src/substitution/termForVariable.js +4 -4
- package/src/substitution.js +5 -5
- package/src/substitutions.js +5 -32
- package/src/supposition.js +0 -22
- package/src/theorem.js +0 -2
- package/src/topLevelAssertion.js +4 -72
- package/src/type.js +0 -44
- package/src/unifier/equality.js +6 -6
- package/src/unifier/intrinsicLevel.js +3 -3
- package/src/unifier/metaLevel.js +9 -9
- package/src/unifier/{statementAgainstCombinator.js → statementWithCombinator.js} +12 -12
- 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 +4 -4
- package/src/unify/{statementAgainstMetaType.js → statementWithMetaType.js} +5 -5
- package/src/unify/{suppositionAgainstProofStep.js → suppositionWithProffStep.js} +5 -5
- package/src/unify/{suppositionsAgainstProofSteps.js → suppositionsWithProofSteps.js} +3 -3
- package/src/unify/{termAgainstTerm.js → termWithTerm.js} +4 -4
- package/src/unify/{termAgainstType.js → termWithType.js} +4 -4
- package/src/unify/{variableAgainstTerm.js → variableWithTerm.js} +5 -5
- package/src/utilities/node.js +2 -48
- package/src/utilities/tokens.js +0 -15
- package/src/variable.js +0 -36
- package/src/verify/error.js +1 -1
- package/src/verify/judgement.js +3 -3
- package/src/verify/metavariable.js +3 -3
- package/src/verify/statement/qualified.js +50 -50
- package/src/verify/statement.js +17 -17
- package/src/verify/statementAsCombinator.js +1 -1
- package/src/verify/term.js +24 -24
- 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/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
|
];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Unifier from "../unifier";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import unifyTermWithType from "../unify/termWithType";
|
|
5
|
+
import unifyStatementWithMetaType from "../unify/statementWithMetaType";
|
|
6
6
|
|
|
7
7
|
import { nodeQuery } from "../utilities/query";
|
|
8
8
|
|
|
@@ -11,17 +11,17 @@ const termNodeQuery = nodeQuery("/term!"),
|
|
|
11
11
|
metaTypeNodeQuery = nodeQuery("/metaType!"),
|
|
12
12
|
statementNodeQuery = nodeQuery("/statement!");
|
|
13
13
|
|
|
14
|
-
class
|
|
14
|
+
class StatementWithCombinatorUnifier extends Unifier {
|
|
15
15
|
unify(statementNode, combinatorStatementNode, localContext) {
|
|
16
|
-
let
|
|
16
|
+
let statementUnifiedWithCombinator;
|
|
17
17
|
|
|
18
18
|
const nonTerminalNodeA = statementNode, ///
|
|
19
19
|
nonTerminalNodeB = combinatorStatementNode, ///
|
|
20
20
|
nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext);
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
statementUnifiedWithCombinator = nonTerminalNodeUnified; ///
|
|
23
23
|
|
|
24
|
-
return
|
|
24
|
+
return statementUnifiedWithCombinator;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
static maps = [
|
|
@@ -31,9 +31,9 @@ class StatementAgainstCombinatorUnifier extends Unifier {
|
|
|
31
31
|
unify: (statementNodeA, metaTypeNodeB, localContext) => {
|
|
32
32
|
const metaTypeNode = metaTypeNodeB, ///
|
|
33
33
|
statementNode = statementNodeA, ///
|
|
34
|
-
|
|
34
|
+
statementUnifiedWithMetaType = unifyStatementWithMetaType(statementNode, metaTypeNode, localContext);
|
|
35
35
|
|
|
36
|
-
return
|
|
36
|
+
return statementUnifiedWithMetaType;
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
{
|
|
@@ -42,14 +42,14 @@ class StatementAgainstCombinatorUnifier extends Unifier {
|
|
|
42
42
|
unify: (termNodeA, typeNodeB, localContext) => {
|
|
43
43
|
const termNode = termNodeA, ///
|
|
44
44
|
typeNode = typeNodeB, ///
|
|
45
|
-
|
|
45
|
+
termUnifiedWithType = unifyTermWithType(termNode, typeNode, localContext);
|
|
46
46
|
|
|
47
|
-
return
|
|
47
|
+
return termUnifiedWithType;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
];
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const
|
|
53
|
+
const statementWithCombinatorUnifier = new StatementWithCombinatorUnifier();
|
|
54
54
|
|
|
55
|
-
export default
|
|
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;
|
|
@@ -5,8 +5,8 @@ import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
|
5
5
|
|
|
6
6
|
import { push } from "../utilities/array";
|
|
7
7
|
|
|
8
|
-
export default function
|
|
9
|
-
let
|
|
8
|
+
export default function unifyStatementWithStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB) {
|
|
9
|
+
let statementUnifiedWithtatement = false;
|
|
10
10
|
|
|
11
11
|
const termForVariableSubstitution = TermForVariableSubstitution.fromSubstitutionAndSubstitutions(substitution, substitutions),
|
|
12
12
|
transformed = termForVariableSubstitution.isTransformed(substitution);
|
|
@@ -35,10 +35,10 @@ export default function unifyStatementAgainstStatement(statementNodeA, statement
|
|
|
35
35
|
push(substitutions, substitutionsA);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
statementUnifiedWithtatement = true;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
return
|
|
41
|
+
return statementUnifiedWithtatement;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function transformSubstitutions(substitutionsA, substitutionsB) {
|
|
@@ -8,8 +8,8 @@ import { FRAME_META_TYPE_NAME, STATEMENT_META_TYPE_NAME } from "../metaTypeNames
|
|
|
8
8
|
const metavariableNodeQuery = nodeQuery("/statement/metavariable"),
|
|
9
9
|
metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type!");
|
|
10
10
|
|
|
11
|
-
export default function
|
|
12
|
-
let
|
|
11
|
+
export default function unifyStatementWithMetaType(statementNode, metaTypeNode, localContext) {
|
|
12
|
+
let statementUnifiedWithMetaType = false;
|
|
13
13
|
|
|
14
14
|
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
15
15
|
metaTypeTerminalNodeContent = metaTypeTerminalNode.getContent(),
|
|
@@ -26,7 +26,7 @@ export default function unifyStatementAgainstMetaType(statementNode, metaTypeNod
|
|
|
26
26
|
const metavariableMetaTypeName = metavariable.getMetaTypeName();
|
|
27
27
|
|
|
28
28
|
if (metavariableMetaTypeName === metaTypeName) {
|
|
29
|
-
|
|
29
|
+
statementUnifiedWithMetaType = true;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -40,11 +40,11 @@ export default function unifyStatementAgainstMetaType(statementNode, metaTypeNod
|
|
|
40
40
|
assignments = [],
|
|
41
41
|
statementVerified = verifyStatement(statementNode, assignments, derived, localContext);
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
statementUnifiedWithMetaType = statementVerified;
|
|
44
44
|
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
return
|
|
49
|
+
return statementUnifiedWithMetaType;
|
|
50
50
|
}
|
|
@@ -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;
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import { areTermNodesEqual } from "../utilities/equivalences";
|
|
4
4
|
|
|
5
|
-
export default function
|
|
6
|
-
let
|
|
5
|
+
export default function unifyTermWithTerm(leftTermNode, rightTermNode, localContext) {
|
|
6
|
+
let termUnifiedWithTerm = false;
|
|
7
7
|
|
|
8
8
|
const equivalences = localContext.getEquivalences(),
|
|
9
9
|
termNodesEqual = areTermNodesEqual(leftTermNode, rightTermNode, equivalences);
|
|
10
10
|
|
|
11
11
|
if (termNodesEqual) {
|
|
12
|
-
|
|
12
|
+
termUnifiedWithTerm = true;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
return
|
|
15
|
+
return termUnifiedWithTerm;
|
|
16
16
|
}
|
|
@@ -4,8 +4,8 @@ import shim from "../shim";
|
|
|
4
4
|
|
|
5
5
|
import { first } from "../utilities/array";
|
|
6
6
|
|
|
7
|
-
export default function
|
|
8
|
-
let
|
|
7
|
+
export default function unifyTermWithType(termNode, typeNode, localContext) {
|
|
8
|
+
let termUnifiedWithType;
|
|
9
9
|
|
|
10
10
|
const { verifyTerm } = shim,
|
|
11
11
|
terms = [],
|
|
@@ -25,7 +25,7 @@ export default function unifyTermAgainstType(termNode, typeNode, localContext) {
|
|
|
25
25
|
return verifiedAhead;
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
termUnifiedWithType = termVerified; ///
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return termUnifiedWithType;
|
|
31
31
|
}
|
|
@@ -6,8 +6,8 @@ import { nodeQuery } from "../utilities/query";
|
|
|
6
6
|
|
|
7
7
|
const variableNodeQuery = nodeQuery("/term/variable");
|
|
8
8
|
|
|
9
|
-
export default function
|
|
10
|
-
let
|
|
9
|
+
export default function unifyVariableWithTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB) {
|
|
10
|
+
let variableUnifiedWithTerm = false;
|
|
11
11
|
|
|
12
12
|
const substitution = substitutions.findSubstitution((substitution) => {
|
|
13
13
|
const substitutionMatchesVariableNodeA = substitution.matchVariableNode(variableNodeA);
|
|
@@ -21,7 +21,7 @@ export default function unifyVariableAgainstTerm(variableNodeA, termNodeB, subst
|
|
|
21
21
|
const substitutionMatchesTermNodeB = substitution.matchTermNode(termNodeB);
|
|
22
22
|
|
|
23
23
|
if (substitutionMatchesTermNodeB) {
|
|
24
|
-
|
|
24
|
+
variableUnifiedWithTerm = true;
|
|
25
25
|
}
|
|
26
26
|
} else {
|
|
27
27
|
const variableA = localContextA.findVariableByVariableNode(variableNodeA);
|
|
@@ -38,11 +38,11 @@ export default function unifyVariableAgainstTerm(variableNodeA, termNodeB, subst
|
|
|
38
38
|
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
variableUnifiedWithTerm = true;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
return
|
|
45
|
+
return variableUnifiedWithTerm;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function variableFromTermNode(termNode, localContext) {
|
package/src/utilities/node.js
CHANGED
|
@@ -4,13 +4,8 @@ import { parsersUtilities } from "occam-custom-grammars";
|
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../utilities/query";
|
|
6
6
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
10
|
-
CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
|
|
11
|
-
import { metavariableTokensFromMetavariableString,
|
|
12
|
-
variableDeclarationTokensFromVariableString,
|
|
13
|
-
unqualifiedStatementTokensFromStatementString } from "../utilities/tokens";
|
|
7
|
+
import { unqualifiedStatementTokensFromStatementString } from "../utilities/tokens";
|
|
8
|
+
import { UNQUALIFIED_STATEMENT_RULE_NAME, CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
|
|
14
9
|
|
|
15
10
|
const { florenceParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
16
11
|
|
|
@@ -18,16 +13,8 @@ const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
|
18
13
|
florenceParser = florenceParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
19
14
|
|
|
20
15
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term!"),
|
|
21
|
-
variableNodeQuery = nodeQuery("/variableDeclaration/variable!"),
|
|
22
16
|
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement!");
|
|
23
17
|
|
|
24
|
-
export function variableNodeFromVariableString(variableString, lexer, parser) {
|
|
25
|
-
const variableTDeclarationTokens = variableDeclarationTokensFromVariableString(variableString, lexer),
|
|
26
|
-
variableNode = variableNodeFromVariableVariableTDeclarationTokens(variableTDeclarationTokens, parser);
|
|
27
|
-
|
|
28
|
-
return variableNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
18
|
export function statementNodeFromStatementString(statementString, lexer, parser) {
|
|
32
19
|
const unqualifiedStatementTokens = unqualifiedStatementTokensFromStatementString(statementString, lexer),
|
|
33
20
|
statementNode = statementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser);
|
|
@@ -35,13 +22,6 @@ export function statementNodeFromStatementString(statementString, lexer, parser)
|
|
|
35
22
|
return statementNode;
|
|
36
23
|
}
|
|
37
24
|
|
|
38
|
-
export function metavariableNodeFromMetavariableString(metavariableString, lexer, parser) {
|
|
39
|
-
const metavariableTokens = metavariableTokensFromMetavariableString(metavariableString, lexer),
|
|
40
|
-
metavariableNode = metavariableNodeFromMetavariableTokens(metavariableTokens, parser);
|
|
41
|
-
|
|
42
|
-
return metavariableNode;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
25
|
export function termNodeFromConstructorDeclarationTokens(constructorDeclarationTokens, parser) {
|
|
46
26
|
let termNode = null;
|
|
47
27
|
|
|
@@ -66,32 +46,6 @@ export function statementNodeFromUnqualifiedStatementTokens(unqualifiedStatement
|
|
|
66
46
|
return statementNode;
|
|
67
47
|
}
|
|
68
48
|
|
|
69
|
-
export function variableNodeFromVariableVariableTDeclarationTokens(variableTDeclarationTokens, parser) {
|
|
70
|
-
let variableNode = null;
|
|
71
|
-
|
|
72
|
-
const variableDeclarationNode = variableDeclarationNodeFromVariableTDeclarationTokens(variableTDeclarationTokens, parser);
|
|
73
|
-
|
|
74
|
-
if (variableDeclarationNode !== null) {
|
|
75
|
-
variableNode = variableNodeQuery(variableDeclarationNode);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return variableNode;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function metavariableNodeFromMetavariableTokens(metavariableTokens, parser) {
|
|
82
|
-
const ruleName = METAVARIABLE_RULE_NAME,
|
|
83
|
-
metavariableNode = nodeFromTokensRuleNameAndParser(metavariableTokens, ruleName, parser);
|
|
84
|
-
|
|
85
|
-
return metavariableNode;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function variableDeclarationNodeFromVariableTDeclarationTokens(variableTDeclarationTokens, parser) {
|
|
89
|
-
const ruleName = VARIABLE_DECLARATION_RULE_NAME,
|
|
90
|
-
variableDeclarationNode = nodeFromTokensRuleNameAndParser(variableTDeclarationTokens, ruleName, parser);
|
|
91
|
-
|
|
92
|
-
return variableDeclarationNode;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
49
|
export function unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser) {
|
|
96
50
|
const ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
97
51
|
unqualifiedStatementNode = nodeFromTokensRuleNameAndParser(unqualifiedStatementTokens, ruleName, parser);
|