mercredi 23 décembre 2020

Pure Prolog Peano List Intersection

Assume we are only looking at lists of Peano numbers. And lets assume pure_2 Prolog is not pure_1 Prolog with dif/2, but rather with pure_1 Prolog with when/2. Can we implement list intersection?

We would step back and pick up ideas from programming languages Gödel and Nu-Prolog. Thus for any needed if-then-else we would draw on this answer here. What would be:

/* pure_2 Prolog = pure_1 Prolog with when/2 */
intersect(A, B, C) :- ??

Note that nevertheless contrary to Gödel and Nu-Prolog, to adhere to pure_2 Prolog for this equestion here we would be not allowed to use ISO Prolog if-then-else (->;_). But we might use an apartness relation as demanded here.

A test case would for example be:

?- intersect([X], [Y], Z).
solution1 ;
solution2 ;
...

Should not crash or hang.

Aucun commentaire:

Enregistrer un commentaire