occam-verify-cli 1.0.388 → 1.0.404
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/action/verify.js +3 -3
- package/lib/assignment/equality.js +2 -2
- package/lib/context/file.js +11 -11
- package/lib/context/local.js +38 -61
- package/lib/context/partial.js +10 -10
- package/lib/context/temporary.js +755 -0
- package/lib/mixins/statement/verify.js +38 -16
- package/lib/mixins/step/unify.js +7 -8
- package/lib/node/argument.js +4 -4
- package/lib/node/assertion/contained.js +6 -6
- package/lib/node/assertion/defined.js +6 -6
- package/lib/node/assertion/property.js +6 -6
- package/lib/node/assertion/satisfies.js +6 -6
- package/lib/node/assertion/subproof.js +6 -6
- package/lib/node/assertion/type.js +6 -6
- package/lib/node/assertion.js +107 -0
- package/lib/node/assumption.js +134 -0
- package/lib/node/axiom.js +6 -6
- package/lib/node/{topLevelAssertion.js → axiomLemmaTheoremConjecture.js} +12 -12
- package/lib/node/body.js +4 -5
- package/lib/node/combinator.js +4 -4
- package/lib/node/conclusion.js +4 -4
- package/lib/node/conjecture.js +6 -6
- package/lib/node/constructor.js +4 -4
- package/lib/node/declaration/combinator.js +6 -6
- package/lib/node/declaration/complexType.js +6 -6
- package/lib/node/declaration/constructor.js +6 -6
- package/lib/node/declaration/metavariable.js +6 -6
- package/lib/node/declaration/property.js +6 -6
- package/lib/node/declaration/simpleType.js +6 -6
- package/lib/node/declaration/typePrefix.js +6 -6
- package/lib/node/declaration/variable.js +6 -6
- package/lib/node/declaration.js +6 -22
- package/lib/node/deduction.js +4 -4
- package/lib/node/derivation.js +4 -4
- package/lib/node/document.js +107 -0
- package/lib/node/equality.js +4 -4
- package/lib/node/error.js +4 -4
- package/lib/node/frame.js +25 -14
- package/lib/node/header.js +4 -4
- package/lib/node/hypothesis.js +4 -4
- package/lib/node/judgement.js +8 -8
- package/lib/node/label.js +4 -4
- package/lib/node/labels.js +4 -4
- package/lib/node/lemma.js +6 -6
- package/lib/node/metaArgument.js +4 -4
- package/lib/node/metaLemma.js +6 -6
- package/lib/node/{topLevelMetaAssertion.js → metaLemmaMetaTheorem.js} +12 -12
- package/lib/node/metaType.js +4 -4
- package/lib/node/metatheorem.js +6 -6
- package/lib/node/metavariable.js +4 -4
- package/lib/node/nonsense.js +4 -4
- package/lib/node/parameter.js +4 -4
- package/lib/node/parenthesisedLabel.js +4 -4
- package/lib/node/parenthesisedLabels.js +4 -4
- package/lib/node/placeholder.js +107 -0
- package/lib/node/premise.js +4 -4
- package/lib/node/procedureCall.js +4 -4
- package/lib/node/procedureReference.js +4 -4
- package/lib/node/proof.js +4 -4
- package/lib/node/property.js +4 -4
- package/lib/node/propertyRelation.js +4 -4
- package/lib/node/qualification.js +4 -4
- package/lib/node/reference.js +4 -4
- package/lib/node/rule.js +4 -4
- package/lib/node/section.js +4 -4
- package/lib/node/signature.js +4 -4
- package/lib/node/statement.js +15 -4
- package/lib/node/step.js +4 -4
- package/lib/node/subDerivation.js +4 -4
- package/lib/node/subproof.js +4 -4
- package/lib/node/substitution/frame.js +28 -6
- package/lib/node/substitution/statement.js +6 -6
- package/lib/node/substitution/term.js +28 -6
- package/lib/node/substitution.js +107 -0
- package/lib/node/supposition.js +4 -4
- package/lib/node/term.js +27 -4
- package/lib/node/theorem.js +6 -6
- package/lib/node/type.js +4 -4
- package/lib/node/typePrefix.js +4 -4
- package/lib/node/types.js +4 -4
- package/lib/node/variable.js +4 -4
- package/lib/nominal/parser.js +3 -3
- package/lib/nonTerminalNode.js +222 -0
- package/lib/nonTerminalNodeMap.js +5 -3
- package/lib/ontology/assertion/contained.js +80 -39
- package/lib/ontology/assertion/defined.js +80 -39
- package/lib/ontology/assertion/property.js +71 -29
- package/lib/ontology/assertion/satisfies.js +73 -25
- package/lib/ontology/assertion/subproof.js +95 -41
- package/lib/ontology/assertion/type.js +74 -18
- package/lib/ontology/assertion.js +66 -0
- package/lib/ontology/assumption.js +379 -0
- package/lib/ontology/axiom.js +8 -11
- package/lib/ontology/combinator/bracketed.js +17 -3
- package/lib/ontology/combinator.js +17 -3
- package/lib/ontology/conclusion.js +38 -9
- package/lib/ontology/constructor/bracketed.js +17 -3
- package/lib/ontology/constructor.js +17 -3
- package/lib/ontology/declaration/combinator.js +75 -33
- package/lib/ontology/declaration/complexType.js +110 -63
- package/lib/ontology/declaration/constructor.js +81 -38
- package/lib/ontology/declaration/metavariable.js +87 -39
- package/lib/ontology/declaration/simpleType.js +95 -48
- package/lib/ontology/declaration/typePrefix.js +87 -40
- package/lib/ontology/declaration/variable.js +87 -39
- package/lib/ontology/declaration.js +13 -313
- package/lib/ontology/deduction.js +38 -9
- package/lib/ontology/equivalence.js +295 -0
- package/lib/ontology/equivalences.js +264 -0
- package/lib/ontology/frame.js +83 -51
- package/lib/ontology/hypothesis.js +11 -11
- package/lib/ontology/judgement.js +8 -8
- package/lib/ontology/label.js +5 -6
- package/lib/ontology/metavariable.js +14 -15
- package/lib/ontology/premise.js +60 -21
- package/lib/ontology/procedureCall.js +15 -15
- package/lib/ontology/procedureReference.js +1 -1
- package/lib/ontology/proof.js +2 -2
- package/lib/ontology/reference.js +6 -13
- package/lib/ontology/rule.js +69 -71
- package/lib/ontology/section.js +2 -2
- package/lib/ontology/signature.js +2 -2
- package/lib/ontology/statement.js +36 -24
- package/lib/ontology/step.js +38 -26
- package/lib/ontology/subproof.js +12 -13
- package/lib/ontology/substitution/frame.js +69 -21
- package/lib/ontology/substitution/reference.js +24 -9
- package/lib/ontology/substitution/statement.js +137 -76
- package/lib/ontology/substitution/term.js +75 -35
- package/lib/ontology/substitution.js +50 -44
- package/lib/ontology/substitutions.js +425 -0
- package/lib/ontology/supposition.js +69 -29
- package/lib/ontology/term.js +35 -37
- package/lib/ontology/topLevelAssertion.js +16 -17
- package/lib/ontology/topLevelMetaAssertion.js +3 -4
- package/lib/ontology/variable.js +9 -14
- package/lib/preamble.js +7 -4
- package/lib/ruleNames.js +20 -12
- package/lib/unifier/intrinsicLevel.js +4 -5
- package/lib/unifier/metaLevel.js +24 -24
- package/lib/utilities/brackets.js +4 -21
- package/lib/utilities/context.js +6 -6
- package/lib/utilities/frame.js +18 -0
- package/lib/utilities/json.js +24 -1
- package/lib/utilities/metavariable.js +18 -0
- package/lib/utilities/statement.js +18 -0
- package/lib/utilities/substitutions.js +43 -30
- package/lib/utilities/unification.js +10 -16
- package/lib/utilities/variable.js +18 -0
- package/package.json +10 -10
- package/src/action/verify.js +2 -2
- package/src/assignment/equality.js +1 -1
- package/src/context/file.js +13 -11
- package/src/context/local.js +40 -65
- package/src/context/partial.js +9 -14
- package/src/context/temporary.js +463 -0
- package/src/mixins/statement/verify.js +60 -23
- package/src/mixins/step/unify.js +6 -6
- package/src/node/argument.js +1 -1
- package/src/node/assertion/contained.js +3 -3
- package/src/node/assertion/defined.js +3 -3
- package/src/node/assertion/property.js +3 -3
- package/src/node/assertion/satisfies.js +3 -3
- package/src/node/assertion/subproof.js +3 -3
- package/src/node/assertion/type.js +3 -3
- package/src/node/assertion.js +7 -0
- package/src/node/assumption.js +35 -0
- package/src/node/axiom.js +3 -3
- package/src/node/{topLevelAssertion.js → axiomLemmaTheoremConjecture.js} +2 -2
- package/src/node/body.js +1 -3
- package/src/node/combinator.js +1 -1
- package/src/node/conclusion.js +1 -1
- package/src/node/conjecture.js +3 -3
- package/src/node/constructor.js +1 -1
- package/src/node/declaration/combinator.js +3 -3
- package/src/node/declaration/complexType.js +3 -3
- package/src/node/declaration/constructor.js +3 -3
- package/src/node/declaration/metavariable.js +3 -3
- package/src/node/declaration/property.js +3 -3
- package/src/node/declaration/simpleType.js +3 -3
- package/src/node/declaration/typePrefix.js +3 -3
- package/src/node/declaration/variable.js +3 -3
- package/src/node/declaration.js +2 -18
- package/src/node/deduction.js +1 -1
- package/src/node/derivation.js +1 -1
- package/src/node/document.js +7 -0
- package/src/node/equality.js +1 -1
- package/src/node/error.js +1 -1
- package/src/node/frame.js +23 -11
- package/src/node/header.js +1 -1
- package/src/node/hypothesis.js +1 -1
- package/src/node/judgement.js +6 -6
- package/src/node/label.js +1 -1
- package/src/node/labels.js +1 -1
- package/src/node/lemma.js +3 -3
- package/src/node/metaArgument.js +1 -1
- package/src/node/metaLemma.js +3 -3
- package/src/node/{topLevelMetaAssertion.js → metaLemmaMetaTheorem.js} +2 -2
- package/src/node/metaType.js +1 -1
- package/src/node/metatheorem.js +3 -3
- package/src/node/metavariable.js +1 -1
- package/src/node/nonsense.js +1 -1
- package/src/node/parameter.js +1 -1
- package/src/node/parenthesisedLabel.js +1 -1
- package/src/node/parenthesisedLabels.js +1 -1
- package/src/node/placeholder.js +7 -0
- package/src/node/premise.js +1 -1
- package/src/node/procedureCall.js +1 -1
- package/src/node/procedureReference.js +1 -1
- package/src/node/proof.js +1 -1
- package/src/node/property.js +1 -1
- package/src/node/propertyRelation.js +1 -1
- package/src/node/qualification.js +1 -1
- package/src/node/reference.js +1 -1
- package/src/node/rule.js +2 -2
- package/src/node/section.js +1 -1
- package/src/node/signature.js +1 -1
- package/src/node/statement.js +13 -1
- package/src/node/step.js +1 -1
- package/src/node/subDerivation.js +1 -1
- package/src/node/subproof.js +1 -1
- package/src/node/substitution/frame.js +29 -3
- package/src/node/substitution/statement.js +3 -3
- package/src/node/substitution/term.js +29 -3
- package/src/node/substitution.js +7 -0
- package/src/node/supposition.js +1 -1
- package/src/node/term.js +27 -1
- package/src/node/theorem.js +3 -3
- package/src/node/type.js +1 -1
- package/src/node/typePrefix.js +1 -1
- package/src/node/types.js +1 -1
- package/src/node/variable.js +1 -1
- package/src/nominal/parser.js +2 -2
- package/src/{node/nonTerminal.js → nonTerminalNode.js} +31 -25
- package/src/nonTerminalNodeMap.js +10 -5
- package/src/ontology/assertion/contained.js +21 -32
- package/src/ontology/assertion/defined.js +20 -31
- package/src/ontology/assertion/property.js +7 -20
- package/src/ontology/assertion/satisfies.js +8 -16
- package/src/ontology/assertion/subproof.js +36 -42
- package/src/ontology/assertion/type.js +10 -11
- package/src/ontology/assertion.js +23 -0
- package/src/ontology/assumption.js +385 -0
- package/src/ontology/axiom.js +7 -16
- package/src/ontology/combinator/bracketed.js +2 -0
- package/src/ontology/combinator.js +2 -0
- package/src/ontology/conclusion.js +51 -10
- package/src/ontology/constructor/bracketed.js +2 -0
- package/src/ontology/constructor.js +2 -0
- package/src/ontology/declaration/combinator.js +15 -24
- package/src/ontology/declaration/complexType.js +57 -53
- package/src/ontology/declaration/constructor.js +25 -31
- package/src/ontology/declaration/metavariable.js +25 -30
- package/src/ontology/declaration/simpleType.js +34 -38
- package/src/ontology/declaration/typePrefix.js +23 -31
- package/src/ontology/declaration/variable.js +26 -31
- package/src/ontology/declaration.js +8 -339
- package/src/ontology/deduction.js +51 -10
- package/src/{equivalence.js → ontology/equivalence.js} +4 -3
- package/src/{equivalences.js → ontology/equivalences.js} +14 -12
- package/src/ontology/frame.js +93 -66
- package/src/ontology/hypothesis.js +8 -8
- package/src/ontology/judgement.js +8 -8
- package/src/ontology/label.js +2 -7
- package/src/ontology/metavariable.js +14 -17
- package/src/ontology/premise.js +82 -25
- package/src/ontology/procedureCall.js +14 -14
- package/src/ontology/procedureReference.js +2 -2
- package/src/ontology/proof.js +1 -1
- package/src/ontology/reference.js +5 -9
- package/src/ontology/rule.js +79 -82
- package/src/ontology/section.js +1 -1
- package/src/ontology/signature.js +1 -1
- package/src/ontology/statement.js +37 -27
- package/src/ontology/step.js +45 -28
- package/src/ontology/subproof.js +10 -10
- package/src/ontology/substitution/frame.js +72 -26
- package/src/ontology/substitution/reference.js +8 -6
- package/src/ontology/substitution/statement.js +95 -76
- package/src/ontology/substitution/term.js +81 -41
- package/src/ontology/substitution.js +35 -34
- package/src/{substitutions.js → ontology/substitutions.js} +29 -28
- package/src/ontology/supposition.js +88 -28
- package/src/ontology/term.js +31 -43
- package/src/ontology/topLevelAssertion.js +16 -18
- package/src/ontology/topLevelMetaAssertion.js +3 -3
- package/src/ontology/variable.js +10 -17
- package/src/preamble.js +6 -3
- package/src/ruleNames.js +10 -8
- package/src/unifier/intrinsicLevel.js +5 -6
- package/src/unifier/metaLevel.js +32 -29
- package/src/utilities/brackets.js +3 -29
- package/src/utilities/context.js +5 -5
- package/src/utilities/frame.js +13 -0
- package/src/utilities/json.js +28 -0
- package/src/utilities/metavariable.js +13 -0
- package/src/utilities/statement.js +13 -0
- package/src/utilities/substitutions.js +59 -33
- package/src/utilities/unification.js +8 -24
- package/src/utilities/variable.js +13 -0
- package/lib/equivalence.js +0 -294
- package/lib/equivalences.js +0 -263
- package/lib/node/nonTerminal.js +0 -218
- package/lib/substitutions.js +0 -424
|
@@ -1,352 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { define } from "../ontology";
|
|
7
|
-
import { unifyStatementIntrinsically } from "../utilities/unification";
|
|
8
|
-
|
|
9
|
-
export default define(class Declaration {
|
|
10
|
-
constructor(string, node, statement, metavariable) {
|
|
11
|
-
this.string = string;
|
|
3
|
+
export default class Declaration {
|
|
4
|
+
constructor(context, node, string) {
|
|
5
|
+
this.context = context;
|
|
12
6
|
this.node = node;
|
|
13
|
-
this.
|
|
14
|
-
this.metavariable = metavariable;
|
|
7
|
+
this.string = string;
|
|
15
8
|
}
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
return this.
|
|
10
|
+
getContext() {
|
|
11
|
+
return this.context;
|
|
19
12
|
}
|
|
20
13
|
|
|
21
14
|
getNode() {
|
|
22
15
|
return this.node;
|
|
23
16
|
}
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
return this.
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getMetavariable() {
|
|
30
|
-
return this.metavariable;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
isSimple() {
|
|
34
|
-
const simple = (this.statement === null);
|
|
35
|
-
|
|
36
|
-
return simple;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
matchSubstitution(substitution, context) {
|
|
40
|
-
let substitutionMatches = false;
|
|
41
|
-
|
|
42
|
-
const declarationString = this.string, ///
|
|
43
|
-
substitutionString = substitution.getString();
|
|
44
|
-
|
|
45
|
-
context.trace(`Matching the '${substitutionString}' substitution against the '${declarationString}' declaration...`);
|
|
46
|
-
|
|
47
|
-
const simple = this.isSimple();
|
|
48
|
-
|
|
49
|
-
if (simple) {
|
|
50
|
-
const judgement = context.findJudgementByMetavariable(this.metavariable);
|
|
51
|
-
|
|
52
|
-
if (judgement !== null) {
|
|
53
|
-
const declaration = judgement.getDeclaration();
|
|
54
|
-
|
|
55
|
-
substitutionMatches = declaration.matchSubstitution(substitution, context);
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
const statement = substitution.getStatement(),
|
|
59
|
-
metavariable = substitution.getMetavariable(),
|
|
60
|
-
statementEqualToStatement = this.statement.isEqualTo(statement),
|
|
61
|
-
metavariableEqualToMetavariable = this.metavariable.isEqualTo(metavariable);
|
|
62
|
-
|
|
63
|
-
if (metavariableEqualToMetavariable && statementEqualToStatement) {
|
|
64
|
-
substitutionMatches = true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (substitutionMatches) {
|
|
69
|
-
context.debug(`...matches the '${declarationString}' substitution against the '${substitutionString}' declaration.`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return substitutionMatches;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
verify(assignments, stated, context) {
|
|
76
|
-
let verifies = false;
|
|
77
|
-
|
|
78
|
-
const declarationString = this.string; ///
|
|
79
|
-
|
|
80
|
-
context.trace(`Verifying the '${declarationString}' declaration...`);
|
|
81
|
-
|
|
82
|
-
const simple = this.isSimple();
|
|
83
|
-
|
|
84
|
-
if (simple) {
|
|
85
|
-
const verifiesAsMetavariable = this.verifyAsMetavariable(assignments, stated, context);
|
|
86
|
-
|
|
87
|
-
verifies = verifiesAsMetavariable; ///
|
|
88
|
-
} else {
|
|
89
|
-
const metavariableVerifiesAsReference = this.verifyMetavariableAsReference(assignments, stated, context);
|
|
90
|
-
|
|
91
|
-
if (metavariableVerifiesAsReference) {
|
|
92
|
-
const statementVerifies = this.verifyStatement(assignments, stated, context);
|
|
93
|
-
|
|
94
|
-
if (statementVerifies) {
|
|
95
|
-
let verifiesWhenStated = false,
|
|
96
|
-
verifiesWhenDerived = false;
|
|
97
|
-
|
|
98
|
-
if (stated) {
|
|
99
|
-
verifiesWhenStated = this.verifyWhenStated(assignments, context);
|
|
100
|
-
} else {
|
|
101
|
-
verifiesWhenDerived = this.verifyWhenDerived(context);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (verifiesWhenStated || verifiesWhenDerived) {
|
|
105
|
-
verifies = true;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (verifies) {
|
|
111
|
-
context.debug(`...verified the '${declarationString}' declaration.`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return verifies;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
verifyMetavariableAsReference(assignments, stated, context) {
|
|
119
|
-
let metavariableVerifiesAsReference;
|
|
120
|
-
|
|
121
|
-
const declarationString = this.string,
|
|
122
|
-
metavariableString = this.metavariable.getString();
|
|
123
|
-
|
|
124
|
-
context.trace(`Verifying the '${declarationString}' declaration's '${metavariableString}' metavariable as a reference...`);
|
|
125
|
-
|
|
126
|
-
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
127
|
-
referenceVerifies = reference.verify(context);
|
|
128
|
-
|
|
129
|
-
metavariableVerifiesAsReference = referenceVerifies; ///
|
|
130
|
-
|
|
131
|
-
if (metavariableVerifiesAsReference) {
|
|
132
|
-
context.debug(`...verified the '${declarationString}' declaration's '${metavariableString}' metavariable as a reference.`);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return metavariableVerifiesAsReference;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
verifyStatement(assignments, stated, context) {
|
|
139
|
-
let statementVerifies;
|
|
140
|
-
|
|
141
|
-
if (this.statement === null) {
|
|
142
|
-
statementVerifies = true;
|
|
143
|
-
} else {
|
|
144
|
-
const statementString = this.statement.getString();
|
|
145
|
-
|
|
146
|
-
context.trace(`Verifying the '${statementString}' statement...`);
|
|
147
|
-
|
|
148
|
-
stated = true; ///
|
|
149
|
-
|
|
150
|
-
assignments = null; ///
|
|
151
|
-
|
|
152
|
-
statementVerifies = this.statement.verify(assignments, stated, context);
|
|
153
|
-
|
|
154
|
-
if (statementVerifies) {
|
|
155
|
-
context.debug(`...verified the '${statementString}' statement.`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return statementVerifies;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
verifyAsMetavariable(assignments, stated, context) {
|
|
163
|
-
let verifiesAsMetavariable;
|
|
164
|
-
|
|
165
|
-
const declarationString = this.string, ///
|
|
166
|
-
metavariableString = this.metavariable.getString();
|
|
167
|
-
|
|
168
|
-
context.trace(`Verifying the '${declarationString}' declaration's '${metavariableString}' metavariable...`);
|
|
169
|
-
|
|
170
|
-
verifiesAsMetavariable = this.metavariable.verify(context);
|
|
171
|
-
|
|
172
|
-
if (verifiesAsMetavariable) {
|
|
173
|
-
context.debug(`...verified the '${declarationString}' declaration's '${metavariableString}' metavariable.`);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return verifiesAsMetavariable;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
verifyWhenStated(assignments, context) {
|
|
180
|
-
let verifiesWhenStated;
|
|
181
|
-
|
|
182
|
-
const declarationString = this.string; ///
|
|
183
|
-
|
|
184
|
-
context.trace(`Verifying the '${declarationString}' stated declaration...`);
|
|
185
|
-
|
|
186
|
-
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
187
|
-
metavariablePresent = context.isMetavariablePresentByReference(reference);
|
|
188
|
-
|
|
189
|
-
if (metavariablePresent) {
|
|
190
|
-
verifiesWhenStated = true;
|
|
191
|
-
} else {
|
|
192
|
-
const metaLemmaMetatheorems = context.findMetaLemmaMetatheoremsByReference(reference),
|
|
193
|
-
metaLemmaMetatheoremsUnify = metaLemmaMetatheorems.every((metaLemmaMetatheorem) => {
|
|
194
|
-
const metaLemmaMetatheoremUnifies = this.unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context);
|
|
195
|
-
|
|
196
|
-
if (metaLemmaMetatheoremUnifies) {
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
verifiesWhenStated = metaLemmaMetatheoremsUnify; ///
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (verifiesWhenStated) {
|
|
205
|
-
context.debug(`...verified the '${declarationString}' stated declaration.`);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return verifiesWhenStated;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
verifyWhenDerived(context) {
|
|
212
|
-
let verifiesWhenDerived;
|
|
213
|
-
|
|
214
|
-
const declarationString = this.string; ///
|
|
215
|
-
|
|
216
|
-
context.trace(`Verifying the '${declarationString}' derived declaration...`);
|
|
217
|
-
|
|
218
|
-
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
219
|
-
metaLemmaMetatheoremPresent = context.isMetaLemmaMetatheoremPresentByReference(reference);
|
|
220
|
-
|
|
221
|
-
verifiesWhenDerived = metaLemmaMetatheoremPresent; ///
|
|
222
|
-
|
|
223
|
-
if (verifiesWhenDerived) {
|
|
224
|
-
context.debug(`...verified the '${declarationString}' derived declaration.`);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return verifiesWhenDerived;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
231
|
-
let statementUnifies;
|
|
232
|
-
|
|
233
|
-
const simple = this.isSimple();
|
|
234
|
-
|
|
235
|
-
if (simple) {
|
|
236
|
-
statementUnifies = false;
|
|
237
|
-
} else {
|
|
238
|
-
const context = generalContext, ///
|
|
239
|
-
statementString = statement.getString(),
|
|
240
|
-
declarationStatementString = this.statement.getString();
|
|
241
|
-
|
|
242
|
-
context.trace(`Unifying the '${statementString}' statement with the '${declarationStatementString}' statement...`);
|
|
243
|
-
|
|
244
|
-
const generalStatement = this.statement,
|
|
245
|
-
specificStatement = statement, ///
|
|
246
|
-
statementUUnifiesIntrinsically = unifyStatementIntrinsically(generalStatement, specificStatement, substitutions, generalContext, specificContext);
|
|
247
|
-
|
|
248
|
-
statementUnifies = statementUUnifiesIntrinsically; ///
|
|
249
|
-
|
|
250
|
-
if (statementUnifies) {
|
|
251
|
-
context.debug(`...unified the '${statementString}' statement with the '${declarationStatementString}' statement.`);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return statementUnifies;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
unifyLabel(label, substitutions, generalContext, specificContext) {
|
|
259
|
-
let labelUnifiesWithReference;
|
|
260
|
-
|
|
261
|
-
const context = generalContext, ///
|
|
262
|
-
labelString = label.getString(),
|
|
263
|
-
declarationString = this.string; //;/
|
|
264
|
-
|
|
265
|
-
context.trace(`Unifying the '${labelString}' label with the '${declarationString}' declaration...`);
|
|
266
|
-
|
|
267
|
-
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
268
|
-
labelUnifies = reference.unifyLabel(label, substitutions, context);
|
|
269
|
-
|
|
270
|
-
labelUnifiesWithReference = labelUnifies; ///
|
|
271
|
-
|
|
272
|
-
if (labelUnifiesWithReference) {
|
|
273
|
-
context.debug(`...unified the '${labelString}' label with the '${declarationString}' declaration.`);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return labelUnifiesWithReference;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context) {
|
|
280
|
-
let metaLemmaMetatheoremUnifies = false;
|
|
281
|
-
|
|
282
|
-
const declarationString = this.string, ///
|
|
283
|
-
metaLemmaMetatheoremString = metaLemmaMetatheorem.getString();
|
|
284
|
-
|
|
285
|
-
context.trace(`Unifying the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${declarationString}' declaration...`);
|
|
286
|
-
|
|
287
|
-
const generalContext = context; ///
|
|
288
|
-
|
|
289
|
-
context = metaLemmaMetatheorem.getContext(); ///
|
|
290
|
-
|
|
291
|
-
const specificContext = context, ///
|
|
292
|
-
labelSubstitutions = Substitutions.fromNothing(),
|
|
293
|
-
label = metaLemmaMetatheorem.getLabel(),
|
|
294
|
-
substitutions = labelSubstitutions, ///
|
|
295
|
-
labelUnifies = this.unifyLabel(label, substitutions, generalContext, specificContext);
|
|
296
|
-
|
|
297
|
-
if (labelUnifies) {
|
|
298
|
-
const statementSubstitutions = Substitutions.fromNothing(),
|
|
299
|
-
statement = metaLemmaMetatheorem.getStatement(),
|
|
300
|
-
substitutions = statementSubstitutions, ///
|
|
301
|
-
statementUUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
302
|
-
|
|
303
|
-
if (statementUUnifies) {
|
|
304
|
-
const labelSubstitutionsCorrelateStatementSubstitutions = labelSubstitutions.correlateSubstitutions(statementSubstitutions);
|
|
305
|
-
|
|
306
|
-
if (labelSubstitutionsCorrelateStatementSubstitutions) {
|
|
307
|
-
metaLemmaMetatheoremUnifies = true; ///
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
if (metaLemmaMetatheoremUnifies) {
|
|
313
|
-
context.trace(`...unified the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${declarationString}' declaration...`);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
return metaLemmaMetatheoremUnifies;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
static name = "Declaration";
|
|
320
|
-
|
|
321
|
-
static fromJudgementNode(judgementNode, context) {
|
|
322
|
-
const declarationNode = judgementNode.getDeclarationNode(),
|
|
323
|
-
declaration = declarationFromDeclarationNode(declarationNode, context);
|
|
324
|
-
|
|
325
|
-
return declaration;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
static fromDeclarationNode(declarationNode, context) {
|
|
329
|
-
const declaration = declarationFromDeclarationNode(declarationNode, context);
|
|
330
|
-
|
|
331
|
-
return declaration;
|
|
18
|
+
getString() {
|
|
19
|
+
return this.string;
|
|
332
20
|
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
function referenceFromMetavariable(metavariable, context) {
|
|
336
|
-
const { Reference } = ontology,
|
|
337
|
-
metavariableNode = metavariable.getNode(),
|
|
338
|
-
reference = Reference.fromMetavariableNode(metavariableNode, context);
|
|
339
|
-
|
|
340
|
-
return reference;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function declarationFromDeclarationNode(declarationNode, context) {
|
|
344
|
-
const { Metavariable, Declaration, Statement } = ontology,
|
|
345
|
-
node = declarationNode, ///
|
|
346
|
-
string = context.nodeAsString(node),
|
|
347
|
-
metavariable = Metavariable.fromDeclarationNode(declarationNode, context),
|
|
348
|
-
statement = Statement.fromDeclarationNode(declarationNode, context),
|
|
349
|
-
declaration = new Declaration(string, node, statement, metavariable);
|
|
350
|
-
|
|
351
|
-
return declaration;
|
|
352
21
|
}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import ontology from "../ontology";
|
|
4
|
+
import TemporaryContext from "../context/temporary";
|
|
4
5
|
|
|
5
6
|
import { define } from "../ontology";
|
|
6
|
-
import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
|
|
7
|
+
import { termsFromJSON, framesFromJSON, statementFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON } from "../utilities/json";
|
|
7
8
|
|
|
8
9
|
export default define(class Deduction {
|
|
9
|
-
constructor(node, string, statement) {
|
|
10
|
+
constructor(context, node, string, statement) {
|
|
11
|
+
this.context = context;
|
|
10
12
|
this.node = node;
|
|
11
13
|
this.string = string;
|
|
12
14
|
this.statement = statement;
|
|
13
15
|
}
|
|
14
16
|
|
|
17
|
+
getContext() {
|
|
18
|
+
return this.context;
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
getNode(node) {
|
|
16
22
|
return this.node;
|
|
17
23
|
}
|
|
@@ -27,6 +33,10 @@ export default define(class Deduction {
|
|
|
27
33
|
verify(context) {
|
|
28
34
|
let verifies = false;
|
|
29
35
|
|
|
36
|
+
const temporaryContext = TemporaryContext.fromNothing(context);
|
|
37
|
+
|
|
38
|
+
context = temporaryContext; ///
|
|
39
|
+
|
|
30
40
|
const deductionString = this.string; ///
|
|
31
41
|
|
|
32
42
|
context.trace(`Verifying the '${deductionString}' deduction...`, this.node);
|
|
@@ -42,25 +52,30 @@ export default define(class Deduction {
|
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
if (verifies) {
|
|
55
|
+
this.context = context;
|
|
56
|
+
|
|
45
57
|
context.debug(`...verified the '${deductionString}' deduction.`, this.node);
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
return verifies;
|
|
49
61
|
}
|
|
50
62
|
|
|
51
|
-
unifyStatement(statement, substitutions,
|
|
63
|
+
unifyStatement(statement, substitutions, context) {
|
|
52
64
|
let statementUnifies;
|
|
53
65
|
|
|
54
66
|
const deduction = this, ///
|
|
55
67
|
statementString = statement.getString(),
|
|
56
68
|
deductionString = deduction.getString();
|
|
57
69
|
|
|
58
|
-
|
|
70
|
+
context.trace(`Unifying the '${statementString}' statement with the '${deductionString}' deduction...`);
|
|
71
|
+
|
|
72
|
+
const generalContext = this.context, ///
|
|
73
|
+
specificContext = context; ///
|
|
59
74
|
|
|
60
75
|
statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
61
76
|
|
|
62
77
|
if (statementUnifies) {
|
|
63
|
-
|
|
78
|
+
context.debug(`...unified the '${statementString}' statement with the '${deductionString}' deduction.`);
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
return statementUnifies;
|
|
@@ -89,10 +104,26 @@ export default define(class Deduction {
|
|
|
89
104
|
}
|
|
90
105
|
|
|
91
106
|
toJSON() {
|
|
107
|
+
let frames,
|
|
108
|
+
terms;
|
|
109
|
+
|
|
110
|
+
frames = this.context.getFrames();
|
|
111
|
+
|
|
112
|
+
terms = this.context.getTerms();
|
|
113
|
+
|
|
92
114
|
const statementJSON = statementToStatementJSON(this.statement),
|
|
93
|
-
|
|
115
|
+
framesJSON = framesToFramesJSON(frames),
|
|
116
|
+
termsJSON = termsToTermsJSON(terms);
|
|
117
|
+
|
|
118
|
+
frames = framesJSON; ///
|
|
119
|
+
|
|
120
|
+
terms = termsJSON; ///
|
|
121
|
+
|
|
122
|
+
const statement = statementJSON, ///
|
|
94
123
|
json = {
|
|
95
|
-
statement
|
|
124
|
+
statement,
|
|
125
|
+
frames,
|
|
126
|
+
terms
|
|
96
127
|
};
|
|
97
128
|
|
|
98
129
|
return json;
|
|
@@ -101,10 +132,16 @@ export default define(class Deduction {
|
|
|
101
132
|
static name = "Deduction";
|
|
102
133
|
|
|
103
134
|
static fromJSON(json, context) {
|
|
104
|
-
const
|
|
135
|
+
const terms = termsFromJSON(json, context),
|
|
136
|
+
frames = framesFromJSON(json, context),
|
|
137
|
+
statement = statementFromJSON(json, context),
|
|
105
138
|
node = null,
|
|
106
139
|
string = statement.getString(),
|
|
107
|
-
|
|
140
|
+
temporaryContext = TemporaryContext.fromTermsAndFrames(terms, frames, context);
|
|
141
|
+
|
|
142
|
+
context = temporaryContext; ///
|
|
143
|
+
|
|
144
|
+
const deduction = new Deduction(context, node, string, statement);
|
|
108
145
|
|
|
109
146
|
return deduction;
|
|
110
147
|
}
|
|
@@ -114,7 +151,11 @@ export default define(class Deduction {
|
|
|
114
151
|
node = deductionNode, ///
|
|
115
152
|
string = context.nodeAsString(node),
|
|
116
153
|
statement = Statement.fromDeductionNode(deductionNode, context),
|
|
117
|
-
|
|
154
|
+
temporaryContext = null;
|
|
155
|
+
|
|
156
|
+
context = temporaryContext; ///
|
|
157
|
+
|
|
158
|
+
const deduction = new Deduction(context, node, string, statement);
|
|
118
159
|
|
|
119
160
|
return deduction;
|
|
120
161
|
}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { define } from "../ontology";
|
|
6
|
+
import { stripBracketsFromTermNode } from "../utilities/brackets";
|
|
6
7
|
|
|
7
8
|
const { compress } = arrayUtilities;
|
|
8
9
|
|
|
9
|
-
export default class Equivalence {
|
|
10
|
+
export default define(class Equivalence {
|
|
10
11
|
constructor(terms) {
|
|
11
12
|
this.terms = terms;
|
|
12
13
|
}
|
|
@@ -265,4 +266,4 @@ export default class Equivalence {
|
|
|
265
266
|
|
|
266
267
|
return equivalence;
|
|
267
268
|
}
|
|
268
|
-
}
|
|
269
|
+
});
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
+
import { define } from "../ontology";
|
|
6
|
+
import { variablesFromTerm } from "./term";
|
|
7
|
+
|
|
5
8
|
const { push, separate } = arrayUtilities;
|
|
6
9
|
|
|
7
|
-
export default class Equivalences {
|
|
10
|
+
export default define(class Equivalences {
|
|
8
11
|
constructor(array) {
|
|
9
12
|
this.array = array;
|
|
10
13
|
}
|
|
@@ -188,22 +191,21 @@ export default class Equivalences {
|
|
|
188
191
|
|
|
189
192
|
return equivalences;
|
|
190
193
|
}
|
|
191
|
-
}
|
|
194
|
+
});
|
|
192
195
|
|
|
193
|
-
function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context) {
|
|
194
|
-
const terms = groundedTerms, ///
|
|
195
|
-
variables = definedVariables; ///
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
function definedVariablesFromGroundedTerms(groundedTerms, definedVariables, context) {
|
|
198
|
+
groundedTerms.forEach((groundedTerm) => {
|
|
199
|
+
const term = groundedTerm, ///
|
|
200
|
+
variables = variablesFromTerm(term, context);
|
|
199
201
|
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
+
variables.forEach((variable) => {
|
|
203
|
+
const definedVariablesIncludesTermVariable = definedVariables.includes(variable);
|
|
202
204
|
|
|
203
|
-
if (!
|
|
204
|
-
const
|
|
205
|
+
if (!definedVariablesIncludesTermVariable) {
|
|
206
|
+
const definedVariable = variable; ///
|
|
205
207
|
|
|
206
|
-
|
|
208
|
+
definedVariables.push(definedVariable);
|
|
207
209
|
}
|
|
208
210
|
});
|
|
209
211
|
});
|