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.
@@ -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
- let statementForMetavariableSubstitution = null;
103
-
104
- let statementNode = statementNodeQuery(substitutionNode),
105
- metavariableNode = metavariableNodeQuery(substitutionNode);
106
-
107
- if (statementNode !== null) {
108
- statementNode = stripBracketsFromStatement(statementNode); ///
109
-
110
- const substitution = null;
111
-
112
- statementForMetavariableSubstitution = new StatementForMetavariableSubstitution(statementNode, metavariableNode, substitution);
113
- }
114
-
115
- return statementForMetavariableSubstitution;
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 statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromSubstitutionNode(substitutionNode);
150
+ const frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromSubstitutionNode(substitutionNode);
150
151
 
151
- if (statementForMetavariableSubstitution !== null) {
152
- substitution = statementForMetavariableSubstitution; ///
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/statement[0]/metavariable"),
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/statement[-1]/metavariable!");
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
- metavariable = localContext.findMetavariableByMetavariableName(metavariableName),
69
- metavariableDefined = localContext.isMetavariableDefined(metavariable);
68
+ metavariableDefinedByMetavariableName = localContext.isMetavariableDefinedByMetavariableName(metavariableName);
70
69
 
71
70
  if (!assertionNegated) {
72
- if (metavariableDefined) {
71
+ if (metavariableDefinedByMetavariableName) {
73
72
  derivedDefinedAssertionVerified = true;
74
73
  }
75
74
  }
76
75
 
77
76
  if (assertionNegated) {
78
- if (!metavariableDefined) {
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, metavariables, localContext);
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
- declaration = Declaration.fromReferenceAndStatementNode(reference, statementNode);
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, metavariables, localContext);
88
+ metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
91
89
 
92
90
  if (metavariableVerifiedGivenMetaType) {
93
- const { verifyStatement } = shim,
94
- stated = true,
95
- assignments = null,
96
- statementNode = statementNodeQuery(declarationNode),
97
- statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
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),
@@ -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
- metavariableNodesQuery = nodesQuery("/frame/metavariable");
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 metavariableNodes = metavariableNodesQuery(frameNode),
99
- metavariableNodesLength = metavariableNodes.length;
100
+ const metavariableNode = metavariableNodeQuery(frameNode);
100
101
 
101
- if (metavariableNodesLength === 1) {
102
- const firstMetavariableNode = first(metavariableNodes),
103
- metavariableNode = firstMetavariableNode,
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 firstMetavariable = first(metavariables),
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
- metavariables = [],
142
- metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
136
+ metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
143
137
 
144
138
  if (metavariableVerifiedGivenMetaType) {
145
- const firstMetavariable = first(metavariables),
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) {
@@ -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 firstFrame = first(frames),
99
- frame = firstFrame, ///
100
- metavariable = frame.getMetavariable(),
101
- metavariableNode = metavariable.getNode(),
102
- metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
103
- judgementPresent = localContext.isJudgementPresentByMetavariableName(metavariableName);
104
-
105
- if (!judgementPresent) {
106
- const declarations = [],
107
- declarationNode = declarationNodeQuery(judgementNode),
108
- declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
109
-
110
- if (declarationVerified) {
111
- if (assignments !== null) {
112
- const firstDeclaration = first(declarations),
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
- } else {
124
- localContext.trace(`There is already a judgement for the '${metavariableName}' metavariable.`, judgementNode);
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, metavariables, localContext) {
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
- if (unified) {
31
- metavariables.push(metavariable);
32
-
33
- metavariableVerifiedGivenMetaType = true;
34
- }
30
+ metavariableVerifiedGivenMetaType = unified; ///
35
31
  } else {
36
32
  const metavariableMetaTypeName = metavariableMetaType.getName();
37
33