1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Rep Power

    Unification_(prolog) in Python

    I'm beginning to study Python and I read that you can define functions of predicates unification (prolog style) in Python .

    I want to define a function:
    def unif(list1, list2):

    which returns: b_ok, d_subst
    b_ok : True if the unification is possible, False sinon
    d_subst : one correct substitution of the case (a substitution function)

    ex: unif(['p','A'],['p','a']) ----> True, {'A':'a'}

    I really do not see how to write python`s code for this...

    any help??

  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power

    Don't enjoy being stumped.

    I'm glancing through a prolog tutorial. Is the answer at the comment correct? Thanks.
    4.14 Prolog operators
    :- op(P,T,O). 
    Declare an operator symbol. For example, with source program ...
    :- op(500,xfx,'has_color'). 
    a has_color red. 
    b has_color blue.
    Then ...
    ?- b has_color C. 
    C = red                          /* Is this correct?  If so, why? */
    ?- What has_color red. 
    What = a
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo