Building a findNode user defined functor in souffle:
First build souffle with the addition below in src/include/souffle/datastrucutre/EquivalenceRelation.h
/*
* Returns unionfind parent of Node
* @param x
*/
value_type findNode(value_type x) const {
return sds.findNode(x);
}
souffle test.dl -g out.cpp
Edit out.cpp. Grep for myeq to find the rel_*_myeq
relation name. Replace
extern "C" {
souffle::RamSigned eqfind(souffle::RamSigned);
}
with
#include "helper.h"
and replace the name in helper.h accordingly
souffle-compile out.cpp ./out
Result:
philip@philip-desktop:~/Documents/prolog/soffule/userdef/eqrel$ ./out
---------------
parents
===============
1
5
7
===============
This is hopefully useful for not inserting obviously bad enodes into the database, reducing pressue on subsumption. Also maybe subsumpition can be written for an add enode for example
add(x,y,z) <= add(@eqfind(x),@eqfind(y),@eqfind(z)) :- add(x,y,z).
Which may be more efficient
One typo: datastrucutre -> datastructure
For subsumption to work,
findNode(x)
needs to returnx
if the equivalence relation does not containx
yet: