83 {
84 for (size_t i = 0; i < stack_size; i++) {
87 LitNum L;
88 ClauseNum C2;
89 LitNum L2;
90 LitNum P;
91 size_t lemma_index;
96 size_t path_index;
102 size_t new_depth;
103 UnificationOutcome u_result;
105 switch (si.item_type) {
106 case StackItemType::Start:
109 current_node = root;
110 current_node->
p.push_back(PathPair(0,0));
111 current_node->
t_child = ++t_count;
113 current_node->
matrix_id = si.this_action.C_2;
115 break;
116 case StackItemType::Axiom:
117 break;
118 case StackItemType::Reduction:
119 L = si.this_action.Lindex;
120 P = si.this_action.index_in_path;
121
122
125
126
128 connection_node->parent = current_node;
129 connection_node->type = TableauNodeType::Reduction;
130 connection_node->
depth = current_node->
depth + 1;
131
133 connection_node->
lemma->type = TableauNodeType::Lemma;
135 connection_node->
lemma->parent = connection_node;
136
138 current_node->
lemma_list.push_back(lemma_count);
139 connection_node->lemma_list_p = current_node->lemma_list_p;
140 current_node->lemma_list_p.push_back(connection_node->
lemma);
141
142 connection_node->
t = current_node->
t_child;
143 connection_node->
l = current_node->
l_child;
144 connection_node->
p = current_node->
p;
145 connection_node->
p.push_back(PathPair(connection_node->
t,
146 connection_node->
l));
148
150 false_node->parent = connection_node;
152 false_node->
t = ++t_count;
153 false_node->
p = connection_node->
p;
154 false_node->
p.push_back(PathPair(false_node->
t, 0));
157
158 complementary_literal = current_node->
path[P];
159 negated_literal = complementary_literal;
161 u_result = u(negated_literal, next_node_literal);
162 if (u_result != UnificationOutcome::Succeed ||
164 cerr << "There's a problem with your reduction unification." << endl;
165 exit(EXIT_FAILURE);
166 }
167 else {
169 }
170 current_node->
children.push_back(connection_node);
171 connection_node->
children.push_back(false_node);
172 break;
173 case StackItemType::LeftBranch:
174 L = si.this_action.Lindex;
175 C2 = si.this_action.C_2;
176 L2 = si.this_action.Lprime;
177
178
181
182 right_stack.push_back(current_node->
depth);
183
184
186
187
188
189 complementary_literal = C[L2];
190 negated_literal = complementary_literal;
192 u_result = u(negated_literal, next_node_literal);
193
194
195
197 if (u_result != UnificationOutcome::Succeed ||
199 cerr << "There's a problem with your extension unification." << endl;
200 exit(EXIT_FAILURE);
201 }
202 else {
204 }
205 new_node->parent = current_node;
206 new_node->
t = current_node->
t_child;
211 new_node->
path = current_node->
path;
212 new_node->
path.push_back(next_node_literal);
213
215 new_node->
lemma->type = TableauNodeType::Lemma;
217 new_node->
lemma->parent = new_node;
218
220 current_node->
lemma_list.push_back(lemma_count);
221 new_node->lemma_list_p = current_node->lemma_list_p;
222 current_node->lemma_list_p.push_back(new_node->
lemma);
223
224 new_node->
l = current_node->
l_child;
228 new_node->
p = current_node->
p;
229 new_node->
p.push_back(PathPair(new_node->
t, new_node->
l));
230
231
232 current_node->
children.push_back(new_node);
233
234
236 connection_node->parent = new_node;
237 connection_node->
depth = current_node->
depth + 2;
238
239 connection_node->
t = t_count;
240 connection_node->
l = new_node->
l_child;
242 connection_node->
p = new_node->
p;
243 connection_node->
p.push_back(PathPair(connection_node->
t,
244 connection_node->
l));
245
247 false_node->parent = connection_node;
249
250 false_node->
t = ++t_count;
251
252 connection_node->
children.push_back(false_node);
253 new_node->
children.push_back(connection_node);
254
255 current_node = new_node;
257 break;
258 case StackItemType::RightBranch:
259 new_depth = right_stack.back();
260 right_stack.pop_back();
261 while (current_node->
depth != new_depth) {
262 current_node = current_node->parent;
263 }
264 break;
265 case StackItemType::Lemmata:
266 L = si.this_action.Lindex;
267 lemma_index = si.this_action.index_in_lemmata;
268
271
272
274 connection_node->parent = current_node;
275 connection_node->
depth = current_node->
depth + 1;
276 connection_node->
t = current_node->
t_child;
277 connection_node->
l = current_node->
l_child;
278 connection_node->
p = current_node->
p;
279 connection_node->
p.push_back(PathPair(connection_node->
t,
280 connection_node->
l));
281
283 current_node->
children.push_back(connection_node);
284
285 lemma_literal = current_node->lemma_list_p[lemma_index]->lit;
287 new_node->type = TableauNodeType::LemmaExtension;
288 new_node->parent = connection_node;
289 new_node->
t = ++t_count;
291 new_node->parent = connection_node;
294 new_node->
p = connection_node->
p;
295 new_node->
p.push_back(PathPair(new_node->
t,
297
298
299
300
301 u_result = u(next_node_literal, lemma_literal);
302 if (u_result != UnificationOutcome::Succeed ||
304 cerr << "There's a problem with your lemma unification." << endl;
305 exit(EXIT_FAILURE);
306 }
307 else {
309 }
311
312 current_node->lemma_list_p[lemma_index]->lemma_is_used=true;
313
314 connection_node->
children.push_back(new_node);
315
317 false_node->parent = new_node;
319 false_node->
t = ++t_count;
320 false_node->
p = connection_node->
p;
321 false_node->
p.push_back(PathPair(false_node->
t, 0));
322
323 new_node->
children.push_back(false_node);
324 break;
325 default:
326 cerr << "Something is really wrong..." << endl;
327 break;
328 }
329
330 }
331}
Representation of clauses.
void drop_literal(LitNum)
Get rid of the specified Literal.
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of argume...
bool is_compatible_with(const Literal *) const
Literals can only be unified if the polarity and actual predicate are the same.
void invert()
Basic manipulation - entirely self-explanatory.
string get_name(size_t _i) const
Retrieve the name of one of the clauses in the matrix.
void make_copy_with_new_unique_vars(size_t, Clause &, VariableIndex &, TermIndex &) const
Make a new copy of a clause in the matrix.
General representation of a substitution.
Class for representing nodes in a tableau proof.
bool needs_lemma_link
Used in producing LaTex output to indicate that a link has to be added.
size_t matrix_id
Some nodes need to produce output referring to a clause in the matrix.
Substitution sub
Substitution associated with reduction, extension or lemma.
LitNum l
A node in the tableau is identified by ‘t : l’.
ClauseNum t_child
Nodes maintain the t value for children.
PathPair reduction_node
Which node is associated with this one?
ClauseNum t
A node in the tableau is identified by ‘t : l’.
vector< Literal > path
Paths are stored both as collections of literals and collections of t:l pairs. Both are needed for co...
vector< size_t > lemma_list
Lemma lists are kept as both numbers and pointer to other nodes. Both are needed.
vector< TableauProofNode * > children
Children of this node.
vector< PathPair > p
Paths are stored both as collections of literals and collections of t:l pairs. Both are needed for co...
bool needs_reduction_link
Used in producing LaTex output to indicate that a link has to be added.
TableauProofNode * lemma
Lemma associated with a reduction or extension.
LitNum l_child
Nodes maintain the l value for children.
size_t depth
Where are we in the tree? Used for backtracking.
size_t lemma_reduction_node
Which node is associated with this one?
size_t lemma_number
Numerical identifier for a lemma.
Clause c_remaining
Starts equal to c. At each step in constructing the tableau a single literal is dealt with in a child...
Wrap up various applications of unificiation into a single class: all the unification you need to do ...
void backtrack()
Apply the backtracking process to the substitution that has been constructed.
Substitution get_substitution() const
Trivial get methods for the result.
Stack items: each contains its own material for generating possible next inferences.