Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different/2 - does a pure, determinate definition exist?

different(Xs, Ys) :-    member(X, Xs),    non_member(X, Ys). different(Xs, Ys) :-    member(Y, Ys),    non_member(Y, Xs). 

While this definition using member/2 and non_member/2 is almost1 perfect from a declarative viewpoint, it produces redundant solutions for certain queries and leaves choice points all around.

What is a definition that improves upon this (in a pure manner probably using if_/3 and (=)/3) such that exactly the same set of solutions is described by different/2 but is determinate at least for ground queries (thus does not leave any useless choice points open) and omits (if possible) any redundant answer?


1 Actually, different([a|nonlist],[]), different([],[b|nonlist]) succeeds. It could equally fail. So a solution that fails for both is fine (maybe even finer).

like image 970
false Avatar asked Jun 16 '15 09:06

false


People also ask

What does determinate mean in philosophy?

Determination relates properties that are more or less specific, relative to each other. For example, red is a determinate of color; scarlet is a determinate of red.

What is existence according to Aristotle?

Aristotle seems to have seen nothing more to existence than essence; there is not a space between an articulation of what a thing is and that thing's existing. Saint Thomas Aquinas, on the other hand, famously distinguished a thing's essence from its existence.

What makes a thing determinate?

A thing is determinate when it is particularly designated or physically segregated from all others of the same class. (Art. 1460) It is determinate or specific if it is distinct from all others and can individually be classified or determined. From the word itself determinate meaning can be determined from all others.

What is essence and existence in philosophy?

Essence and Existence. A general notion of essence is the following: essence is the definable nature of the thing that exists. Quite generally then, the essence of a thing is signified by its definition. The immediate question then is how the essence of a thing relates to its existence.


1 Answers

First try!

The following code is based on the meta-predicates tfilter/3 and tpartition/4, the monotone if-then-else control construct if_/3, the reified unary logical connective not_t/3, and the reified term equality predicate (=)/3:

different([],[_|_]). different([X|Xs0],Ys0) :-    tpartition(=(X),Ys0,Es,Ys1),    if_(Es=[], true, (tfilter(not_t(=(X)),Xs0,Xs1),different(Xs1,Ys1))). 

Sample query:

?- different([A,B],[X,Y]).                 A=Y ,           dif(B,Y),     X=Y ;     A=X           ,     B=X           , dif(X,Y) ;     A=X           , dif(B,X), dif(B,Y), dif(X,Y) ;               A=Y ,               B=Y , dif(X,Y) ;               A=Y , dif(B,X), dif(B,Y), dif(X,Y) ; dif(A,X), dif(A,Y). 

Let's observe determinism when working with ground data:

?- different([5,4],[1,2]). true. 

The above approach feels like a step in the right direction... But, as-is, I wouldn't call it perfect.

like image 109
repeat Avatar answered Sep 20 '22 15:09

repeat