[Edit to add examples] I’m trying to table a predicate of specializations (like a class hierarchy) where the order of backtracking matters:
:- table specializesAll/2.
specializesAll(Type, BaseType) :-
rel(Type, specializes, BaseType).
specializesAll(Type, BaseType) :-
rel(IntermediateType, specializes, BaseType),
specializesAll(Type, IntermediateType).
When I table and then query it, it seems the backtracking order isn’t preserved. Is this by design or am I doing something wrong?
Before tabling:
?- specializes(idWorld, X).
X = idThing ;
X = idPhysicalObject ;
X = idPlace.
After tabling:
?- specializes(idWorld, X).
X = idPhysicalObject ;
X = idPlace ;
X = idThing.