From 3c91e1c9a03f0392a3ed3a918b7ce62fd5bb4b90 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 4 Jun 2016 22:25:36 +0100 Subject: [PATCH] add missing atom nodes to previous patch --- packages/bdd/trie_sp.yap | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/bdd/trie_sp.yap b/packages/bdd/trie_sp.yap index ba9106690..650763cf4 100644 --- a/packages/bdd/trie_sp.yap +++ b/packages/bdd/trie_sp.yap @@ -48,15 +48,20 @@ complex_to_and(atom(A1,[endlist]), Map0, MapF, V) :- !, check(Map0, A1, V, MapF). complex_to_and(functor(not,1,[int(A1,[endlist])]), Map0, MapF, not(V)) :- !, check(Map0, A1, V, MapF). -complex_to_and(atom(A1,Els), Map0, MapF, and(V,T2)) :- !, +complex_to_and(functor(not,1,[atom(A1,[endlist])]), Map0, MapF, not(V)) :- !, + check(Map0, A1, V, MapF). +complex_to_and(int(A1,Els), Map0, MapF, and(V,T2)) :- !, check(Map0, A1, V, MapI), complex_to_andor(Els, MapI, MapF, T2). -complex_to_and(int(A1,Els), Map0, MapF, and(V,T2)) :- !, +complex_to_and(atom(A1,Els), Map0, MapF, and(V,T2)) :- !, check(Map0, A1, V, MapI), complex_to_andor(Els, MapI, MapF, T2). complex_to_and(functor(not,1,[int(A1,Els)]), Map0, MapF, and(not(V),T2)) :- !, check(Map0, A1, V, MapI), complex_to_andor(Els, MapI, MapF, T2). +complex_to_and(functor(not,1,[atom(A1,Els)]), Map0, MapF, and(not(V),T2)) :- !, + check(Map0, A1, V, MapI), + complex_to_andor(Els, MapI, MapF, T2). % HASH TABLE, it can be an OR or an AND. complex_to_and(functor(not,1,[int(A1,Els)|More]), Map0, MapF, or(NOTV1,O2)) :- check(Map0, A1, V, MapI), @@ -69,6 +74,17 @@ complex_to_and(functor(not,1,[int(A1,Els)|More]), Map0, MapF, or(NOTV1,O2)) :- NOTV1 = and(not(V), T2) ), complex_to_and(functor(not,1,More), MapI2, MapF, O2). +complex_to_and(functor(not,1,[atom(A1,Els)|More]), Map0, MapF, or(NOTV1,O2)) :- + check(Map0, A1, V, MapI), + (Els == [endlist] + -> + NOTV1 = not(V), + MapI = MapI2 + ; + complex_to_andor(Els, MapI, MapI2, T2), + NOTV1 = and(not(V), T2) + ), + complex_to_and(functor(not,1,More), MapI2, MapF, O2). tabled_complex_to_andor(T, Map, Map, Tab, Tab, V) :- rb_lookup(T, V, Tab), !, @@ -88,6 +104,8 @@ tabled_complex_to_and(atom(A1,[endlist]), Map0, MapF, Tab, Tab, V) :- !, check(Map0, A1, V, MapF). tabled_complex_to_and(functor(not,1,[int(A1,[endlist])]), Map0, MapF, Tab, Tab, not(V)) :- !, check(Map0, A1, V, MapF). +tabled_complex_to_and(functor(not,1,[atom(A1,[endlist])]), Map0, MapF, Tab, Tab, not(V)) :- !, + check(Map0, A1, V, MapF). tabled_complex_to_and(T, Map, Map, Tab, Tab, V) :- rb_lookup(T, V, Tab), !, increment_ref_count(V). @@ -97,12 +115,24 @@ tabled_complex_to_and(IN, Map0, MapF, Tab0, TabF, OUT) :- rb_insert(Tab0, IN, OUT, TabI), OUT = and(0, _, V, T2), tabled_complex_to_andor(Els, MapI, MapF, TabI, TabF, T2). +tabled_complex_to_and(IN, Map0, MapF, Tab0, TabF, OUT) :- + IN = atom(A1,Els), !, + check(Map0, A1, V, MapI), + rb_insert(Tab0, IN, OUT, TabI), + OUT = and(0, _, V, T2), + tabled_complex_to_andor(Els, MapI, MapF, TabI, TabF, T2). tabled_complex_to_and(IN, Map0, MapF, Tab0, TabF, OUT) :- IN = functor(not,1,[int(A1,Els)]), !, check(Map0, A1, V, MapI), rb_insert(Tab0, IN, OUT, TabI), OUT = and(0, _, not(V), T2), tabled_complex_to_andor(Els, MapI, MapF, TabI, TabF, T2). +tabled_complex_to_and(IN, Map0, MapF, Tab0, TabF, OUT) :- + IN = functor(not,1,[atom(A1,Els)]), !, + check(Map0, A1, V, MapI), + rb_insert(Tab0, IN, OUT, TabI), + OUT = and(0, _, not(V), T2), + tabled_complex_to_andor(Els, MapI, MapF, TabI, TabF, T2). check(M0, K, V, M) :- rb_lookup(K, V, M0), !, M = M0. check(M0, K, V, M) :- rb_insert(M0, K, V, M).