occam-verify-cli 0.0.981 → 0.0.983
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/local.js +9 -9
- package/lib/frame.js +32 -29
- package/lib/judgement.js +4 -4
- package/lib/substitution/frameForMetavariable.js +251 -0
- package/lib/substitution/statementForMetavariable.js +22 -18
- package/lib/verify/assertion/contained.js +2 -2
- package/lib/verify/assertion/defined.js +5 -5
- package/lib/verify/declaration.js +3 -3
- package/lib/verify/frame.js +9 -8
- package/lib/verify/judgement.js +7 -12
- package/lib/verify/metavariableGivenMetaType.js +3 -6
- package/package.json +3 -3
- package/src/context/local.js +11 -12
- package/src/frame.js +31 -27
- package/src/judgement.js +1 -1
- package/src/substitution/frameForMetavariable.js +179 -0
- package/src/substitution/statementForMetavariable.js +20 -19
- package/src/verify/assertion/contained.js +1 -1
- package/src/verify/assertion/defined.js +4 -5
- package/src/verify/declaration.js +8 -10
- package/src/verify/frame.js +11 -19
- package/src/verify/judgement.js +17 -26
- package/src/verify/metavariableGivenMetaType.js +2 -6
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import Substitution from "../substitution";
|
|
4
4
|
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
5
|
+
import FrameForMetavariableSubstitution from "../substitution/frameForMetavariable";
|
|
5
6
|
|
|
6
7
|
import { nodeQuery } from "../utilities/query";
|
|
7
8
|
import { stripBracketsFromStatement } from "../utilities/brackets";
|
|
@@ -98,22 +99,22 @@ export default class StatementForMetavariableSubstitution extends Substitution {
|
|
|
98
99
|
return string;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
static fromSubstitutionNode(substitutionNode) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
102
|
+
// static fromSubstitutionNode(substitutionNode) {
|
|
103
|
+
// let statementForMetavariableSubstitution = null;
|
|
104
|
+
//
|
|
105
|
+
// let statementNode = statementNodeQuery(substitutionNode),
|
|
106
|
+
// metavariableNode = metavariableNodeQuery(substitutionNode);
|
|
107
|
+
//
|
|
108
|
+
// if (statementNode !== null) {
|
|
109
|
+
// statementNode = stripBracketsFromStatement(statementNode); ///
|
|
110
|
+
//
|
|
111
|
+
// const substitution = null;
|
|
112
|
+
//
|
|
113
|
+
// statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode, substitution);
|
|
114
|
+
// }
|
|
115
|
+
//
|
|
116
|
+
// return statementForMetavariableSubstitution;
|
|
117
|
+
// }
|
|
117
118
|
|
|
118
119
|
static fromStatementNodeAndMetavariableNode(statementNode, metavariableNode) {
|
|
119
120
|
statementNode = stripBracketsFromStatement(statementNode); ///
|
|
@@ -146,10 +147,10 @@ function substitutionFromSubstitutionNode(substitutionNode) {
|
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
if (substitution === null) {
|
|
149
|
-
const
|
|
150
|
+
const frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromSubstitutionNode(substitutionNode);
|
|
150
151
|
|
|
151
|
-
if (
|
|
152
|
-
substitution =
|
|
152
|
+
if (frameForMetavariableSubstitution !== null) {
|
|
153
|
+
substitution = frameForMetavariableSubstitution; ///
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
|
|
@@ -6,7 +6,7 @@ import { isAssertionNegated } from "../../utilities/assertion";
|
|
|
6
6
|
import { nodeQuery, nodesQuery } from "../../utilities/query";
|
|
7
7
|
|
|
8
8
|
const variableNodeQuery = nodeQuery("/containedAssertion/term/variable!"),
|
|
9
|
-
metavariableNodeQuery = nodeQuery("/containedAssertion/
|
|
9
|
+
metavariableNodeQuery = nodeQuery("/containedAssertion/frame[0]/metavariable"),
|
|
10
10
|
statementVariableNodesQuery = nodesQuery("/containedAssertion/statement[-1]//variable"),
|
|
11
11
|
statementMetavariableNodesQuery = nodesQuery("/containedAssertion/statement[-1]//metavariable");
|
|
12
12
|
|
|
@@ -9,7 +9,7 @@ import { isAssertionNegated } from "../../utilities/assertion";
|
|
|
9
9
|
import { metavariableNameFromMetavariableNode } from "../../utilities/name";
|
|
10
10
|
|
|
11
11
|
const variableNodeQuery = nodeQuery("/definedAssertion/term/variable!"),
|
|
12
|
-
metavariableNodeQuery = nodeQuery("/definedAssertion/
|
|
12
|
+
metavariableNodeQuery = nodeQuery("/definedAssertion/frame[-1]/metavariable!");
|
|
13
13
|
|
|
14
14
|
const verifyDefinedAssertionFunctions = [
|
|
15
15
|
verifyDerivedDefinedAssertion,
|
|
@@ -65,17 +65,16 @@ function verifyDerivedDefinedAssertion(definedAssertionNode, assignments, stated
|
|
|
65
65
|
///
|
|
66
66
|
} else if (metavariableNode !== null) {
|
|
67
67
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
68
|
-
|
|
69
|
-
metavariableDefined = localContext.isMetavariableDefined(metavariable);
|
|
68
|
+
metavariableDefinedByMetavariableName = localContext.isMetavariableDefinedByMetavariableName(metavariableName);
|
|
70
69
|
|
|
71
70
|
if (!assertionNegated) {
|
|
72
|
-
if (
|
|
71
|
+
if (metavariableDefinedByMetavariableName) {
|
|
73
72
|
derivedDefinedAssertionVerified = true;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
if (assertionNegated) {
|
|
78
|
-
if (!
|
|
77
|
+
if (!metavariableDefinedByMetavariableName) {
|
|
79
78
|
derivedDefinedAssertionVerified = true;
|
|
80
79
|
}
|
|
81
80
|
}
|
|
@@ -47,9 +47,8 @@ function verifyDerivedDeclaration(declarationNode, declarations, stated, localCo
|
|
|
47
47
|
localContext.trace(`Verifying the '${declarationString}' derived declaration...`, declarationNode);
|
|
48
48
|
|
|
49
49
|
const metaType = referenceMetaType, ///
|
|
50
|
-
metavariables = [],
|
|
51
50
|
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
52
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType,
|
|
51
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
53
52
|
|
|
54
53
|
if (metavariableVerifiedGivenMetaType) {
|
|
55
54
|
const { verifyStatement } = shim,
|
|
@@ -60,7 +59,7 @@ function verifyDerivedDeclaration(declarationNode, declarations, stated, localCo
|
|
|
60
59
|
|
|
61
60
|
if (statementVerified) {
|
|
62
61
|
const reference = Reference.fromMetavariableNode(metavariableNode),
|
|
63
|
-
|
|
62
|
+
declaration = Declaration.fromReferenceAndStatementNode(reference, statementNode);
|
|
64
63
|
|
|
65
64
|
declarations.push(declaration);
|
|
66
65
|
|
|
@@ -85,16 +84,15 @@ function verifyStatedDeclaration(declarationNode, declarations, stated, localCon
|
|
|
85
84
|
localContext.trace(`Verifying the '${declarationString}' stated declaration...`, declarationNode);
|
|
86
85
|
|
|
87
86
|
const metaType = referenceMetaType, ///
|
|
88
|
-
metavariables = [],
|
|
89
87
|
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
90
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType,
|
|
88
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
91
89
|
|
|
92
90
|
if (metavariableVerifiedGivenMetaType) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
const { verifyStatement } = shim,
|
|
92
|
+
stated = true,
|
|
93
|
+
assignments = null,
|
|
94
|
+
statementNode = statementNodeQuery(declarationNode),
|
|
95
|
+
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
98
96
|
|
|
99
97
|
if (statementVerified) {
|
|
100
98
|
const reference = Reference.fromMetavariableNode(metavariableNode),
|
package/src/verify/frame.js
CHANGED
|
@@ -6,10 +6,12 @@ import verifyDeclaration from "../verify/declaration";
|
|
|
6
6
|
import verifyMetavariableGivenMetaType from "./metavariableGivenMetaType";
|
|
7
7
|
|
|
8
8
|
import { first } from "../utilities/array";
|
|
9
|
-
import { nodesQuery } from "../utilities/query";
|
|
9
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
10
|
+
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
10
11
|
|
|
11
12
|
const declarationNodesQuery = nodesQuery("/frame/declaration"),
|
|
12
|
-
|
|
13
|
+
metavariableNodeQuery = nodeQuery("/frame/statement!/metavariable"),
|
|
14
|
+
metavariableNodesQuery = nodesQuery("/frame/statement/metavariable");
|
|
13
15
|
|
|
14
16
|
const verifyFrameFunctions = [
|
|
15
17
|
verifyDerivedFrame,
|
|
@@ -95,21 +97,14 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
|
|
|
95
97
|
declarationNodesLength = declarationNodes.length;
|
|
96
98
|
|
|
97
99
|
if (declarationNodesLength === 0) {
|
|
98
|
-
const
|
|
99
|
-
metavariableNodesLength = metavariableNodes.length;
|
|
100
|
+
const metavariableNode = metavariableNodeQuery(frameNode);
|
|
100
101
|
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
metaType = frameMetaType, ///
|
|
105
|
-
metavariables = [],
|
|
106
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
|
|
102
|
+
if (metavariableNode !== null) {
|
|
103
|
+
const metaType = frameMetaType, ///
|
|
104
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
107
105
|
|
|
108
106
|
if (metavariableVerifiedGivenMetaType) {
|
|
109
|
-
const
|
|
110
|
-
metavariable = firstMetavariable,
|
|
111
|
-
|
|
112
|
-
frame = Frame.fromMetavariable(metavariable);
|
|
107
|
+
const frame = Frame.fromMetavariableNode(metavariableNode);
|
|
113
108
|
|
|
114
109
|
frames.push(frame);
|
|
115
110
|
|
|
@@ -138,13 +133,10 @@ function verifyMetavariable(metavariableNode, declarations, localContext) {
|
|
|
138
133
|
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
139
134
|
|
|
140
135
|
const metaType = frameMetaType, ///
|
|
141
|
-
|
|
142
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
|
|
136
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
143
137
|
|
|
144
138
|
if (metavariableVerifiedGivenMetaType) {
|
|
145
|
-
const
|
|
146
|
-
metavariable = firstMetavariable, ///
|
|
147
|
-
metavariableName = metavariable.getName(),
|
|
139
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
148
140
|
judgement = localContext.findJudgementByMetavariableName(metavariableName);
|
|
149
141
|
|
|
150
142
|
if (judgement !== null) {
|
package/src/verify/judgement.js
CHANGED
|
@@ -95,33 +95,24 @@ function verifyStatedJudgement(judgementNode, assignments, stated, localContext)
|
|
|
95
95
|
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
96
96
|
|
|
97
97
|
if (frameVerified) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
declaration = firstDeclaration, ///
|
|
114
|
-
judgement = Judgement.fromJudgementNodeFrameAndDeclaration(judgementNode, frame, declaration),
|
|
115
|
-
judgementAssignment = JudgementAssignment.fromJudgement(judgement),
|
|
116
|
-
assignment = judgementAssignment;
|
|
117
|
-
|
|
118
|
-
assignments.push(assignment);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
statedJudgementVerified = true;
|
|
98
|
+
const declarations = [],
|
|
99
|
+
declarationNode = declarationNodeQuery(judgementNode),
|
|
100
|
+
declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
101
|
+
|
|
102
|
+
if (declarationVerified) {
|
|
103
|
+
if (assignments !== null) {
|
|
104
|
+
const firstDeclaration = first(declarations),
|
|
105
|
+
firstFrame = first(frames),
|
|
106
|
+
frame = firstFrame,
|
|
107
|
+
declaration = firstDeclaration, ///
|
|
108
|
+
judgement = Judgement.fromJudgementNodeFrameAndDeclaration(judgementNode, frame, declaration),
|
|
109
|
+
judgementAssignment = JudgementAssignment.fromJudgement(judgement),
|
|
110
|
+
assignment = judgementAssignment;
|
|
111
|
+
|
|
112
|
+
assignments.push(assignment);
|
|
122
113
|
}
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
|
|
115
|
+
statedJudgementVerified = true;
|
|
125
116
|
}
|
|
126
117
|
}
|
|
127
118
|
|
|
@@ -4,7 +4,7 @@ import metavariableUnifier from "../unifier/metavariable";
|
|
|
4
4
|
|
|
5
5
|
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
6
6
|
|
|
7
|
-
export default function verifyMetavariableGivenMetaType(metavariableNode, metaType,
|
|
7
|
+
export default function verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext) {
|
|
8
8
|
let metavariableVerifiedGivenMetaType = false;
|
|
9
9
|
|
|
10
10
|
const metaTypeName = metaType.getName(),
|
|
@@ -27,11 +27,7 @@ export default function verifyMetavariableGivenMetaType(metavariableNode, metaTy
|
|
|
27
27
|
|
|
28
28
|
const unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
metavariables.push(metavariable);
|
|
32
|
-
|
|
33
|
-
metavariableVerifiedGivenMetaType = true;
|
|
34
|
-
}
|
|
30
|
+
metavariableVerifiedGivenMetaType = unified; ///
|
|
35
31
|
} else {
|
|
36
32
|
const metavariableMetaTypeName = metavariableMetaType.getName();
|
|
37
33
|
|