Skip to content

Commit

Permalink
iterative make_rep (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-irfan committed Mar 7, 2023
1 parent af766a4 commit ae6aa42
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions src/mcsat/weq/weak_eq_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

#include "mcsat/tracing.h"

//#include "utils/int_array_sort2.h"
#include "utils/ptr_vectors.h"
#include "utils/refcount_strings.h"
#include "utils/int_array_sort2.h"


#define USE_ARRAY_DIFF 0 //experimental
Expand Down Expand Up @@ -344,17 +345,37 @@ static void weq_graph_make_rep(weq_graph_t* weq, weq_graph_node_t* n) {
return;
}

// TODO: make the code non-recursive
weq_graph_make_rep(weq, n->p);
// invert primary edge
n->p->p = n;
n->p->pstore = n->pstore;
n->p->pi = n->pi;
n->p = NULL;
// fix weak-i representatives
weq_graph_make_rep_i(weq, n);
n->pstore = NULL_TERM;
n->pi = NULL_TERM;
weq_graph_node_t* tmp = n;
weq_graph_node_t* prev = NULL;
weq_graph_node_t* next = NULL;
pvector_t to_process;
init_pvector(&to_process, 0);

// invert all the primary edges
// first goto the root and keep track of the visited nodes in a stack
while (tmp) {
pvector_push(&to_process, tmp);
tmp = tmp->p;
}

// now invert he primary edges by popping nodes from the stack
prev = pvector_pop2(&to_process);
while (to_process.size > 0) {
next = pvector_pop2(&to_process);
prev->p = next;
prev->pstore = next->pstore;
prev->pi = next->pi;

next->p = NULL;
// make sure the node is weak-rep-i
weq_graph_make_rep_i(weq, next);
next->pstore = NULL_TERM;
next->pi = NULL_TERM;

prev = next;
}

delete_pvector(&to_process);
}

/* Get representative term w.r.t. the equality graph.
Expand Down

0 comments on commit ae6aa42

Please sign in to comment.