[m-users.] unification of object terms

Christophe Rey cjcrey at gmail.com
Sat Mar 5 03:29:21 AEDT 2016


Dear Zoltan,

thank you for your quick answer, and sorry for my naive questions. I am 
still beginning learning mercury.
I will follow your advices.
Thanks again.

Regards

Christophe

Le 04/03/2016 12:01, Zoltan Somogyi a écrit :
>
> On Fri, 4 Mar 2016 11:05:05 +0100, Christophe REY <cjcrey at gmail.com> wrote:
>> unify_term(term(T)::in, term(T)::in, substitution(T)::in, substitution(T)::out)
>>
>> from the term module.
>>
>> Using term_io.read_term, I am able to read object terms, so I have two
>> ground terms for the first two arguments of unify_terms.
>> When I call unify_term with the object terms p(X,foo) and p(bar,Y), then
>> it fails. It seems that there cannot be (object) variables inside both
>> terms to unify. When there are variables only inside one term, then it
>> is ok.
>> Is it normal ?
> It is not normal, but it is exactly what I would expect if you gave
> unify_term two terms that you read in separately, and did not do anything
> to merge their varsets. That way, p(X, foo) would have X as variable 1,
> p(bar, Y) would have Y as variable 1, and the unification would fail
> because variable 1 cannot be bound to both bar and foo at the same time.
>
> If you get two terms from two different sources but want to unify them,
> (or do any other operation that operates on both terms), you need to
> get them to use variables from the same varset first.
> The predicate varset.merge_renaming is what you need.
> merge_renaming(TermAVarSet, TermBVarSet, BothTermsVarSet,
> RenamingFromBToBoth) extends TermAVarSet, adding to it all
> the variables in TermBVarSet, and returns the result as BothTermsVarSet.
> It also returns the renaming that you apply to TermB; the result will
> use the variables in BpthTermsVarSet.
>   
> Zoltan.
>
>

-- 
___________________________________________________
Christophe Rey
  
MCF / Associate professor
Université Blaise Pascal Clermont 2

Email : christophe.rey at univ-bpclermont.fr
         rey at isima.fr
Web   : http://fc.isima.fr/~crey/

Laboratoire LIMOS
   Campus Universitaire des Cézeaux
   1 rue de la Chebarde TSA 60125 - CS 60026
   63178 AUBIERE cedex
   Tel : +33 (0)4 73 40 50 09
   Fax : +33 (0)4 73 40 50 01

IUT d'Allier, Dept MMI Vichy
   Pôle Universitaire
   1, av. des Célestins 03200 VICHY
   Tel : +33 (0)4 70 30 43 92
   Fax : +33 (0)4 70 30 43 78
___________________________________________________




More information about the users mailing list