occam-verify-cli 0.0.978 → 0.0.979

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/src/rule.js CHANGED
@@ -29,16 +29,6 @@ export default class Rule {
29
29
  return this.fileContext;
30
30
  }
31
31
 
32
- getLabelMetavariableNodes() {
33
- const labelMetavariableNodes = this.labels.map((label) => {
34
- const labelMetavariableNode = label.getMetavariableNode();
35
-
36
- return labelMetavariableNode;
37
- });
38
-
39
- return labelMetavariableNodes;
40
- }
41
-
42
32
  unifyStatement(statementNode, localContext) {
43
33
  let statementUnified = false;
44
34
 
@@ -34,16 +34,6 @@ export default class TopLevelAssertion {
34
34
  return this.fileContext;
35
35
  }
36
36
 
37
- getLabelMetavariableNodes() {
38
- const labelMetavariableNodes = this.labels.map((label) => {
39
- const labelMetavariableNode = label.getMetavariableNode();
40
-
41
- return labelMetavariableNode;
42
- });
43
-
44
- return labelMetavariableNodes;
45
- }
46
-
47
37
  unifyStatement(statementNode, localContext) {
48
38
  let statementUnified = false;
49
39
 
@@ -46,18 +46,17 @@ function unifyQualifiedStatementAWithRule(qualifiedStatementNode, substitutions,
46
46
 
47
47
  if (rule !== null) {
48
48
  const statementNode = statementNodeQuery(qualifiedStatementNode),
49
- labelMetavariableNodes = rule.getLabelMetavariableNodes(),
50
- qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
51
- labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
49
+ metavariableString = localContext.nodeAsString(metavariableNode),
50
+ qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
52
51
 
53
- localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' rule...`, qualifiedStatementNode);
52
+ localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' rule...`, qualifiedStatementNode);
54
53
 
55
54
  const statementUnified = rule.unifyStatement(statementNode, localContext);
56
55
 
57
56
  qualifiedStatementUnifiedWithRule = statementUnified; ///
58
57
 
59
58
  if (qualifiedStatementUnifiedWithRule) {
60
- localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' rule.`, qualifiedStatementNode);
59
+ localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' rule.`, qualifiedStatementNode);
61
60
  }
62
61
  }
63
62
 
@@ -72,18 +71,17 @@ function unifyQualifiedStatementAWithAxiom(qualifiedStatementNode, substitutions
72
71
 
73
72
  if (axiom !== null) {
74
73
  const statementNode = statementNodeQuery(qualifiedStatementNode),
75
- labelMetavariableNodes = axiom.getLabelMetavariableNodes(),
76
- qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
77
- labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
74
+ metavariableString = localContext.nodeAsString(metavariableNode),
75
+ qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
78
76
 
79
- localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' axiom...`, qualifiedStatementNode);
77
+ localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' axiom...`, qualifiedStatementNode);
80
78
 
81
79
  const statementUnified = axiom.unifyStatement(statementNode, localContext);
82
80
 
83
81
  qualifiedStatementUnifiedWithAxiom = statementUnified; ///
84
82
 
85
83
  if (qualifiedStatementUnifiedWithAxiom) {
86
- localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' axiom.`, qualifiedStatementNode);
84
+ localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' axiom.`, qualifiedStatementNode);
87
85
  }
88
86
  }
89
87
 
@@ -98,18 +96,17 @@ function unifyQualifiedStatementAWithLemma(qualifiedStatementNode, substitutions
98
96
 
99
97
  if (lemma !== null) {
100
98
  const statementNode = statementNodeQuery(qualifiedStatementNode),
101
- labelMetavariableNodes = lemma.getLabelMetavariableNodes(),
102
- qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
103
- labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
99
+ metavariableString = localContext.nodeAsString(metavariableNode),
100
+ qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
104
101
 
105
- localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' lemma...`, qualifiedStatementNode);
102
+ localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' lemma...`, qualifiedStatementNode);
106
103
 
107
104
  const statementUnified = lemma.unifyStatement(statementNode, localContext);
108
105
 
109
106
  qualifiedStatementUnifiedWithLemma = statementUnified; ///
110
107
 
111
108
  if (qualifiedStatementUnifiedWithLemma) {
112
- localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' lemma.`, qualifiedStatementNode);
109
+ localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' lemma.`, qualifiedStatementNode);
113
110
  }
114
111
  }
115
112
 
@@ -124,18 +121,17 @@ function unifyQualifiedStatementAWithTheorem(qualifiedStatementNode, substitutio
124
121
 
125
122
  if (theorem !== null) {
126
123
  const statementNode = statementNodeQuery(qualifiedStatementNode),
127
- labelMetavariableNodes = theorem.getLabelMetavariableNodes(),
128
- qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
129
- labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
124
+ metavariableString = localContext.nodeAsString(metavariableNode),
125
+ qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
130
126
 
131
- localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' theorem...`, qualifiedStatementNode);
127
+ localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' theorem...`, qualifiedStatementNode);
132
128
 
133
129
  const statementUnified = theorem.unifyStatement(statementNode, localContext);
134
130
 
135
131
  qualifiedStatementUnifiedWithTheorem = statementUnified; ///
136
132
 
137
133
  if (qualifiedStatementUnifiedWithTheorem) {
138
- localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' theorem.`, qualifiedStatementNode);
134
+ localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' theorem.`, qualifiedStatementNode);
139
135
  }
140
136
  }
141
137
 
@@ -150,18 +146,17 @@ function unifyQualifiedStatementAWithConjecture(qualifiedStatementNode, substitu
150
146
 
151
147
  if (conjecture !== null) {
152
148
  const statementNode = statementNodeQuery(qualifiedStatementNode),
153
- labelMetavariableNodes = conjecture.getLabelMetavariableNodes(),
154
- qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
155
- labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
149
+ metavariableString = localContext.nodeAsString(metavariableNode),
150
+ qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
156
151
 
157
- localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' conjecture...`, qualifiedStatementNode);
152
+ localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' conjecture...`, qualifiedStatementNode);
158
153
 
159
154
  const statementUnified = conjecture.unifyStatement(statementNode, localContext);
160
155
 
161
156
  qualifiedStatementUnifiedWithConjecture = statementUnified; ///
162
157
 
163
158
  if (qualifiedStatementUnifiedWithConjecture) {
164
- localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' conjecture.`, qualifiedStatementNode);
159
+ localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' conjecture.`, qualifiedStatementNode);
165
160
  }
166
161
  }
167
162
 
@@ -10,6 +10,5 @@ export default function unifyTermWithType(termNode, typeNode, localContext) {
10
10
 
11
11
  termUnifiedWithType = termVerifiedGivenType; ///
12
12
 
13
-
14
13
  return termUnifiedWithType;
15
14
  }
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  import shim from "../shim";
4
+ import Reference from "../reference";
4
5
  import Declaration from "../declaration"
5
- import frameMetaType from "../metaType/frame";
6
6
  import referenceMetaType from "../metaType/reference";
7
7
  import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
8
8
 
9
9
  import { nodeQuery } from "../utilities/query";
10
10
 
11
11
  const statementNodeQuery = nodeQuery("/declaration/statement"),
12
- metavariableNodeQuery = nodeQuery("/declaration/metavariable");
12
+ metavariableNodeQuery = nodeQuery("/declaration/reference/metavariable"); ///
13
13
 
14
14
  const verifyDeclarationFunctions = [
15
15
  verifyDerivedDeclaration,
@@ -47,8 +47,9 @@ 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 = [],
50
51
  metavariableNode = metavariableNodeQuery(declarationNode),
51
- metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
52
+ metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
52
53
 
53
54
  if (metavariableVerifiedGivenMetaType) {
54
55
  const { verifyStatement } = shim,
@@ -58,7 +59,8 @@ function verifyDerivedDeclaration(declarationNode, declarations, stated, localCo
58
59
  statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
59
60
 
60
61
  if (statementVerified) {
61
- const declaration = Declaration.fromMetavariableNodeAndStatementNode(metavariableNode, statementNode);
62
+ const reference = Reference.fromMetavariableNode(metavariableNode),
63
+ declaration = Declaration.fromReferenceAndStatementNode(reference, statementNode);
62
64
 
63
65
  declarations.push(declaration);
64
66
 
@@ -82,26 +84,21 @@ function verifyStatedDeclaration(declarationNode, declarations, stated, localCon
82
84
 
83
85
  localContext.trace(`Verifying the '${declarationString}' stated declaration...`, declarationNode);
84
86
 
85
- const statementNode = statementNodeQuery(declarationNode),
86
- metaType = (statementNode === null) ?
87
- frameMetaType :
88
- referenceMetaType,
87
+ const metaType = referenceMetaType, ///
88
+ metavariables = [],
89
89
  metavariableNode = metavariableNodeQuery(declarationNode),
90
- metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
90
+ metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
91
91
 
92
92
  if (metavariableVerifiedGivenMetaType) {
93
- let statementVerified = true; ///
94
-
95
- if (statementNode !== null) {
96
93
  const { verifyStatement } = shim,
97
94
  stated = true,
98
- assignments = null;
99
-
100
- statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
101
- }
95
+ assignments = null,
96
+ statementNode = statementNodeQuery(declarationNode),
97
+ statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
102
98
 
103
99
  if (statementVerified) {
104
- const declaration = Declaration.fromMetavariableNodeAndStatementNode(metavariableNode, statementNode);
100
+ const reference = Reference.fromMetavariableNode(metavariableNode),
101
+ declaration = Declaration.fromReferenceAndStatementNode(reference, statementNode);
105
102
 
106
103
  declarations.push(declaration);
107
104
 
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  import Frame from "../frame";
4
+ import frameMetaType from "../metaType/frame";
4
5
  import verifyDeclaration from "../verify/declaration";
6
+ import verifyMetavariableGivenMetaType from "./metavariableGivenMetaType";
5
7
 
6
8
  import { first } from "../utilities/array";
7
- import { nodeQuery, nodesQuery } from "../utilities/query";
9
+ import { nodesQuery } from "../utilities/query";
8
10
 
9
- const declarationNodeQuery = nodeQuery("/frame/declaration!"),
10
- declarationNodesQuery = nodesQuery("/frame/declaration"),
11
+ const declarationNodesQuery = nodesQuery("/frame/declaration"),
11
12
  metavariableNodesQuery = nodesQuery("/frame/metavariable");
12
13
 
13
14
  const verifyFrameFunctions = [
@@ -45,35 +46,33 @@ function verifyDerivedFrame(frameNode, frames, stated, localContext) {
45
46
 
46
47
  localContext.trace(`Verifying the '${frameString}' derived frame...`, frameNode);
47
48
 
48
- const declarationNode = declarationNodeQuery(frameNode);
49
+ const declarations = [],
50
+ declarationNodes = declarationNodesQuery(frameNode),
51
+ declarationsVerified = declarationNodes.every((declarationNode) => {
52
+ const declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
49
53
 
50
- if (declarationNode !== null) {
54
+ if (declarationVerified) {
55
+ return true;
56
+ }
57
+ });
51
58
 
52
- }
53
- const declarationNodesLength = declarationNodes.length;
54
-
55
- if (declarationNodesLength === 1) {
59
+ if (declarationsVerified) {
56
60
  const metavariableNodes = metavariableNodesQuery(frameNode),
57
- metavariableNodesLength = metavariableNodes.length;
61
+ metavariablesVerified = metavariableNodes.every((metavariableNode) => {
62
+ const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localContext);
58
63
 
59
- if (metavariableNodesLength === 0) {
60
- const firstDeclarationNode = first(declarationNodes),
61
- declarationNode = firstDeclarationNode, ///
62
- declarations = [],
63
- declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
64
+ if (metavariableVerified) {
65
+ return true;
66
+ }
67
+ });
64
68
 
65
- if (declarationVerified) {
66
- const frame = Frame.fromDeclarations(declarations);
69
+ if (metavariablesVerified) {
70
+ const frame = Frame.fromDeclarations(declarations);
67
71
 
68
- frames.push(frame);
72
+ frames.push(frame);
69
73
 
70
- derivedFrameVerified = true; ///
71
- }
72
- } else {
73
- localContext.debug(`The '${frameString}' derived frame must no spread metavariables.`, frameNode);
74
+ derivedFrameVerified = true; ///
74
75
  }
75
- } else {
76
- localContext.debug(`The '${frameString}' derived frame must have one and only one declaration.`, frameNode);
77
76
  }
78
77
 
79
78
  if (derivedFrameVerified) {
@@ -92,29 +91,35 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
92
91
 
93
92
  localContext.trace(`Verifying the '${frameString}' stated frame...`, frameNode);
94
93
 
95
- const declarationNode = declarationNodeQuery(frameNode);
94
+ const declarationNodes = declarationNodesQuery(frameNode),
95
+ declarationNodesLength = declarationNodes.length;
96
96
 
97
- if (declarationNode !== null) {
98
- const declarations = [],
99
- declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
97
+ if (declarationNodesLength === 0) {
98
+ const metavariableNodes = metavariableNodesQuery(frameNode),
99
+ metavariableNodesLength = metavariableNodes.length;
100
+
101
+ if (metavariableNodesLength === 1) {
102
+ const firstMetavariableNode = first(metavariableNodes),
103
+ metavariableNode = firstMetavariableNode,
104
+ metaType = frameMetaType, ///
105
+ metavariables = [],
106
+ metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
100
107
 
101
- if (declarationVerified) {
102
- const firstDeclaration = first(declarations),
103
- declaration = firstDeclaration, ///
104
- statementNode = declaration.getStatementNode();
108
+ if (metavariableVerifiedGivenMetaType) {
109
+ const firstMetavariable = first(metavariables),
110
+ metavariable = firstMetavariable,
105
111
 
106
- if (statementNode === null) {
107
- const frame = Frame.fromDeclarations(declarations);
112
+ frame = Frame.fromMetavariable(metavariable);
108
113
 
109
114
  frames.push(frame);
110
115
 
111
116
  statedFrameVerified = true;
112
- } else {
113
- localContext.trace(`The '${frameString}' stated frame's declaration cannot contain a statement.`, frameNode);
114
117
  }
118
+ } else {
119
+ localContext.trace(`The '${frameString}' stated frame cannot have more than one metavariable.`, frameNode);
115
120
  }
116
121
  } else {
117
- localContext.trace(`The '${frameString}' stated frame has more than one declaration .`, frameNode);
122
+ localContext.trace(`The '${frameString}' stated frame cannot have declarations.`, frameNode);
118
123
  }
119
124
 
120
125
  if (statedFrameVerified) {
@@ -124,3 +129,38 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
124
129
 
125
130
  return statedFrameVerified;
126
131
  }
132
+
133
+ function verifyMetavariable(metavariableNode, declarations, localContext) {
134
+ let metavariableVerified = false;
135
+
136
+ const metavariableString = localContext.nodeAsString(metavariableNode);
137
+
138
+ localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
139
+
140
+ const metaType = frameMetaType, ///
141
+ metavariables = [],
142
+ metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
143
+
144
+ if (metavariableVerifiedGivenMetaType) {
145
+ const firstMetavariable = first(metavariables),
146
+ metavariable = firstMetavariable, ///
147
+ metavariableName = metavariable.getName(),
148
+ judgement = localContext.findJudgementByMetavariableName(metavariableName);
149
+
150
+ if (judgement !== null) {
151
+ const declaration = judgement.getDeclaration();
152
+
153
+ declarations.push(declaration);
154
+
155
+ metavariableVerified = true;
156
+ } else {
157
+ localContext.trace(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode);
158
+ }
159
+ }
160
+
161
+ if (metavariableVerified) {
162
+ localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
163
+ }
164
+
165
+ return metavariableVerified;
166
+ }
@@ -2,11 +2,12 @@
2
2
 
3
3
  import Judgement from "../judgement";
4
4
  import verifyFrame from "../verify/frame";
5
+ import verifyDeclaration from "./declaration";
5
6
  import JudgementAssignment from "../assignment/judgement";
6
7
 
7
8
  import { first } from "../utilities/array";
8
9
  import { nodeQuery } from "../utilities/query";
9
- import verifyDeclaration from "./declaration";
10
+ import { metavariableNameFromMetavariableNode } from "../utilities/name";
10
11
 
11
12
  const frameNodeQuery = nodeQuery("/judgement/frame"),
12
13
  declarationNodeQuery = nodeQuery("/judgement/declaration");
@@ -46,29 +47,31 @@ function verifyDerivedJudgement(judgementNode, assignments, stated, localContext
46
47
 
47
48
  localContext.trace(`Verifying the '${judgementString}' derived judgement...`, judgementNode);
48
49
 
49
- const frames = [],
50
- frameNode = frameNodeQuery(judgementNode),
51
- frameVerified = verifyFrame(frameNode, frames, stated, localContext);
50
+ const declarations = [],
51
+ declarationNode = declarationNodeQuery(judgementNode),
52
+ declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
53
+
54
+ if (declarationVerified) {
55
+ const firstDeclaration = first(declarations),
56
+ declaration = firstDeclaration, ///
57
+ metavariableNode = declaration.getMetavariableNode(),
58
+ metatheorem = localContext.findMetatheoremByMetavariableNode(metavariableNode),
59
+ metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
60
+ metaLemmaMetatheorem = (metaLemma || metatheorem); ///
61
+
62
+ if (metaLemmaMetatheorem !== null) {
63
+ const frames = [],
64
+ frameNode = frameNodeQuery(judgementNode),
65
+ frameVerified = verifyFrame(frameNode, frames, stated, localContext);
66
+
67
+ if (frameVerified) {
68
+ const firstFrame = first(frames),
69
+ frame = firstFrame, ///
70
+ metaLemmaMetatheoremUnified = frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem);
52
71
 
53
- if (frameVerified) {
54
- // const firstFrame = first(frames),
55
- // frame = firstFrame, ///
56
- // declaration = frame.getDeclaration(),
57
- // metavariableNode = declaration.getMetavariableNode(),
58
- // metatheorem = localContext.findMetatheoremByMetavariableNode(metavariableNode),
59
- // metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
60
- // metaLemmaMetatheorem = (metaLemma || metatheorem); ///
61
- //
62
- // if (metaLemmaMetatheorem !== null) {
63
- // const metaLemmaMetatheoremUnifiedWithJudgement = judgement.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem),
64
- // metaLemmaMetatheoremUnifiedWithDeclaration = declaration.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem);
65
- //
66
- // derivedJudgementVerified = (metaLemmaMetatheoremUnifiedWithJudgement && metaLemmaMetatheoremUnifiedWithDeclaration);
67
- // }
68
- } else {
69
- // const metavariableString = localContext.nodeAsString(metavariableNode);
70
- //
71
- // localContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode)
72
+ derivedJudgementVerified = metaLemmaMetatheoremUnified; ///
73
+ }
74
+ }
72
75
  }
73
76
 
74
77
  if (derivedJudgementVerified) {
@@ -92,24 +95,33 @@ function verifyStatedJudgement(judgementNode, assignments, stated, localContext)
92
95
  frameVerified = verifyFrame(frameNode, frames, stated, localContext);
93
96
 
94
97
  if (frameVerified) {
95
- const declarations = [],
96
- declarationNode = declarationNodeQuery(judgementNode),
97
- declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
98
-
99
- if (declarationVerified) {
100
- if (assignments !== null) {
101
- const firstDeclaration = first(declarations),
102
- declaration = firstDeclaration, ///
103
- firstFrame = first(frames),
104
- frame = firstFrame, ///
105
- judgement = Judgement.fromJudgementNodeFrameAndDeclaration(judgementNode, frame, declaration),
106
- judgementAssignment = JudgementAssignment.fromJudgement(judgement),
107
- assignment = judgementAssignment;
108
-
109
- assignments.push(assignment);
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;
110
122
  }
111
-
112
- statedJudgementVerified = true;
123
+ } else {
124
+ localContext.trace(`There is already a judgement for the '${metavariableName}' metavariable.`, judgementNode);
113
125
  }
114
126
  }
115
127
 
@@ -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, localContext) {
7
+ export default function verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext) {
8
8
  let metavariableVerifiedGivenMetaType = false;
9
9
 
10
10
  const metaTypeName = metaType.getName(),
@@ -27,7 +27,11 @@ export default function verifyMetavariableGivenMetaType(metavariableNode, metaTy
27
27
 
28
28
  const unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
29
29
 
30
- metavariableVerifiedGivenMetaType = unified; ///
30
+ if (unified) {
31
+ metavariables.push(metavariable);
32
+
33
+ metavariableVerifiedGivenMetaType = true;
34
+ }
31
35
  } else {
32
36
  const metavariableMetaTypeName = metavariableMetaType.getName();
33
37
 
@@ -96,7 +96,7 @@ function verifyStatementAsMetavariable(statementNode, assignments, stated, local
96
96
 
97
97
  const metavariableUnified = unifyMetavariable(metavariableNode, localContext);
98
98
 
99
- statementVerifiedAsMetavariable = metavariableUnified;
99
+ statementVerifiedAsMetavariable = metavariableUnified; ///
100
100
 
101
101
  if (statementVerifiedAsMetavariable) {
102
102
  localContext.debug(`...verified the '${statementString}' statement as a metavariable.`, statementNode);