occam-verify-cli 1.0.768 → 1.0.776
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/context/file/nominal.js +11 -11
- package/lib/context/illative.js +28 -0
- package/lib/context/nested.js +27 -0
- package/lib/context/proof.js +232 -0
- package/lib/context/thetic.js +28 -0
- package/lib/context.js +15 -21
- package/lib/element/assertion/contained.js +24 -22
- package/lib/element/assertion/defined.js +20 -19
- package/lib/element/assertion/property.js +14 -13
- package/lib/element/assertion/satisfies.js +8 -9
- package/lib/element/assertion/subproof.js +23 -26
- package/lib/element/assertion/type.js +9 -11
- package/lib/element/assumption.js +32 -39
- package/lib/element/combinator/bracketed.js +3 -3
- package/lib/element/combinator.js +20 -20
- package/lib/element/conclusion.js +33 -29
- package/lib/element/constructor.js +19 -18
- package/lib/element/deduction.js +33 -29
- package/lib/element/equality.js +13 -15
- package/lib/element/equivalence.js +59 -52
- package/lib/element/frame.js +41 -34
- package/lib/element/hypothesis.js +7 -5
- package/lib/element/judgement.js +32 -73
- package/lib/element/label.js +22 -22
- package/lib/element/metavariable.js +23 -7
- package/lib/element/proofAssertion/premise.js +48 -35
- package/lib/element/proofAssertion/step.js +35 -20
- package/lib/element/proofAssertion/supposition.js +48 -34
- package/lib/element/proofAssertion.js +1 -14
- package/lib/element/reference.js +80 -53
- package/lib/element/signature.js +44 -3
- package/lib/element/statement.js +28 -29
- package/lib/element/subproof.js +2 -2
- package/lib/element/substitution/frame.js +24 -19
- package/lib/element/substitution/metaLevel.js +31 -27
- package/lib/element/substitution/reference.js +11 -10
- package/lib/element/substitution/statement.js +30 -23
- package/lib/element/substitution/term.js +11 -10
- package/lib/element/term.js +24 -20
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/variable.js +6 -2
- package/lib/process/assign.js +10 -4
- package/lib/process/unify.js +8 -8
- package/lib/process/validate.js +10 -8
- package/lib/utilities/context.js +68 -23
- package/lib/utilities/element.js +55 -27
- package/lib/utilities/json.js +8 -8
- package/lib/utilities/statement.js +1 -8
- package/lib/utilities/string.js +12 -1
- package/lib/utilities/unification.js +9 -7
- package/lib/utilities/validation.js +39 -31
- package/package.json +1 -1
- package/src/context/file/nominal.js +14 -16
- package/src/context/illative.js +17 -0
- package/src/context/nested.js +15 -0
- package/src/context/{scoped.js → proof.js} +73 -73
- package/src/context/thetic.js +17 -0
- package/src/context.js +23 -36
- package/src/element/assertion/contained.js +28 -28
- package/src/element/assertion/defined.js +23 -23
- package/src/element/assertion/property.js +15 -14
- package/src/element/assertion/satisfies.js +7 -9
- package/src/element/assertion/subproof.js +26 -31
- package/src/element/assertion/type.js +10 -12
- package/src/element/assumption.js +33 -54
- package/src/element/combinator/bracketed.js +2 -2
- package/src/element/combinator.js +23 -29
- package/src/element/conclusion.js +37 -40
- package/src/element/constructor.js +29 -34
- package/src/element/deduction.js +36 -39
- package/src/element/equality.js +16 -18
- package/src/element/equivalence.js +76 -67
- package/src/element/frame.js +42 -34
- package/src/element/hypothesis.js +7 -6
- package/src/element/judgement.js +34 -44
- package/src/element/label.js +25 -31
- package/src/element/metavariable.js +32 -12
- package/src/element/proofAssertion/premise.js +63 -49
- package/src/element/proofAssertion/step.js +43 -23
- package/src/element/proofAssertion/supposition.js +64 -50
- package/src/element/proofAssertion.js +0 -22
- package/src/element/reference.js +119 -80
- package/src/element/signature.js +5 -2
- package/src/element/statement.js +30 -35
- package/src/element/subproof.js +1 -1
- package/src/element/substitution/frame.js +27 -26
- package/src/element/substitution/metaLevel.js +38 -42
- package/src/element/substitution/reference.js +13 -14
- package/src/element/substitution/statement.js +35 -33
- package/src/element/substitution/term.js +13 -14
- package/src/element/term.js +42 -34
- package/src/element/topLevelMetaAssertion.js +1 -1
- package/src/element/variable.js +8 -1
- package/src/process/assign.js +9 -3
- package/src/process/unify.js +7 -7
- package/src/process/validate.js +9 -8
- package/src/utilities/context.js +82 -31
- package/src/utilities/element.js +68 -31
- package/src/utilities/json.js +13 -13
- package/src/utilities/statement.js +1 -9
- package/src/utilities/string.js +16 -2
- package/src/utilities/unification.js +10 -9
- package/src/utilities/validation.js +50 -38
- package/lib/context/scoped.js +0 -232
- package/lib/utilities/term.js +0 -17
- package/src/utilities/term.js +0 -10
|
@@ -4,10 +4,9 @@ import Substitution from "../substitution";
|
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
6
|
import { instantiateMetaLevelSubstitution } from "../../process/instantiate";
|
|
7
|
-
import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
|
|
8
7
|
import { metaLevelSubstitutionFromMetaLevelSubstitutionNode } from "../../utilities/element";
|
|
9
8
|
import { metaLevelSubstitutionStringFromStatementAndReference } from "../../utilities/string";
|
|
10
|
-
import {
|
|
9
|
+
import { descend, simplify, serialise, unserialise, instantiate } from "../../utilities/context";
|
|
11
10
|
|
|
12
11
|
export default define(class MetaLevelSubstitution extends Substitution {
|
|
13
12
|
constructor(context, string, node, targetReference, replacementStatement) {
|
|
@@ -132,12 +131,13 @@ export default define(class MetaLevelSubstitution extends Substitution {
|
|
|
132
131
|
|
|
133
132
|
context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level substitution's '${replacementStatementString}' replacement statement...`);
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
replacementStatement = this.replacementStatement.validate(
|
|
134
|
+
descend((context) => {
|
|
135
|
+
const replacementStatement = this.replacementStatement.validate(context);
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
if (replacementStatement !== null) {
|
|
138
|
+
replacementStatementValidates = true;
|
|
139
|
+
}
|
|
140
|
+
}, context);
|
|
141
141
|
|
|
142
142
|
if (replacementStatementValidates) {
|
|
143
143
|
context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level substitution's '${replacementStatementString}' replacement statement.`);
|
|
@@ -147,57 +147,53 @@ export default define(class MetaLevelSubstitution extends Substitution {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
toJSON() {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
context = this.getContext();
|
|
153
|
-
|
|
154
|
-
const ephemeralContext = context, ///
|
|
155
|
-
ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
|
|
156
|
-
contextJSON = ephemeralContextJSON; ///
|
|
157
|
-
|
|
158
|
-
context = contextJSON; ///
|
|
150
|
+
const context = this.getContext();
|
|
159
151
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
152
|
+
return serialise((context) => {
|
|
153
|
+
const string = this.getString(),
|
|
154
|
+
json = {
|
|
155
|
+
context,
|
|
156
|
+
string
|
|
157
|
+
};
|
|
165
158
|
|
|
166
|
-
|
|
159
|
+
return json;
|
|
160
|
+
}, context);
|
|
167
161
|
}
|
|
168
162
|
|
|
169
163
|
static name = "MetaLevelSubstitution";
|
|
170
164
|
|
|
171
165
|
static fromJSON(json, context) {
|
|
172
|
-
|
|
166
|
+
let metaLevelSubstitution;
|
|
173
167
|
|
|
174
|
-
context
|
|
168
|
+
unserialise((json, context) => {
|
|
169
|
+
instantiate((context) => {
|
|
170
|
+
const { string } = json,
|
|
171
|
+
metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
|
|
172
|
+
node = metaLevelSubstitutionNode, ///
|
|
173
|
+
targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
|
|
174
|
+
replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
node = metaLevelSubstitutionNode, ///
|
|
180
|
-
targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
|
|
181
|
-
replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
|
|
182
|
-
metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
|
|
176
|
+
metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
|
|
177
|
+
}, context);
|
|
178
|
+
}, json, context);
|
|
183
179
|
|
|
184
|
-
|
|
185
|
-
}, context);
|
|
180
|
+
return metaLevelSubstitution;
|
|
186
181
|
}
|
|
187
182
|
|
|
188
183
|
static fromStatementAndReference(statement, reference, context) {
|
|
189
|
-
|
|
184
|
+
let metaLevelSubstitution;
|
|
190
185
|
|
|
191
|
-
context
|
|
186
|
+
simplify((context) => {
|
|
187
|
+
instantiate((context) => {
|
|
188
|
+
const metaLevelSubstitutionString = metaLevelSubstitutionStringFromStatementAndReference(statement, reference),
|
|
189
|
+
string = metaLevelSubstitutionString, ///
|
|
190
|
+
metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context);
|
|
192
191
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
string = metaLevelSubstitutionString, ///
|
|
196
|
-
metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
|
|
197
|
-
metaLevelSubstitution = metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
|
|
198
|
-
|
|
199
|
-
return metaLevelSubstitution;
|
|
192
|
+
metaLevelSubstitution = metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
|
|
193
|
+
}, context);
|
|
200
194
|
}, context);
|
|
195
|
+
|
|
196
|
+
return metaLevelSubstitution;
|
|
201
197
|
}
|
|
202
198
|
});
|
|
203
199
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { simplify, instantiate } from "../../utilities/context";
|
|
6
7
|
import { instantiateReferenceSubstitution } from "../../process/instantiate";
|
|
7
|
-
import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
|
|
8
8
|
import { referenceSubstitutionFromReferenceSubstitutionNode } from "../../utilities/element";
|
|
9
9
|
import { referenceSubstitutionStringFromReferenceAndMetavariable } from "../../utilities/string";
|
|
10
10
|
|
|
@@ -163,7 +163,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
163
163
|
const { name } = json;
|
|
164
164
|
|
|
165
165
|
if (this.name === name) {
|
|
166
|
-
|
|
166
|
+
instantiate((context) => {
|
|
167
167
|
const { string } = json,
|
|
168
168
|
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
|
|
169
169
|
node = referenceSubstitutionNode, ///
|
|
@@ -172,9 +172,7 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
172
172
|
|
|
173
173
|
context = null;
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return referenceSubstitutionn;
|
|
175
|
+
referenceSubstitutionn = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
|
|
178
176
|
}, context);
|
|
179
177
|
}
|
|
180
178
|
|
|
@@ -182,18 +180,19 @@ export default define(class ReferenceSubstitution extends Substitution {
|
|
|
182
180
|
}
|
|
183
181
|
|
|
184
182
|
static fromReferenceAndMetavariable(reference, metavariable, context) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
context = santisedContext; ///
|
|
183
|
+
let referenceSubstitution;
|
|
188
184
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
simplify((context) => {
|
|
186
|
+
instantiate((context) => {
|
|
187
|
+
const referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
|
|
188
|
+
string = referenceSubstitutionString, ///
|
|
189
|
+
referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
|
|
194
190
|
|
|
195
|
-
|
|
191
|
+
referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
|
|
192
|
+
}, context);
|
|
196
193
|
}, context);
|
|
194
|
+
|
|
195
|
+
return referenceSubstitution;
|
|
197
196
|
}
|
|
198
197
|
});
|
|
199
198
|
|
|
@@ -6,8 +6,8 @@ import { define } from "../../elements";
|
|
|
6
6
|
import { unifySubstitution } from "../../process/unify";
|
|
7
7
|
import { stripBracketsFromStatement } from "../../utilities/brackets";
|
|
8
8
|
import { instantiateStatementSubstitution } from "../../process/instantiate";
|
|
9
|
+
import { join, simplify, descend, reconcile, instantiate } from "../../utilities/context";
|
|
9
10
|
import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
|
|
10
|
-
import { join, reconcile, instantiate, sanitisedContextFromContext } from "../../utilities/context";
|
|
11
11
|
import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
|
|
12
12
|
|
|
13
13
|
export default define(class StatementSubstitution extends Substitution {
|
|
@@ -158,12 +158,13 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
158
158
|
const targetStatementSingular = this.targetStatement.isSingular();
|
|
159
159
|
|
|
160
160
|
if (targetStatementSingular) {
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
descend((context) => {
|
|
162
|
+
const targetStatement = this.targetStatement.validate(context);
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
if (targetStatement !== null) {
|
|
165
|
+
targetStatementValidates = true;
|
|
166
|
+
}
|
|
167
|
+
}, context);
|
|
167
168
|
} else {
|
|
168
169
|
context.debug(`The '${statementSubstitutionString}' statement substitution's '${targetStatementString}' target statement is not singular.`);
|
|
169
170
|
}
|
|
@@ -184,12 +185,13 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
184
185
|
|
|
185
186
|
context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${replacementStatementString}' replacement statement...`);
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
descend((context) => {
|
|
189
|
+
const replacementStatement = this.replacementStatement.validate(context);
|
|
189
190
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
if (replacementStatement !== null) {
|
|
192
|
+
replacementStatementValidates = true;
|
|
193
|
+
}
|
|
194
|
+
}, context);
|
|
193
195
|
|
|
194
196
|
if (replacementStatementValidates) {
|
|
195
197
|
context.debug(`...validated the '${statementSubstitutionString}' statement substitution's '${replacementStatementString}' replacement statement.`);
|
|
@@ -344,7 +346,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
344
346
|
const { name } = json;
|
|
345
347
|
|
|
346
348
|
if (this.name === name) {
|
|
347
|
-
|
|
349
|
+
instantiate((context) => {
|
|
348
350
|
const { string } = json,
|
|
349
351
|
statementSubstitutionNode = instantiateStatementSubstitution(string, context),
|
|
350
352
|
node = statementSubstitutionNode, ///
|
|
@@ -353,9 +355,7 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
353
355
|
|
|
354
356
|
context = null;
|
|
355
357
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return statementSubstitutionn;
|
|
358
|
+
statementSubstitutionn = new StatementSubstitution(context, string, node, targetStatement, replacementStatement);
|
|
359
359
|
}, context);
|
|
360
360
|
}
|
|
361
361
|
|
|
@@ -365,35 +365,37 @@ export default define(class StatementSubstitution extends Substitution {
|
|
|
365
365
|
static fromStatementAndMetavariable(statement, metavariable, context) {
|
|
366
366
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
367
367
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
context = santisedContext; ///
|
|
368
|
+
let statementSubstitution;
|
|
371
369
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
370
|
+
simplify((context) => {
|
|
371
|
+
instantiate((context) => {
|
|
372
|
+
const statementSubstitutionString = statementSubstitutionStringFromStatementAndMetavariable(statement, metavariable, context),
|
|
373
|
+
string = statementSubstitutionString, ///
|
|
374
|
+
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
377
375
|
|
|
378
|
-
|
|
376
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
377
|
+
}, context);
|
|
379
378
|
}, context);
|
|
379
|
+
|
|
380
|
+
return statementSubstitution;
|
|
380
381
|
}
|
|
381
382
|
|
|
382
383
|
static fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) {
|
|
383
384
|
statement = stripBracketsFromStatement(statement, context); ///
|
|
384
385
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
context = santisedContext; ///
|
|
386
|
+
let statementSubstitution;
|
|
388
387
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
388
|
+
simplify((context) => {
|
|
389
|
+
instantiate((context) => {
|
|
390
|
+
const statementSubstitutionString = statementSubstitutionStringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution),
|
|
391
|
+
string = statementSubstitutionString, ///
|
|
392
|
+
statementSubstitutionNode = instantiateStatementSubstitution(string, context);
|
|
394
393
|
|
|
395
|
-
|
|
394
|
+
statementSubstitution = statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context);
|
|
395
|
+
}, context);
|
|
396
396
|
}, context);
|
|
397
|
+
|
|
398
|
+
return statementSubstitution;
|
|
397
399
|
}
|
|
398
400
|
});
|
|
399
401
|
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
|
|
5
5
|
import { define } from "../../elements";
|
|
6
|
+
import { simplify, instantiate } from "../../utilities/context";
|
|
6
7
|
import { stripBracketsFromTerm } from "../../utilities/brackets";
|
|
7
8
|
import { instantiateTermSubstitution } from "../../process/instantiate";
|
|
8
|
-
import { instantiate, sanitisedContextFromContext } from "../../utilities/context";
|
|
9
9
|
import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
|
|
10
10
|
import { termSubstitutionFromStatementNode, termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
|
|
11
11
|
|
|
@@ -184,7 +184,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
184
184
|
const { name } = json;
|
|
185
185
|
|
|
186
186
|
if (this.name === name) {
|
|
187
|
-
|
|
187
|
+
instantiate((context) => {
|
|
188
188
|
const { string } = json,
|
|
189
189
|
termSubstitutionNode = instantiateTermSubstitution(string, context),
|
|
190
190
|
node = termSubstitutionNode, ///
|
|
@@ -193,9 +193,7 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
193
193
|
|
|
194
194
|
context = null;
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return termSubstitutionn;
|
|
196
|
+
termSubstitutionn = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
|
|
199
197
|
}, context);
|
|
200
198
|
}
|
|
201
199
|
|
|
@@ -212,18 +210,19 @@ export default define(class TermSubstitution extends Substitution {
|
|
|
212
210
|
static fromTermAndVariable(term, variable, context) {
|
|
213
211
|
term = stripBracketsFromTerm(term, context); ///
|
|
214
212
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
context = santisedContext; ///
|
|
213
|
+
let termSubstitution;
|
|
218
214
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
215
|
+
simplify((context) => {
|
|
216
|
+
instantiate((context) => {
|
|
217
|
+
const termSubstitutionString = termSubstitutionStringFromTermAndVariable(term, variable),
|
|
218
|
+
string = termSubstitutionString, ///
|
|
219
|
+
termSubstitutionNode = instantiateTermSubstitution(string, context);
|
|
224
220
|
|
|
225
|
-
|
|
221
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
222
|
+
}, context);
|
|
226
223
|
}, context);
|
|
224
|
+
|
|
225
|
+
return termSubstitution;
|
|
227
226
|
}
|
|
228
227
|
});
|
|
229
228
|
|
package/src/element/term.js
CHANGED
|
@@ -41,40 +41,6 @@ export default define(class Term extends Element {
|
|
|
41
41
|
return variableIdentifier;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
matchTermNode(termNode) {
|
|
45
|
-
const node = termNode, ///
|
|
46
|
-
nodeMatches = this.matchNode(node),
|
|
47
|
-
termNodeMatches = nodeMatches; ///
|
|
48
|
-
|
|
49
|
-
return termNodeMatches;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
compareVariableIdentifier(variableIdentifier) {
|
|
53
|
-
let comparesToVariableIdentifier = false;
|
|
54
|
-
|
|
55
|
-
const singular = this.isSingular();
|
|
56
|
-
|
|
57
|
-
if (singular) {
|
|
58
|
-
const variableIdentifierA = variableIdentifier; ///
|
|
59
|
-
|
|
60
|
-
variableIdentifier = this.getVariableIdentifier();
|
|
61
|
-
|
|
62
|
-
const variableIdentifierB = variableIdentifier;
|
|
63
|
-
|
|
64
|
-
comparesToVariableIdentifier = (variableIdentifierA === variableIdentifierB);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return comparesToVariableIdentifier;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
findValidTerm(context) {
|
|
71
|
-
const termNode = this.getTermNode(),
|
|
72
|
-
term = context.findTermByTermNode(termNode),
|
|
73
|
-
validTerm = term; ///
|
|
74
|
-
|
|
75
|
-
return validTerm;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
44
|
isEqualTo(term) {
|
|
79
45
|
const termNode = term.getNode(),
|
|
80
46
|
termNodeMatches = this.matchTermNode(termNode),
|
|
@@ -127,6 +93,22 @@ export default define(class Term extends Element {
|
|
|
127
93
|
return implicitlyGrounded;
|
|
128
94
|
}
|
|
129
95
|
|
|
96
|
+
matchTermNode(termNode) {
|
|
97
|
+
const node = termNode, ///
|
|
98
|
+
nodeMatches = this.matchNode(node),
|
|
99
|
+
termNodeMatches = nodeMatches; ///
|
|
100
|
+
|
|
101
|
+
return termNodeMatches;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
compareTerm(term) {
|
|
105
|
+
const termNode = term.getNode(),
|
|
106
|
+
termNodeMatches = this.matchNode(termNode),
|
|
107
|
+
comparesTo = termNodeMatches; ///
|
|
108
|
+
|
|
109
|
+
return comparesTo;
|
|
110
|
+
}
|
|
111
|
+
|
|
130
112
|
compareParameter(parameter) {
|
|
131
113
|
let comparesToParamter = false;
|
|
132
114
|
|
|
@@ -147,6 +129,32 @@ export default define(class Term extends Element {
|
|
|
147
129
|
return comparesToParamter;
|
|
148
130
|
}
|
|
149
131
|
|
|
132
|
+
compareVariableIdentifier(variableIdentifier) {
|
|
133
|
+
let comparesToVariableIdentifier = false;
|
|
134
|
+
|
|
135
|
+
const singular = this.isSingular();
|
|
136
|
+
|
|
137
|
+
if (singular) {
|
|
138
|
+
const variableIdentifierA = variableIdentifier; ///
|
|
139
|
+
|
|
140
|
+
variableIdentifier = this.getVariableIdentifier();
|
|
141
|
+
|
|
142
|
+
const variableIdentifierB = variableIdentifier;
|
|
143
|
+
|
|
144
|
+
comparesToVariableIdentifier = (variableIdentifierA === variableIdentifierB);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return comparesToVariableIdentifier;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
findValidTerm(context) {
|
|
151
|
+
const termNode = this.getTermNode(),
|
|
152
|
+
term = context.findTermByTermNode(termNode),
|
|
153
|
+
validTerm = term; ///
|
|
154
|
+
|
|
155
|
+
return validTerm;
|
|
156
|
+
}
|
|
157
|
+
|
|
150
158
|
validate(context, validateForwards) {
|
|
151
159
|
let term = null;
|
|
152
160
|
|
package/src/element/variable.js
CHANGED
|
@@ -7,8 +7,8 @@ import elements from "../elements";
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
8
|
import { instantiate } from "../utilities/context";
|
|
9
9
|
import { instantiateVariable } from "../process/instantiate";
|
|
10
|
-
import {identifierFromVarialbeNode, variableFromVariableNode} from "../utilities/element";
|
|
11
10
|
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
11
|
+
import { variableFromTermNode, identifierFromVarialbeNode } from "../utilities/element";
|
|
12
12
|
|
|
13
13
|
export default define(class Variable extends Element {
|
|
14
14
|
constructor(context, string, node, type, identifier) {
|
|
@@ -198,4 +198,11 @@ export default define(class Variable extends Element {
|
|
|
198
198
|
return variable;
|
|
199
199
|
}, context);
|
|
200
200
|
}
|
|
201
|
+
|
|
202
|
+
static fromTerm(term, context) {
|
|
203
|
+
const termNode = term.getNode(),
|
|
204
|
+
variable = variableFromTermNode(termNode, context);
|
|
205
|
+
|
|
206
|
+
return variable;
|
|
207
|
+
}
|
|
201
208
|
});
|
package/src/process/assign.js
CHANGED
|
@@ -23,7 +23,9 @@ export function judgementAssignmentFromJudgement(judgement, context) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function leftVariableAssignmentFromEquality(equality, context) {
|
|
26
|
-
let leftVariableAssignment =
|
|
26
|
+
let leftVariableAssignment = (contxt) => {
|
|
27
|
+
///
|
|
28
|
+
};
|
|
27
29
|
|
|
28
30
|
const leftTermNode = equality.getLeftTermNode(),
|
|
29
31
|
singularVariableNode = leftTermNode.getSingularVariableNode();
|
|
@@ -39,7 +41,9 @@ export function leftVariableAssignmentFromEquality(equality, context) {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export function rightVariableAssignmentFromEquality(equality, context) {
|
|
42
|
-
let rightVariableAssignment =
|
|
44
|
+
let rightVariableAssignment = (context) => {
|
|
45
|
+
///
|
|
46
|
+
};
|
|
43
47
|
|
|
44
48
|
const rightTermNode = equality.getRightTermNode(),
|
|
45
49
|
singularVariableNode = rightTermNode.getSingularVariableNode();
|
|
@@ -55,7 +59,9 @@ export function rightVariableAssignmentFromEquality(equality, context) {
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
export function variableAssignmentFromTypeAssertion(typeAssertion, context) {
|
|
58
|
-
let variableAssignment =
|
|
62
|
+
let variableAssignment = (context) => {
|
|
63
|
+
///
|
|
64
|
+
};
|
|
59
65
|
|
|
60
66
|
const term = typeAssertion.getTerm(),
|
|
61
67
|
termSingular = term.isSingular();
|
package/src/process/unify.js
CHANGED
|
@@ -152,7 +152,7 @@ class CombinatorPass extends ZipPass {
|
|
|
152
152
|
{
|
|
153
153
|
generalNodeQuery: metaTypeNodeQuery,
|
|
154
154
|
specificNodeQuery: statementNodeQuery,
|
|
155
|
-
run: (generalMetaTypeNode, specificStatementNode,
|
|
155
|
+
run: (generalMetaTypeNode, specificStatementNode, generalContext, specificContext) => {
|
|
156
156
|
let success = false;
|
|
157
157
|
|
|
158
158
|
const metaTypeNode = generalMetaTypeNode, ///
|
|
@@ -167,7 +167,7 @@ class CombinatorPass extends ZipPass {
|
|
|
167
167
|
|
|
168
168
|
statement = statementFromStatementNode(statementNode, context);
|
|
169
169
|
|
|
170
|
-
statement = statement.validate(
|
|
170
|
+
statement = statement.validate(context); ///
|
|
171
171
|
|
|
172
172
|
if (statement !== null) {
|
|
173
173
|
success = true;
|
|
@@ -180,7 +180,7 @@ class CombinatorPass extends ZipPass {
|
|
|
180
180
|
{
|
|
181
181
|
generalNodeQuery: metaTypeNodeQuery,
|
|
182
182
|
specificNodeQuery: frameNodeQuery,
|
|
183
|
-
run: (generalMetaTypeNode, specificFrameNode,
|
|
183
|
+
run: (generalMetaTypeNode, specificFrameNode, generalContext, specificContext) => {
|
|
184
184
|
let success = false;
|
|
185
185
|
|
|
186
186
|
const metaTypeNode = generalMetaTypeNode, ///
|
|
@@ -195,7 +195,7 @@ class CombinatorPass extends ZipPass {
|
|
|
195
195
|
|
|
196
196
|
frame = frameFromFrameNode(frameNode, context);
|
|
197
197
|
|
|
198
|
-
frame = frame.validate(
|
|
198
|
+
frame = frame.validate(context); ///
|
|
199
199
|
|
|
200
200
|
if (frame !== null) {
|
|
201
201
|
success = true;
|
|
@@ -208,7 +208,7 @@ class CombinatorPass extends ZipPass {
|
|
|
208
208
|
{
|
|
209
209
|
generalNodeQuery: typeNodeQuery,
|
|
210
210
|
specificNodeQuery: termNodeQuery,
|
|
211
|
-
run: (generalTypeNode, specificTermNode,
|
|
211
|
+
run: (generalTypeNode, specificTermNode, generalContext, specificContext) => {
|
|
212
212
|
let success = false;
|
|
213
213
|
|
|
214
214
|
const typeNode = generalTypeNode, ///
|
|
@@ -466,13 +466,13 @@ export function unifyTermWithConstructor(term, constructor, generalContext, spec
|
|
|
466
466
|
return termUnifiesWithConstructor;
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
-
export function unifyStatementWithCombinator(statement, combinator,
|
|
469
|
+
export function unifyStatementWithCombinator(statement, combinator, generalContext, specificContext) {
|
|
470
470
|
let statementUnifiesWithCombinator = false;
|
|
471
471
|
|
|
472
472
|
const statementNode = statement.getNode(),
|
|
473
473
|
combinatorStatement = combinator.getStatement(),
|
|
474
474
|
combinatorStatementNode = combinatorStatement.getNode(),
|
|
475
|
-
success = combinatorPass.run(combinatorStatementNode, statementNode,
|
|
475
|
+
success = combinatorPass.run(combinatorStatementNode, statementNode, generalContext, specificContext);
|
|
476
476
|
|
|
477
477
|
if (success) {
|
|
478
478
|
statementUnifiesWithCombinator = true;
|
package/src/process/validate.js
CHANGED
|
@@ -4,6 +4,7 @@ import { SimplePass } from "occam-languages";
|
|
|
4
4
|
import { queryUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
6
|
import { termFromTermNode, statementFromStatementNode } from "../utilities/element";
|
|
7
|
+
import {descend} from "../utilities/context";
|
|
7
8
|
|
|
8
9
|
const { nodeQuery } = queryUtilities;
|
|
9
10
|
|
|
@@ -32,17 +33,17 @@ class CombinatorPass extends SimplePass {
|
|
|
32
33
|
run: (statementNode, context) => {
|
|
33
34
|
let success = false;
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
descend((context) => {
|
|
37
|
+
let statement;
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
statement = statementFromStatementNode(statementNode, context);
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
statement = statement.validate(context); ///
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
43
|
+
if (statement !== null) {
|
|
44
|
+
success = true;
|
|
45
|
+
}
|
|
46
|
+
}, context);
|
|
46
47
|
|
|
47
48
|
return success;
|
|
48
49
|
}
|