occam-verify-cli 1.0.396 → 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/assignment/equality.js +2 -2
- package/lib/context/file.js +4 -5
- package/lib/context/local.js +17 -6
- package/lib/context/partial.js +10 -10
- package/lib/context/temporary.js +102 -52
- package/lib/mixins/step/unify.js +5 -6
- 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 +6 -6
- package/lib/node/substitution/statement.js +6 -6
- package/lib/node/substitution/term.js +6 -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 +8 -9
- package/lib/ontology/assertion/defined.js +9 -10
- package/lib/ontology/assertion/satisfies.js +4 -4
- package/lib/ontology/assumption.js +379 -0
- 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 -338
- package/lib/ontology/equivalence.js +295 -0
- package/lib/ontology/equivalences.js +264 -0
- package/lib/ontology/frame.js +49 -54
- package/lib/ontology/judgement.js +8 -8
- package/lib/ontology/metavariable.js +4 -4
- package/lib/ontology/premise.js +14 -5
- package/lib/ontology/reference.js +3 -9
- package/lib/ontology/rule.js +3 -4
- package/lib/ontology/statement.js +28 -24
- package/lib/ontology/step.js +2 -3
- package/lib/ontology/subproof.js +2 -3
- package/lib/ontology/substitution/statement.js +77 -36
- package/lib/ontology/substitution/term.js +14 -34
- package/lib/ontology/substitution.js +18 -19
- package/lib/ontology/substitutions.js +425 -0
- package/lib/ontology/supposition.js +14 -5
- package/lib/ontology/term.js +33 -36
- package/lib/ontology/topLevelAssertion.js +2 -3
- package/lib/ontology/topLevelMetaAssertion.js +2 -3
- package/lib/ontology/variable.js +1 -34
- package/lib/preamble.js +7 -4
- package/lib/ruleNames.js +20 -12
- package/lib/unifier/intrinsicLevel.js +4 -12
- package/lib/unifier/metaLevel.js +14 -22
- package/lib/utilities/frame.js +18 -0
- package/lib/utilities/statement.js +18 -0
- package/lib/utilities/substitutions.js +43 -30
- package/lib/utilities/variable.js +5 -17
- package/package.json +10 -10
- package/src/assignment/equality.js +1 -1
- package/src/context/file.js +5 -4
- package/src/context/local.js +28 -5
- package/src/context/partial.js +9 -14
- package/src/context/temporary.js +120 -51
- package/src/mixins/step/unify.js +4 -4
- 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 +3 -3
- package/src/node/substitution/statement.js +3 -3
- package/src/node/substitution/term.js +3 -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 +14 -14
- package/src/ontology/assertion/defined.js +13 -13
- package/src/ontology/assertion/satisfies.js +2 -1
- package/src/ontology/assumption.js +385 -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 -372
- package/src/{equivalence.js → ontology/equivalence.js} +4 -3
- package/src/{equivalences.js → ontology/equivalences.js} +14 -12
- package/src/ontology/frame.js +53 -63
- package/src/ontology/judgement.js +8 -8
- package/src/ontology/metavariable.js +2 -2
- package/src/ontology/premise.js +18 -4
- package/src/ontology/reference.js +4 -3
- package/src/ontology/rule.js +4 -3
- package/src/ontology/statement.js +31 -27
- package/src/ontology/step.js +2 -2
- package/src/ontology/subproof.js +2 -2
- package/src/ontology/substitution/statement.js +56 -53
- package/src/ontology/substitution/term.js +9 -35
- package/src/ontology/substitution.js +11 -15
- package/src/{substitutions.js → ontology/substitutions.js} +4 -3
- package/src/ontology/supposition.js +18 -4
- package/src/ontology/term.js +27 -39
- package/src/ontology/topLevelAssertion.js +2 -2
- package/src/ontology/topLevelMetaAssertion.js +2 -2
- package/src/ontology/variable.js +0 -54
- package/src/preamble.js +6 -3
- package/src/ruleNames.js +10 -8
- package/src/unifier/intrinsicLevel.js +3 -14
- package/src/unifier/metaLevel.js +14 -25
- package/src/utilities/frame.js +13 -0
- package/src/utilities/statement.js +13 -0
- package/src/utilities/substitutions.js +59 -31
- package/src/utilities/variable.js +1 -10
- 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,385 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { define } from "../ontology";
|
|
7
|
-
import { unifyStatementIntrinsically } from "../utilities/unification";
|
|
8
|
-
import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
|
|
9
|
-
|
|
10
|
-
export default define(class Declaration {
|
|
11
|
-
constructor(string, node, statement, metavariable) {
|
|
12
|
-
this.string = string;
|
|
3
|
+
export default class Declaration {
|
|
4
|
+
constructor(context, node, string) {
|
|
5
|
+
this.context = context;
|
|
13
6
|
this.node = node;
|
|
14
|
-
this.
|
|
15
|
-
this.metavariable = metavariable;
|
|
7
|
+
this.string = string;
|
|
16
8
|
}
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
return this.
|
|
10
|
+
getContext() {
|
|
11
|
+
return this.context;
|
|
20
12
|
}
|
|
21
13
|
|
|
22
14
|
getNode() {
|
|
23
15
|
return this.node;
|
|
24
16
|
}
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
return this.
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getMetavariable() {
|
|
31
|
-
return this.metavariable;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
isSimple() {
|
|
35
|
-
const simple = (this.statement === null);
|
|
36
|
-
|
|
37
|
-
return simple;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
matchSubstitution(substitution, context) {
|
|
41
|
-
let substitutionMatches = false;
|
|
42
|
-
|
|
43
|
-
const declarationString = this.string, ///
|
|
44
|
-
substitutionString = substitution.getString();
|
|
45
|
-
|
|
46
|
-
context.trace(`Matching the '${substitutionString}' substitution against the '${declarationString}' declaration...`);
|
|
47
|
-
|
|
48
|
-
const simple = this.isSimple();
|
|
49
|
-
|
|
50
|
-
if (simple) {
|
|
51
|
-
const judgement = context.findJudgementByMetavariable(this.metavariable);
|
|
52
|
-
|
|
53
|
-
if (judgement !== null) {
|
|
54
|
-
const declaration = judgement.getDeclaration();
|
|
55
|
-
|
|
56
|
-
substitutionMatches = declaration.matchSubstitution(substitution, context);
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
const statement = substitution.getStatement(),
|
|
60
|
-
metavariable = substitution.getMetavariable(),
|
|
61
|
-
statementEqualToStatement = this.statement.isEqualTo(statement),
|
|
62
|
-
metavariableEqualToMetavariable = this.metavariable.isEqualTo(metavariable);
|
|
63
|
-
|
|
64
|
-
if (metavariableEqualToMetavariable && statementEqualToStatement) {
|
|
65
|
-
substitutionMatches = true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (substitutionMatches) {
|
|
70
|
-
context.debug(`...matches the '${declarationString}' substitution against the '${substitutionString}' declaration.`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return substitutionMatches;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
verify(assignments, stated, context) {
|
|
77
|
-
let verifies = false;
|
|
78
|
-
|
|
79
|
-
const declarationString = this.string; ///
|
|
80
|
-
|
|
81
|
-
context.trace(`Verifying the '${declarationString}' declaration...`);
|
|
82
|
-
|
|
83
|
-
const simple = this.isSimple();
|
|
84
|
-
|
|
85
|
-
if (simple) {
|
|
86
|
-
const verifiesAsMetavariable = this.verifyAsMetavariable(assignments, stated, context);
|
|
87
|
-
|
|
88
|
-
verifies = verifiesAsMetavariable; ///
|
|
89
|
-
} else {
|
|
90
|
-
const metavariableVerifiesAsReference = this.verifyMetavariableAsReference(assignments, stated, context);
|
|
91
|
-
|
|
92
|
-
if (metavariableVerifiesAsReference) {
|
|
93
|
-
const statementVerifies = this.verifyStatement(assignments, stated, context);
|
|
94
|
-
|
|
95
|
-
if (statementVerifies) {
|
|
96
|
-
let verifiesWhenStated = false,
|
|
97
|
-
verifiesWhenDerived = false;
|
|
98
|
-
|
|
99
|
-
if (stated) {
|
|
100
|
-
verifiesWhenStated = this.verifyWhenStated(assignments, context);
|
|
101
|
-
} else {
|
|
102
|
-
verifiesWhenDerived = this.verifyWhenDerived(context);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (verifiesWhenStated || verifiesWhenDerived) {
|
|
106
|
-
verifies = true;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (verifies) {
|
|
112
|
-
context.debug(`...verified the '${declarationString}' declaration.`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return verifies;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
verifyMetavariableAsReference(assignments, stated, context) {
|
|
120
|
-
let metavariableVerifiesAsReference;
|
|
121
|
-
|
|
122
|
-
const declarationString = this.string,
|
|
123
|
-
metavariableString = this.metavariable.getString();
|
|
124
|
-
|
|
125
|
-
context.trace(`Verifying the '${declarationString}' declaration's '${metavariableString}' metavariable as a reference...`);
|
|
126
|
-
|
|
127
|
-
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
128
|
-
referenceVerifies = reference.verify(context);
|
|
129
|
-
|
|
130
|
-
metavariableVerifiesAsReference = referenceVerifies; ///
|
|
131
|
-
|
|
132
|
-
if (metavariableVerifiesAsReference) {
|
|
133
|
-
context.debug(`...verified the '${declarationString}' declaration's '${metavariableString}' metavariable as a reference.`);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return metavariableVerifiesAsReference;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
verifyStatement(assignments, stated, context) {
|
|
140
|
-
let statementVerifies;
|
|
141
|
-
|
|
142
|
-
if (this.statement === null) {
|
|
143
|
-
statementVerifies = true;
|
|
144
|
-
} else {
|
|
145
|
-
const statementString = this.statement.getString();
|
|
146
|
-
|
|
147
|
-
context.trace(`Verifying the '${statementString}' statement...`);
|
|
148
|
-
|
|
149
|
-
stated = true; ///
|
|
150
|
-
|
|
151
|
-
assignments = null; ///
|
|
152
|
-
|
|
153
|
-
statementVerifies = this.statement.verify(assignments, stated, context);
|
|
154
|
-
|
|
155
|
-
if (statementVerifies) {
|
|
156
|
-
context.debug(`...verified the '${statementString}' statement.`);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return statementVerifies;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
verifyAsMetavariable(assignments, stated, context) {
|
|
164
|
-
let verifiesAsMetavariable;
|
|
165
|
-
|
|
166
|
-
const declarationString = this.string, ///
|
|
167
|
-
metavariableString = this.metavariable.getString();
|
|
168
|
-
|
|
169
|
-
context.trace(`Verifying the '${declarationString}' declaration's '${metavariableString}' metavariable...`);
|
|
170
|
-
|
|
171
|
-
verifiesAsMetavariable = this.metavariable.verify(context);
|
|
172
|
-
|
|
173
|
-
if (verifiesAsMetavariable) {
|
|
174
|
-
context.debug(`...verified the '${declarationString}' declaration's '${metavariableString}' metavariable.`);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return verifiesAsMetavariable;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
verifyWhenStated(assignments, context) {
|
|
181
|
-
let verifiesWhenStated;
|
|
182
|
-
|
|
183
|
-
const declarationString = this.string; ///
|
|
184
|
-
|
|
185
|
-
context.trace(`Verifying the '${declarationString}' stated declaration...`);
|
|
186
|
-
|
|
187
|
-
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
188
|
-
metavariablePresent = context.isMetavariablePresentByReference(reference);
|
|
189
|
-
|
|
190
|
-
if (metavariablePresent) {
|
|
191
|
-
verifiesWhenStated = true;
|
|
192
|
-
} else {
|
|
193
|
-
const metaLemmaMetatheorems = context.findMetaLemmaMetatheoremsByReference(reference),
|
|
194
|
-
metaLemmaMetatheoremsUnify = metaLemmaMetatheorems.every((metaLemmaMetatheorem) => {
|
|
195
|
-
const metaLemmaMetatheoremUnifies = this.unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context);
|
|
196
|
-
|
|
197
|
-
if (metaLemmaMetatheoremUnifies) {
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
verifiesWhenStated = metaLemmaMetatheoremsUnify; ///
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (verifiesWhenStated) {
|
|
206
|
-
context.debug(`...verified the '${declarationString}' stated declaration.`);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return verifiesWhenStated;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
verifyWhenDerived(context) {
|
|
213
|
-
let verifiesWhenDerived;
|
|
214
|
-
|
|
215
|
-
const declarationString = this.string; ///
|
|
216
|
-
|
|
217
|
-
context.trace(`Verifying the '${declarationString}' derived declaration...`);
|
|
218
|
-
|
|
219
|
-
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
220
|
-
metaLemmaMetatheoremPresent = context.isMetaLemmaMetatheoremPresentByReference(reference);
|
|
221
|
-
|
|
222
|
-
verifiesWhenDerived = metaLemmaMetatheoremPresent; ///
|
|
223
|
-
|
|
224
|
-
if (verifiesWhenDerived) {
|
|
225
|
-
context.debug(`...verified the '${declarationString}' derived declaration.`);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return verifiesWhenDerived;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
unifyStatement(statement, substitutions, generalContext, specificContext) {
|
|
232
|
-
let statementUnifies;
|
|
233
|
-
|
|
234
|
-
const simple = this.isSimple();
|
|
235
|
-
|
|
236
|
-
if (simple) {
|
|
237
|
-
statementUnifies = false;
|
|
238
|
-
} else {
|
|
239
|
-
const context = generalContext, ///
|
|
240
|
-
statementString = statement.getString(),
|
|
241
|
-
declarationStatementString = this.statement.getString();
|
|
242
|
-
|
|
243
|
-
context.trace(`Unifying the '${statementString}' statement with the '${declarationStatementString}' statement...`);
|
|
244
|
-
|
|
245
|
-
const generalStatement = this.statement,
|
|
246
|
-
specificStatement = statement, ///
|
|
247
|
-
statementUUnifiesIntrinsically = unifyStatementIntrinsically(generalStatement, specificStatement, substitutions, generalContext, specificContext);
|
|
248
|
-
|
|
249
|
-
statementUnifies = statementUUnifiesIntrinsically; ///
|
|
250
|
-
|
|
251
|
-
if (statementUnifies) {
|
|
252
|
-
context.debug(`...unified the '${statementString}' statement with the '${declarationStatementString}' statement.`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return statementUnifies;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
unifyLabel(label, substitutions, generalContext, specificContext) {
|
|
260
|
-
let labelUnifiesWithReference;
|
|
261
|
-
|
|
262
|
-
const context = generalContext, ///
|
|
263
|
-
labelString = label.getString(),
|
|
264
|
-
declarationString = this.string; //;/
|
|
265
|
-
|
|
266
|
-
context.trace(`Unifying the '${labelString}' label with the '${declarationString}' declaration...`);
|
|
267
|
-
|
|
268
|
-
const reference = referenceFromMetavariable(this.metavariable, context),
|
|
269
|
-
labelUnifies = reference.unifyLabel(label, substitutions, context);
|
|
270
|
-
|
|
271
|
-
labelUnifiesWithReference = labelUnifies; ///
|
|
272
|
-
|
|
273
|
-
if (labelUnifiesWithReference) {
|
|
274
|
-
context.debug(`...unified the '${labelString}' label with the '${declarationString}' declaration.`);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return labelUnifiesWithReference;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
unifyMetaLemmaMetatheorem(metaLemmaMetatheorem, context) {
|
|
281
|
-
let metaLemmaMetatheoremUnifies = false;
|
|
282
|
-
|
|
283
|
-
const declarationString = this.string, ///
|
|
284
|
-
metaLemmaMetatheoremString = metaLemmaMetatheorem.getString();
|
|
285
|
-
|
|
286
|
-
context.trace(`Unifying the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${declarationString}' declaration...`);
|
|
287
|
-
|
|
288
|
-
const generalContext = context; ///
|
|
289
|
-
|
|
290
|
-
context = metaLemmaMetatheorem.getContext(); ///
|
|
291
|
-
|
|
292
|
-
const specificContext = context, ///
|
|
293
|
-
labelSubstitutions = Substitutions.fromNothing(),
|
|
294
|
-
label = metaLemmaMetatheorem.getLabel(),
|
|
295
|
-
substitutions = labelSubstitutions, ///
|
|
296
|
-
labelUnifies = this.unifyLabel(label, substitutions, generalContext, specificContext);
|
|
297
|
-
|
|
298
|
-
if (labelUnifies) {
|
|
299
|
-
const statementSubstitutions = Substitutions.fromNothing(),
|
|
300
|
-
statement = metaLemmaMetatheorem.getStatement(),
|
|
301
|
-
substitutions = statementSubstitutions, ///
|
|
302
|
-
statementUUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
|
|
303
|
-
|
|
304
|
-
if (statementUUnifies) {
|
|
305
|
-
const labelSubstitutionsCorrelateStatementSubstitutions = labelSubstitutions.correlateSubstitutions(statementSubstitutions);
|
|
306
|
-
|
|
307
|
-
if (labelSubstitutionsCorrelateStatementSubstitutions) {
|
|
308
|
-
metaLemmaMetatheoremUnifies = true; ///
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (metaLemmaMetatheoremUnifies) {
|
|
314
|
-
context = generalContext; ///
|
|
315
|
-
|
|
316
|
-
context.trace(`...unified the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem with the '${declarationString}' declaration...`);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return metaLemmaMetatheoremUnifies;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
toJSON() {
|
|
323
|
-
let json = null;
|
|
324
|
-
|
|
325
|
-
const simple = this.isSimple();
|
|
326
|
-
|
|
327
|
-
if (simple) {
|
|
328
|
-
const metavariable = this.getMetavariable(),
|
|
329
|
-
metavariableJSON = metavariableToMetavariableJSON(metavariable);
|
|
330
|
-
|
|
331
|
-
json = metavariableJSON; ///
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return json;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
static name = "Declaration";
|
|
338
|
-
|
|
339
|
-
static fromJSON(json, context) {
|
|
340
|
-
let declaration = null;
|
|
341
|
-
|
|
342
|
-
if (json !== null) {
|
|
343
|
-
const string = null,
|
|
344
|
-
node = null,
|
|
345
|
-
statement = null,
|
|
346
|
-
metavariable = metavariableFromJSON(json, context);
|
|
347
|
-
|
|
348
|
-
declaration = new Declaration(string, node, statement, metavariable)
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return declaration;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
static fromJudgementNode(judgementNode, context) {
|
|
355
|
-
const declarationNode = judgementNode.getDeclarationNode(),
|
|
356
|
-
declaration = declarationFromDeclarationNode(declarationNode, context);
|
|
357
|
-
|
|
358
|
-
return declaration;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
static fromDeclarationNode(declarationNode, context) {
|
|
362
|
-
const declaration = declarationFromDeclarationNode(declarationNode, context);
|
|
363
|
-
|
|
364
|
-
return declaration;
|
|
18
|
+
getString() {
|
|
19
|
+
return this.string;
|
|
365
20
|
}
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
function referenceFromMetavariable(metavariable, context) {
|
|
369
|
-
const { Reference } = ontology,
|
|
370
|
-
metavariableNode = metavariable.getNode(),
|
|
371
|
-
reference = Reference.fromMetavariableNode(metavariableNode, context);
|
|
372
|
-
|
|
373
|
-
return reference;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function declarationFromDeclarationNode(declarationNode, context) {
|
|
377
|
-
const { Metavariable, Declaration, Statement } = ontology,
|
|
378
|
-
node = declarationNode, ///
|
|
379
|
-
string = context.nodeAsString(node),
|
|
380
|
-
statement = Statement.fromDeclarationNode(declarationNode, context),
|
|
381
|
-
metavariable = Metavariable.fromDeclarationNode(declarationNode, context),
|
|
382
|
-
declaration = new Declaration(string, node, statement, metavariable);
|
|
383
|
-
|
|
384
|
-
return declaration;
|
|
385
21
|
}
|
|
@@ -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
|
});
|
package/src/ontology/frame.js
CHANGED
|
@@ -11,11 +11,11 @@ import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
|
11
11
|
const { first } = arrayUtilities;
|
|
12
12
|
|
|
13
13
|
export default define(class Frame {
|
|
14
|
-
constructor(string, node, tokens,
|
|
14
|
+
constructor(string, node, tokens, assumptions) {
|
|
15
15
|
this.string = string;
|
|
16
16
|
this.node = node;
|
|
17
17
|
this.tokens = tokens;
|
|
18
|
-
this.
|
|
18
|
+
this.assumptions = assumptions;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
getString() {
|
|
@@ -30,24 +30,24 @@ export default define(class Frame {
|
|
|
30
30
|
return this.tokens;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
return this.
|
|
33
|
+
getAssumptions() {
|
|
34
|
+
return this.assumptions;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
getLength() { return this.
|
|
37
|
+
getLength() { return this.assumptions.length; }
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
let
|
|
39
|
+
getAssumption() {
|
|
40
|
+
let assumption = null;
|
|
41
41
|
|
|
42
42
|
const length = this.getLength();
|
|
43
43
|
|
|
44
44
|
if (length === 1) {
|
|
45
|
-
const
|
|
45
|
+
const firstAssumption = first(this.assumptions);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
assumption = firstAssumption; ///
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
return
|
|
50
|
+
return assumption;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
getMetavariable() {
|
|
@@ -56,25 +56,15 @@ export default define(class Frame {
|
|
|
56
56
|
const simple = this.isSimple();
|
|
57
57
|
|
|
58
58
|
if (simple) {
|
|
59
|
-
const
|
|
59
|
+
const assumption = this.getAssumption();
|
|
60
60
|
|
|
61
|
-
metavariable =
|
|
61
|
+
metavariable = assumption.getMetavariable();
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
return metavariable;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
isSimple() {
|
|
68
|
-
let simple = false;
|
|
69
|
-
|
|
70
|
-
const declaration = this.getDeclaration();
|
|
71
|
-
|
|
72
|
-
if (declaration !== null) {
|
|
73
|
-
simple = declaration.isSimple();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return simple;
|
|
77
|
-
}
|
|
67
|
+
isSimple() { return this.node.isSimple();}
|
|
78
68
|
|
|
79
69
|
isEqualTo(frame) {
|
|
80
70
|
const frameString = frame.getString(),
|
|
@@ -94,10 +84,10 @@ export default define(class Frame {
|
|
|
94
84
|
context.trace(`Matching the '${substitutionString}' substitution against the '${frameString}' frame...`);
|
|
95
85
|
|
|
96
86
|
if (!substitutionMatches) {
|
|
97
|
-
substitutionMatches = this.
|
|
98
|
-
const
|
|
87
|
+
substitutionMatches = this.assumptions.some((assumption) => {
|
|
88
|
+
const substitutionMatchesAssumption = assumption.matchSubstitution(substitution, context);
|
|
99
89
|
|
|
100
|
-
if (
|
|
90
|
+
if (substitutionMatchesAssumption) {
|
|
101
91
|
return true;
|
|
102
92
|
}
|
|
103
93
|
});
|
|
@@ -140,9 +130,9 @@ export default define(class Frame {
|
|
|
140
130
|
|
|
141
131
|
context.trace(`Verifying the '${frameString}' frame...`);
|
|
142
132
|
|
|
143
|
-
const
|
|
133
|
+
const assumptionsVerify = this.verifyAssumptions(assignments, stated, context);
|
|
144
134
|
|
|
145
|
-
if (
|
|
135
|
+
if (assumptionsVerify) {
|
|
146
136
|
let verifiesWhenStated = false,
|
|
147
137
|
verifiesWhenDerived = false;
|
|
148
138
|
|
|
@@ -206,8 +196,8 @@ export default define(class Frame {
|
|
|
206
196
|
return verifiesWhenDerived;
|
|
207
197
|
}
|
|
208
198
|
|
|
209
|
-
|
|
210
|
-
let
|
|
199
|
+
verifyAssumptions(assignments, stated, context) {
|
|
200
|
+
let assumptionsVerify = true; ///
|
|
211
201
|
|
|
212
202
|
const length = this.getLength();
|
|
213
203
|
|
|
@@ -215,26 +205,26 @@ export default define(class Frame {
|
|
|
215
205
|
const sOrNothing = (length > 1) ?
|
|
216
206
|
S :
|
|
217
207
|
NOTHING,
|
|
218
|
-
|
|
208
|
+
assumptionsString = assumptionsStringFromAssumptions(this.assumptions);
|
|
219
209
|
|
|
220
|
-
context.trace(`Verifying the '${
|
|
210
|
+
context.trace(`Verifying the '${assumptionsString}' assumption${sOrNothing}...`);
|
|
221
211
|
|
|
222
212
|
stated = true; ///
|
|
223
213
|
|
|
224
214
|
assignments = null; ///
|
|
225
215
|
|
|
226
|
-
|
|
227
|
-
const
|
|
216
|
+
assumptionsVerify = this.assumptions.every((assumption) => {
|
|
217
|
+
const assumptionVerifies = assumption.verify(assignments, stated, context);
|
|
228
218
|
|
|
229
|
-
return
|
|
219
|
+
return assumptionVerifies;
|
|
230
220
|
});
|
|
231
221
|
|
|
232
|
-
if (
|
|
233
|
-
context.debug(`...verified the '${
|
|
222
|
+
if (assumptionsVerify) {
|
|
223
|
+
context.debug(`...verified the '${assumptionsString}' assumption${sOrNothing}.`);
|
|
234
224
|
}
|
|
235
225
|
}
|
|
236
226
|
|
|
237
|
-
return
|
|
227
|
+
return assumptionsVerify;
|
|
238
228
|
}
|
|
239
229
|
|
|
240
230
|
verifyGivenMetaType(metaType, assignments, stated, context) {
|
|
@@ -266,10 +256,10 @@ export default define(class Frame {
|
|
|
266
256
|
const simple = this.isSimple();
|
|
267
257
|
|
|
268
258
|
if (simple) {
|
|
269
|
-
const
|
|
270
|
-
|
|
259
|
+
const assumption = this.getAssumption(),
|
|
260
|
+
assumptionJSON = assumption.toJSON();
|
|
271
261
|
|
|
272
|
-
json =
|
|
262
|
+
json = assumptionJSON; ///
|
|
273
263
|
}
|
|
274
264
|
|
|
275
265
|
return json;
|
|
@@ -281,16 +271,16 @@ export default define(class Frame {
|
|
|
281
271
|
let frame = null;
|
|
282
272
|
|
|
283
273
|
if (json !== null) {
|
|
284
|
-
const {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
274
|
+
const { Assumption } =ontology,
|
|
275
|
+
assumption = Assumption.fromJSON(json, context),
|
|
276
|
+
assumptions = [
|
|
277
|
+
assumption
|
|
288
278
|
],
|
|
289
279
|
string = null,
|
|
290
280
|
node = null,
|
|
291
281
|
tokens = null;
|
|
292
282
|
|
|
293
|
-
frame = new Frame(string, node, tokens,
|
|
283
|
+
frame = new Frame(string, node, tokens, assumptions);
|
|
294
284
|
}
|
|
295
285
|
|
|
296
286
|
return frame;
|
|
@@ -343,34 +333,34 @@ function frameFromFrameNode(frameNode, context) {
|
|
|
343
333
|
node = frameNode, ///
|
|
344
334
|
string = context.nodeAsString(node),
|
|
345
335
|
tokens = context.nodeAsTokens(node),
|
|
346
|
-
|
|
347
|
-
frame = new Frame(string, node, tokens,
|
|
336
|
+
assumptions = assumptionsFromFrameNode(frameNode, context),
|
|
337
|
+
frame = new Frame(string, node, tokens, assumptions);
|
|
348
338
|
|
|
349
339
|
return frame;
|
|
350
340
|
}
|
|
351
341
|
|
|
352
|
-
function
|
|
353
|
-
const {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
const
|
|
342
|
+
function assumptionsFromFrameNode(frameNode, context) {
|
|
343
|
+
const { Assumption } = ontology,
|
|
344
|
+
assumptionNodes = frameNode.getAssumptionNodes(),
|
|
345
|
+
assumptions = assumptionNodes.map((assumptionNode) => {
|
|
346
|
+
const assumption = Assumption.fromAssumptionNode(assumptionNode, context);
|
|
357
347
|
|
|
358
|
-
return
|
|
348
|
+
return assumption;
|
|
359
349
|
});
|
|
360
350
|
|
|
361
|
-
return
|
|
351
|
+
return assumptions;
|
|
362
352
|
}
|
|
363
353
|
|
|
364
|
-
function
|
|
365
|
-
const
|
|
366
|
-
const
|
|
354
|
+
function assumptionsStringFromAssumptions(assumptions) {
|
|
355
|
+
const assumptionsString = assumptions.reduce((assumptionsString, assumption) => {
|
|
356
|
+
const assumptionString = assumption.getString();
|
|
367
357
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
`${
|
|
358
|
+
assumptionsString = (assumptionsString === null) ?
|
|
359
|
+
assumptionString :
|
|
360
|
+
`${assumptionsString}, ${assumptionString}`;
|
|
371
361
|
|
|
372
|
-
return
|
|
362
|
+
return assumptionsString;
|
|
373
363
|
}, null);
|
|
374
364
|
|
|
375
|
-
return
|
|
365
|
+
return assumptionsString;
|
|
376
366
|
}
|