When do two Prolog terms marry? (Was: The issue with free speech)

Liste des GroupesRevenir à cl prolog 
Sujet : When do two Prolog terms marry? (Was: The issue with free speech)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 14. Oct 2024, 18:15:17
Autres entêtes
Message-ID : <vejjj4$dlal$1@solani.org>
References : 1 2 3 4 5
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
Now I was struggling giving this predicate
a better name. Namely variant_term bootstrapped
as follows:
variant_term(X, Y) :-
    subsumes_term(X, Y),
    subsumes_term(Y, X).
Why does it need a better name? Well because it
is not really the variant, as realized by
for example SWI-Prolog's (=@=):
For example I find:
?- variant_term(f(X,Y,Z,T), f(A,B,C,D)).
true.
?- variant_term(f(X,Y,Z,T), f(A,B,Z,D)).
true.
?- variant_term(f(A,Y,Z,T), f(A,B,Z,D)).
true.
?- variant_term(f(A,Y,Z,T), f(A,B,C,Z)).
fail.
?- variant_term(f(X,A,Z,T), f(A,B,Z,D)).
fail.
The first 3 test cases match what variant/2
usually does. But the last 2 test cases don't
match what variant/2 usually does.
So how can characterize the behaviour of
this weak variant. I came up with this observation:
- A weak variant takes has variables that appear
   in the left hand side and in the right hand side,
   i.e. common variables, only obtaining an identity
   relation.
- Othewise variables that are either specific to
   the right hand side or that are either specific
   to the left hand side, are associated by a
   bijection relation.
I came up with names like "twin", "sibling" for
this relation. But I got also inspired by the
fact that builtins:variant/2 from Scryer Prolog
leaves bindings. So looking for a name similar
like "unify", but only its weak variant and it
leaves a binding trace. My idea is to use "marry"!

Date Sujet#  Auteur
9 Oct 24 * A FFI for evaluable functions7Mild Shock
9 Oct 24 +* Name resolution is a blackbox (Re: A FFI for evaluable functions)5Mild Shock
9 Oct 24 i`* plonk in discourse (Was: The issue with free speech)4Mild Shock
14 Oct 24 i `* When do two Prolog terms marry? (Was: The issue with free speech)3Mild Shock
14 Oct 24 i  +- Re: When do two Prolog terms marry? (Was: The issue with free speech)1Mild Shock
15 Oct 24 i  `- native implementation of variant/2 can be fast (Was: When do two Prolog terms marry?)1Mild Shock
3 Nov 24 `- KISS principle pays off (Was: A FFI for evaluable functions)1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal