occam-verify-cli 1.0.651 → 1.0.655
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/ephemeral.js +42 -1
- package/lib/context/file/nominal.js +23 -4
- package/lib/element/assertion/contained.js +24 -1
- package/lib/element/assertion/defined.js +24 -1
- package/lib/element/assertion/property.js +24 -1
- package/lib/element/assertion/satisfies.js +24 -1
- package/lib/element/assertion/subproof.js +37 -1
- package/lib/element/assertion/type.js +27 -1
- package/lib/element/assumption.js +2 -7
- package/lib/element/combinator.js +16 -3
- package/lib/element/conclusion.js +18 -3
- package/lib/element/constructor.js +8 -2
- package/lib/element/declaration/complexType.js +52 -52
- package/lib/element/declaration/constructor.js +38 -38
- package/lib/element/declaration/metavariable.js +35 -35
- package/lib/element/declaration/simpleType.js +42 -42
- package/lib/element/declaration/typePrefix.js +32 -32
- package/lib/element/declaration/variable.js +39 -39
- package/lib/element/deduction.js +2 -4
- package/lib/element/equivalences.js +3 -3
- package/lib/element/frame.js +2 -9
- package/lib/element/hypothesis.js +18 -24
- package/lib/element/label.js +14 -3
- package/lib/element/metavariable.js +10 -3
- package/lib/element/parameter.js +2 -3
- package/lib/element/procedureCall.js +2 -3
- package/lib/element/procedureReference.js +2 -3
- package/lib/element/proofAssertion/premise.js +54 -49
- package/lib/element/proofAssertion/step.js +86 -86
- package/lib/element/proofAssertion/supposition.js +39 -49
- package/lib/element/property.js +2 -3
- package/lib/element/reference.js +2 -3
- package/lib/element/rule.js +2 -4
- package/lib/element/section.js +14 -14
- package/lib/element/signature.js +2 -3
- package/lib/element/statement.js +8 -2
- package/lib/element/subproof.js +8 -8
- package/lib/element/substitution/statement.js +2 -2
- package/lib/element/term.js +15 -29
- package/lib/element/topLevelAssertion/axiom.js +63 -63
- package/lib/element/topLevelMetaAssertion.js +15 -15
- package/lib/element/type.js +2 -3
- package/lib/element/typePrefix.js +2 -3
- package/lib/element/variable.js +2 -2
- package/lib/process/instantiate.js +38 -2
- package/lib/utilities/equivalence.js +27 -0
- package/lib/utilities/json.js +197 -30
- package/package.json +1 -1
- package/src/context/ephemeral.js +84 -0
- package/src/context/file/nominal.js +38 -18
- package/src/element/assertion/contained.js +25 -0
- package/src/element/assertion/defined.js +25 -0
- package/src/element/assertion/property.js +25 -0
- package/src/element/assertion/satisfies.js +25 -0
- package/src/element/assertion/subproof.js +46 -0
- package/src/element/assertion/type.js +32 -0
- package/src/element/assumption.js +1 -12
- package/src/element/combinator.js +33 -3
- package/src/element/conclusion.js +33 -3
- package/src/element/constructor.js +17 -4
- package/src/element/declaration/complexType.js +49 -49
- package/src/element/declaration/constructor.js +32 -32
- package/src/element/declaration/metavariable.js +26 -26
- package/src/element/declaration/simpleType.js +34 -34
- package/src/element/declaration/typePrefix.js +35 -35
- package/src/element/declaration/variable.js +30 -30
- package/src/element/deduction.js +1 -6
- package/src/element/equivalences.js +1 -1
- package/src/element/frame.js +1 -15
- package/src/element/hypothesis.js +23 -34
- package/src/element/label.js +22 -5
- package/src/element/metavariable.js +20 -2
- package/src/element/parameter.js +1 -6
- package/src/element/procedureCall.js +1 -7
- package/src/element/procedureReference.js +1 -6
- package/src/element/proofAssertion/premise.js +54 -39
- package/src/element/proofAssertion/step.js +62 -62
- package/src/element/proofAssertion/supposition.js +27 -44
- package/src/element/property.js +1 -6
- package/src/element/reference.js +1 -6
- package/src/element/rule.js +3 -11
- package/src/element/section.js +12 -12
- package/src/element/signature.js +1 -7
- package/src/element/statement.js +13 -1
- package/src/element/subproof.js +6 -6
- package/src/element/substitution/statement.js +1 -1
- package/src/element/term.js +16 -24
- package/src/element/topLevelAssertion/axiom.js +45 -45
- package/src/element/topLevelMetaAssertion.js +19 -19
- package/src/element/type.js +1 -10
- package/src/element/typePrefix.js +1 -6
- package/src/element/variable.js +1 -1
- package/src/process/instantiate.js +26 -2
- package/src/utilities/equivalence.js +26 -0
- package/src/utilities/json.js +233 -37
package/src/element/term.js
CHANGED
|
@@ -4,10 +4,13 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
|
+
import { literally } from "../utilities/context";
|
|
7
8
|
import { validateTerms } from "../utilities/validation";
|
|
8
|
-
import {
|
|
9
|
+
import { instantiateTerm } from "../process/instantiate";
|
|
10
|
+
import { variablesFromTerm } from "../utilities/equivalence";
|
|
11
|
+
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
9
12
|
|
|
10
|
-
const { filter
|
|
13
|
+
const { filter } = arrayUtilities;
|
|
11
14
|
|
|
12
15
|
export default define(class Term extends Element {
|
|
13
16
|
constructor(context, string, node, type) {
|
|
@@ -234,28 +237,17 @@ export default define(class Term extends Element {
|
|
|
234
237
|
static name = "Term";
|
|
235
238
|
|
|
236
239
|
static fromJSON(json, context) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
variableNodes = termNode.getVariableNodes(),
|
|
244
|
-
variables = variableNodes.map((variableNode) => {
|
|
245
|
-
const variableIdentifier = variableNode.getVariableIdentifier(),
|
|
246
|
-
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
240
|
+
const term = literally((context) => {
|
|
241
|
+
const { string } = json,
|
|
242
|
+
termNode = instantiateTerm(string, context),
|
|
243
|
+
node = termNode, ///
|
|
244
|
+
type = typeFromJSON(json, context),
|
|
245
|
+
term = new Term(context, string, node, type);
|
|
247
246
|
|
|
248
|
-
|
|
249
|
-
});
|
|
247
|
+
return term;
|
|
250
248
|
|
|
251
|
-
|
|
252
|
-
const variableAEqualToVariableB = variableA.isEqualTo(variableB);
|
|
253
|
-
|
|
254
|
-
if (!variableAEqualToVariableB) {
|
|
255
|
-
return true;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
return variables;
|
|
260
|
-
}
|
|
249
|
+
}, context);
|
|
261
250
|
|
|
251
|
+
return term;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
@@ -19,23 +19,6 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
19
19
|
return satisfiable;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
verifySignature() {
|
|
23
|
-
let signatureVerifies;
|
|
24
|
-
|
|
25
|
-
const satisfiable = this.isSatisfiable();
|
|
26
|
-
|
|
27
|
-
if (satisfiable) {
|
|
28
|
-
const context = this.getContext(),
|
|
29
|
-
signature = this.getSignature();
|
|
30
|
-
|
|
31
|
-
signatureVerifies = signature.verify(context);
|
|
32
|
-
} else {
|
|
33
|
-
signatureVerifies = true
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return signatureVerifies;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
22
|
compareSignature(signature, substitutions, context) {
|
|
40
23
|
let comparesToSignature = false;
|
|
41
24
|
|
|
@@ -59,6 +42,51 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
59
42
|
return comparesToSignature;
|
|
60
43
|
}
|
|
61
44
|
|
|
45
|
+
async verify() {
|
|
46
|
+
let verifies;
|
|
47
|
+
|
|
48
|
+
const context = this.getContext();
|
|
49
|
+
|
|
50
|
+
await this.break(context);
|
|
51
|
+
|
|
52
|
+
const axiomString = this.getString(); ///
|
|
53
|
+
|
|
54
|
+
context.trace(`Verifying the '${axiomString}' axiom...`);
|
|
55
|
+
|
|
56
|
+
const signatureVerifies = this.verifySignature();
|
|
57
|
+
|
|
58
|
+
if (signatureVerifies) {
|
|
59
|
+
verifies = await super.verify();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (verifies) {
|
|
63
|
+
const axiom = this; ///
|
|
64
|
+
|
|
65
|
+
context.addAxiom(axiom);
|
|
66
|
+
|
|
67
|
+
context.debug(`...verified the '${axiomString}' axiom.`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return verifies;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
verifySignature() {
|
|
74
|
+
let signatureVerifies;
|
|
75
|
+
|
|
76
|
+
const satisfiable = this.isSatisfiable();
|
|
77
|
+
|
|
78
|
+
if (satisfiable) {
|
|
79
|
+
const context = this.getContext(),
|
|
80
|
+
signature = this.getSignature();
|
|
81
|
+
|
|
82
|
+
signatureVerifies = signature.verify(context);
|
|
83
|
+
} else {
|
|
84
|
+
signatureVerifies = true
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return signatureVerifies;
|
|
88
|
+
}
|
|
89
|
+
|
|
62
90
|
unifyStep(step, substitutions, context) {
|
|
63
91
|
let stepUnifies = false;
|
|
64
92
|
|
|
@@ -239,34 +267,6 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
239
267
|
return topLevelAssertionUnifies;
|
|
240
268
|
}
|
|
241
269
|
|
|
242
|
-
async verify() {
|
|
243
|
-
let verifies;
|
|
244
|
-
|
|
245
|
-
const context = this.getContext();
|
|
246
|
-
|
|
247
|
-
await this.break(context);
|
|
248
|
-
|
|
249
|
-
const axiomString = this.getString(); ///
|
|
250
|
-
|
|
251
|
-
context.trace(`Verifying the '${axiomString}' axiom...`);
|
|
252
|
-
|
|
253
|
-
const signatureVerifies = this.verifySignature();
|
|
254
|
-
|
|
255
|
-
if (signatureVerifies) {
|
|
256
|
-
verifies = await super.verify();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (verifies) {
|
|
260
|
-
const axiom = this; ///
|
|
261
|
-
|
|
262
|
-
context.addAxiom(axiom);
|
|
263
|
-
|
|
264
|
-
context.debug(`...verified the '${axiomString}' axiom.`);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return verifies;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
270
|
static name = "Axiom";
|
|
271
271
|
|
|
272
272
|
static fromJSON(json, context) { return TopLevelAssertion.fromJSON(Axiom, json, context); }
|
|
@@ -53,25 +53,6 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
53
53
|
return comparesToReference;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
verifyLabel() {
|
|
57
|
-
let labelVerifies;
|
|
58
|
-
|
|
59
|
-
const context = this.getContext(),
|
|
60
|
-
topLevelMetaAssertionString = this.getString(); ///
|
|
61
|
-
|
|
62
|
-
context.trace(`Verifiesing the '${topLevelMetaAssertionString}' top level meta assertion's label...`);
|
|
63
|
-
|
|
64
|
-
const nameOnly = true;
|
|
65
|
-
|
|
66
|
-
labelVerifies = this.label.verify(nameOnly);
|
|
67
|
-
|
|
68
|
-
if (labelVerifies) {
|
|
69
|
-
context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta assertion's label.`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return labelVerifies;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
56
|
async verify() {
|
|
76
57
|
let verifies = false;
|
|
77
58
|
|
|
@@ -107,6 +88,25 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
107
88
|
return verifies;
|
|
108
89
|
}
|
|
109
90
|
|
|
91
|
+
verifyLabel() {
|
|
92
|
+
let labelVerifies;
|
|
93
|
+
|
|
94
|
+
const context = this.getContext(),
|
|
95
|
+
topLevelMetaAssertionString = this.getString(); ///
|
|
96
|
+
|
|
97
|
+
context.trace(`Verifiesing the '${topLevelMetaAssertionString}' top level meta assertion's label...`);
|
|
98
|
+
|
|
99
|
+
const nameOnly = true;
|
|
100
|
+
|
|
101
|
+
labelVerifies = this.label.verify(nameOnly);
|
|
102
|
+
|
|
103
|
+
if (labelVerifies) {
|
|
104
|
+
context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta assertion's label.`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return labelVerifies;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
110
|
async verifyProof(context) {
|
|
111
111
|
let proofVerifies;
|
|
112
112
|
|
package/src/element/type.js
CHANGED
|
@@ -314,16 +314,7 @@ export default define(class Type extends Element {
|
|
|
314
314
|
static name = "Type";
|
|
315
315
|
|
|
316
316
|
static fromJSON(json, context) {
|
|
317
|
-
|
|
318
|
-
properties = propertiesFromJSON(json, context),
|
|
319
|
-
superTypes = superTypesFromJSON(json, context),
|
|
320
|
-
typeName = name, ///
|
|
321
|
-
typePrefixName = null,
|
|
322
|
-
string = typeStringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes),
|
|
323
|
-
node = null,
|
|
324
|
-
type = new Type(context, string, node, name, prefixName, superTypes, properties, provisional);
|
|
325
|
-
|
|
326
|
-
return type;
|
|
317
|
+
debugger
|
|
327
318
|
}
|
|
328
319
|
|
|
329
320
|
static fromName(name, context) {
|
|
@@ -40,11 +40,6 @@ export default define(class TypePrefix extends Element {
|
|
|
40
40
|
static name = "TypePrefix";
|
|
41
41
|
|
|
42
42
|
static fromJSON(json, context) {
|
|
43
|
-
|
|
44
|
-
string = name, ///
|
|
45
|
-
node = null,
|
|
46
|
-
typePrefix = new TypePrefix(context, string, node, name);
|
|
47
|
-
|
|
48
|
-
return typePrefix;
|
|
43
|
+
debugger
|
|
49
44
|
}
|
|
50
45
|
});
|
package/src/element/variable.js
CHANGED
|
@@ -1,34 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { ruleFromRuleName } from "../utilities/bnf";
|
|
4
|
-
import {
|
|
4
|
+
import { LABEL_RULE_NAME,
|
|
5
|
+
PREMISE_RULE_NAME,
|
|
6
|
+
STATEMENT_RULE_NAME,
|
|
7
|
+
REFERENCE_RULE_NAME,
|
|
5
8
|
COMBINATOR_RULE_NAME,
|
|
9
|
+
CONCLUSION_RULE_NAME,
|
|
6
10
|
CONSTRUCTOR_RULE_NAME,
|
|
7
11
|
EQUIVALENCE_RULE_NAME,
|
|
12
|
+
METAVARIABLE_RULE_NAME,
|
|
8
13
|
TERM_SUBSTITUTION_RULE_NAME,
|
|
9
14
|
FRAME_SUBSTITUTION_RULE_NAME,
|
|
15
|
+
SUBPROOF_ASSERTION_RULE_NAME,
|
|
10
16
|
STATEMENT_SUBSTITUTION_RULE_NAME,
|
|
11
17
|
REFERENCE_SUBSTITUTION_RULE_NAME } from "../ruleNames";
|
|
12
18
|
|
|
13
|
-
const
|
|
19
|
+
const labelPlaceholderRule = ruleFromRuleName(LABEL_RULE_NAME),
|
|
20
|
+
premisePlaceholderRule = ruleFromRuleName(PREMISE_RULE_NAME),
|
|
21
|
+
statementPlaceholderRule = ruleFromRuleName(STATEMENT_RULE_NAME),
|
|
22
|
+
referencePlaceholderRule = ruleFromRuleName(REFERENCE_RULE_NAME),
|
|
14
23
|
combinatorPlaceholderRule = ruleFromRuleName(COMBINATOR_RULE_NAME),
|
|
24
|
+
conclusionPlaceholderRule = ruleFromRuleName(CONCLUSION_RULE_NAME),
|
|
15
25
|
constructorPlaceholderRule = ruleFromRuleName(CONSTRUCTOR_RULE_NAME),
|
|
16
26
|
equivalencePlaceholderRule = ruleFromRuleName(EQUIVALENCE_RULE_NAME),
|
|
27
|
+
metavariablePlaceholderRule = ruleFromRuleName(METAVARIABLE_RULE_NAME),
|
|
28
|
+
subproofAssertionlaceholderRule = ruleFromRuleName(SUBPROOF_ASSERTION_RULE_NAME),
|
|
17
29
|
termSubstitutionPlaceholderRule = ruleFromRuleName(TERM_SUBSTITUTION_RULE_NAME),
|
|
18
30
|
frameSubstitutionPlaceholderRule = ruleFromRuleName(FRAME_SUBSTITUTION_RULE_NAME),
|
|
19
31
|
statementSubstitutionPlaceholderRule = ruleFromRuleName(STATEMENT_SUBSTITUTION_RULE_NAME),
|
|
20
32
|
referenceSubstitutionPlaceholderRule = ruleFromRuleName(REFERENCE_SUBSTITUTION_RULE_NAME);
|
|
21
33
|
|
|
34
|
+
export function instantiateLabel(string, context) { return instantiate(labelPlaceholderRule, string, context); }
|
|
35
|
+
|
|
36
|
+
export function instantiatePremise(string, context) { return instantiate(premisePlaceholderRule, string, context); }
|
|
37
|
+
|
|
38
|
+
export function instantiateStatement(string, context) { return instantiate(statementPlaceholderRule, string, context); }
|
|
39
|
+
|
|
22
40
|
export function instantiateReference(string, context) { return instantiate(referencePlaceholderRule, string, context); }
|
|
23
41
|
|
|
24
42
|
export function instantiateCombinator(string, context) { return instantiate(combinatorPlaceholderRule, string, context); }
|
|
25
43
|
|
|
44
|
+
export function instantiateConclusion(string, context) { return instantiate(conclusionPlaceholderRule, string, context); }
|
|
45
|
+
|
|
26
46
|
export function instantiateConstructor(string, context) { return instantiate(constructorPlaceholderRule, string, context); }
|
|
27
47
|
|
|
28
48
|
export function instantiateEquivalence(string, context) { return instantiate(equivalencePlaceholderRule, string, context); }
|
|
29
49
|
|
|
50
|
+
export function instantiateMetavariable(string, context) { return instantiate(metavariablePlaceholderRule, string, context); }
|
|
51
|
+
|
|
30
52
|
export function instantiateTermSubstitution(string, context) { return instantiate(termSubstitutionPlaceholderRule, string, context); }
|
|
31
53
|
|
|
54
|
+
export function instantiateSubproofAssertion(string, context) { return instantiate(subproofAssertionlaceholderRule, string, context); }
|
|
55
|
+
|
|
32
56
|
export function instantiateFrameSubstitution(string, context) { return instantiate(frameSubstitutionPlaceholderRule, string, context); }
|
|
33
57
|
|
|
34
58
|
export function instantiateStatementSubstitution(string, context) { return instantiate(statementSubstitutionPlaceholderRule, string, context); }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
const { compress } = arrayUtilities;
|
|
6
|
+
|
|
7
|
+
export function variablesFromTerm(term, context) {
|
|
8
|
+
const termNode = term.getNode(),
|
|
9
|
+
variableNodes = termNode.getVariableNodes(),
|
|
10
|
+
variables = variableNodes.map((variableNode) => {
|
|
11
|
+
const variableIdentifier = variableNode.getVariableIdentifier(),
|
|
12
|
+
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
13
|
+
|
|
14
|
+
return variable;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
compress(variables, (variableA, variableB) => {
|
|
18
|
+
const variableAEqualToVariableB = variableA.isEqualTo(variableB);
|
|
19
|
+
|
|
20
|
+
if (!variableAEqualToVariableB) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return variables;
|
|
26
|
+
}
|