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

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0

    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??


    thanks!
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,711
    Rep Power
    480

    Don't enjoy being stumped.


    I'm glancing through a prolog tutorial. Is the answer at the comment correct? Thanks.
    Code:
    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