For SSU is the guard used as part of indexing to reduce choice point creation (if applicable)?

Hello,

I am listening to Markus video about indexing [1] and might have an epiphany …

Markus enumerates a number of techniques to help first argument indexing in determining when a clause is selected deterministically and without choice points.

One technique relates to pulling into, or rearranging the head to help the indexing identify that two clauses don’t equally unify.

So, i am now wondering with SSU and guards – is it now the guard that unequivocally determines which clause is selected deterministically and hence without choice point – (unless, the body reintroduces one?).

So, if the structure of guards make clauses distinguishable, then no choice point is created?

thanks,

Dan

[1] https://youtu.be/FZLofckPu4A

You don’t need SSU for that. There are also systems that deal with a clause stating X > 0 and a clause X =< 0 are mutually exclusive. Don’t exaggerate the price of a choicepoint though. Creating one is merely copying a handful values and reclaiming is even cheaper if nothing needs to be undone. Choicepoints are fairly ok for proper Prolog code that actually searches using non-determinism, i.e., the thing Prolog was meant for. Only “functional” code (code that uniquely matches inputs to output) requires choicepoints to be removed as early as possible. Failure to do so kills LCO and causes much more memory to remain accessible, slowing down GC. Short-lived choice points used to do a little backtracking to find the right clause are not a big issue.