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
package/src/ontology/term.js
CHANGED
|
@@ -35,37 +35,10 @@ export default define(class Term {
|
|
|
35
35
|
this.type = type;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
getVariable(context) {
|
|
39
|
-
const { Variable } = ontology,
|
|
40
|
-
termNode = this.node, ///
|
|
41
|
-
variable = Variable.fromTermNode(termNode, context);
|
|
42
|
-
|
|
43
|
-
return variable;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getVariables(context) {
|
|
47
|
-
const termNode = this.node,
|
|
48
|
-
variableNodes = termNode.getVariableNodes(),
|
|
49
|
-
variables = variableNodes.map((variableNode) => {
|
|
50
|
-
const { Variable } = ontology,
|
|
51
|
-
variable = Variable.fromVariableNode(variableNode, context);
|
|
52
|
-
|
|
53
|
-
return variable;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
compress(variables, (variableA, variableB) => {
|
|
57
|
-
const variableAEqualToVariableB = variableA.isEqualTo(variableB);
|
|
58
|
-
|
|
59
|
-
if (variableAEqualToVariableB) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return variables;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
38
|
matchTermNode(termNode) { return this.node.match(termNode); }
|
|
68
39
|
|
|
40
|
+
isSimple() { return this.node.isSimple();}
|
|
41
|
+
|
|
69
42
|
isProvisional() { return this.type.isProvisional(); }
|
|
70
43
|
|
|
71
44
|
isEqualTo(term) {
|
|
@@ -75,16 +48,9 @@ export default define(class Term {
|
|
|
75
48
|
return equalTo;
|
|
76
49
|
}
|
|
77
50
|
|
|
78
|
-
isSimple() {
|
|
79
|
-
const termNode = this.node,
|
|
80
|
-
singularVariableNode = termNode.getSingularVariableNode(),
|
|
81
|
-
simple = (singularVariableNode !== null);
|
|
82
|
-
|
|
83
|
-
return simple;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
51
|
isGrounded(definedVariables, context) {
|
|
87
|
-
const
|
|
52
|
+
const term = this, ///
|
|
53
|
+
variables = variablesFromTerm(term, context);
|
|
88
54
|
|
|
89
55
|
filter(variables, (variable) => {
|
|
90
56
|
const definedVariablesIncludesVariable = definedVariables.includes(variable);
|
|
@@ -102,7 +68,8 @@ export default define(class Term {
|
|
|
102
68
|
}
|
|
103
69
|
|
|
104
70
|
isInitiallyGrounded(context) {
|
|
105
|
-
const
|
|
71
|
+
const term = this, ///
|
|
72
|
+
variables = variablesFromTerm(term, context),
|
|
106
73
|
variablesLength = variables.length,
|
|
107
74
|
initiallyGrounded = (variablesLength === 0);
|
|
108
75
|
|
|
@@ -274,3 +241,24 @@ export default define(class Term {
|
|
|
274
241
|
}
|
|
275
242
|
});
|
|
276
243
|
|
|
244
|
+
export function variablesFromTerm(term, context) {
|
|
245
|
+
const termNode = term.getNode(),
|
|
246
|
+
variableNodes = termNode.getVariableNodes(),
|
|
247
|
+
variables = variableNodes.map((variableNode) => {
|
|
248
|
+
const variableIdentifier = variableNode.getVariableIdentifier(),
|
|
249
|
+
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
250
|
+
|
|
251
|
+
return variable;
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
compress(variables, (variableA, variableB) => {
|
|
255
|
+
const variableAEqualToVariableB = variableA.isEqualTo(variableB);
|
|
256
|
+
|
|
257
|
+
if (variableAEqualToVariableB) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
return variables;
|
|
263
|
+
}
|
|
264
|
+
|
|
@@ -4,7 +4,6 @@ import { arrayUtilities } from "necessary";
|
|
|
4
4
|
|
|
5
5
|
import ontology from "../ontology";
|
|
6
6
|
import LocalContext from "../context/local";
|
|
7
|
-
import Substitutions from "../substitutions";
|
|
8
7
|
|
|
9
8
|
import { labelsFromJSON,
|
|
10
9
|
deductionFromJSON,
|
|
@@ -175,7 +174,8 @@ export default class TopLevelAssertion {
|
|
|
175
174
|
if (this.proof === null) {
|
|
176
175
|
proofVerifies = true;
|
|
177
176
|
} else {
|
|
178
|
-
const
|
|
177
|
+
const { Substitutions } = ontology,
|
|
178
|
+
substitutions = Substitutions.fromNothing();
|
|
179
179
|
|
|
180
180
|
proofVerifies = this.proof.verify(substitutions, this.deduction, context);
|
|
181
181
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import ontology from "../ontology";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
|
-
import Substitutions from "../substitutions";
|
|
6
5
|
|
|
7
6
|
import { proofFromProofNode, deductionFromDeductionNode, suppositionsFromSuppositionNodes } from "./topLevelAssertion";
|
|
8
7
|
import { labelFromJSON,
|
|
@@ -169,7 +168,8 @@ export default class TopLevelMetaAssertion {
|
|
|
169
168
|
}
|
|
170
169
|
|
|
171
170
|
static fromNode(Class, node, context) {
|
|
172
|
-
const
|
|
171
|
+
const { Substitutions } = ontology,
|
|
172
|
+
topLevelAssertionNode = node, ///
|
|
173
173
|
proofNode = topLevelAssertionNode.getProofNode(),
|
|
174
174
|
labelNode = topLevelAssertionNode.getLabelNode(),
|
|
175
175
|
deductionNode = topLevelAssertionNode.getDeductionNode(),
|
package/src/ontology/variable.js
CHANGED
|
@@ -172,60 +172,6 @@ export default define(class Variable {
|
|
|
172
172
|
return termUnifies;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
unifyTermVariable(termVariable, substitutions, generalContext, specificContext) {
|
|
176
|
-
let termVariableUnifies = false;
|
|
177
|
-
|
|
178
|
-
const variableString = this.string, ///
|
|
179
|
-
termVariableString = termVariable.getString();
|
|
180
|
-
|
|
181
|
-
specificContext.trace(`Unifying the '${termVariableString}' term variable with the '${variableString}' variable...`);
|
|
182
|
-
|
|
183
|
-
let context,
|
|
184
|
-
variable;
|
|
185
|
-
|
|
186
|
-
variable = this; ///
|
|
187
|
-
|
|
188
|
-
const substitution = substitutions.findSubstitutionByVariable(variable);
|
|
189
|
-
|
|
190
|
-
if (substitution !== null) {
|
|
191
|
-
context = specificContext; ///
|
|
192
|
-
|
|
193
|
-
const substitutionTermVariableEqualToTerm = substitution.isTermVariableEqualToTerm(termVariable, context);
|
|
194
|
-
|
|
195
|
-
if (substitutionTermVariableEqualToTerm) {
|
|
196
|
-
termVariableUnifies = true;
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
context = generalContext; ///
|
|
200
|
-
|
|
201
|
-
const variableIdentifier = variable.getIdentifier();
|
|
202
|
-
|
|
203
|
-
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
204
|
-
|
|
205
|
-
context = specificContext; ///
|
|
206
|
-
|
|
207
|
-
const variableType = variable.getType(),
|
|
208
|
-
termVariableType = termVariable.getType(),
|
|
209
|
-
termVariableTypeEqualToOrSubTypeOfVariableType = termVariableType.isEqualToOrSubTypeOf(variableType);
|
|
210
|
-
|
|
211
|
-
if (termVariableTypeEqualToOrSubTypeOfVariableType) {
|
|
212
|
-
const { TermSubstitution } = ontology,
|
|
213
|
-
termSubstitution = TermSubstitution.fromTernVariableAndVariable(termVariable, variable, context),
|
|
214
|
-
substitution = termSubstitution; ///
|
|
215
|
-
|
|
216
|
-
substitutions.addSubstitution(substitution, context);
|
|
217
|
-
|
|
218
|
-
termVariableUnifies = true;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (termVariableUnifies) {
|
|
223
|
-
specificContext.debug(`...unified the '${termVariableString}' term variable with the '${variableString}' variable.`);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return termVariableUnifies;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
175
|
toJSON() {
|
|
230
176
|
const typeJSON = typeToTypeJSON(this.type),
|
|
231
177
|
string = this.string, ///
|
package/src/preamble.js
CHANGED
|
@@ -31,23 +31,26 @@ import Conclusion from "./ontology/conclusion";
|
|
|
31
31
|
import Derivation from "./ontology/derivation";
|
|
32
32
|
import Combinator from "./ontology/combinator";
|
|
33
33
|
import Hypothesis from "./ontology/hypothesis";
|
|
34
|
+
import Assumption from "./ontology/assumption";
|
|
34
35
|
import Constructor from "./ontology/constructor";
|
|
35
|
-
import Declaration from "./ontology/declaration";
|
|
36
36
|
import Supposition from "./ontology/supposition";
|
|
37
37
|
import Metatheorem from "./ontology/metatheorem";
|
|
38
|
+
import Equivalence from "./ontology/equivalence";
|
|
39
|
+
import Equivalences from "./ontology/equivalences";
|
|
38
40
|
import Metavariable from "./ontology/metavariable";
|
|
41
|
+
import Substitutions from "./ontology/substitutions";
|
|
39
42
|
import ProcedureCall from "./ontology/procedureCall";
|
|
40
43
|
import SubDerivation from "./ontology/subDerivation";
|
|
41
44
|
import TypeAssertion from "./ontology/assertion/type";
|
|
42
|
-
import DefinedAssertion from "./ontology/assertion/defined";
|
|
43
45
|
import PropertyRelation from "./ontology/propertyRelation";
|
|
46
|
+
import DefinedAssertion from "./ontology/assertion/defined";
|
|
44
47
|
import TermSubstitution from "./ontology/substitution/term";
|
|
45
48
|
import FrameSubstitution from "./ontology/substitution/frame";
|
|
46
49
|
import SubproofAssertion from "./ontology/assertion/subproof";
|
|
47
50
|
import PropertyAssertion from "./ontology/assertion/property";
|
|
51
|
+
import ProcedureReference from "./ontology/procedureReference";
|
|
48
52
|
import ContainedAssertion from "./ontology/assertion/contained";
|
|
49
53
|
import SatisfiesAssertion from "./ontology/assertion/satisfies";
|
|
50
|
-
import ProcedureReference from "./ontology/procedureReference";
|
|
51
54
|
import VariableDeclaration from "./ontology/declaration/variable";
|
|
52
55
|
import BracketedCombinator from "./ontology/combinator/bracketed";
|
|
53
56
|
import BracketedConstructor from "./ontology/constructor/bracketed";
|
package/src/ruleNames.js
CHANGED
|
@@ -21,28 +21,30 @@ export const EQUALITY_RULE_NAME = "equality";
|
|
|
21
21
|
export const VARIABLE_RULE_NAME = "variable";
|
|
22
22
|
export const SUBPROOF_RULE_NAME = "subproof";
|
|
23
23
|
export const NONSENSE_RULE_NAME = "nonsense";
|
|
24
|
-
export const
|
|
24
|
+
export const DOCUMENT_RULE_NAME = "document";
|
|
25
|
+
export const RULE_BODY_RULE_NAME = "ruleBody";
|
|
25
26
|
export const META_TYPE_RULE_NAME = "metaType";
|
|
27
|
+
export const SIGNATURE_RULE_NAME = "signature";
|
|
26
28
|
export const PARAMETER_RULE_NAME = "parameter";
|
|
27
29
|
export const DEDUCTION_RULE_NAME = "deduction";
|
|
28
30
|
export const JUDGEMENT_RULE_NAME = "judgement";
|
|
29
31
|
export const REFERENCE_RULE_NAME = "reference";
|
|
30
32
|
export const STATEMENT_RULE_NAME = "statement";
|
|
31
|
-
export const RULE_BODY_RULE_NAME = "ruleBody";
|
|
32
33
|
export const META_LEMMA_RULE_NAME = "metaLemma";
|
|
34
|
+
export const AXIOM_BODY_RULE_NAME = "axiomBody";
|
|
35
|
+
export const LEMMA_BODY_RULE_NAME = "lemmaBody";
|
|
33
36
|
export const COMBINATOR_RULE_NAME = "combinator";
|
|
34
37
|
export const CONCLUSION_RULE_NAME = "conclusion";
|
|
35
38
|
export const CONJECTURE_RULE_NAME = "conjecture";
|
|
36
39
|
export const DERIVATION_RULE_NAME = "derivation";
|
|
37
40
|
export const HYPOTHESIS_RULE_NAME = "hypothesis";
|
|
38
|
-
export const
|
|
39
|
-
export const
|
|
41
|
+
export const ASSUMPTION_RULE_NAME = "assumption";
|
|
42
|
+
export const PLACEHOLDER_RULE_NAME = "_"; ///
|
|
43
|
+
export const RULE_HEADER_RULE_NAME = "ruleHeader";
|
|
40
44
|
export const TYPE_PREFIX_RULE_NAME = "typePrefix";
|
|
41
45
|
export const SUPPOSITION_RULE_NAME = "supposition";
|
|
42
46
|
export const CONSTRUCTOR_RULE_NAME = "constructor";
|
|
43
|
-
export const DECLARATION_RULE_NAME = "declaration";
|
|
44
47
|
export const METATHEOREM_RULE_NAME = "metatheorem";
|
|
45
|
-
export const RULE_HEADER_RULE_NAME = "ruleHeader";
|
|
46
48
|
export const AXIOM_HEADER_RULE_NAME = "axiomHeader";
|
|
47
49
|
export const LEMMA_HEADER_RULE_NAME = "lemmaHeader";
|
|
48
50
|
export const THEOREM_BODY_RULE_NAME = "theoremBody";
|
|
@@ -57,18 +59,18 @@ export const META_LEMMA_BODY_RULE_NAME = "metaLemmaBody";
|
|
|
57
59
|
export const CONJECTURE_BODY_RULE_NAME = "conjectureBody";
|
|
58
60
|
export const METATHEOREM_BODY_RULE_NAME = "metatheoremBody";
|
|
59
61
|
export const META_LEMMA_HEADER_RULE_NAME = "metaLemmaHeader";
|
|
62
|
+
export const CONJECTURE_HEADER_RULE_NAME = "conjectureHeader";
|
|
60
63
|
export const PROPERTY_RELATION_RULE_NAME = "propertyRelation";
|
|
61
64
|
export const DEFINED_ASSERTION_RULE_NAME = "definedAssertion";
|
|
62
65
|
export const TERM_SUBSTITUTION_RULE_NAME = "termSubstitution";
|
|
63
|
-
export const CONJECTURE_HEADER_RULE_NAME = "conjectureHeader";
|
|
64
66
|
export const METATHEOREM_HEADER_RULE_NAME = "metatheoremHeader";
|
|
65
67
|
export const PROPERTY_ASSERTION_RULE_NAME = "propertyAssertion";
|
|
66
68
|
export const SUBPROOF_ASSERTION_RULE_NAME = "subproofAssertion";
|
|
67
69
|
export const FRAME_SUBSTITUTION_RULE_NAME = "frameSubstitution";
|
|
70
|
+
export const PARENTHESISED_LABEL_RULE_NAME = "parenthesisedLabel";
|
|
68
71
|
export const PROCEDURE_REFERENCE_RULE_NAME = "procedureReference";
|
|
69
72
|
export const CONTAINED_ASSERTION_RULE_NAME = "containedAssertion";
|
|
70
73
|
export const SATISFIES_ASSERTION_RULE_NAME = "satisfiesAssertion";
|
|
71
|
-
export const PARENTHESISED_LABEL_RULE_NAME = "parenthesisedLabel";
|
|
72
74
|
export const PARENTHESISED_LABELS_RULE_NAME = "parenthesisedLabels";
|
|
73
75
|
export const PROPERTY_DECLARATION_RULE_NAME = "propertyDeclaration";
|
|
74
76
|
export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import Unifier from "../unifier";
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../utilities/query";
|
|
6
|
-
import { variableIdentifierFromVariableNode, termVariableIdentifierFromTermNode } from "../utilities/variable";
|
|
7
6
|
|
|
8
7
|
const termNodeQuery = nodeQuery("/term"),
|
|
9
8
|
termVariableNodeQuery = nodeQuery("/term/variable!");
|
|
@@ -24,11 +23,11 @@ class IntrinsicLevelUnifier extends Unifier {
|
|
|
24
23
|
generalNodeQuery: termVariableNodeQuery,
|
|
25
24
|
specificNodeQuery: termNodeQuery,
|
|
26
25
|
unify: (generalTermVariableNode, specificTermNode, substitutions, generalContext, specificContext) => {
|
|
27
|
-
let termUnifies
|
|
26
|
+
let termUnifies;
|
|
28
27
|
|
|
29
28
|
const termNode = specificTermNode, ///
|
|
30
29
|
variableNode = generalTermVariableNode, ///
|
|
31
|
-
variableIdentifier =
|
|
30
|
+
variableIdentifier = variableNode.getVariableIdentifier();
|
|
32
31
|
|
|
33
32
|
let context;
|
|
34
33
|
|
|
@@ -40,17 +39,7 @@ class IntrinsicLevelUnifier extends Unifier {
|
|
|
40
39
|
|
|
41
40
|
const term = context.findTermByTermNode(termNode);
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
termUnifies = variable.unifyTerm(term, substitutions, generalContext, specificContext);
|
|
45
|
-
} else {
|
|
46
|
-
const termVariaibleIdentifer = termVariableIdentifierFromTermNode(termNode),
|
|
47
|
-
termVariable = context.findVariableByVariableIdentifier(termVariaibleIdentifer),
|
|
48
|
-
termVariableUnifies = variable.unifyTermVariable(termVariable, substitutions, generalContext, specificContext);
|
|
49
|
-
|
|
50
|
-
if (termVariableUnifies) {
|
|
51
|
-
termUnifies = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
42
|
+
termUnifies = variable.unifyTerm(term, substitutions, generalContext, specificContext);
|
|
54
43
|
|
|
55
44
|
return termUnifies;
|
|
56
45
|
}
|
package/src/unifier/metaLevel.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import ontology from "../ontology";
|
|
4
3
|
import Unifier from "../unifier";
|
|
4
|
+
import ontology from "../ontology";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
import { metavariableNameFromMetavariableNode } from "../utilities/metavariable";
|
|
8
|
-
import { variableIdentifierFromVariableNode, termVariableIdentifierFromTermNode } from "../utilities/variable";
|
|
9
8
|
|
|
10
9
|
const termNodeQuery = nodeQuery("/term"),
|
|
11
10
|
frameNodeQuery = nodeQuery("/frame"),
|
|
12
11
|
statementNodeQuery = nodeQuery("/statement"),
|
|
13
12
|
termVariableNodeQuery = nodeQuery("/term/variable!"),
|
|
14
13
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
assumptionMetavariableNodeQuery = nodeQuery("/assumption/metavariable!"),
|
|
15
|
+
frameAssumptionMetavariableNodeQuery = nodeQuery("/frame/assumption!/metavariable!");
|
|
17
16
|
|
|
18
17
|
class MetaLevelUnifier extends Unifier {
|
|
19
18
|
unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext) {
|
|
@@ -66,13 +65,13 @@ class MetaLevelUnifier extends Unifier {
|
|
|
66
65
|
}
|
|
67
66
|
},
|
|
68
67
|
{
|
|
69
|
-
generalNodeQuery:
|
|
68
|
+
generalNodeQuery: frameAssumptionMetavariableNodeQuery,
|
|
70
69
|
specificNodeQuery: frameNodeQuery,
|
|
71
|
-
unify: (
|
|
70
|
+
unify: (generalFrameAssumptionMetavariableNode, specificFrameNode, substitutions, generalContext, specificContext) => {
|
|
72
71
|
let frameUnifies;
|
|
73
72
|
|
|
74
73
|
const frameNode = specificFrameNode, ///
|
|
75
|
-
metavariableNode =
|
|
74
|
+
metavariableNode = generalFrameAssumptionMetavariableNode, ///
|
|
76
75
|
metavariableName = metavariableNameFromMetavariableNode(metavariableNode);
|
|
77
76
|
|
|
78
77
|
let context;
|
|
@@ -94,11 +93,11 @@ class MetaLevelUnifier extends Unifier {
|
|
|
94
93
|
generalNodeQuery: termVariableNodeQuery,
|
|
95
94
|
specificNodeQuery: termNodeQuery,
|
|
96
95
|
unify: (generalTermVariableNode, specificTermNode, substitutions, generalContext, specificContext) => {
|
|
97
|
-
let termUnifies
|
|
96
|
+
let termUnifies;
|
|
98
97
|
|
|
99
98
|
const termNode = specificTermNode, ///
|
|
100
99
|
variableNode = generalTermVariableNode, ///
|
|
101
|
-
variableIdentifier =
|
|
100
|
+
variableIdentifier = variableNode.getVariableIdentifier();
|
|
102
101
|
|
|
103
102
|
let context;
|
|
104
103
|
|
|
@@ -110,25 +109,15 @@ class MetaLevelUnifier extends Unifier {
|
|
|
110
109
|
|
|
111
110
|
const term = context.findTermByTermNode(termNode);
|
|
112
111
|
|
|
113
|
-
|
|
114
|
-
termUnifies = variable.unifyTerm(term, substitutions, generalContext, specificContext);
|
|
115
|
-
} else {
|
|
116
|
-
const termVariaibleIdentifer = termVariableIdentifierFromTermNode(termNode),
|
|
117
|
-
termVariable = context.findVariableByVariableIdentifier(termVariaibleIdentifer),
|
|
118
|
-
termVariableUnifies = variable.unifyTermVariable(termVariable, substitutions, generalContext, specificContext);
|
|
119
|
-
|
|
120
|
-
if (termVariableUnifies) {
|
|
121
|
-
termUnifies = true;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
112
|
+
termUnifies = variable.unifyTerm(term, substitutions, generalContext, specificContext);
|
|
124
113
|
|
|
125
114
|
return termUnifies;
|
|
126
115
|
}
|
|
127
116
|
},
|
|
128
117
|
{
|
|
129
|
-
generalNodeQuery:
|
|
130
|
-
specificNodeQuery:
|
|
131
|
-
unify: (
|
|
118
|
+
generalNodeQuery: assumptionMetavariableNodeQuery,
|
|
119
|
+
specificNodeQuery: assumptionMetavariableNodeQuery,
|
|
120
|
+
unify: (generalAssumptionMetavariableNode, specificAssumptionMetavariableNode, substitutions, generalContext, specificContext) => {
|
|
132
121
|
let referenceUnifies;
|
|
133
122
|
|
|
134
123
|
const { Reference } = ontology;
|
|
@@ -138,14 +127,14 @@ class MetaLevelUnifier extends Unifier {
|
|
|
138
127
|
|
|
139
128
|
context = generalContext; ///
|
|
140
129
|
|
|
141
|
-
metavariableNode =
|
|
130
|
+
metavariableNode = generalAssumptionMetavariableNode; ///
|
|
142
131
|
|
|
143
132
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
144
133
|
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
145
134
|
|
|
146
135
|
context = specificContext; ///
|
|
147
136
|
|
|
148
|
-
metavariableNode =
|
|
137
|
+
metavariableNode = specificAssumptionMetavariableNode; ///
|
|
149
138
|
|
|
150
139
|
const reference = Reference.fromMetavariableNode(metavariableNode, context);
|
|
151
140
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery } from "../utilities/query";
|
|
4
|
+
|
|
5
|
+
const frameMetavariableNameNodeQuery = nodeQuery("/frame/assumption!/metavariable!/@name!");
|
|
6
|
+
|
|
7
|
+
export function frameMetavariableNameFromFrameNode(frmaeNode) {
|
|
8
|
+
const frameMetavariableNameTerminalNode = frameMetavariableNameNodeQuery(frmaeNode),
|
|
9
|
+
frameMetavariableNameTerminalNodeContent = frameMetavariableNameTerminalNode.getContent(),
|
|
10
|
+
frameMetavariableName = frameMetavariableNameTerminalNodeContent; ///
|
|
11
|
+
|
|
12
|
+
return frameMetavariableName;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery } from "../utilities/query";
|
|
4
|
+
|
|
5
|
+
const statementMetavariableNameNodeQuery = nodeQuery("/statement/metavariable!/@name!");
|
|
6
|
+
|
|
7
|
+
export function statementMetavariableNameFromFrameNode(frmaeNode) {
|
|
8
|
+
const statementMetavariableNameTerminalNode = statementMetavariableNameNodeQuery(frmaeNode),
|
|
9
|
+
statementMetavariableNameTerminalNodeContent = statementMetavariableNameTerminalNode.getContent(),
|
|
10
|
+
statementMetavariableName = statementMetavariableNameTerminalNodeContent; ///
|
|
11
|
+
|
|
12
|
+
return statementMetavariableName;
|
|
13
|
+
}
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { nodeQuery } from "../utilities/query";
|
|
4
|
+
import { frameMetavariableNameFromFrameNode } from "../utilities/frame";
|
|
5
|
+
import { termVariableIdentifierFromTermNode } from "../utilities/variable";
|
|
6
|
+
import { statementMetavariableNameFromFrameNode } from "../utilities/statement";
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
const substitutionNodeQuery = nodeQuery("/statement/termSubstitution|frameSubstitution!");
|
|
9
|
+
|
|
10
|
+
export function termFromTermAndSubstitutions(term, substitutions, generalContext, specificContext) {
|
|
6
11
|
if (term !== null) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
variable = Variable.fromTermNode(termNode, context);
|
|
12
|
+
const termNode = term.getNode(),
|
|
13
|
+
termSimple = term.isSimple();
|
|
10
14
|
|
|
11
15
|
term = null; ///
|
|
12
16
|
|
|
13
|
-
if (
|
|
14
|
-
const
|
|
17
|
+
if (termSimple) {
|
|
18
|
+
const termVariableIdentifier = termVariableIdentifierFromTermNode(termNode),
|
|
19
|
+
variableIdentifier = termVariableIdentifier, ///
|
|
20
|
+
variable = generalContext.findVariableByVariableIdentifier(variableIdentifier);
|
|
21
|
+
|
|
22
|
+
if (variable !== null) {
|
|
23
|
+
const substitution = substitutions.findSubstitutionByVariable(variable);
|
|
24
|
+
|
|
25
|
+
if (substitution !== null) {
|
|
26
|
+
const termSubstitution = substitution; ///
|
|
15
27
|
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
term = termSubstitution.getTerm();
|
|
29
|
+
}
|
|
18
30
|
}
|
|
19
31
|
}
|
|
20
32
|
}
|
|
@@ -22,21 +34,28 @@ export function termFromTermAndSubstitutions(term, substitutions, context) {
|
|
|
22
34
|
return term;
|
|
23
35
|
}
|
|
24
36
|
|
|
25
|
-
export function frameFromFrameAndSubstitutions(frame, substitutions,
|
|
37
|
+
export function frameFromFrameAndSubstitutions(frame, substitutions, generalContext, specificContext) {
|
|
26
38
|
if (frame !== null) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
metavariable = Metavariable.fromFrameNode(frameNode, context);
|
|
39
|
+
const frameNode = frame.getNode(),
|
|
40
|
+
frameSimple = frame.isSimple();
|
|
30
41
|
|
|
31
|
-
frame = null;
|
|
42
|
+
frame = null; ///
|
|
32
43
|
|
|
33
|
-
if (
|
|
34
|
-
|
|
44
|
+
if (frameSimple) {
|
|
45
|
+
const frameMetavariableName = frameMetavariableNameFromFrameNode(frameNode),
|
|
46
|
+
metavariableName = frameMetavariableName, ///
|
|
47
|
+
metavariable = generalContext.findMetavariableByMetavariableName(metavariableName);
|
|
48
|
+
|
|
49
|
+
if (metavariable !== null) {
|
|
50
|
+
let substitution = null;
|
|
35
51
|
|
|
36
|
-
|
|
52
|
+
substitution = substitutions.findSubstitutionByMetavariableAndSubstitution(metavariable, substitution);
|
|
37
53
|
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
if (substitution !== null) {
|
|
55
|
+
const frameSubstitution = substitution; ///
|
|
56
|
+
|
|
57
|
+
frame = frameSubstitution.getFrame();
|
|
58
|
+
}
|
|
40
59
|
}
|
|
41
60
|
}
|
|
42
61
|
}
|
|
@@ -44,25 +63,34 @@ export function frameFromFrameAndSubstitutions(frame, substitutions, context) {
|
|
|
44
63
|
return frame;
|
|
45
64
|
}
|
|
46
65
|
|
|
47
|
-
export function statementFromStatementAndSubstitutions(statement, substitutions,
|
|
66
|
+
export function statementFromStatementAndSubstitutions(statement, substitutions, generalContext, specificContext) {
|
|
48
67
|
if (statement !== null) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
68
|
+
const statementNode = statement.getNode(),
|
|
69
|
+
statementSimple = statement.isSimple();
|
|
70
|
+
|
|
71
|
+
if (statementSimple) {
|
|
72
|
+
statement = null;
|
|
52
73
|
|
|
53
|
-
|
|
74
|
+
let substitution = null;
|
|
54
75
|
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
const substitutionNode = substitutionNodeQuery(statementNode);
|
|
77
|
+
|
|
78
|
+
if (substitutionNode !== null) {
|
|
79
|
+
substitution = generalContext.findSubstitutionBySubstitutionNode(substitutionNode);
|
|
80
|
+
}
|
|
57
81
|
|
|
58
|
-
const
|
|
82
|
+
const statementMetavariableName = statementMetavariableNameFromFrameNode(statementNode),
|
|
83
|
+
metavariableName = statementMetavariableName, ///
|
|
84
|
+
metavariable = generalContext.findMetavariableByMetavariableName(metavariableName);
|
|
59
85
|
|
|
60
|
-
|
|
86
|
+
if (metavariable !== null) {
|
|
87
|
+
substitution = substitutions.findSubstitutionByMetavariableAndSubstitution(metavariable, substitution);
|
|
61
88
|
|
|
62
|
-
|
|
89
|
+
if (substitution !== null) {
|
|
90
|
+
const statementSubstitution = substitution; ///
|
|
63
91
|
|
|
64
|
-
|
|
65
|
-
|
|
92
|
+
statement = statementSubstitution.getStatement();
|
|
93
|
+
}
|
|
66
94
|
}
|
|
67
95
|
}
|
|
68
96
|
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { nodeQuery } from "../utilities/query";
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
termVariableIdentifierNodeQuery = nodeQuery("/term/variable!/@identifier!");
|
|
5
|
+
const termVariableIdentifierNodeQuery = nodeQuery("/term/variable!/@identifier!");
|
|
7
6
|
|
|
8
7
|
export function termVariableIdentifierFromTermNode(TermNode) {
|
|
9
8
|
const termVariableIdentifierTerminalNode = termVariableIdentifierNodeQuery(TermNode),
|
|
@@ -12,11 +11,3 @@ export function termVariableIdentifierFromTermNode(TermNode) {
|
|
|
12
11
|
|
|
13
12
|
return termVariableIdentifier;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
export function variableIdentifierFromVariableNode(variableNode) {
|
|
17
|
-
const variableIdentifierTerminalNode = variableIdentifierNodeQuery(variableNode),
|
|
18
|
-
variableIdentifierTerminalNodeContent = variableIdentifierTerminalNode.getContent(),
|
|
19
|
-
variableIdentifier = variableIdentifierTerminalNodeContent; ///
|
|
20
|
-
|
|
21
|
-
return variableIdentifier;
|
|
22
|
-
}
|