Given multiple lists with sub-lists, how do you check for equivalence? For example, you are give data sets like this:
table(book,
[[["A"], ["A"], ["B", "C"], ["B", "C"]],
[["C"], ["S", "A"], ["S", "B", "A"]],
[["C", "A"], ["C", "S", "A"]],
[["C", "B", "S", "A"]]]).
table(book3,
[[["A"], ["A"], ["B", "C"], ["B", "C"]],
[["C"], ["S", "A"], ["S", "B", "A"]],
[["C", "A"], ["C", "S", "A"]],
[["A", "S", "B", "C"]]]).
Now, you have to check if these two tables are equivalent. Here is a sample output for when the two tables are equivalent:
?- table(book,T1),table(book3,T2),table_equivalent(T1,T2).
T1 = [[["A"], ["A"], ["B", "C"], ["B", "C"]],
[["C"], ["S", "A"],["S", "B", "A"]],
[["C", "A"], ["C", "S", "A"]], [["C", "B", "S", "A"]]],
T2 = [[["A"], ["A"], ["B", "C"], ["B", "C"]],
[["C"], ["S", "A"],["S", "B", "A"]],
[["C", "A"], ["C", "S", "A"]],
[["A", "S", "B", "C"]]].
I have a predicate that checks the equivalence of two lists with sub-lists:
row_equivalent(RowA,RowB) :-
check_sublist_equivalence(RowA, RowB).
check_sublist_equivalence([],[]).
check_sublist_equivalence([H|T],[H1|T1]) :-
rows(H,H1),
check_sublist_equivalence(T,T1).
rows([],_).
rows([H2|T2],K) :- member(H2,K), rows(T2,K).
Is there any way I can use this predicate to check the equivalence of the above two tables?