occam-verify-cli 1.0.578 → 1.0.581
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/liminal.js +2 -2
- package/lib/context/literal.js +13 -34
- package/lib/context/nominal.js +134 -0
- package/lib/context.js +79 -1
- package/lib/element/parameter.js +2 -2
- package/lib/element/procedureCall.js +5 -4
- package/lib/element/proofAssertion/premise.js +4 -8
- package/lib/element/proofAssertion/supposition.js +3 -7
- package/lib/element/rule.js +16 -16
- package/lib/utilities/context.js +4 -3
- package/lib/utilities/instance.js +11 -3
- package/package.json +4 -4
- package/src/context/liminal.js +1 -1
- package/src/context/literal.js +15 -31
- package/src/context/nominal.js +43 -0
- package/src/context.js +78 -0
- package/src/element/parameter.js +1 -1
- package/src/element/procedureCall.js +7 -5
- package/src/element/proofAssertion/premise.js +3 -11
- package/src/element/proofAssertion/supposition.js +2 -10
- package/src/element/rule.js +16 -16
- package/src/utilities/context.js +4 -3
- package/src/utilities/instance.js +8 -2
package/src/context.js
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
import { Context as ContextBase } from "occam-languages";
|
|
4
4
|
|
|
5
5
|
export default class Context extends ContextBase {
|
|
6
|
+
getLexer() {
|
|
7
|
+
const context = this.getContext(),
|
|
8
|
+
lexer = context.getLexer();
|
|
9
|
+
|
|
10
|
+
return lexer;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getParser() {
|
|
14
|
+
const context = this.getContext(),
|
|
15
|
+
parser = context.getParser();
|
|
16
|
+
|
|
17
|
+
return parser;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getFilePath() {
|
|
21
|
+
const context = this.getContext(),
|
|
22
|
+
filePath = context.getFilePath();
|
|
23
|
+
|
|
24
|
+
return filePath;
|
|
25
|
+
}
|
|
26
|
+
|
|
6
27
|
getCombinators(includeRelease) {
|
|
7
28
|
const context = this.getContext(),
|
|
8
29
|
combinators = context.getCombinators(includeRelease);
|
|
@@ -10,6 +31,21 @@ export default class Context extends ContextBase {
|
|
|
10
31
|
return combinators;
|
|
11
32
|
}
|
|
12
33
|
|
|
34
|
+
getSubproofOrProofAssertions() {
|
|
35
|
+
const context = this.getContext(),
|
|
36
|
+
subproofOrProofAssertions = context.getSubproofOrProofAssertions();
|
|
37
|
+
|
|
38
|
+
return subproofOrProofAssertions;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
findMetavariable(metavariable) {
|
|
42
|
+
const context = this.getContext();
|
|
43
|
+
|
|
44
|
+
metavariable = context.findMetavariable(metavariable); ///
|
|
45
|
+
|
|
46
|
+
return metavariable;
|
|
47
|
+
}
|
|
48
|
+
|
|
13
49
|
findProcedureByName(name) {
|
|
14
50
|
const context = this.getContext(),
|
|
15
51
|
procedure = context.findProcedureByName(name);
|
|
@@ -17,6 +53,27 @@ export default class Context extends ContextBase {
|
|
|
17
53
|
return procedure;
|
|
18
54
|
}
|
|
19
55
|
|
|
56
|
+
findRuleByReference(reference) {
|
|
57
|
+
const context = this.getContext(),
|
|
58
|
+
rule = context.findRuleByReference(reference);
|
|
59
|
+
|
|
60
|
+
return rule;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
findFrameByFrameNode(frameNode) {
|
|
64
|
+
const context = this.getContext(),
|
|
65
|
+
frame = context.findFrameByFrameNode(frameNode);
|
|
66
|
+
|
|
67
|
+
return frame;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
findStatementByStatementNode(statementNode) {
|
|
71
|
+
const context = this.getContext(),
|
|
72
|
+
statement = context.findStatementByStatementNode(statementNode);
|
|
73
|
+
|
|
74
|
+
return statement;
|
|
75
|
+
}
|
|
76
|
+
|
|
20
77
|
findVariableByVariableIdentifier(variableIdentifier) {
|
|
21
78
|
const context = this.getContext(),
|
|
22
79
|
variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
@@ -31,6 +88,27 @@ export default class Context extends ContextBase {
|
|
|
31
88
|
return metavariable;
|
|
32
89
|
}
|
|
33
90
|
|
|
91
|
+
isLabelPresentByReference(reference) {
|
|
92
|
+
const context = this.getContext(),
|
|
93
|
+
labelPresent = context.isLabelPresentByReference(reference);
|
|
94
|
+
|
|
95
|
+
return labelPresent;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
isMetavariablePresentByReference(reference) {
|
|
99
|
+
const context = this.getContext(),
|
|
100
|
+
metavariablePresent = context.isMetavariablePresentByReference(reference);
|
|
101
|
+
|
|
102
|
+
return metavariablePresent;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
addJudgement(judgement) {
|
|
106
|
+
const context = this.getContext(),
|
|
107
|
+
judgementAdded = context.addJudgement(judgement);
|
|
108
|
+
|
|
109
|
+
return judgementAdded;
|
|
110
|
+
}
|
|
111
|
+
|
|
34
112
|
addSubproofOrProofAssertion(subproofOrProofAssertion) {
|
|
35
113
|
const context = this.getContext();
|
|
36
114
|
|
package/src/element/parameter.js
CHANGED
|
@@ -24,7 +24,7 @@ export default define(class Parameter extends Element {
|
|
|
24
24
|
let replacementNode = null;
|
|
25
25
|
|
|
26
26
|
const parameter = this, ///
|
|
27
|
-
substitution = substitutions.
|
|
27
|
+
substitution = substitutions.find((substitution) => {
|
|
28
28
|
const substitutionComparesToParamter = substitution.compareParameter(parameter);
|
|
29
29
|
|
|
30
30
|
if (substitutionComparesToParamter) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
|
-
import {
|
|
4
|
+
import { termsUtilities } from "occam-furtle";
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
import { parametersFromJSON, procedureReferenceFromJSON, parametersToParametersJSON, procedureReferenceToProcedureReferenceJSON } from "../utilities/json";
|
|
8
8
|
|
|
9
|
+
const { termsFromPrimitives } = termsUtilities;
|
|
10
|
+
|
|
9
11
|
export default define(class ProcedureCall extends Element {
|
|
10
12
|
constructor(context, string, node, parameters, procedureReference) {
|
|
11
13
|
super(context, string, node);
|
|
@@ -65,7 +67,7 @@ export default define(class ProcedureCall extends Element {
|
|
|
65
67
|
return validates;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
unifyIndependently(
|
|
70
|
+
unifyIndependently(context) {
|
|
69
71
|
let unifiesIndependently = false;
|
|
70
72
|
|
|
71
73
|
const procedureCallString = this.getString(); ///
|
|
@@ -74,11 +76,11 @@ export default define(class ProcedureCall extends Element {
|
|
|
74
76
|
|
|
75
77
|
const name = this.getName(),
|
|
76
78
|
nodes = this.findNodes(context),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
terms = termsFromPrimitives(nodes, context),
|
|
80
|
+
procedure = context.findProcedureByName(name);
|
|
79
81
|
|
|
80
82
|
try {
|
|
81
|
-
const value = procedure.call(
|
|
83
|
+
const value = procedure.call(terms, context),
|
|
82
84
|
boolean = value.getBoolean();
|
|
83
85
|
|
|
84
86
|
unifiesIndependently = boolean; ///
|
|
@@ -78,25 +78,17 @@ export default define(class Premise extends ProofAssertion {
|
|
|
78
78
|
return verifies;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
unifyIndependently(
|
|
81
|
+
unifyIndependently(context) {
|
|
82
82
|
let unifiesIndependently = false;
|
|
83
83
|
|
|
84
84
|
const premiseString = this.getString(); ///
|
|
85
85
|
|
|
86
86
|
context.trace(`Unifying the '${premiseString}' premise independently...`);
|
|
87
87
|
|
|
88
|
-
const specificContext = context; ///
|
|
89
|
-
|
|
90
|
-
context = this.getContext();
|
|
91
|
-
|
|
92
|
-
const generalContext = context; ///
|
|
93
|
-
|
|
94
|
-
context = specificContext; ///
|
|
95
|
-
|
|
96
88
|
const statement = this.getStatement();
|
|
97
89
|
|
|
98
90
|
if (statement !== null) {
|
|
99
|
-
const statementUnifiesIndependently = statement.unifyIndependently(
|
|
91
|
+
const statementUnifiesIndependently = statement.unifyIndependently(context);
|
|
100
92
|
|
|
101
93
|
if (statementUnifiesIndependently) {
|
|
102
94
|
unifiesIndependently = true;
|
|
@@ -104,7 +96,7 @@ export default define(class Premise extends ProofAssertion {
|
|
|
104
96
|
}
|
|
105
97
|
|
|
106
98
|
if (this.procedureCall !== null) {
|
|
107
|
-
const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(
|
|
99
|
+
const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(context);
|
|
108
100
|
|
|
109
101
|
if (procedureCallResolvedIndependently) {
|
|
110
102
|
unifiesIndependently = true;
|
|
@@ -85,18 +85,10 @@ export default define(class Supposition extends ProofAssertion {
|
|
|
85
85
|
|
|
86
86
|
context.trace(`Unifying the '${suppositionString}' supposition independently...`);
|
|
87
87
|
|
|
88
|
-
const specificContext = context; ///
|
|
89
|
-
|
|
90
|
-
context = this.getContext();
|
|
91
|
-
|
|
92
|
-
const generalContext = context; ///
|
|
93
|
-
|
|
94
|
-
context = specificContext; ///
|
|
95
|
-
|
|
96
88
|
const statement = this.getStatement();
|
|
97
89
|
|
|
98
90
|
if (statement !== null) {
|
|
99
|
-
const statementUnifiesIndependently = statement.unifyIndependently(
|
|
91
|
+
const statementUnifiesIndependently = statement.unifyIndependently(context);
|
|
100
92
|
|
|
101
93
|
if (statementUnifiesIndependently) {
|
|
102
94
|
unifiesIndependently = true;
|
|
@@ -104,7 +96,7 @@ export default define(class Supposition extends ProofAssertion {
|
|
|
104
96
|
}
|
|
105
97
|
|
|
106
98
|
if (this.procedureCall !== null) {
|
|
107
|
-
const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(
|
|
99
|
+
const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(context);
|
|
108
100
|
|
|
109
101
|
if (procedureCallResolvedIndependently) {
|
|
110
102
|
unifiesIndependently = true;
|
package/src/element/rule.js
CHANGED
|
@@ -146,6 +146,22 @@ export default define(class Rule extends Element {
|
|
|
146
146
|
return statementAndSubproofOrProofAssertionsUnify;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions, context) {
|
|
150
|
+
let subproofOrProofAssertionsUnifiesWithPremises;
|
|
151
|
+
|
|
152
|
+
subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
|
|
153
|
+
|
|
154
|
+
subproofOrProofAssertionsUnifiesWithPremises = backwardsEvery(this.premises, (premise) => {
|
|
155
|
+
const stepUnifiesWithPremise = this.unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise, context);
|
|
156
|
+
|
|
157
|
+
if (stepUnifiesWithPremise) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return subproofOrProofAssertionsUnifiesWithPremises;
|
|
163
|
+
}
|
|
164
|
+
|
|
149
165
|
unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise, context) {
|
|
150
166
|
let subproofOrProofAssertionsUnifiesWithPremise = false;
|
|
151
167
|
|
|
@@ -174,22 +190,6 @@ export default define(class Rule extends Element {
|
|
|
174
190
|
return subproofOrProofAssertionsUnifiesWithPremise;
|
|
175
191
|
}
|
|
176
192
|
|
|
177
|
-
unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions, context) {
|
|
178
|
-
let subproofOrProofAssertionsUnifiesWithPremises;
|
|
179
|
-
|
|
180
|
-
subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
|
|
181
|
-
|
|
182
|
-
subproofOrProofAssertionsUnifiesWithPremises = backwardsEvery(this.premises, (premise) => {
|
|
183
|
-
const stepUnifiesWithPremise = this.unifySubproofOrProofAssertionsWithPremise(subproofOrProofAssertions, premise, context);
|
|
184
|
-
|
|
185
|
-
if (stepUnifiesWithPremise) {
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
return subproofOrProofAssertionsUnifiesWithPremises;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
193
|
async verify() {
|
|
194
194
|
let verifies = false;
|
|
195
195
|
|
package/src/utilities/context.js
CHANGED
|
@@ -29,9 +29,10 @@ export function liminally(innerFunction, context) {
|
|
|
29
29
|
return innerFunction(context);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function literally(innerFunction) {
|
|
33
|
-
const literalContext = LiteralContext.fromNothing()
|
|
34
|
-
|
|
32
|
+
export function literally(innerFunction, context) {
|
|
33
|
+
const literalContext = LiteralContext.fromNothing(context);
|
|
34
|
+
|
|
35
|
+
context = literalContext; ///
|
|
35
36
|
|
|
36
37
|
return innerFunction(context);
|
|
37
38
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import nominalContext from "../context/nominal";
|
|
4
|
+
|
|
3
5
|
import { literally } from "../utilities/context";
|
|
4
6
|
import { BASE_TYPE_SYMBOL } from "../constants";
|
|
5
7
|
import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
|
|
@@ -11,6 +13,8 @@ let bracketedCombinator = null,
|
|
|
11
13
|
|
|
12
14
|
export function bracketedCombinatorFromNothing() {
|
|
13
15
|
if (bracketedCombinator === null) {
|
|
16
|
+
const context = nominalContext; ///
|
|
17
|
+
|
|
14
18
|
bracketedCombinator = literally((context) => {
|
|
15
19
|
const bracketedCombinatorString = `(${STATEMENT_META_TYPE_NAME})`,
|
|
16
20
|
string = bracketedCombinatorString, ///
|
|
@@ -19,7 +23,7 @@ export function bracketedCombinatorFromNothing() {
|
|
|
19
23
|
bracketedCombinator = combinatorFromCombinatorNode(bracketedCombinatorNode, context);
|
|
20
24
|
|
|
21
25
|
return bracketedCombinator;
|
|
22
|
-
});
|
|
26
|
+
}, context);
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
return bracketedCombinator;
|
|
@@ -27,6 +31,8 @@ export function bracketedCombinatorFromNothing() {
|
|
|
27
31
|
|
|
28
32
|
export function bracketedConstructorFromNothing() {
|
|
29
33
|
if (bracketedConstructor === null) {
|
|
34
|
+
const context = nominalContext; ///
|
|
35
|
+
|
|
30
36
|
bracketedConstructor = literally((context) => {
|
|
31
37
|
const bracketedConstructorString = `(${BASE_TYPE_SYMBOL})`,
|
|
32
38
|
string = bracketedConstructorString, ///
|
|
@@ -35,7 +41,7 @@ export function bracketedConstructorFromNothing() {
|
|
|
35
41
|
bracketedConstructor = constructorFromConstructorNode(bracketedConstructorNode, context);
|
|
36
42
|
|
|
37
43
|
return bracketedConstructor;
|
|
38
|
-
});
|
|
44
|
+
}, context);
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
return bracketedConstructor;
|