1

I am currently learning about predicate logic in Prolog. I am having trouble answering a question on the topic and would like to know the steps one one take to solve such a question using Prolog predicates. I have a scenario which must be represented in Prolog predicates using only two different predicate names.

  1. A and B are married
  2. B likes C
  3. C and D are married
  4. D likes E
  5. F likes B
  6. E likes B
  7. E and G are married
  8. A likes G
DrKhan
  • 313
  • 1
  • 3
  • 10

1 Answers1

2

Just write down what it says.

are_married(a,b).

likes(b,c).

And so on. We've used two names of predicates so far.

In Prolog, atoms are denoted by identifiers starting with a lower case letter. Identifiers starting with an upper case letter or an underscore _ denote logical variables.

Will Ness
  • 70,110
  • 9
  • 98
  • 181
  • Could they all be placed in two predicates? E.g are_married((a,b),(c,d),(e,g)). – DrKhan May 12 '13 at 15:56
  • 1
    @DrKhan no, thats not how Prolog works. You could of course define another predicate, `married_couples([ (a,b), (c,d), (e,f) ]).`. But then to get one married couple you'd have to spend some work. – Will Ness May 12 '13 at 16:17
  • Would this be correct for the following, I produced two predicates:
    1. is_married([a,b],[c,d],[e,g]). 2. likes([b,c],[d,e],[f,b],[e,b],[a,g]).
    – DrKhan May 15 '13 at 12:56
  • @DrKhan I don't know what you mean by that. If you could formulate more fully the background and describe what you need, then you can post a new question with all that. :) – Will Ness May 15 '13 at 13:05