occam-verify-cli 0.0.1077 → 0.0.1078
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/assertion/contained.js +47 -27
- package/lib/assertion/defined.js +44 -22
- package/lib/context/local.js +5 -5
- package/lib/equality.js +2 -2
- package/lib/equivalence.js +8 -21
- package/lib/mixins/statement/resolve.js +54 -0
- package/lib/premise.js +18 -1
- package/lib/rule.js +54 -16
- package/lib/statement/unqualified.js +15 -1
- package/lib/statement.js +23 -1
- package/lib/substitution/statementForMetavariable.js +2 -2
- package/lib/term.js +15 -8
- package/lib/type.js +1 -8
- package/lib/utilities/equivalences.js +3 -3
- package/lib/utilities/substitutions.js +77 -0
- package/package.json +1 -1
- package/src/assertion/contained.js +62 -32
- package/src/assertion/defined.js +63 -32
- package/src/context/local.js +3 -3
- package/src/equality.js +3 -2
- package/src/equivalence.js +6 -18
- package/src/mixins/statement/resolve.js +68 -0
- package/src/premise.js +24 -0
- package/src/rule.js +60 -16
- package/src/statement/unqualified.js +18 -0
- package/src/statement.js +30 -0
- package/src/substitution/statementForMetavariable.js +2 -2
- package/src/term.js +17 -7
- package/src/type.js +0 -6
- package/src/utilities/equivalences.js +2 -2
- package/src/utilities/substitutions.js +77 -0
package/src/statement.js
CHANGED
|
@@ -4,6 +4,7 @@ import shim from "./shim";
|
|
|
4
4
|
import unifyMixins from "./mixins/statement/unify";
|
|
5
5
|
import verifyMixins from "./mixins/statement/verify";
|
|
6
6
|
import LocalContext from "./context/local";
|
|
7
|
+
import resolveMixins from "./mixins/statement/resolve";
|
|
7
8
|
import metaLevelUnifier from "./unifier/metaLevel";
|
|
8
9
|
import statementAsCombinatorVerifier from "./verifier/statementAsCombinator";
|
|
9
10
|
|
|
@@ -105,6 +106,35 @@ class Statement {
|
|
|
105
106
|
return statementNodeMatches;
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
resolveIndependently(substitutions, localContextA, localContextB) {
|
|
110
|
+
let resolvedIndependently;
|
|
111
|
+
|
|
112
|
+
const statement = this, ///
|
|
113
|
+
statementString = this.string; ///
|
|
114
|
+
|
|
115
|
+
localContextB.trace(`Resolving the '${statementString}' statement independently...`);
|
|
116
|
+
|
|
117
|
+
const context = localContextA; ///
|
|
118
|
+
|
|
119
|
+
localContextA = LocalContext.fromContextAndTokens(context, this.tokens);
|
|
120
|
+
|
|
121
|
+
const resolved = resolveMixins.some((resolveMixin) => {
|
|
122
|
+
const resolved = resolveMixin(statement, substitutions, localContextA, localContextB);
|
|
123
|
+
|
|
124
|
+
if (resolved) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
resolvedIndependently = resolved; ///
|
|
130
|
+
|
|
131
|
+
if (resolvedIndependently) {
|
|
132
|
+
localContextB.debug(`...resolved the '${statementString}' statement independently.`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return resolvedIndependently;
|
|
136
|
+
}
|
|
137
|
+
|
|
108
138
|
unifyStatement(statement, substitutions, localContextA, localContextB) {
|
|
109
139
|
let statementUnified;
|
|
110
140
|
|
|
@@ -201,9 +201,9 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
201
201
|
|
|
202
202
|
statement = Statement.fromStatementNode(statementNode, localContext);
|
|
203
203
|
|
|
204
|
-
const
|
|
204
|
+
const substitution = null,
|
|
205
205
|
resolved = true,
|
|
206
|
-
|
|
206
|
+
string = stringFromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext),
|
|
207
207
|
statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(string, resolved, statement, metavariable, substitution);
|
|
208
208
|
|
|
209
209
|
return statementForMetavariableSubstitution;
|
package/src/term.js
CHANGED
|
@@ -42,13 +42,6 @@ class Term {
|
|
|
42
42
|
this.type = type;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
match(term) {
|
|
46
|
-
const node = term.getNode(),
|
|
47
|
-
matches = this.node.match(node);
|
|
48
|
-
|
|
49
|
-
return matches;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
45
|
getVariable(localContext) {
|
|
53
46
|
let variable = null;
|
|
54
47
|
|
|
@@ -98,6 +91,23 @@ class Term {
|
|
|
98
91
|
return grounded;
|
|
99
92
|
}
|
|
100
93
|
|
|
94
|
+
isEqualTo(term) {
|
|
95
|
+
let equalTo = false;
|
|
96
|
+
|
|
97
|
+
const termNode = term.getNode(),
|
|
98
|
+
termNodeMatches = this.node.match(termNode);
|
|
99
|
+
|
|
100
|
+
if (termNodeMatches) {
|
|
101
|
+
const termType = term.getType();
|
|
102
|
+
|
|
103
|
+
if (this.type === termType) {
|
|
104
|
+
equalTo = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return equalTo;
|
|
109
|
+
}
|
|
110
|
+
|
|
101
111
|
matchTermNode(termNode) {
|
|
102
112
|
const termNodeMatches = this.node.match(termNode);
|
|
103
113
|
|
package/src/type.js
CHANGED
|
@@ -57,9 +57,9 @@ export function findEquivalenceByType(equivalences, type) {
|
|
|
57
57
|
|
|
58
58
|
export function findEquivalenceByTerm(equivalences, term) {
|
|
59
59
|
const equivalence = equivalences.find((equivalence) => {
|
|
60
|
-
const
|
|
60
|
+
const termEquates = equivalence.equateTerm(term);
|
|
61
61
|
|
|
62
|
-
if (
|
|
62
|
+
if (termEquates) {
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
65
|
}) || null;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery } from "../utilities/query";
|
|
4
|
+
import { variableNameFromVariableNode } from "../utilities/name";
|
|
5
|
+
|
|
6
|
+
const variableNodeQuery = nodeQuery("/term/variable!"),
|
|
7
|
+
metavariableNodeQuery = nodeQuery("/*/metavariable!");
|
|
8
|
+
|
|
9
|
+
export function termFromTermAndSubstitutions(term, substitutions) {
|
|
10
|
+
if (term !== null) {
|
|
11
|
+
const termNode = term.getNode(),
|
|
12
|
+
variableNode = variableNodeQuery(termNode);
|
|
13
|
+
|
|
14
|
+
if (variableNode !== null) {
|
|
15
|
+
const variableName = variableNameFromVariableNode(variableNode),
|
|
16
|
+
substitution = substitutions.findSubstitution((substitution) => {
|
|
17
|
+
const variableNameMatches = substitution.matchVariableName(variableName);
|
|
18
|
+
|
|
19
|
+
if (variableNameMatches) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (substitution !== null) {
|
|
25
|
+
term = substitution.getTerm();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return term;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function frameFromFrameAndSubstitutions(frame, substitutions) {
|
|
34
|
+
if (frame !== null) {
|
|
35
|
+
const frameNode = frame.getNode(),
|
|
36
|
+
metavariableNode = metavariableNodeQuery(frameNode);
|
|
37
|
+
|
|
38
|
+
if (metavariableNode !== null) {
|
|
39
|
+
const substitution = substitutions.findSubstitution((substitution) => {
|
|
40
|
+
const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
|
|
41
|
+
|
|
42
|
+
if (metavariableNodeMatches) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (substitution !== null) {
|
|
48
|
+
frame = substitution.getTerm();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return frame;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function statementFromStatementAndSubstitutions(statement, substitutions) {
|
|
57
|
+
if (statement !== null) {
|
|
58
|
+
const statementNode = statement.getNode(),
|
|
59
|
+
metavariableNode = metavariableNodeQuery(statementNode);
|
|
60
|
+
|
|
61
|
+
if (metavariableNode !== null) {
|
|
62
|
+
const substitution = substitutions.findSubstitution((substitution) => {
|
|
63
|
+
const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
|
|
64
|
+
|
|
65
|
+
if (metavariableNodeMatches) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (substitution !== null) {
|
|
71
|
+
statement = substitution.getStatement();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return statement;
|
|
77
|
+
}
|