occam-verify-cli 0.0.941 → 0.0.943
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/conclusion.js +3 -4
- package/lib/consequent.js +3 -4
- package/lib/constants.js +5 -1
- package/lib/context/file.js +1 -1
- package/lib/context/local.js +15 -5
- package/lib/frame.js +2 -2
- package/lib/metavariable.js +12 -4
- package/lib/premise.js +11 -12
- package/lib/proofStep.js +14 -18
- package/lib/rule.js +6 -32
- package/lib/substitution/statementForMetavariable.js +15 -1
- package/lib/substitution/termForVariable.js +17 -3
- package/lib/substitutions.js +208 -0
- package/lib/supposition.js +11 -12
- package/lib/topLevelAssertion.js +9 -41
- package/lib/unifier/equality.js +6 -8
- package/lib/unifier/metaLevel.js +7 -10
- package/lib/unifier/statementAgainstCombinator.js +6 -9
- package/lib/unifier/termAgainstConstructor.js +5 -5
- package/lib/unifier.js +34 -13
- package/lib/unify/conclusionAgainstStatement.js +34 -0
- package/lib/unify/consequentAgainstStatement.js +34 -0
- package/lib/unify/metavariableAgainstStatement.js +24 -16
- package/lib/unify/premiseAgainstProofStep.js +41 -0
- package/lib/unify/premisesAgainstProofSteps.js +31 -0
- package/lib/unify/statementAgainstMetaType.js +5 -9
- package/lib/unify/suppositionAgainstProofStep.js +41 -0
- package/lib/unify/suppositionsAgainstProofSteps.js +31 -0
- package/lib/unify/termAgainstTerm.js +4 -5
- package/lib/unify/termAgainstType.js +7 -7
- package/lib/unify/variableAgainstTerm.js +12 -28
- package/lib/utilities/arguments.js +27 -0
- package/lib/utilities/array.js +17 -2
- package/lib/utilities/unify.js +19 -0
- package/lib/verifier/metaLevel.js +8 -11
- package/lib/verifier/statementAsCombinator.js +13 -22
- package/lib/verifier/topLevel.js +3 -6
- package/lib/verifier.js +28 -8
- package/lib/verify/assertion/type.js +3 -7
- package/lib/verify/axiom.js +3 -2
- package/lib/verify/conjecture.js +5 -3
- package/lib/verify/declaration/metavariable.js +1 -1
- package/lib/verify/equality.js +3 -7
- package/lib/verify/lemma.js +4 -3
- package/lib/verify/metaLemma.js +3 -2
- package/lib/verify/metatheorem.js +3 -2
- package/lib/verify/metavariable.js +26 -63
- package/lib/verify/rule.js +3 -2
- package/lib/verify/statement/qualified.js +54 -54
- package/lib/verify/statement/unqualified.js +2 -2
- package/lib/verify/statement.js +35 -30
- package/lib/verify/term.js +26 -32
- package/lib/verify/theorem.js +4 -3
- package/lib/verify/variable.js +3 -4
- package/package.json +4 -4
- package/src/conclusion.js +2 -6
- package/src/consequent.js +2 -6
- package/src/constants.js +1 -0
- package/src/context/file.js +5 -5
- package/src/context/local.js +20 -9
- package/src/frame.js +1 -1
- package/src/metavariable.js +1 -1
- package/src/premise.js +18 -24
- package/src/proofStep.js +16 -20
- package/src/rule.js +12 -50
- package/src/substitution/statementForMetavariable.js +16 -0
- package/src/substitution/termForVariable.js +18 -2
- package/src/substitutions.js +143 -0
- package/src/supposition.js +18 -24
- package/src/topLevelAssertion.js +15 -62
- package/src/unifier/equality.js +7 -8
- package/src/unifier/metaLevel.js +6 -10
- package/src/unifier/statementAgainstCombinator.js +9 -9
- package/src/unifier/termAgainstConstructor.js +6 -4
- package/src/unifier.js +35 -11
- package/src/unify/conclusionAgainstStatement.js +34 -0
- package/src/unify/consequentAgainstStatement.js +34 -0
- package/src/unify/metavariableAgainstStatement.js +33 -23
- package/src/unify/premiseAgainstProofStep.js +54 -0
- package/src/unify/premisesAgainstProofSteps.js +23 -0
- package/src/unify/statementAgainstMetaType.js +3 -11
- package/src/unify/suppositionAgainstProofStep.js +54 -0
- package/src/unify/suppositionsAgainstProofSteps.js +23 -0
- package/src/unify/termAgainstTerm.js +3 -7
- package/src/unify/termAgainstType.js +5 -6
- package/src/unify/variableAgainstTerm.js +18 -48
- package/src/utilities/arguments.js +18 -0
- package/src/utilities/array.js +16 -1
- package/src/utilities/unify.js +18 -0
- package/src/verifier/metaLevel.js +7 -11
- package/src/verifier/statementAsCombinator.js +15 -28
- package/src/verifier/topLevel.js +13 -17
- package/src/verifier.js +28 -6
- package/src/verify/assertion/type.js +2 -6
- package/src/verify/axiom.js +2 -1
- package/src/verify/conjecture.js +5 -2
- package/src/verify/declaration/metavariable.js +9 -9
- package/src/verify/equality.js +2 -6
- package/src/verify/lemma.js +3 -2
- package/src/verify/metaLemma.js +2 -1
- package/src/verify/metatheorem.js +2 -1
- package/src/verify/metavariable.js +31 -91
- package/src/verify/rule.js +2 -1
- package/src/verify/statement/qualified.js +53 -53
- package/src/verify/statement/unqualified.js +1 -1
- package/src/verify/statement.js +37 -31
- package/src/verify/term.js +25 -31
- package/src/verify/theorem.js +3 -2
- package/src/verify/variable.js +2 -4
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import verifyTerm from "../verify/term";
|
|
4
3
|
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
5
4
|
|
|
6
|
-
import { first } from "../utilities/array";
|
|
7
5
|
import { nodeQuery } from "../utilities/query";
|
|
8
6
|
|
|
9
7
|
const variableNodeQuery = nodeQuery("/term/variable");
|
|
10
8
|
|
|
11
|
-
export default function unifyVariableAgainstTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB
|
|
9
|
+
export default function unifyVariableAgainstTerm(variableNodeA, termNodeB, substitutions, localContextA, localContextB) {
|
|
12
10
|
let variableUnifiedAgainstTerm = false;
|
|
13
11
|
|
|
14
|
-
const substitution = substitutions.
|
|
12
|
+
const substitution = substitutions.findSubstitution((substitution) => {
|
|
15
13
|
const substitutionMatchesVariableNodeA = substitution.matchVariableNode(variableNodeA);
|
|
16
14
|
|
|
17
15
|
if (substitutionMatchesVariableNodeA) {
|
|
@@ -23,66 +21,38 @@ export default function unifyVariableAgainstTerm(variableNodeA, termNodeB, subst
|
|
|
23
21
|
const substitutionMatchesTermNodeB = substitution.matchTermNode(termNodeB);
|
|
24
22
|
|
|
25
23
|
if (substitutionMatchesTermNodeB) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
variableUnifiedAgainstTerm = verifiedAhead; ///
|
|
24
|
+
variableUnifiedAgainstTerm = true;
|
|
29
25
|
}
|
|
30
26
|
} else {
|
|
31
27
|
const variableA = localContextA.findVariableByVariableNode(variableNodeA);
|
|
32
28
|
|
|
33
29
|
if (variableA !== null) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
variable = variableA, ///
|
|
47
|
-
termType = term.getType(),
|
|
48
|
-
variableType = variable.getType(),
|
|
49
|
-
variableTypeEqualToOrSuperTypeOfTermType = variableType.isEqualToOrSuperTypeOf(termType);
|
|
50
|
-
|
|
51
|
-
if (variableTypeEqualToOrSuperTypeOfTermType) {
|
|
52
|
-
const termNode = termNodeB, ///
|
|
53
|
-
variableNode = variableNodeA, ///
|
|
54
|
-
termForVariableSubstitution = TermForVariableSubstitution.fromVariableNodeAndTermNode(variableNode, termNode),
|
|
55
|
-
substitution = termForVariableSubstitution; ///
|
|
56
|
-
|
|
57
|
-
substitutions.push(substitution);
|
|
58
|
-
|
|
59
|
-
verifiedAhead = verifyAhead();
|
|
60
|
-
|
|
61
|
-
if (!verifiedAhead) {
|
|
62
|
-
substitutions.pop();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return verifiedAhead;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
variableUnifiedAgainstTerm = termUnified; ///
|
|
30
|
+
const variableB = variableFromTermNode(termNodeB, localContextB);
|
|
31
|
+
|
|
32
|
+
if (variableA !== variableB) {
|
|
33
|
+
const termNode = termNodeB, ///
|
|
34
|
+
variableNode = variableNodeA, ///
|
|
35
|
+
termForVariableSubstitution = TermForVariableSubstitution.fromVariableNodeAndTermNode(variableNode, termNode),
|
|
36
|
+
substitution = termForVariableSubstitution; ///
|
|
37
|
+
|
|
38
|
+
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
variableUnifiedAgainstTerm = true;
|
|
71
42
|
}
|
|
72
43
|
}
|
|
73
44
|
|
|
74
45
|
return variableUnifiedAgainstTerm;
|
|
75
46
|
}
|
|
76
47
|
|
|
77
|
-
function
|
|
48
|
+
function variableFromTermNode(termNode, localContext) {
|
|
78
49
|
let variable = null;
|
|
79
50
|
|
|
80
|
-
const
|
|
81
|
-
variableNode = variableNodeQuery(termNode);
|
|
51
|
+
const variableNode = variableNodeQuery(termNode);
|
|
82
52
|
|
|
83
53
|
if (variableNode !== null) {
|
|
84
54
|
variable = localContext.findVariableByVariableNode(variableNode);
|
|
85
55
|
}
|
|
86
56
|
|
|
87
57
|
return variable;
|
|
88
|
-
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { last } from "./array";
|
|
4
|
+
import { FUNCTION } from "../constants";
|
|
5
|
+
|
|
6
|
+
export function isLastRemainingArgumentFunction(remainingArguments) {
|
|
7
|
+
let lastRemainingArgumentFunction = false;
|
|
8
|
+
|
|
9
|
+
const remainingArgumentsLength = remainingArguments.length;
|
|
10
|
+
|
|
11
|
+
if (remainingArgumentsLength > 0) {
|
|
12
|
+
const lastRemainingArgument = last(remainingArguments);
|
|
13
|
+
|
|
14
|
+
lastRemainingArgumentFunction = (typeof lastRemainingArgument === FUNCTION);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return lastRemainingArgumentFunction;
|
|
18
|
+
}
|
package/src/utilities/array.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
export const { first, second, last, extract, push, match, filter, compress, separate } = arrayUtilities;
|
|
5
|
+
export const { first, second, last, extract, push, match, prune, filter, compress, separate } = arrayUtilities;
|
|
6
6
|
|
|
7
7
|
export function reverse(array) {
|
|
8
8
|
array = [ ///
|
|
@@ -12,6 +12,21 @@ export function reverse(array) {
|
|
|
12
12
|
return array;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export function compare(arrayA, arrayB) {
|
|
16
|
+
let compares = false;
|
|
17
|
+
|
|
18
|
+
const arrayALength = arrayA.length,
|
|
19
|
+
arrayBLength = arrayB.length;
|
|
20
|
+
|
|
21
|
+
if (arrayALength === arrayBLength) {
|
|
22
|
+
const correlates = correlate(arrayA, arrayB);
|
|
23
|
+
|
|
24
|
+
compares = correlates; ///
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return compares;
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
export function correlate(arrayA, arrayB, callback) {
|
|
16
31
|
arrayB = [ ///
|
|
17
32
|
...arrayB
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery, nodesQuery } from "./query";
|
|
4
|
+
import { nodeAsString, nodesAsString } from "./string";
|
|
5
|
+
|
|
6
|
+
const subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
7
|
+
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
|
|
8
|
+
|
|
9
|
+
export function subproofNodeAsSubproofString(subproofNode, localContext) {
|
|
10
|
+
const tokens = localContext.getTokens(),
|
|
11
|
+
subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
12
|
+
subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
|
|
13
|
+
subproofSuppositionStatementsString = nodesAsString(subproofSuppositionStatementNodes, tokens),
|
|
14
|
+
subproofLastProofStepStatementString = nodeAsString(subproofLastProofStepStatementNode, tokens),
|
|
15
|
+
subproofString = `[${subproofSuppositionStatementsString}]...${subproofLastProofStepStatementString}`;
|
|
16
|
+
|
|
17
|
+
return subproofString;
|
|
18
|
+
}
|
|
@@ -16,11 +16,7 @@ class MetaLevelVerifier extends Verifier {
|
|
|
16
16
|
let verified;
|
|
17
17
|
|
|
18
18
|
const nonTerminalNode = node, ///
|
|
19
|
-
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNode, localContext
|
|
20
|
-
const verifiedAhead = true;
|
|
21
|
-
|
|
22
|
-
return verifiedAhead;
|
|
23
|
-
});
|
|
19
|
+
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNode, localContext);
|
|
24
20
|
|
|
25
21
|
verified = nonTerminalNodeVerified; ///
|
|
26
22
|
|
|
@@ -30,25 +26,25 @@ class MetaLevelVerifier extends Verifier {
|
|
|
30
26
|
static maps = [
|
|
31
27
|
{
|
|
32
28
|
nodeQuery: metavariableNodeQuery,
|
|
33
|
-
verify: (metavariableNode, localContext
|
|
34
|
-
const metavariableVerified = verifyMetavariable(metavariableNode, localContext
|
|
29
|
+
verify: (metavariableNode, localContext) => {
|
|
30
|
+
const metavariableVerified = verifyMetavariable(metavariableNode, localContext);
|
|
35
31
|
|
|
36
32
|
return metavariableVerified;
|
|
37
33
|
}
|
|
38
34
|
},
|
|
39
35
|
{
|
|
40
36
|
nodeQuery: variableNodeQuery,
|
|
41
|
-
verify: (variableNode, localContext
|
|
42
|
-
const variableVerified = verifyVariable(variableNode, localContext
|
|
37
|
+
verify: (variableNode, localContext) => {
|
|
38
|
+
const variableVerified = verifyVariable(variableNode, localContext);
|
|
43
39
|
|
|
44
40
|
return variableVerified;
|
|
45
41
|
}
|
|
46
42
|
},
|
|
47
43
|
{
|
|
48
44
|
nodeQuery: termNodeQuery,
|
|
49
|
-
verify: (termNode, localContext
|
|
45
|
+
verify: (termNode, localContext) => {
|
|
50
46
|
const terms = [],
|
|
51
|
-
termVerified = verifyTerm(termNode, terms, localContext
|
|
47
|
+
termVerified = verifyTerm(termNode, terms, localContext);
|
|
52
48
|
|
|
53
49
|
return termVerified;
|
|
54
50
|
}
|
|
@@ -17,11 +17,7 @@ class StatementAsCombinatorVerifier extends Verifier {
|
|
|
17
17
|
|
|
18
18
|
const nonTerminalNode = statementNode, ///
|
|
19
19
|
childNodes = nonTerminalNode.getChildNodes(),
|
|
20
|
-
childNodesVerified = this.verifyChildNodes(childNodes, fileContext
|
|
21
|
-
const verifiedAhead = true;
|
|
22
|
-
|
|
23
|
-
return verifiedAhead;
|
|
24
|
-
});
|
|
20
|
+
childNodesVerified = this.verifyChildNodes(childNodes, fileContext);
|
|
25
21
|
|
|
26
22
|
statementVerifiedAsCombinator = childNodesVerified; ///
|
|
27
23
|
|
|
@@ -29,41 +25,32 @@ class StatementAsCombinatorVerifier extends Verifier {
|
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
static maps = [
|
|
28
|
+
{
|
|
29
|
+
nodeQuery: statementNodeQuery,
|
|
30
|
+
verify: (statementNode, localContext) => {
|
|
31
|
+
const derived = false,
|
|
32
|
+
assignments = [],
|
|
33
|
+
statementVerified = verifyStatement(statementNode, assignments, derived, localContext);
|
|
34
|
+
|
|
35
|
+
return statementVerified;
|
|
36
|
+
}
|
|
37
|
+
},
|
|
32
38
|
{
|
|
33
39
|
nodeQuery: termNodeQuery,
|
|
34
|
-
verify: (termNode, localContext
|
|
40
|
+
verify: (termNode, localContext) => {
|
|
35
41
|
const terms = [],
|
|
36
|
-
termVerified = verifyTerm(termNode, terms, localContext
|
|
42
|
+
termVerified = verifyTerm(termNode, terms, localContext);
|
|
37
43
|
|
|
38
44
|
return termVerified;
|
|
39
45
|
}
|
|
40
46
|
},
|
|
41
47
|
{
|
|
42
48
|
nodeQuery: typeNodeQuery,
|
|
43
|
-
verify: (typeNode, localContext
|
|
44
|
-
const typeVerified = verifyType(typeNode, localContext
|
|
49
|
+
verify: (typeNode, localContext) => {
|
|
50
|
+
const typeVerified = verifyType(typeNode, localContext);
|
|
45
51
|
|
|
46
52
|
return typeVerified;
|
|
47
53
|
}
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
nodeQuery: statementNodeQuery,
|
|
51
|
-
verify: (statementNode, localContext, verifyAhead) => {
|
|
52
|
-
let statementVerified;
|
|
53
|
-
|
|
54
|
-
const derived = false,
|
|
55
|
-
assignments = [];
|
|
56
|
-
|
|
57
|
-
statementVerified = verifyStatement(statementNode, assignments, derived, localContext);
|
|
58
|
-
|
|
59
|
-
if (statementVerified) {
|
|
60
|
-
const verifiedAhead = verifyAhead();
|
|
61
|
-
|
|
62
|
-
statementVerified = verifiedAhead; ///
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return statementVerified;
|
|
66
|
-
}
|
|
67
54
|
}
|
|
68
55
|
];
|
|
69
56
|
}
|
package/src/verifier/topLevel.js
CHANGED
|
@@ -18,29 +18,25 @@ import verifyMetavariableDeclaration from "../verify/declaration/metavariable";
|
|
|
18
18
|
import { nodeQuery } from "../utilities/query";
|
|
19
19
|
|
|
20
20
|
const errorNodeQuery = nodeQuery("/error"),
|
|
21
|
-
ruleNodeQuery = nodeQuery("/rule
|
|
22
|
-
axiomNodeQuery = nodeQuery("/axiom
|
|
23
|
-
lemmaNodeQuery = nodeQuery("/lemma
|
|
24
|
-
theoremNodeQuery = nodeQuery("/theorem
|
|
25
|
-
metaLemmaNodeQuery = nodeQuery("/metaLemma
|
|
26
|
-
conjectureNodeQuery = nodeQuery("/conjecture
|
|
27
|
-
metatheoremNodeQuery = nodeQuery("/metatheorem
|
|
28
|
-
typeDeclarationNodeQuery = nodeQuery("/typeDeclaration
|
|
29
|
-
variableDeclarationNodeQuery = nodeQuery("/variableDeclaration
|
|
30
|
-
combinatorDeclarationNodeQuery = nodeQuery("/combinatorDeclaration
|
|
31
|
-
constructorDeclarationNodeQuery = nodeQuery("/constructorDeclaration
|
|
32
|
-
metavariableDeclarationNodeQuery = nodeQuery("/metavariableDeclaration
|
|
21
|
+
ruleNodeQuery = nodeQuery("/rule"),
|
|
22
|
+
axiomNodeQuery = nodeQuery("/axiom"),
|
|
23
|
+
lemmaNodeQuery = nodeQuery("/lemma"),
|
|
24
|
+
theoremNodeQuery = nodeQuery("/theorem"),
|
|
25
|
+
metaLemmaNodeQuery = nodeQuery("/metaLemma"),
|
|
26
|
+
conjectureNodeQuery = nodeQuery("/conjecture"),
|
|
27
|
+
metatheoremNodeQuery = nodeQuery("/metatheorem"),
|
|
28
|
+
typeDeclarationNodeQuery = nodeQuery("/typeDeclaration"),
|
|
29
|
+
variableDeclarationNodeQuery = nodeQuery("/variableDeclaration"),
|
|
30
|
+
combinatorDeclarationNodeQuery = nodeQuery("/combinatorDeclaration"),
|
|
31
|
+
constructorDeclarationNodeQuery = nodeQuery("/constructorDeclaration"),
|
|
32
|
+
metavariableDeclarationNodeQuery = nodeQuery("/metavariableDeclaration");
|
|
33
33
|
|
|
34
34
|
class TopLevelVerifier extends Verifier {
|
|
35
35
|
verify(node, fileContext) {
|
|
36
36
|
let verified;
|
|
37
37
|
|
|
38
38
|
const nonTerminalNode = node, ///
|
|
39
|
-
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNode, fileContext
|
|
40
|
-
const verifiedAhead = true;
|
|
41
|
-
|
|
42
|
-
return verifiedAhead;
|
|
43
|
-
});
|
|
39
|
+
nonTerminalNodeVerified = this.verifyNonTerminalNode(nonTerminalNode, fileContext);
|
|
44
40
|
|
|
45
41
|
verified = nonTerminalNodeVerified; ///
|
|
46
42
|
|
package/src/verifier.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { nodeQuery } from "./utilities/query";
|
|
4
|
+
import { isLastRemainingArgumentFunction } from "./utilities/arguments";
|
|
4
5
|
|
|
5
6
|
const nonTerminalNodeQuery = nodeQuery("/*");
|
|
6
7
|
|
|
@@ -38,10 +39,23 @@ export default class Verifier {
|
|
|
38
39
|
verifyChildNodes(childNodes, ...remainingArguments) {
|
|
39
40
|
let childNodesVerify;
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
-
childNodesVerifyAhead = this.verifyChildNodesAhead(index, childNodes, ...remainingArguments);
|
|
42
|
+
const lastRemainingArgumentFunction = isLastRemainingArgumentFunction(remainingArguments);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
if (lastRemainingArgumentFunction) {
|
|
45
|
+
const index = 0,
|
|
46
|
+
childNodesVerifyAhead = this.verifyChildNodesAhead(index, childNodes, ...remainingArguments);
|
|
47
|
+
|
|
48
|
+
childNodesVerify = childNodesVerifyAhead; ///
|
|
49
|
+
} else {
|
|
50
|
+
childNodesVerify = childNodes.every((childNode) => {
|
|
51
|
+
const node = childNode,
|
|
52
|
+
nodeVerified = this.verifyNode(node, ...remainingArguments);
|
|
53
|
+
|
|
54
|
+
if (nodeVerified) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
45
59
|
|
|
46
60
|
return childNodesVerify;
|
|
47
61
|
}
|
|
@@ -49,10 +63,18 @@ export default class Verifier {
|
|
|
49
63
|
verifyTerminalNode(terminalNode, ...remainingArguments) {
|
|
50
64
|
let terminalNodeVerified;
|
|
51
65
|
|
|
52
|
-
const
|
|
53
|
-
|
|
66
|
+
const lastRemainingArgumentFunction = isLastRemainingArgumentFunction(remainingArguments);
|
|
67
|
+
|
|
68
|
+
if (lastRemainingArgumentFunction) {
|
|
69
|
+
const verifyAhead = remainingArguments.pop(), ///
|
|
70
|
+
verifiedAhead = verifyAhead();
|
|
71
|
+
|
|
72
|
+
terminalNodeVerified = verifiedAhead; ///
|
|
54
73
|
|
|
55
|
-
|
|
74
|
+
remainingArguments.push(verifyAhead);
|
|
75
|
+
} else {
|
|
76
|
+
terminalNodeVerified = true;
|
|
77
|
+
}
|
|
56
78
|
|
|
57
79
|
return terminalNodeVerified;
|
|
58
80
|
}
|
|
@@ -77,9 +77,7 @@ function verifyDerivedTypeAssertion(typeAssertionNode, assignments, derived, loc
|
|
|
77
77
|
|
|
78
78
|
verifiedAhead = true;
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
assignments.pop();
|
|
82
|
-
}
|
|
80
|
+
assignments.pop();
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
}
|
|
@@ -136,9 +134,7 @@ function verifyStatedTypeAssertion(typeAssertionNode, assignments, derived, loca
|
|
|
136
134
|
|
|
137
135
|
verifiedAhead = true;
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
assignments.pop();
|
|
141
|
-
}
|
|
137
|
+
assignments.pop();
|
|
142
138
|
}
|
|
143
139
|
}
|
|
144
140
|
}
|
package/src/verify/axiom.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Axiom from "../axiom";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
5
|
import verifyLabels from "../verify/labels";
|
|
6
|
+
import Substitutions from "../substitutions";
|
|
6
7
|
import verifyConsequent from "../verify/consequent";
|
|
7
8
|
import verifySuppositions from "../verify/suppositions";
|
|
8
9
|
|
|
@@ -37,8 +38,8 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
37
38
|
|
|
38
39
|
if (consequentVerified) {
|
|
39
40
|
const firstConsequent = first(consequents),
|
|
41
|
+
substitutions = Substitutions.fromNothing(),
|
|
40
42
|
consequent = firstConsequent, ///
|
|
41
|
-
substitutions = [],
|
|
42
43
|
axiom = Axiom.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext);
|
|
43
44
|
|
|
44
45
|
fileContext.addAxiom(axiom);
|
package/src/verify/conjecture.js
CHANGED
|
@@ -4,6 +4,7 @@ import Conjecture from "../conjecture";
|
|
|
4
4
|
import verifyProof from "../verify/proof";
|
|
5
5
|
import verifyLabels from "../verify/labels";
|
|
6
6
|
import LocalContext from "../context/local";
|
|
7
|
+
import Substitutions from "../substitutions";
|
|
7
8
|
import verifyConsequent from "../verify/consequent";
|
|
8
9
|
import verifySuppositions from "../verify/suppositions";
|
|
9
10
|
|
|
@@ -43,10 +44,12 @@ export default function verifyConjecture(conjectureNode, fileContext) {
|
|
|
43
44
|
consequent = firstConsequent; ///
|
|
44
45
|
|
|
45
46
|
if (proofNode !== null) {
|
|
46
|
-
|
|
47
|
+
const substitutions = Substitutions.fromNothing();
|
|
48
|
+
|
|
49
|
+
verifyProof(proofNode, consequent, substitutions, localContext);
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
const substitutions =
|
|
52
|
+
const substitutions = Substitutions.fromNothing(),
|
|
50
53
|
conjecture = Conjecture.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext);
|
|
51
54
|
|
|
52
55
|
fileContext.addConjecture(conjecture);
|
|
@@ -47,14 +47,14 @@ function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
|
|
|
47
47
|
fileContext.debug(`The metavariable '${metavariableString}' is already present.`, metavariableNode);
|
|
48
48
|
} else {
|
|
49
49
|
const termTypes = [],
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
metaTypes = [],
|
|
51
|
+
argumentNode = argumentNodeQuery(metavariableNode),
|
|
52
|
+
argumentVerified = verifyArgument(argumentNode, termTypes, fileContext),
|
|
53
|
+
metaTypeVerified = verifyMetaType(metaTypeNode, metaTypes, fileContext);
|
|
54
54
|
|
|
55
55
|
if (argumentVerified && metaTypeVerified) {
|
|
56
56
|
let termType,
|
|
57
|
-
|
|
57
|
+
metaType;
|
|
58
58
|
|
|
59
59
|
const firstMetaType = first(metaTypes);
|
|
60
60
|
|
|
@@ -71,10 +71,10 @@ function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const node = metavariableNode, ///
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
name = nameFromMetavariableNode(metavariableNode),
|
|
75
|
+
metavariable = Metavariable.fromNodeNameTermTypeAndMetaType(node, name, termType, metaType),
|
|
76
|
+
metavariableAssignment = MetavariableAssignment.fromMetavariable(metavariable),
|
|
77
|
+
metavariableAssigned = metavariableAssignment.assign(fileContext);
|
|
78
78
|
|
|
79
79
|
if (metavariableAssigned) {
|
|
80
80
|
metavariableVerified = true;
|
package/src/verify/equality.js
CHANGED
|
@@ -72,9 +72,7 @@ function verifyDerivedEquality(equalityNode, assignments, derived, localContext,
|
|
|
72
72
|
|
|
73
73
|
verifiedAhead = verifyAhead();
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
assignments.pop();
|
|
77
|
-
}
|
|
75
|
+
assignments.pop();
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
|
|
@@ -123,9 +121,7 @@ function verifyStatedEquality(equalityNode, assignments, derived, localContext,
|
|
|
123
121
|
|
|
124
122
|
verifiedAhead = verifyAhead();
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
assignments.pop();
|
|
128
|
-
}
|
|
124
|
+
assignments.pop();
|
|
129
125
|
}
|
|
130
126
|
|
|
131
127
|
return verifiedAhead;
|
package/src/verify/lemma.js
CHANGED
|
@@ -4,6 +4,7 @@ import Lemma from "../lemma";
|
|
|
4
4
|
import verifyProof from "../verify/proof";
|
|
5
5
|
import verifyLabels from "../verify/labels";
|
|
6
6
|
import LocalContext from "../context/local";
|
|
7
|
+
import Substitutions from "../substitutions";
|
|
7
8
|
import verifyConsequent from "../verify/consequent";
|
|
8
9
|
import verifySuppositions from "../verify/suppositions";
|
|
9
10
|
|
|
@@ -45,11 +46,11 @@ export default function verifyLemma(lemmaNode, fileContext) {
|
|
|
45
46
|
firstConsequent = first(consequents),
|
|
46
47
|
consequent = firstConsequent, ///
|
|
47
48
|
statementNode = consequent.getStatementNode(),
|
|
48
|
-
substitutions =
|
|
49
|
+
substitutions = Substitutions.fromNothing(),
|
|
49
50
|
proofVerified = verifyProof(proofNode, statementNode, substitutions, localContext);
|
|
50
51
|
|
|
51
52
|
if (proofVerified) {
|
|
52
|
-
const substitutions =
|
|
53
|
+
const substitutions = Substitutions.fromNothing(),
|
|
53
54
|
lemma = Lemma.fromLabelsSuppositionsConsequentSubstitutionsAndFileContext(labels, suppositions, consequent, substitutions, fileContext);
|
|
54
55
|
|
|
55
56
|
fileContext.addLemma(lemma);
|
package/src/verify/metaLemma.js
CHANGED
|
@@ -4,6 +4,7 @@ import MetaLemma from "../metaLemma";
|
|
|
4
4
|
import verifyProof from "../verify/proof";
|
|
5
5
|
import LocalContext from "../context/local";
|
|
6
6
|
import verifyLabels from "../verify/labels";
|
|
7
|
+
import Substitutions from "../substitutions";
|
|
7
8
|
import verifyConsequent from "../verify/consequent";
|
|
8
9
|
import verifySuppositions from "../verify/suppositions";
|
|
9
10
|
|
|
@@ -45,7 +46,7 @@ export default function verifyMetaLemma(metaLemmaNode, fileContext) {
|
|
|
45
46
|
firstConsequent = first(consequents),
|
|
46
47
|
consequent = firstConsequent, ///
|
|
47
48
|
statementNode = consequent.getStatementNode(),
|
|
48
|
-
substitutions =
|
|
49
|
+
substitutions = Substitutions.fromNothing(),
|
|
49
50
|
proofVerified = verifyProof(proofNode, statementNode, substitutions, localContext);
|
|
50
51
|
|
|
51
52
|
if (proofVerified) {
|
|
@@ -4,6 +4,7 @@ import verifyProof from "../verify/proof";
|
|
|
4
4
|
import Metatheorem from "../metatheorem";
|
|
5
5
|
import verifyLabels from "../verify/labels";
|
|
6
6
|
import LocalContext from "../context/local";
|
|
7
|
+
import Substitutions from "../substitutions";
|
|
7
8
|
import verifyConsequent from "../verify/consequent";
|
|
8
9
|
import verifySuppositions from "../verify/suppositions";
|
|
9
10
|
|
|
@@ -41,7 +42,7 @@ export default function verifyMetatheorem(metatheoremNode, fileContext) {
|
|
|
41
42
|
const proofNode = proofNodeQuery(metatheoremNode),
|
|
42
43
|
firstConsequent = first(consequents),
|
|
43
44
|
consequent = firstConsequent, ///
|
|
44
|
-
substitutions =
|
|
45
|
+
substitutions = Substitutions.fromNothing(),
|
|
45
46
|
statementNode = consequent.getStatementNode(),
|
|
46
47
|
proofVerified = verifyProof(proofNode, statementNode, substitutions, localContext);
|
|
47
48
|
|