problem: how to translate predicate logic sentences to Prolog? - PROLOG

This is a discussion on problem: how to translate predicate logic sentences to Prolog? - PROLOG ; given these 2 sentences in predicate logic: 1. for all Car: color(Car, blue) -> not owner(tim, Car) // tim doesnot have a blue car 2. color ( auto4, blue) // auto4 is a blue car with modus ponens I can ...

+ Reply to Thread
Results 1 to 6 of 6

problem: how to translate predicate logic sentences to Prolog?

  1. Default problem: how to translate predicate logic sentences to Prolog?

    given these 2 sentences in predicate logic:
    1. for all Car: color(Car, blue) -> not owner(tim, Car) // tim doesnot
    have a blue car
    2. color ( auto4, blue) // auto4 is a blue car

    with modus ponens I can conclude:
    3. not owner(tim, auto4) // tim doesnot have auto4

    How can I make a corresponding Prolog program ( translating 1. and 2.
    in Prolog) to derive fact 3.?

    greetings
    jeu van loon


  2. Default Re: problem: how to translate predicate logic sentences to Prolog?

    Hi!

    j.vanloon-ab@fontys.nl wrote:

    >
    > How can I make a corresponding Prolog program ( translating 1. and 2.
    > in Prolog) to derive fact 3.?


    You can use constraint handling rules:

    :- use_module(library(chr)).

    :- chr_constraint color/2, not_owner/2.

    color(Car, blue) ==> not_owner(tim, Car).


    Now, you can query:

    ?- color(auto4, blue).
    color(auto4, blue)
    not_owner(tim, auto4)

    Yes

    All the best,
    Markus.

  3. Default Re: problem: how to translate predicate logic sentences to Prolog?

    "j.vanloon-ab@fontys.nl" <j.vanloon-ab@fontys.nl> writes:

    > given these 2 sentences in predicate logic:
    > 1. for all Car: color(Car, blue) -> not owner(tim, Car) // tim doesnot
    > have a blue car


    Is Car of some particular type? "for all" suggests not, but the
    naming suggests yes.

    > 2. color ( auto4, blue) // auto4 is a blue car
    >
    > with modus ponens I can conclude:
    > 3. not owner(tim, auto4) // tim doesnot have auto4
    >
    > How can I make a corresponding Prolog program ( translating 1. and 2.
    > in Prolog) to derive fact 3.?


    Are you free to use the closed-world assumption or not? Ie, can you
    deduce "tim does not have auto4" just because you can't prove that
    "tim has auto4"?

    It sounds like you are not, but Prolog uses the CWA.

    If so, it's more a question of what you want to do with queries about
    people other than tim and cars other than blue. Letting all
    unmentioned cases succeed (Ie, treating other people as owning all
    cars and tim as owning all cars other than blue and all objects as
    possible cars and possible people), it's straightforward:

    %%1
    owner(Person, Car) :-
    Person \= tim
    ;
    \+ color(Car, blue).

    %%2
    color(auto4, blue).

    3 ?- owner(tim,auto4).

    No



    --
    Tom Breton, the calm-eyed visionary

  4. Default Re: problem: how to translate predicate logic sentences to Prolog?

    Hi Jeu,

    Well, if your question is theoretical one, you could see the book: W.
    F. Clocksin and C. S. Melish. Programming in Prolog. Springer-Verlag,
    1987. There are detailed instructions and an algorithm of translation
    of arbitrary logic rules into the Prolog notation (see chapter 10).

    If your question is practical one, you could see the last build of the
    Actor Prolog language, where the algorithm from the Clocksin Melish
    book is adopted.

    Please investigate the following example:
    A_PROLOG\EXAMPLES\FOR_RUSSIANS\STUDENTS\TRANSLATE.A

    The educational distribution pack of the Actor Prolog language you can
    get for free:

    http://www.cplire.ru/Lab144/start/setup1.exe

    Best regards,

    Alexei

    http://www.cplire.ru/Lab144/start/index.html


  5. Default Re: problem: how to translate predicate logic sentences to Prolog?

    You should read some (more) of the basic theory. There is a lot of substance
    pointed to by your question.

    Prolog has only "definite clauses", eg: "A is true if B and C are true".
    You can't prove things like "not A" except under certain assumptions, such
    as a failure to prove A true means that A is false.

    Hence you will various techniques to get to something resembling FOL in
    specific applications,
    and various extensions to Prolog to handle specific cases.

    In Logic Programming, there are lots of variations.
    Some like Prolog fall on the Programming end of the spectrum in that you
    have immediate control over the algorithm used.
    Others (notably various constraint extensions and the "rules" engines) fall
    more towards the Logic end and can apply in specific environments. But you
    don't have direct control over the algorithm.

    Sorry I didn't give you a piece of code to use in your class.

    Walter


    <j.vanloon-ab@fontys.nl> wrote in message
    news:1138711210.464470.171550@g47g2000cwa.googlegroups.com...
    > given these 2 sentences in predicate logic:
    > 1. for all Car: color(Car, blue) -> not owner(tim, Car) // tim doesnot
    > have a blue car
    > 2. color ( auto4, blue) // auto4 is a blue car
    >
    > with modus ponens I can conclude:
    > 3. not owner(tim, auto4) // tim doesnot have auto4
    >
    > How can I make a corresponding Prolog program ( translating 1. and 2.
    > in Prolog) to derive fact 3.?
    >
    > greetings
    > jeu van loon
    >




  6. Default Re: problem: how to translate predicate logic sentences to Prolog?

    you can use this two rules

    color(car,blue).
    color(auto4,blue). % auto4 is a blue car
    not_owner(tim,car).


    colours(X,Z):-color(X,Y),color(Z,Y),X\=Z.
    not_tim(X):-colours(X,Z),not_owner(tim,Z).


+ Reply to Thread

Similar Threads

  1. Strange clause/2 predicate behaviour in SWI-Prolog
    By Application Development in forum PROLOG
    Replies: 2
    Last Post: 03-25-2006, 04:28 AM
  2. Prolog Remote predicate call
    By Application Development in forum PROLOG
    Replies: 4
    Last Post: 09-28-2005, 03:38 AM
  3. Newbie: Translate natural language statements into logic
    By Application Development in forum PROLOG
    Replies: 7
    Last Post: 07-14-2005, 12:31 PM