occam-verify-cli 1.0.448 → 1.0.472
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/constants.js +13 -5
- package/lib/context/ephemeral.js +270 -0
- package/lib/context/file.js +136 -128
- package/lib/context/liminal.js +120 -0
- package/lib/context/literal.js +92 -0
- package/lib/context/nominal.js +15 -1
- package/lib/context/release.js +68 -9
- package/lib/context/scoped.js +322 -0
- package/lib/context/synthetic.js +133 -0
- package/lib/element/assertion/contained.js +66 -66
- package/lib/element/assertion/defined.js +32 -32
- package/lib/element/assertion/property.js +39 -39
- package/lib/element/assertion/satisfies.js +22 -22
- package/lib/element/assumption.js +71 -87
- package/lib/element/combinator/bracketed.js +1 -10
- package/lib/element/conclusion.js +19 -15
- package/lib/element/constructor/bracketed.js +1 -10
- package/lib/element/constructor.js +2 -2
- package/lib/element/declaration/combinator.js +1 -2
- package/lib/element/declaration/metavariable.js +3 -3
- package/lib/element/declaration/variable.js +3 -3
- package/lib/element/deduction.js +26 -20
- package/lib/element/derivation.js +3 -3
- package/lib/element/equality.js +5 -5
- package/lib/element/equivalence.js +112 -107
- package/lib/element/equivalences.js +24 -10
- package/lib/element/error.js +3 -3
- package/lib/element/frame.js +73 -62
- package/lib/element/hypothesis.js +2 -2
- package/lib/element/judgement.js +40 -60
- package/lib/element/metaType.js +4 -4
- package/lib/element/metavariable.js +49 -38
- package/lib/element/parameter.js +13 -5
- package/lib/element/procedureCall.js +16 -16
- package/lib/element/proof.js +14 -13
- package/lib/element/proofAssertion/premise.js +319 -0
- package/lib/element/proofAssertion/step.js +309 -0
- package/lib/element/proofAssertion/supposition.js +333 -0
- package/lib/element/proofAssertion.js +20 -10
- package/lib/element/propertyRelation.js +2 -2
- package/lib/element/reference.js +72 -30
- package/lib/element/rule.js +26 -28
- package/lib/element/section.js +5 -5
- package/lib/element/signature.js +9 -6
- package/lib/element/statement.js +44 -36
- package/lib/element/subproof.js +18 -17
- package/lib/element/substitution/frame.js +86 -49
- package/lib/element/substitution/reference.js +101 -19
- package/lib/element/substitution/statement.js +128 -105
- package/lib/element/substitution/term.js +93 -57
- package/lib/element/substitution.js +20 -69
- package/lib/element/substitutions.js +49 -34
- package/lib/element/term.js +41 -30
- package/lib/element/topLevelAssertion/axiom.js +331 -0
- package/lib/element/{conjecture.js → topLevelAssertion/conjecture.js} +10 -10
- package/lib/element/{lemma.js → topLevelAssertion/lemma.js} +9 -9
- package/lib/element/{theorem.js → topLevelAssertion/theorem.js} +8 -8
- package/lib/element/topLevelAssertion.js +434 -0
- package/lib/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +8 -8
- package/lib/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +8 -8
- package/lib/element/topLevelMetaAssertion.js +293 -0
- package/lib/element/type.js +4 -4
- package/lib/element/variable.js +48 -40
- package/lib/index.js +3 -3
- package/lib/main.js +3 -3
- package/lib/metaTypes.js +18 -15
- package/lib/node/frame.js +2 -2
- package/lib/node/metavariable.js +4 -4
- package/lib/node/parameter.js +28 -7
- package/lib/node/proofAssertion/premise.js +116 -0
- package/lib/node/proofAssertion/step.js +152 -0
- package/lib/node/proofAssertion/supposition.js +116 -0
- package/lib/node/{premise.js → proofAssertion.js} +11 -18
- package/lib/node/statement.js +2 -2
- package/lib/node/substitution/frame.js +9 -31
- package/lib/node/substitution/reference.js +137 -0
- package/lib/node/substitution/statement.js +9 -31
- package/lib/node/substitution/term.js +9 -23
- package/lib/node/{axiom.js → topLevelAssertion/axiom.js} +7 -7
- package/lib/node/{conjecture.js → topLevelAssertion/conjecture.js} +7 -7
- package/lib/node/{lemma.js → topLevelAssertion/lemma.js} +7 -7
- package/lib/node/{theorem.js → topLevelAssertion/theorem.js} +7 -7
- package/lib/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +9 -9
- package/lib/node/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +7 -7
- package/lib/node/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +7 -7
- package/lib/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +9 -9
- package/lib/nonTerminalNodeMap.js +15 -14
- package/lib/preamble.js +10 -10
- package/lib/process/instantiate.js +6 -21
- package/lib/process/unify.js +11 -10
- package/lib/tokenTypes.js +22 -0
- package/lib/types.js +3 -3
- package/lib/utilities/bnf.js +5 -5
- package/lib/utilities/context.js +63 -0
- package/lib/utilities/element.js +235 -408
- package/lib/utilities/instance.js +12 -34
- package/lib/utilities/json.js +3 -2
- package/lib/utilities/string.js +56 -21
- package/lib/utilities/unification.js +38 -32
- package/lib/utilities/validation.js +47 -50
- package/package.json +2 -2
- package/src/constants.js +12 -1
- package/src/context/ephemeral.js +257 -0
- package/src/context/file.js +108 -116
- package/src/context/liminal.js +67 -0
- package/src/context/literal.js +51 -0
- package/src/context/nominal.js +12 -0
- package/src/context/release.js +48 -8
- package/src/context/{local.js → scoped.js} +43 -125
- package/src/context/synthetic.js +60 -0
- package/src/element/assertion/contained.js +49 -47
- package/src/element/assertion/defined.js +29 -27
- package/src/element/assertion/property.js +35 -35
- package/src/element/assertion/satisfies.js +19 -18
- package/src/element/assumption.js +71 -93
- package/src/element/combinator/bracketed.js +0 -7
- package/src/element/conclusion.js +25 -24
- package/src/element/constructor/bracketed.js +0 -7
- package/src/element/constructor.js +1 -1
- package/src/element/declaration/combinator.js +0 -1
- package/src/element/declaration/metavariable.js +2 -2
- package/src/element/declaration/variable.js +5 -5
- package/src/element/deduction.js +33 -31
- package/src/element/derivation.js +2 -2
- package/src/element/equality.js +4 -4
- package/src/element/equivalence.js +115 -135
- package/src/element/equivalences.js +9 -7
- package/src/element/error.js +4 -2
- package/src/element/frame.js +80 -65
- package/src/element/hypothesis.js +1 -1
- package/src/element/judgement.js +42 -62
- package/src/element/metaType.js +3 -4
- package/src/element/metavariable.js +59 -56
- package/src/element/parameter.js +10 -5
- package/src/element/procedureCall.js +20 -18
- package/src/element/proof.js +14 -16
- package/src/element/{premise.js → proofAssertion/premise.js} +57 -53
- package/src/element/{step.js → proofAssertion/step.js} +59 -62
- package/src/element/{supposition.js → proofAssertion/supposition.js} +67 -56
- package/src/element/proofAssertion.js +24 -13
- package/src/element/propertyRelation.js +1 -1
- package/src/element/reference.js +87 -37
- package/src/element/rule.js +31 -37
- package/src/element/section.js +5 -5
- package/src/element/signature.js +8 -8
- package/src/element/statement.js +52 -48
- package/src/element/subproof.js +16 -18
- package/src/element/substitution/frame.js +104 -50
- package/src/element/substitution/reference.js +120 -20
- package/src/element/substitution/statement.js +169 -130
- package/src/element/substitution/term.js +104 -63
- package/src/element/substitution.js +16 -58
- package/src/element/substitutions.js +43 -41
- package/src/element/term.js +47 -41
- package/src/element/{axiom.js → topLevelAssertion/axiom.js} +22 -20
- package/src/element/{conjecture.js → topLevelAssertion/conjecture.js} +5 -6
- package/src/element/{lemma.js → topLevelAssertion/lemma.js} +5 -6
- package/src/element/{theorem.js → topLevelAssertion/theorem.js} +5 -5
- package/src/element/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +37 -33
- package/src/element/{metaLemma.js → topLevelMetaAssertion/metaLemma.js} +5 -6
- package/src/element/{metatheorem.js → topLevelMetaAssertion/metatheorem.js} +5 -6
- package/src/element/{metaLemmaMetatheorem.js → topLevelMetaAssertion.js} +19 -17
- package/src/element/type.js +2 -4
- package/src/element/variable.js +47 -48
- package/src/index.js +2 -1
- package/src/main.js +2 -1
- package/src/metaTypes.js +25 -9
- package/src/node/frame.js +1 -1
- package/src/node/metavariable.js +3 -3
- package/src/node/parameter.js +32 -5
- package/src/node/proofAssertion/premise.js +16 -0
- package/src/node/{step.js → proofAssertion/step.js} +4 -18
- package/src/node/proofAssertion/supposition.js +16 -0
- package/src/node/proofAssertion.js +23 -0
- package/src/node/statement.js +1 -1
- package/src/node/substitution/frame.js +6 -32
- package/src/node/substitution/reference.js +38 -0
- package/src/node/substitution/statement.js +6 -32
- package/src/node/substitution/term.js +6 -22
- package/src/node/topLevelAssertion/axiom.js +13 -0
- package/src/node/topLevelAssertion/conjecture.js +13 -0
- package/src/node/topLevelAssertion/lemma.js +13 -0
- package/src/node/topLevelAssertion/theorem.js +13 -0
- package/src/node/{axiomLemmaTheoremConjecture.js → topLevelAssertion.js} +1 -1
- package/src/node/topLevelMetaAssertion/metaLemma.js +13 -0
- package/src/node/topLevelMetaAssertion/metatheorem.js +13 -0
- package/src/node/{metaLemmaMetaTheorem.js → topLevelMetaAssertion.js} +1 -1
- package/src/nonTerminalNodeMap.js +15 -12
- package/src/preamble.js +9 -9
- package/src/process/instantiate.js +27 -36
- package/src/process/unify.js +10 -9
- package/src/tokenTypes.js +4 -0
- package/src/types.js +4 -2
- package/src/utilities/bnf.js +3 -2
- package/src/utilities/context.js +46 -0
- package/src/utilities/element.js +302 -509
- package/src/utilities/instance.js +19 -42
- package/src/utilities/json.js +3 -1
- package/src/utilities/string.js +69 -28
- package/src/utilities/unification.js +41 -38
- package/src/utilities/validation.js +66 -75
- package/lib/context/local.js +0 -605
- package/lib/context/temporary.js +0 -752
- package/lib/element/axiom.js +0 -329
- package/lib/element/axiomLemmaTheoremConjecture.js +0 -427
- package/lib/element/metaLemmaMetatheorem.js +0 -289
- package/lib/element/premise.js +0 -307
- package/lib/element/step.js +0 -311
- package/lib/element/supposition.js +0 -320
- package/lib/log.js +0 -150
- package/lib/node/step.js +0 -166
- package/lib/node/supposition.js +0 -130
- package/src/context/temporary.js +0 -476
- package/src/log.js +0 -118
- package/src/node/axiom.js +0 -13
- package/src/node/conjecture.js +0 -13
- package/src/node/lemma.js +0 -13
- package/src/node/metaLemma.js +0 -13
- package/src/node/metatheorem.js +0 -13
- package/src/node/premise.js +0 -30
- package/src/node/supposition.js +0 -30
- package/src/node/theorem.js +0 -13
package/src/element/judgement.js
CHANGED
|
@@ -22,114 +22,94 @@ export default define(class Judgement extends Element {
|
|
|
22
22
|
return this.assumption;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
isSingular() {
|
|
25
|
+
isSingular() {
|
|
26
|
+
const node = this.getNode(),
|
|
27
|
+
singular = node.isSingular();
|
|
28
|
+
|
|
29
|
+
return singular;
|
|
30
|
+
}
|
|
26
31
|
|
|
27
32
|
getMetavariable() { return this.frame.getMetavariable(); }
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
let
|
|
34
|
+
validate(assignments, stated, context) {
|
|
35
|
+
let validates = false;
|
|
31
36
|
|
|
32
|
-
const judgementString = this.
|
|
37
|
+
const judgementString = this.getString(); ///
|
|
33
38
|
|
|
34
|
-
context.trace(`
|
|
39
|
+
context.trace(`Validating the '${judgementString}' judgement...`);
|
|
35
40
|
|
|
36
|
-
const
|
|
41
|
+
const frameValidates = this.frame.validate(assignments, stated, context);
|
|
37
42
|
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
43
|
+
if (frameValidates) {
|
|
44
|
+
const assumptionValidates = this.assumption.validate(assignments, stated, context);
|
|
40
45
|
|
|
41
|
-
if (
|
|
42
|
-
let
|
|
43
|
-
|
|
46
|
+
if (assumptionValidates) {
|
|
47
|
+
let validatesWhenStated = false,
|
|
48
|
+
validatesWhenDerived = false;
|
|
44
49
|
|
|
45
50
|
if (stated) {
|
|
46
|
-
|
|
51
|
+
validatesWhenStated = this.validateWhenStated(assignments, context);
|
|
47
52
|
} else {
|
|
48
|
-
|
|
53
|
+
validatesWhenDerived = this.validateWhenDerived(context);
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
if (
|
|
52
|
-
|
|
56
|
+
if (validatesWhenStated || validatesWhenDerived) {
|
|
57
|
+
validates = true;
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
if (
|
|
62
|
+
if (validates) {
|
|
58
63
|
if (stated) {
|
|
59
64
|
this.assign(assignments, context);
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
if (
|
|
64
|
-
context.debug(`...
|
|
68
|
+
if (validates) {
|
|
69
|
+
context.debug(`...validated the '${judgementString}' judgement.`);
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
return
|
|
72
|
+
return validates;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
let
|
|
75
|
+
validateWhenStated(assignments, context) {
|
|
76
|
+
let validatesWhenStated;
|
|
72
77
|
|
|
73
|
-
const
|
|
78
|
+
const judgementString = this.getString(); ///
|
|
74
79
|
|
|
75
|
-
context.trace(`
|
|
80
|
+
context.trace(`Validating the '${judgementString}' stated judgement...`);
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
validatesWhenStated = true;
|
|
78
83
|
|
|
79
|
-
if (
|
|
80
|
-
context.debug(`...
|
|
84
|
+
if (validatesWhenStated) {
|
|
85
|
+
context.debug(`...validated the '${judgementString}' stated judgement.`);
|
|
81
86
|
}
|
|
82
87
|
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
verifyDeclaration(assignments, stated, context) {
|
|
87
|
-
let declarationVerifies;
|
|
88
|
-
|
|
89
|
-
declarationVerifies = this.assumption.verify(assignments, stated, context);
|
|
90
|
-
|
|
91
|
-
return declarationVerifies;
|
|
88
|
+
return validatesWhenStated;
|
|
92
89
|
}
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
let
|
|
91
|
+
validateWhenDerived(context) {
|
|
92
|
+
let validatesWhenDerived = false;
|
|
96
93
|
|
|
97
|
-
const judgementString = this.
|
|
94
|
+
const judgementString = this.getString(); ///
|
|
98
95
|
|
|
99
|
-
context.trace(`
|
|
100
|
-
|
|
101
|
-
verifiesWhenStated = true;
|
|
102
|
-
|
|
103
|
-
if (verifiesWhenStated) {
|
|
104
|
-
context.debug(`...verified the '${judgementString}' stated judgement.`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return verifiesWhenStated;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
verifyWhenDerived(context) {
|
|
111
|
-
let verifiesWhenDerived = false;
|
|
112
|
-
|
|
113
|
-
const judgementString = this.string; ///
|
|
114
|
-
|
|
115
|
-
context.trace(`Verifying the '${judgementString}' derived judgement...`);
|
|
96
|
+
context.trace(`Validating the '${judgementString}' derived judgement...`);
|
|
116
97
|
|
|
117
98
|
const metavariable = this.assumption.getMetavariable(),
|
|
118
99
|
reference = referenceFromMetavariable(metavariable, context),
|
|
119
|
-
|
|
120
|
-
substitutions =
|
|
100
|
+
topLevelMetaAssertion = context.findTopLevelMetaAssertionByReference(reference),
|
|
101
|
+
substitutions = topLevelMetaAssertion.getSubstitutions(),
|
|
121
102
|
frameComparesToSubstitutions = this.frame.compareSubstitutions(substitutions, context);
|
|
122
103
|
|
|
123
104
|
if (frameComparesToSubstitutions) {
|
|
124
|
-
|
|
125
|
-
|
|
105
|
+
validatesWhenDerived = true;
|
|
126
106
|
}
|
|
127
107
|
|
|
128
|
-
if (
|
|
129
|
-
context.debug(`...
|
|
108
|
+
if (validatesWhenDerived) {
|
|
109
|
+
context.debug(`...validated the '${judgementString}' derived judgement.`);
|
|
130
110
|
}
|
|
131
111
|
|
|
132
|
-
return
|
|
112
|
+
return validatesWhenDerived;
|
|
133
113
|
}
|
|
134
114
|
|
|
135
115
|
assign(assignments, context) {
|
package/src/element/metaType.js
CHANGED
|
@@ -41,14 +41,13 @@ export default define(class MetaType extends Element {
|
|
|
41
41
|
static fromJSON(json, context) {
|
|
42
42
|
const { name } = json,
|
|
43
43
|
metaTypeName = name, ///
|
|
44
|
-
metaType =
|
|
44
|
+
metaType = findMetaTypeByMetaTypeName(metaTypeName);
|
|
45
45
|
|
|
46
46
|
return metaType;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
static fromName(name) {
|
|
50
|
-
const
|
|
51
|
-
string = name,
|
|
49
|
+
static fromName(name, context) {
|
|
50
|
+
const string = name,
|
|
52
51
|
node = null,
|
|
53
52
|
metaType = new MetaType(context, string, node, name);
|
|
54
53
|
|
|
@@ -5,9 +5,9 @@ import elements from "../elements";
|
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
import { EMPTY_STRING } from "../constants";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { synthetically } from "../utilities/context";
|
|
9
|
+
import { typeToTypeJSON } from "../utilities/json";
|
|
10
|
+
import { metaTypeToMetaTypeJSON } from "../utilities/json";
|
|
11
11
|
import { unifyMetavariable, unifyMetavariableIntrinsically } from "../process/unify";
|
|
12
12
|
|
|
13
13
|
export default define(class Metavariable extends Element {
|
|
@@ -45,6 +45,8 @@ export default define(class Metavariable extends Element {
|
|
|
45
45
|
return nameEqualTo;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
49
|
+
|
|
48
50
|
compareMetavariableName(metavariableName) {
|
|
49
51
|
const nameMetavariableName = (this.name === metavariableName),
|
|
50
52
|
comparesToMetavariableName = nameMetavariableName; ///
|
|
@@ -52,8 +54,6 @@ export default define(class Metavariable extends Element {
|
|
|
52
54
|
return comparesToMetavariableName;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
56
|
-
|
|
57
57
|
validate(context) {
|
|
58
58
|
let validates = false;
|
|
59
59
|
|
|
@@ -78,8 +78,8 @@ export default define(class Metavariable extends Element {
|
|
|
78
78
|
validateGivenMetaType(metaType, context) {
|
|
79
79
|
let validatesGivenMetaType = false;
|
|
80
80
|
|
|
81
|
-
const
|
|
82
|
-
|
|
81
|
+
const metaTypeString = metaType.getString(),
|
|
82
|
+
metavariableString = this.getString(); ///
|
|
83
83
|
|
|
84
84
|
context.trace(`Validating the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
|
|
85
85
|
|
|
@@ -105,10 +105,11 @@ export default define(class Metavariable extends Element {
|
|
|
105
105
|
unifyFrame(frame, substitutions, generalContext, specificContext) {
|
|
106
106
|
let frameUnifies = false;
|
|
107
107
|
|
|
108
|
-
const
|
|
108
|
+
const context = specificContext, ///
|
|
109
|
+
frameString = frame.getString(),
|
|
109
110
|
metavariableString = this.getString(); ///
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
context.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
112
113
|
|
|
113
114
|
const frameMetavariableUnifies = this.unifyFrameMetavariable(frame, substitutions, generalContext, specificContext);
|
|
114
115
|
|
|
@@ -127,20 +128,20 @@ export default define(class Metavariable extends Element {
|
|
|
127
128
|
frameUnifies = true;
|
|
128
129
|
}
|
|
129
130
|
} else {
|
|
130
|
-
const
|
|
131
|
-
context = specificContext, ///
|
|
132
|
-
metavariable = this, ///
|
|
133
|
-
frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, context),
|
|
134
|
-
substitution = frameSubstitution; ///
|
|
131
|
+
const metavariable = this; ///
|
|
135
132
|
|
|
136
|
-
|
|
133
|
+
synthetically((context) => {
|
|
134
|
+
const { FrameSubstitution } = elements;
|
|
135
|
+
|
|
136
|
+
FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, context);
|
|
137
|
+
}, generalContext, specificContext);
|
|
137
138
|
|
|
138
139
|
frameUnifies = true;
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
if (frameUnifies) {
|
|
143
|
-
|
|
144
|
+
context.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
return frameUnifies;
|
|
@@ -149,13 +150,14 @@ export default define(class Metavariable extends Element {
|
|
|
149
150
|
unifyStatement(statement, substitution, substitutions, generalContext, specificContext) {
|
|
150
151
|
let statementUnifies = false;
|
|
151
152
|
|
|
152
|
-
const
|
|
153
|
+
const context = specificContext, ///
|
|
154
|
+
statementString = statement.getString(),
|
|
153
155
|
metavariableString = this.getString(), ///
|
|
154
156
|
substitutionString = (substitution !== null) ?
|
|
155
157
|
substitution.getString() :
|
|
156
158
|
EMPTY_STRING;
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
context.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
|
|
159
161
|
|
|
160
162
|
const statementMetavariableUnifies = this.unifyStatementMetavariable(statement, substitutions, generalContext, specificContext);
|
|
161
163
|
|
|
@@ -169,26 +171,29 @@ export default define(class Metavariable extends Element {
|
|
|
169
171
|
if (substitutionPresent) {
|
|
170
172
|
substitution = substitutions.findSubstitutionByMetavariableAndSubstitution(metavariable, substitution); ///
|
|
171
173
|
|
|
172
|
-
const
|
|
174
|
+
const substitutionComparesToStatement = substitution.compareStatement(statement, context);
|
|
173
175
|
|
|
174
|
-
if (
|
|
176
|
+
if (substitutionComparesToStatement) {
|
|
175
177
|
statementUnifies = true;
|
|
176
178
|
}
|
|
177
179
|
} else {
|
|
178
|
-
const
|
|
179
|
-
metavariable = this,
|
|
180
|
-
statementSubstitution = StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context);
|
|
180
|
+
const metavariable = this; ///
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
synthetically((context) => {
|
|
183
|
+
const { StatementSubstitution } = elements;
|
|
183
184
|
|
|
184
|
-
|
|
185
|
+
(substitution !== null) ?
|
|
186
|
+
StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) :
|
|
187
|
+
StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, context);
|
|
188
|
+
|
|
189
|
+
}, generalContext, specificContext);
|
|
185
190
|
|
|
186
191
|
statementUnifies = true;
|
|
187
192
|
}
|
|
188
193
|
}
|
|
189
194
|
|
|
190
195
|
if (statementUnifies) {
|
|
191
|
-
|
|
196
|
+
context.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
return statementUnifies;
|
|
@@ -197,42 +202,43 @@ export default define(class Metavariable extends Element {
|
|
|
197
202
|
unifyReference(reference, substitutions, generalContext, specificContext) {
|
|
198
203
|
let referenceUnifies = false;
|
|
199
204
|
|
|
200
|
-
const
|
|
205
|
+
const context = specificContext, ///
|
|
206
|
+
referenceString = reference.getString(),
|
|
201
207
|
metavariableString = this.getString(); ///
|
|
202
208
|
|
|
203
|
-
|
|
209
|
+
context.trace(`Unifying the '${referenceString}' reference with the '${metavariableString}' metavariable...`);
|
|
204
210
|
|
|
205
211
|
const referenceMetavariableUnifies = this.unifyReferenceMetavariable(reference, substitutions, generalContext, specificContext);
|
|
206
212
|
|
|
207
213
|
if (referenceMetavariableUnifies) {
|
|
208
214
|
referenceUnifies = true;
|
|
209
215
|
} else {
|
|
210
|
-
const
|
|
211
|
-
metavariable = this, ///
|
|
216
|
+
const metavariable = this, ///
|
|
212
217
|
simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariable(metavariable);
|
|
213
218
|
|
|
214
219
|
if (simpleSubstitutionPresent) {
|
|
215
220
|
const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariable(metavariable), ///
|
|
216
221
|
substitution = simpleSubstitution, ///
|
|
217
|
-
substitutionReferenceEqualToReference = substitution.isReferenceEqualToReference(reference
|
|
222
|
+
substitutionReferenceEqualToReference = substitution.isReferenceEqualToReference(reference);
|
|
218
223
|
|
|
219
224
|
if (substitutionReferenceEqualToReference) {
|
|
220
225
|
referenceUnifies = true;
|
|
221
226
|
}
|
|
222
227
|
} else {
|
|
223
|
-
const
|
|
224
|
-
metavariable = this,
|
|
225
|
-
referenceSubstitution = ReferenceSubstitution.fromReferenceAndMetavariable(reference, metavariable, context),
|
|
226
|
-
substitution = referenceSubstitution; ///
|
|
228
|
+
const metavariable = this; ///
|
|
227
229
|
|
|
228
|
-
|
|
230
|
+
synthetically((context) => {
|
|
231
|
+
const { ReferenceSubstitution } = elements;
|
|
232
|
+
|
|
233
|
+
ReferenceSubstitution.fromReferenceAndMetavariable(reference, metavariable, context);
|
|
234
|
+
}, generalContext, specificContext);
|
|
229
235
|
|
|
230
236
|
referenceUnifies = true;
|
|
231
237
|
}
|
|
232
238
|
}
|
|
233
239
|
|
|
234
240
|
if (referenceUnifies) {
|
|
235
|
-
|
|
241
|
+
context.debug(`...unified the '${referenceString}' reference with the '${metavariableString}' metavariable.`);
|
|
236
242
|
}
|
|
237
243
|
|
|
238
244
|
return referenceUnifies;
|
|
@@ -241,19 +247,25 @@ export default define(class Metavariable extends Element {
|
|
|
241
247
|
unifyMetavariable(metavariable, context) {
|
|
242
248
|
let metavariableUnifies;
|
|
243
249
|
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
250
|
+
const specificContext = context; ///
|
|
251
|
+
|
|
252
|
+
context = this.getContext();
|
|
253
|
+
|
|
254
|
+
const generalContext = context; ///
|
|
255
|
+
|
|
256
|
+
context = specificContext; ///
|
|
257
|
+
|
|
258
|
+
const generalMetavariable = this, ///
|
|
247
259
|
specificMetavariable = metavariable, ///
|
|
248
260
|
generalMetavariableString = generalMetavariable.getString(),
|
|
249
261
|
specificMetavariableString = specificMetavariable.getString();
|
|
250
262
|
|
|
251
|
-
|
|
263
|
+
context.trace(`Unifying the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable...`);
|
|
252
264
|
|
|
253
265
|
metavariableUnifies = unifyMetavariable(generalMetavariable, specificMetavariable, generalContext, specificContext);
|
|
254
266
|
|
|
255
267
|
if (metavariableUnifies) {
|
|
256
|
-
|
|
268
|
+
context.debug(`...unified the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable.`);
|
|
257
269
|
}
|
|
258
270
|
|
|
259
271
|
return metavariableUnifies;
|
|
@@ -267,8 +279,8 @@ export default define(class Metavariable extends Element {
|
|
|
267
279
|
specificContextFilePath = specificContext.getFilePath();
|
|
268
280
|
|
|
269
281
|
if (generalContextFilePath === specificContextFilePath) {
|
|
270
|
-
const metavariable = this,
|
|
271
|
-
metavariableString =
|
|
282
|
+
const metavariable = this, ///
|
|
283
|
+
metavariableString = metavariable.getString(),
|
|
272
284
|
frameMetavariableEqualToMetvariable = frame.isMetavariableEqualToMetavariable(metavariable, context);
|
|
273
285
|
|
|
274
286
|
if (frameMetavariableEqualToMetvariable) {
|
|
@@ -308,7 +320,7 @@ export default define(class Metavariable extends Element {
|
|
|
308
320
|
|
|
309
321
|
if (generalContextFilePath === specificContextFilePath) {
|
|
310
322
|
const metavariable = this, ///
|
|
311
|
-
metavariableString =
|
|
323
|
+
metavariableString = metavariable.getString(),
|
|
312
324
|
statementMetavariableEqualToMetvariable = statement.isMetavariableEqualToMetavariable(metavariable, context);
|
|
313
325
|
|
|
314
326
|
if (statementMetavariableEqualToMetvariable) {
|
|
@@ -348,7 +360,7 @@ export default define(class Metavariable extends Element {
|
|
|
348
360
|
|
|
349
361
|
if (generalContextFilePath === specificContextFilePath) {
|
|
350
362
|
const metavariable = this, ///
|
|
351
|
-
metavariableString =
|
|
363
|
+
metavariableString = metavariable.getString(),
|
|
352
364
|
referenceMetavariableEqualToMetvariable = reference.isMetavariableEqualToMetavariable(metavariable);
|
|
353
365
|
|
|
354
366
|
if (referenceMetavariableEqualToMetvariable) {
|
|
@@ -392,15 +404,6 @@ export default define(class Metavariable extends Element {
|
|
|
392
404
|
static name = "Metavariable";
|
|
393
405
|
|
|
394
406
|
static fromJSON(json, context) {
|
|
395
|
-
|
|
396
|
-
metavariableNode = instantiateMetavariable(string, context),
|
|
397
|
-
metavariableName = metavariableNode.getMetavariableName(),
|
|
398
|
-
name = metavariableName, ///
|
|
399
|
-
node = metavariableNode, ///
|
|
400
|
-
type = typeFromJSON(json, context),
|
|
401
|
-
metaType = metaTypeFromJSON(json, context),
|
|
402
|
-
metavariable = new Metavariable(context, string, node, name, type, metaType);
|
|
403
|
-
|
|
404
|
-
return metavariable;
|
|
407
|
+
///
|
|
405
408
|
}
|
|
406
409
|
});
|
package/src/element/parameter.js
CHANGED
|
@@ -5,16 +5,21 @@ import Element from "../element";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
|
|
7
7
|
export default define(class Parameter extends Element {
|
|
8
|
-
constructor(context, string, node, name) {
|
|
9
|
-
super(context, string, node);
|
|
8
|
+
constructor(context, string, node, name, identifier) {
|
|
9
|
+
super(context, string, node, identifier);
|
|
10
10
|
|
|
11
11
|
this.name = name;
|
|
12
|
+
this.identifier = identifier;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
getName() {
|
|
15
16
|
return this.name;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
getIdentifier() {
|
|
20
|
+
return this.identifier;
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
findReplacementNode(substitutions) {
|
|
19
24
|
let replacementNode = null;
|
|
20
25
|
|
|
@@ -25,7 +30,7 @@ export default define(class Parameter extends Element {
|
|
|
25
30
|
if (substitutionComparesToParamter) {
|
|
26
31
|
return true;
|
|
27
32
|
}
|
|
28
|
-
});
|
|
33
|
+
}) || null;
|
|
29
34
|
|
|
30
35
|
if (substitution !== null) {
|
|
31
36
|
replacementNode = substitution.getReplacementNode();
|
|
@@ -46,10 +51,10 @@ export default define(class Parameter extends Element {
|
|
|
46
51
|
static name = "Parameter";
|
|
47
52
|
|
|
48
53
|
static fromJSON(json, context) {
|
|
49
|
-
const { name } = json,
|
|
54
|
+
const { name, identifier } = json,
|
|
50
55
|
string = null,
|
|
51
56
|
node = null,
|
|
52
|
-
parameter = new Parameter(context, string, node, name);
|
|
57
|
+
parameter = new Parameter(context, string, node, name, identifier);
|
|
53
58
|
|
|
54
59
|
return parameter;
|
|
55
60
|
}
|
|
@@ -10,6 +10,7 @@ import { parametersFromJSON, procedureReferenceFromJSON, parametersToParametersJ
|
|
|
10
10
|
export default define(class ProcedureCall extends Element {
|
|
11
11
|
constructor(context, string, node, parameters, procedureReference) {
|
|
12
12
|
super(context, string, node);
|
|
13
|
+
|
|
13
14
|
this.parameters = parameters;
|
|
14
15
|
this.procedureReference = procedureReference;
|
|
15
16
|
}
|
|
@@ -24,23 +25,24 @@ export default define(class ProcedureCall extends Element {
|
|
|
24
25
|
|
|
25
26
|
getName() { return this.procedureReference.getName(); }
|
|
26
27
|
|
|
27
|
-
findNodes(
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
findNodes(context) {
|
|
29
|
+
const substitutions = context.getSubstitutions(),
|
|
30
|
+
nodes = this.parameters.map((parameter) => {
|
|
31
|
+
const replacementNode = parameter.findReplacementNode(substitutions),
|
|
32
|
+
node = replacementNode; ///
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
return node;
|
|
35
|
+
});
|
|
34
36
|
|
|
35
37
|
return nodes;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
let
|
|
40
|
+
validate(context) {
|
|
41
|
+
let validates = false;
|
|
40
42
|
|
|
41
|
-
const procedureCallString = this.
|
|
43
|
+
const procedureCallString = this.getString(); ///
|
|
42
44
|
|
|
43
|
-
context.trace(`
|
|
45
|
+
context.trace(`Validating the '${procedureCallString}' procedure call...`);
|
|
44
46
|
|
|
45
47
|
const name = this.getName(),
|
|
46
48
|
procedure = context.findProcedureByName(name);
|
|
@@ -49,30 +51,30 @@ export default define(class ProcedureCall extends Element {
|
|
|
49
51
|
const procedureBoolean = procedure.isBoolean();
|
|
50
52
|
|
|
51
53
|
if (procedureBoolean) {
|
|
52
|
-
|
|
54
|
+
validates = true;
|
|
53
55
|
} else {
|
|
54
|
-
context.trace(`The '${procedureCallString}' procedure is not boolean
|
|
56
|
+
context.trace(`The '${procedureCallString}' procedure is not boolean.`);
|
|
55
57
|
}
|
|
56
58
|
} else {
|
|
57
|
-
context.trace(`The '${procedureCallString}' procedure is not present
|
|
59
|
+
context.trace(`The '${procedureCallString}' procedure is not present.`);
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
if (
|
|
61
|
-
context.debug(`...
|
|
62
|
+
if (validates) {
|
|
63
|
+
context.debug(`...validated the '${procedureCallString}' procedure call.`);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
return
|
|
66
|
+
return validates;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
unifyIndependently(substitutions, context) {
|
|
68
70
|
let unifiesIndependently = false;
|
|
69
71
|
|
|
70
|
-
const procedureCallString = this.
|
|
72
|
+
const procedureCallString = this.getString(); ///
|
|
71
73
|
|
|
72
74
|
context.trace(`Unifying the '${procedureCallString}' procedure call independently...`);
|
|
73
75
|
|
|
74
76
|
const name = this.getName(),
|
|
75
|
-
nodes = this.findNodes(
|
|
77
|
+
nodes = this.findNodes(context),
|
|
76
78
|
procedure = context.findProcedureByName(name),
|
|
77
79
|
expressions = Expressions.fromNodes(nodes, context);
|
|
78
80
|
|
package/src/element/proof.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Element from "../element";
|
|
4
|
-
import LocalContext from "../context/local";
|
|
5
4
|
|
|
5
|
+
import { scope } from "../utilities/context";
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
|
|
8
8
|
export default define(class Proof extends Element {
|
|
@@ -26,28 +26,26 @@ export default define(class Proof extends Element {
|
|
|
26
26
|
return statement;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
verify(
|
|
29
|
+
verify(conclusion, context) {
|
|
30
30
|
let verifies = false;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
scope((context) => {
|
|
33
|
+
const derivationVerifies = this.derivation.verify(context);
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
if (derivationVerifies) {
|
|
36
|
+
const lastProofAssertion = context.getLastProofAssertion();
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
if (lastProofAssertion !== null) {
|
|
39
|
+
const statement = this.getStatement(),
|
|
40
|
+
conclusionStatement = conclusion.getStatement(),
|
|
41
|
+
conclusionStatementEqualToStatement = conclusionStatement.isEqualTo(statement);
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (lastProofAssertion !== null) {
|
|
42
|
-
const statement = this.getStatement(),
|
|
43
|
-
conclusionStatement = conclusion.getStatement(),
|
|
44
|
-
conclusionStatementEqualToStatement = conclusionStatement.isEqualTo(statement);
|
|
45
|
-
|
|
46
|
-
if (conclusionStatementEqualToStatement) {
|
|
47
|
-
verifies = true;
|
|
43
|
+
if (conclusionStatementEqualToStatement) {
|
|
44
|
+
verifies = true;
|
|
45
|
+
}
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
|
-
}
|
|
48
|
+
}, context);
|
|
51
49
|
|
|
52
50
|
return verifies;
|
|
53
51
|
}
|