occam-verify-cli 0.0.1002 → 0.0.1005
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/README.md +0 -2
- package/bin/abbreviations.js +1 -3
- package/bin/action/help.js +0 -2
- package/bin/action/verify.js +4 -24
- package/bin/defaults.js +0 -2
- package/bin/main.js +3 -4
- package/bin/options.js +0 -2
- package/lib/assertion/subproof.js +106 -0
- package/lib/assignment/metavariable.js +2 -2
- package/lib/combinator.js +50 -16
- package/lib/conclusion.js +73 -14
- package/lib/context/file.js +191 -31
- package/lib/context/local.js +37 -49
- package/lib/context/release.js +42 -35
- package/lib/context/release.other.js +605 -0
- package/lib/declaration/combinator.js +83 -0
- package/lib/derivation.js +86 -0
- package/lib/equality.js +3 -11
- package/lib/index.js +1 -1
- package/lib/judgement.js +3 -10
- package/lib/label.js +58 -16
- package/lib/log.js +3 -11
- package/lib/metaType.js +31 -19
- package/lib/metavariable.js +39 -12
- package/lib/mixins/statement/qualified/unify.js +118 -0
- package/lib/mixins/statement/unify.js +57 -0
- package/lib/mixins/statement/verify.js +184 -0
- package/lib/node/statement/combinator/bracketed.js +15 -11
- package/lib/ocmbinator/bracketed.js +52 -8
- package/lib/premise.js +109 -56
- package/lib/proof.js +91 -0
- package/lib/proofStep.js +78 -25
- package/lib/reference.js +62 -16
- package/lib/rule.js +146 -26
- package/lib/ruleNames.js +5 -5
- package/lib/statement/qualified.js +127 -0
- package/lib/statement/unqualified.js +89 -0
- package/lib/statement.js +176 -0
- package/lib/subDerivation.js +86 -0
- package/lib/subproof.js +155 -0
- package/lib/substitution/frameForMetavariable.js +14 -15
- package/lib/substitution/statementForMetavariable.js +23 -24
- package/lib/substitution/termForVariable.js +11 -12
- package/lib/substitution.js +9 -2
- package/lib/substitutions.js +14 -14
- package/lib/supposition.js +92 -60
- package/lib/unifier/statementWithCombinator.js +3 -3
- package/lib/unify/metavariableWithFrame.js +2 -2
- package/lib/unify/metavariableWithStatement.js +2 -2
- package/lib/unify/metavariableWithStatementGivenSubstitution.js +2 -2
- package/lib/unify/variableWithTerm.js +2 -2
- package/lib/utilities/node.js +13 -11
- package/lib/utilities/releaseContext.js +3 -3
- package/lib/utilities/string.js +8 -2
- package/lib/utilities/subproof.js +5 -5
- package/lib/utilities/tokens.js +10 -10
- package/lib/variable.js +1 -10
- package/lib/verifier/metaLevel.js +2 -2
- package/lib/verifier/topLevel.js +5 -5
- package/lib/verify/axiom.js +3 -5
- package/lib/verify/conjecture.js +4 -7
- package/lib/verify/consequent.js +2 -3
- package/lib/verify/declaration/combinator.js +2 -14
- package/lib/verify/declaration/metavariable.js +9 -10
- package/lib/verify/files.js +4 -4
- package/lib/verify/frame.js +12 -12
- package/lib/verify/lemma.js +4 -7
- package/lib/verify/metaLemma.js +4 -7
- package/lib/verify/metatheorem.js +4 -7
- package/lib/verify/proofStep.js +2 -31
- package/lib/verify/theorem.js +4 -7
- package/package.json +4 -4
- package/src/assertion/subproof.js +84 -0
- package/src/assignment/metavariable.js +2 -2
- package/src/combinator.js +45 -15
- package/src/conclusion.js +83 -13
- package/src/context/file.js +223 -11
- package/src/context/local.js +12 -16
- package/src/context/release.js +57 -39
- package/src/context/release.other.js +547 -0
- package/src/declaration/combinator.js +44 -0
- package/src/derivation.js +50 -0
- package/src/equality.js +2 -9
- package/src/index.js +0 -1
- package/src/judgement.js +2 -8
- package/src/label.js +56 -13
- package/src/log.js +2 -9
- package/src/metaType.js +26 -14
- package/src/metavariable.js +57 -9
- package/src/mixins/statement/qualified/unify.js +186 -0
- package/src/mixins/statement/unify.js +70 -0
- package/src/mixins/statement/verify.js +274 -0
- package/src/node/statement/combinator/bracketed.js +4 -3
- package/src/ocmbinator/bracketed.js +15 -12
- package/src/premise.js +136 -44
- package/src/proof.js +58 -0
- package/src/proofStep.js +92 -22
- package/src/reference.js +58 -12
- package/src/rule.js +199 -30
- package/src/ruleNames.js +1 -1
- package/src/statement/qualified.js +104 -0
- package/src/statement/unqualified.js +60 -0
- package/src/statement.js +179 -0
- package/src/subDerivation.js +52 -0
- package/src/subproof.js +99 -0
- package/src/substitution/frameForMetavariable.js +20 -17
- package/src/substitution/statementForMetavariable.js +31 -29
- package/src/substitution/termForVariable.js +15 -14
- package/src/substitution.js +8 -0
- package/src/substitutions.js +12 -13
- package/src/supposition.js +94 -44
- package/src/unifier/statementWithCombinator.js +6 -3
- package/src/unify/metavariableWithFrame.js +1 -1
- package/src/unify/metavariableWithStatement.js +1 -1
- package/src/unify/metavariableWithStatementGivenSubstitution.js +1 -1
- package/src/unify/variableWithTerm.js +1 -1
- package/src/utilities/node.js +18 -12
- package/src/utilities/releaseContext.js +2 -2
- package/src/utilities/string.js +6 -2
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/tokens.js +7 -7
- package/src/variable.js +0 -10
- package/src/verifier/metaLevel.js +3 -2
- package/src/verifier/topLevel.js +6 -4
- package/src/verify/axiom.js +1 -2
- package/src/verify/conjecture.js +2 -3
- package/src/verify/consequent.js +1 -1
- package/src/verify/declaration/combinator.js +0 -20
- package/src/verify/declaration/metavariable.js +8 -12
- package/src/verify/files.js +3 -3
- package/src/verify/frame.js +11 -11
- package/src/verify/lemma.js +2 -3
- package/src/verify/metaLemma.js +2 -3
- package/src/verify/metatheorem.js +2 -3
- package/src/verify/proofStep.js +0 -41
- package/src/verify/theorem.js +2 -3
- package/lib/tokens/combinatorStatement/bracketed.js +0 -17
- package/lib/unify/premiseWithProofStep.js +0 -41
- package/lib/unify/premisesWithProofSteps.js +0 -31
- package/lib/unify/qualifiedStatement.js +0 -136
- package/lib/unify/statementWithBracketedCombinator.js +0 -30
- package/lib/unify/statementWithCombinator.js +0 -29
- package/lib/unify/statementWithCombinators.js +0 -31
- package/lib/unify/statementWithMetaType.js +0 -24
- package/lib/verify/conclusion.js +0 -39
- package/lib/verify/derivation.js +0 -31
- package/lib/verify/label.js +0 -37
- package/lib/verify/labels.js +0 -28
- package/lib/verify/premise.js +0 -45
- package/lib/verify/premises.js +0 -28
- package/lib/verify/proof.js +0 -34
- package/lib/verify/rule.js +0 -56
- package/lib/verify/statement/qualified.js +0 -41
- package/lib/verify/statement/unqualified.js +0 -45
- package/lib/verify/statement.js +0 -219
- package/lib/verify/statementAsCombinator.js +0 -33
- package/lib/verify/statementGivenMetaType.js +0 -52
- package/lib/verify/subproof.js +0 -34
- package/lib/verify/supposition.js +0 -45
- package/lib/verify/suppositions.js +0 -28
- package/src/tokens/combinatorStatement/bracketed.js +0 -10
- package/src/unify/premiseWithProofStep.js +0 -54
- package/src/unify/premisesWithProofSteps.js +0 -23
- package/src/unify/qualifiedStatement.js +0 -208
- package/src/unify/statementWithBracketedCombinator.js +0 -22
- package/src/unify/statementWithCombinator.js +0 -22
- package/src/unify/statementWithCombinators.js +0 -23
- package/src/unify/statementWithMetaType.js +0 -14
- package/src/verify/conclusion.js +0 -40
- package/src/verify/derivation.js +0 -23
- package/src/verify/label.js +0 -34
- package/src/verify/labels.js +0 -17
- package/src/verify/premise.js +0 -49
- package/src/verify/premises.js +0 -17
- package/src/verify/proof.js +0 -31
- package/src/verify/rule.js +0 -71
- package/src/verify/statement/qualified.js +0 -40
- package/src/verify/statement/unqualified.js +0 -49
- package/src/verify/statement.js +0 -312
- package/src/verify/statementAsCombinator.js +0 -27
- package/src/verify/statementGivenMetaType.js +0 -52
- package/src/verify/subproof.js +0 -32
- package/src/verify/supposition.js +0 -49
- package/src/verify/suppositions.js +0 -17
package/src/proofStep.js
CHANGED
|
@@ -1,45 +1,115 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
import Subproof from "./subproof";
|
|
5
|
+
import QualifiedStatement from "./statement/qualified";
|
|
6
|
+
import UnqualifiedStatement from "./statement/unqualified";
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
import { nodeQuery } from "./utilities/query";
|
|
9
|
+
|
|
10
|
+
const subproofNodeQuery = nodeQuery("/proofStep|lastProofStep/subproof"),
|
|
11
|
+
qualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/qualifiedStatement"),
|
|
12
|
+
unqualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/unqualifiedStatement");
|
|
13
|
+
|
|
14
|
+
class ProofStep {
|
|
15
|
+
constructor(subproof, qualifiedStatement, unqualifiedStatement) {
|
|
16
|
+
this.subproof = subproof;
|
|
17
|
+
this.qualifiedStatement = qualifiedStatement;
|
|
18
|
+
this.unqualifiedStatement = unqualifiedStatement;
|
|
9
19
|
}
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
return this.
|
|
21
|
+
getSubproof() {
|
|
22
|
+
return this.subproof;
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
return this.
|
|
25
|
+
getQualifiedStatement() {
|
|
26
|
+
return this.qualifiedStatement;
|
|
17
27
|
}
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
getUnqualifiedStatement() {
|
|
30
|
+
return this.unqualifiedStatement;
|
|
31
|
+
}
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
getStatement() {
|
|
34
|
+
let statement = null;
|
|
35
|
+
|
|
36
|
+
if (this.qualifiedStatement !== null) {
|
|
37
|
+
statement = this.qualifiedStatement.getStatement();
|
|
38
|
+
}
|
|
25
39
|
|
|
26
|
-
|
|
40
|
+
if (this.unqualifiedStatement !== null) {
|
|
41
|
+
statement = this.unqualifiedStatement.getStatement();
|
|
27
42
|
}
|
|
28
43
|
|
|
29
|
-
return
|
|
44
|
+
return statement;
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
// unifyStatement(statementB, equivalences, localContextA, localContextB) {
|
|
48
|
+
// let statementUnified = false;
|
|
49
|
+
//
|
|
50
|
+
// if (this.statement !== null) {
|
|
51
|
+
// const statementA = this.statement, ///
|
|
52
|
+
// statementUnifiedWithStatement = unifyStatementWithStatementGivenEquivalences(statementA, statementB, equivalences, localContextA, localContextB);
|
|
53
|
+
//
|
|
54
|
+
// statementUnified = statementUnifiedWithStatement; ///
|
|
55
|
+
// }
|
|
56
|
+
//
|
|
57
|
+
// return statementUnified;
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
verify(substitutions, localContext) {
|
|
61
|
+
let verified = false;
|
|
62
|
+
|
|
63
|
+
if (false) {
|
|
64
|
+
///
|
|
65
|
+
} else if (this.subproof !== null) {
|
|
66
|
+
const subproofVerified = this.subproof.verify(substitutions, localContext);
|
|
67
|
+
|
|
68
|
+
verified = subproofVerified; ///
|
|
69
|
+
} else if (this.qualifiedStatement !== null) {
|
|
70
|
+
const qualifiedStatementVerified = this.qualifiedStatement.verify(substitutions, localContext);
|
|
71
|
+
|
|
72
|
+
verified = qualifiedStatementVerified; ///
|
|
73
|
+
} else if (this.unqualifiedStatement !== null) {
|
|
74
|
+
const stated = true,
|
|
75
|
+
assignments = [],
|
|
76
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(stated, assignments, localContext);
|
|
77
|
+
|
|
78
|
+
verified = unqualifiedStatementVerified; ///
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (verified) {
|
|
82
|
+
const proofStep = this; ///
|
|
83
|
+
|
|
84
|
+
localContext.addProofStep(proofStep);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return verified;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static fromProofStepNode(proofStepNode, fileContext) {
|
|
91
|
+
const subproofNode = subproofNodeQuery(proofStepNode),
|
|
92
|
+
qualifiedStatementNode = qualifiedStatementNodeQuery(proofStepNode),
|
|
93
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(proofStepNode),
|
|
94
|
+
subproof = Subproof.fromSubproofNode(subproofNode, fileContext),
|
|
95
|
+
qualifiedStatement = QualifiedStatement.fromQualifiedStatementNode(qualifiedStatementNode, fileContext),
|
|
96
|
+
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
97
|
+
proofStep = new ProofStep(subproof, qualifiedStatement, unqualifiedStatement);
|
|
35
98
|
|
|
36
99
|
return proofStep;
|
|
37
100
|
}
|
|
38
101
|
|
|
39
|
-
static
|
|
40
|
-
const
|
|
41
|
-
|
|
102
|
+
static fromUnqualifiedStatement(unqualifiedStatement) {
|
|
103
|
+
const subproof = null,
|
|
104
|
+
qualifiedStatement = null,
|
|
105
|
+
proofStep = new ProofStep(subproof, qualifiedStatement, unqualifiedStatement);
|
|
42
106
|
|
|
43
107
|
return proofStep;
|
|
44
108
|
}
|
|
45
109
|
}
|
|
110
|
+
|
|
111
|
+
Object.assign(shim, {
|
|
112
|
+
ProofStep
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export default ProofStep;
|
package/src/reference.js
CHANGED
|
@@ -1,30 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Metavariable from "./metavariable";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "./utilities/query";
|
|
6
|
+
|
|
7
|
+
const metavariableNodeQuery = nodeQuery("//reference/metavariable");
|
|
4
8
|
|
|
5
9
|
export default class Reference {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
10
|
+
constructor(metavariable) {
|
|
11
|
+
this.metavariable = metavariable;
|
|
8
12
|
}
|
|
9
13
|
|
|
14
|
+
getMetavariable() {
|
|
15
|
+
return this.metavariable;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getString() { return this.metavariable.getString(); }
|
|
19
|
+
|
|
20
|
+
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
21
|
+
|
|
10
22
|
getMetavariableNode() {
|
|
11
|
-
|
|
23
|
+
const metavariableNode = this.metavariable.getNode();
|
|
24
|
+
|
|
25
|
+
return metavariableNode;
|
|
12
26
|
}
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
verify(fileContext) {
|
|
29
|
+
let verified;
|
|
30
|
+
|
|
31
|
+
const referenceString = this.getString(); ///
|
|
32
|
+
|
|
33
|
+
fileContext.trace(`Verifying the '${referenceString}' reference...`);
|
|
34
|
+
|
|
35
|
+
verified = true;
|
|
16
36
|
|
|
17
|
-
|
|
37
|
+
if (verified) {
|
|
38
|
+
fileContext.debug(`...verified the '${referenceString}' reference.`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return verified;
|
|
18
42
|
}
|
|
19
43
|
|
|
20
|
-
|
|
21
|
-
const
|
|
44
|
+
toJSON() {
|
|
45
|
+
const metavariableJSON = this.metavariable.toJSON(),
|
|
46
|
+
metavariable = metavariableJSON, ///
|
|
47
|
+
string = this.string,
|
|
48
|
+
json = {
|
|
49
|
+
string,
|
|
50
|
+
metavariable
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return json;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static fromJSON(json, fileContext) {
|
|
57
|
+
const { string } = json;
|
|
58
|
+
|
|
59
|
+
let { metavariable } = json;
|
|
22
60
|
|
|
23
|
-
|
|
61
|
+
json = metavariable; ///
|
|
62
|
+
|
|
63
|
+
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
64
|
+
|
|
65
|
+
const reference = new Reference(string, metavariable);
|
|
66
|
+
|
|
67
|
+
return reference;
|
|
24
68
|
}
|
|
25
69
|
|
|
26
|
-
static
|
|
27
|
-
const
|
|
70
|
+
static fromReferenceNode(referenceNode, fileContext) {
|
|
71
|
+
const metavariableNode = metavariableNodeQuery(referenceNode),
|
|
72
|
+
metavariable = Metavariable.fromMetavariableNode(metavariableNode, fileContext),
|
|
73
|
+
reference = new Reference(metavariable);
|
|
28
74
|
|
|
29
75
|
return reference;
|
|
30
76
|
}
|
package/src/rule.js
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Label from "./label";
|
|
4
|
+
import Proof from "./proof";
|
|
5
|
+
import Premise from "./premise";
|
|
6
|
+
import Conclusion from "./conclusion";
|
|
7
|
+
import LocalContext from "./context/local";
|
|
3
8
|
import Substitutions from "./substitutions";
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
9
|
+
|
|
10
|
+
import { reverse, correlate } from "./utilities/array";
|
|
11
|
+
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
12
|
+
|
|
13
|
+
const proofNodeQuery = nodeQuery("/rule/proof"),
|
|
14
|
+
labelNodesQuery = nodesQuery("/rule/label"),
|
|
15
|
+
premiseNodesQuery = nodesQuery("/rule/premise"),
|
|
16
|
+
conclusionNodeQuery = nodeQuery("/rule/conclusion");
|
|
7
17
|
|
|
8
18
|
export default class Rule {
|
|
9
|
-
constructor(labels, premises, conclusion,
|
|
19
|
+
constructor(fileContext, labels, premises, conclusion, proof) {
|
|
20
|
+
this.fileContext = fileContext;
|
|
10
21
|
this.labels = labels;
|
|
11
22
|
this.premises = premises;
|
|
12
23
|
this.conclusion = conclusion;
|
|
13
|
-
this.
|
|
24
|
+
this.proof = proof;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getFileContext() {
|
|
28
|
+
return this.fileContext;
|
|
14
29
|
}
|
|
15
30
|
|
|
16
31
|
getLabels() {
|
|
@@ -25,50 +40,204 @@ export default class Rule {
|
|
|
25
40
|
return this.conclusion;
|
|
26
41
|
}
|
|
27
42
|
|
|
28
|
-
|
|
29
|
-
return this.
|
|
43
|
+
getProof() {
|
|
44
|
+
return this.proof;
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
matchMetavariableNode(metavariableNode) {
|
|
48
|
+
const metavariableNodeMatches = this.labels.some((label) => {
|
|
49
|
+
const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
|
|
50
|
+
|
|
51
|
+
if (metavariableNodeMatches) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
34
55
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
premisesA = this.premises,
|
|
38
|
-
proofStepsB = proofSteps, ///
|
|
39
|
-
fileContextA = this.fileContext, ///
|
|
40
|
-
localContextB = localContext, ///
|
|
41
|
-
premisesUnified = unifyPremisesWithProofSteps(premisesA, proofStepsB, substitutions, fileContextA, localContextB);
|
|
56
|
+
return metavariableNodeMatches;
|
|
57
|
+
}
|
|
42
58
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
conclusionUnified = unifyConclusionWithStatement(conclusionA, statementNode, substitutions, fileContextA, localContextB);
|
|
59
|
+
unifyStatement(statement, localContext) {
|
|
60
|
+
let statementUnified = false;
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
const proofSteps = localContext.getProofSteps(),
|
|
63
|
+
substitutions = Substitutions.fromNothing(),
|
|
64
|
+
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
49
65
|
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
if (proofStepsUnified) {
|
|
67
|
+
statementUnified = this.conclusion.unifyStatement(statement, substitutions, localContext);
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
return statementUnified;
|
|
55
71
|
}
|
|
56
72
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
|
|
73
|
+
unifyProofSteps(proofSteps, substitutions, localContext) {
|
|
74
|
+
let proofStepsUnified;
|
|
60
75
|
|
|
61
|
-
|
|
76
|
+
let premises = this.premises;
|
|
77
|
+
|
|
78
|
+
premises = reverse(premises); ///
|
|
79
|
+
|
|
80
|
+
proofSteps = reverse(proofSteps); ///
|
|
81
|
+
|
|
82
|
+
proofStepsUnified = correlate(premises, proofSteps, (premise, proofStep) => {
|
|
83
|
+
const proofStepUnified = premise.unifyProofStep(proofStep, substitutions, localContext);
|
|
84
|
+
|
|
85
|
+
if (proofStepUnified) {
|
|
62
86
|
return true;
|
|
63
87
|
}
|
|
64
88
|
});
|
|
65
89
|
|
|
66
|
-
return
|
|
90
|
+
return proofStepsUnified;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
verify(fileContext) {
|
|
94
|
+
let verified = false;
|
|
95
|
+
|
|
96
|
+
const labelsString = labelsStringFromLabels(this.labels);
|
|
97
|
+
|
|
98
|
+
fileContext.trace(`Verifying the '${labelsString}' rule...`);
|
|
99
|
+
|
|
100
|
+
const labelsVerified = this.labels.every((label) => {
|
|
101
|
+
const labelVVerified = label.verify(fileContext);
|
|
102
|
+
|
|
103
|
+
if (labelVVerified) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (labelsVerified) {
|
|
109
|
+
const localContext = LocalContext.fromFileContext(fileContext),
|
|
110
|
+
premisesVerified = this.premises.every((premise) => {
|
|
111
|
+
const premiseVerified = premise.verify(localContext);
|
|
112
|
+
|
|
113
|
+
if (premiseVerified) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
if (premisesVerified) {
|
|
119
|
+
const conclusionVerified = this.conclusion.verify(localContext);
|
|
120
|
+
|
|
121
|
+
if (conclusionVerified) {
|
|
122
|
+
let proofVerified = true; ///
|
|
123
|
+
|
|
124
|
+
if (this.proof !== null) {
|
|
125
|
+
const substitutions = Substitutions.fromNothing();
|
|
126
|
+
|
|
127
|
+
proofVerified = this.proof.verify(substitutions, this.conclusion, localContext);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (proofVerified) {
|
|
131
|
+
const rule = this; ///
|
|
132
|
+
|
|
133
|
+
fileContext.addRule(rule);
|
|
134
|
+
|
|
135
|
+
verified = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (verified) {
|
|
142
|
+
fileContext.debug(`...verified the '${labelsString}' rule.`);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return verified;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
toJSON() {
|
|
149
|
+
const labelsJSON = this.labels.map((label) => {
|
|
150
|
+
const labelJSON = label.toJSON();
|
|
151
|
+
|
|
152
|
+
return labelJSON;
|
|
153
|
+
}),
|
|
154
|
+
premisesJSON = this.premises.map((premise) => {
|
|
155
|
+
const premiseJSON = premise.toJSON();
|
|
156
|
+
|
|
157
|
+
return premiseJSON;
|
|
158
|
+
}),
|
|
159
|
+
conclusionJSON = this.conclusion.toJSON(),
|
|
160
|
+
labels = labelsJSON, ///
|
|
161
|
+
premises = premisesJSON, ///
|
|
162
|
+
conclusion = conclusionJSON, ///
|
|
163
|
+
json = {
|
|
164
|
+
labels,
|
|
165
|
+
premises,
|
|
166
|
+
conclusion
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
return json;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static fromJSON(json, fileContext) {
|
|
173
|
+
let rule;
|
|
174
|
+
|
|
175
|
+
let { labels } = json;
|
|
176
|
+
|
|
177
|
+
const labelsJSON = labels; ///
|
|
178
|
+
|
|
179
|
+
labels = labelsJSON.map((labelJSON) => {
|
|
180
|
+
const json = labelJSON, ///
|
|
181
|
+
label = Label.fromJSON(json, fileContext);
|
|
182
|
+
|
|
183
|
+
return label;
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
let { premises } = json;
|
|
187
|
+
|
|
188
|
+
const premisesJSON = premises; ///
|
|
189
|
+
|
|
190
|
+
premises = premisesJSON.map((premiseJSON) => {
|
|
191
|
+
const json = premiseJSON, ///
|
|
192
|
+
premise = Premise.fromJSON(json, fileContext);
|
|
193
|
+
|
|
194
|
+
return premise;
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
let { conclusion } = json;
|
|
198
|
+
|
|
199
|
+
const conclusionJSON = conclusion; ///
|
|
200
|
+
|
|
201
|
+
json = conclusionJSON; ///
|
|
202
|
+
|
|
203
|
+
conclusion = Conclusion.fromJSON(json, fileContext);
|
|
204
|
+
|
|
205
|
+
const proof = null;
|
|
206
|
+
|
|
207
|
+
rule = new Rule(fileContext, labels, premises, conclusion, proof);
|
|
208
|
+
|
|
209
|
+
return rule;
|
|
67
210
|
}
|
|
68
211
|
|
|
69
|
-
static
|
|
70
|
-
const
|
|
212
|
+
static fromRuleNode(ruleNode, fileContext) {
|
|
213
|
+
const proofNode = proofNodeQuery(ruleNode),
|
|
214
|
+
labelNodes = labelNodesQuery(ruleNode),
|
|
215
|
+
premiseNodes = premiseNodesQuery(ruleNode),
|
|
216
|
+
conclusionNode = conclusionNodeQuery(ruleNode),
|
|
217
|
+
labels = labelNodes.map((labelNode) => {
|
|
218
|
+
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
219
|
+
|
|
220
|
+
return label;
|
|
221
|
+
}),
|
|
222
|
+
premises = premiseNodes.map((premiseNode) => {
|
|
223
|
+
const premise = Premise.fromPremiseNode(premiseNode, fileContext);
|
|
224
|
+
|
|
225
|
+
return premise;
|
|
226
|
+
}),
|
|
227
|
+
conclusion = Conclusion.fromConclusionNode(conclusionNode, fileContext),
|
|
228
|
+
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
229
|
+
rule = new Rule(fileContext, labels, premises, conclusion, proof);
|
|
71
230
|
|
|
72
231
|
return rule;
|
|
73
232
|
}
|
|
74
233
|
}
|
|
234
|
+
|
|
235
|
+
function labelsStringFromLabels(labels) {
|
|
236
|
+
const labelsString = labels.map((label) => {
|
|
237
|
+
const labelString = label.getString();
|
|
238
|
+
|
|
239
|
+
return labelString;
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
return labelsString;
|
|
243
|
+
}
|
package/src/ruleNames.js
CHANGED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Statement from "../statement";
|
|
4
|
+
import Reference from "../reference";
|
|
5
|
+
import unifyMixins from "../mixins/statement/qualified/unify";
|
|
6
|
+
import LocalContext from "../context/local";
|
|
7
|
+
|
|
8
|
+
import { trim } from "../utilities/string";
|
|
9
|
+
import { nodeQuery } from "../utilities/query";
|
|
10
|
+
import { assignAssignments } from "../utilities/assignments";
|
|
11
|
+
|
|
12
|
+
const statementNodeQuery = nodeQuery("/qualifiedStatement/statement"),
|
|
13
|
+
referenceNodeQuery = nodeQuery("/qualifiedStatement/reference");
|
|
14
|
+
|
|
15
|
+
export default class QualifiedStatement {
|
|
16
|
+
constructor(string, statement, reference) {
|
|
17
|
+
this.string = string;
|
|
18
|
+
this.statement = statement;
|
|
19
|
+
this.reference = reference;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getString() {
|
|
23
|
+
return this.string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getStatement() {
|
|
27
|
+
return this.statement;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getReference() {
|
|
31
|
+
return this.reference;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getMetavariableNode() { return this.reference.getMetavariableNode(); }
|
|
35
|
+
|
|
36
|
+
verify(substitutions, localContext) {
|
|
37
|
+
let verified;
|
|
38
|
+
|
|
39
|
+
const qualifiedStatementString = trim(this.string); ///
|
|
40
|
+
|
|
41
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement...`);
|
|
42
|
+
|
|
43
|
+
const stated = true,
|
|
44
|
+
assignments = [],
|
|
45
|
+
statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
46
|
+
|
|
47
|
+
if (statementVerified) {
|
|
48
|
+
const unified = this.unify(substitutions, localContext);
|
|
49
|
+
|
|
50
|
+
if (unified) {
|
|
51
|
+
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
52
|
+
|
|
53
|
+
verified = assignmentsAssigned; ///
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (verified) {
|
|
58
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement.`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return verified;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
unify(substitutions, localContext) {
|
|
65
|
+
let unified;
|
|
66
|
+
|
|
67
|
+
const qualifiedStatement = this, ///
|
|
68
|
+
qualifiedStatementString = trim(this.string); ///
|
|
69
|
+
|
|
70
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement...`);
|
|
71
|
+
|
|
72
|
+
unified = unifyMixins.some((unifyMixin) => {
|
|
73
|
+
const unified = unifyMixin(qualifiedStatement, substitutions, localContext);
|
|
74
|
+
|
|
75
|
+
return unified;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (unified) {
|
|
79
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement.`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return unified;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static fromQualifiedStatementNode(qualifiedStatementNode, fileContext) {
|
|
86
|
+
let qualifiedStatement = null;
|
|
87
|
+
|
|
88
|
+
if (qualifiedStatementNode !== null) {
|
|
89
|
+
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
90
|
+
referenceNode = referenceNodeQuery(qualifiedStatementNode),
|
|
91
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
92
|
+
statement = (statementNode !== null) ?
|
|
93
|
+
Statement.fromStatementNode(statementNode, localContext) :
|
|
94
|
+
null,
|
|
95
|
+
reference = Reference.fromReferenceNode(referenceNode, fileContext),
|
|
96
|
+
node = qualifiedStatementNode, ///
|
|
97
|
+
string = fileContext.nodeAsString(node);
|
|
98
|
+
|
|
99
|
+
qualifiedStatement = new QualifiedStatement(string, statement, reference);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return qualifiedStatement;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Statement from "../statement";
|
|
4
|
+
import LocalContext from "../context/local";
|
|
5
|
+
|
|
6
|
+
import { trim } from "../utilities/string";
|
|
7
|
+
import { nodeQuery } from "../utilities/query";
|
|
8
|
+
|
|
9
|
+
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement");
|
|
10
|
+
|
|
11
|
+
export default class UnqualifiedStatement {
|
|
12
|
+
constructor(string, statement) {
|
|
13
|
+
this.string = string;
|
|
14
|
+
this.statement = statement;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getString() {
|
|
18
|
+
return this.string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getStatement() {
|
|
22
|
+
return this.statement;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
verify(assignments, stated, localContext) {
|
|
26
|
+
let verified;
|
|
27
|
+
|
|
28
|
+
const unqualifiedStatementString = trim(this.string); ///
|
|
29
|
+
|
|
30
|
+
localContext.trace(`Verifying the '${unqualifiedStatementString}' unqualified statement...`);
|
|
31
|
+
|
|
32
|
+
const statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
33
|
+
|
|
34
|
+
verified = statementVerified; ///
|
|
35
|
+
|
|
36
|
+
if (verified) {
|
|
37
|
+
localContext.debug(`...verified the '${unqualifiedStatementString}' unqualified statement.`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return verified;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext) {
|
|
44
|
+
let unqualifiedStatement = null;
|
|
45
|
+
|
|
46
|
+
if (unqualifiedStatementNode !== null) {
|
|
47
|
+
const statementNode = statementNodeQuery(unqualifiedStatementNode),
|
|
48
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
49
|
+
statement = (statementNode !== null) ?
|
|
50
|
+
Statement.fromStatementNode(statementNode, localContext) :
|
|
51
|
+
null,
|
|
52
|
+
node = unqualifiedStatementNode, ///
|
|
53
|
+
string = fileContext.nodeAsString(node);
|
|
54
|
+
|
|
55
|
+
unqualifiedStatement = new UnqualifiedStatement(string, statement);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return unqualifiedStatement;
|
|
59
|
+
}
|
|
60
|
+
}
|