3

I am very new to PROLOG so it might be a very trivial question, but I absolutely have no idea how to solve it. There are 4 sentences I need to formulate into PROLOG code:

  • All hounds howl at night.

  • Anyone who has any cats will not have any mice.

  • Light sleepers do not have anything which howls at night.

  • John has either a cat or a hound.

I convert sentences to well-formed formula in first-order predicate calculus like that

- ∀x (HOUND(x) → HOWL(x))

- ∀x ∀y (HAVE(x,y) ∧ CAT (y) → ¬∃z (HAVE(x,z) ∧ MOUSE (z)))

- ∀x (Light_Sleeper(x) → ¬∃y (HAVE (x,y) ∧ HOWL(y)))

- ∃x (HAVE (John,x) ∧ (CAT(x) ∨ HOUND(x)))

Now I don't know how to write them in Prolog. Also, how can I make query on them?

Nagham
  • 39
  • 2

1 Answers1

2

If you can convert them to Horn clauses, you can convert them to Prolog.

If you can't convert them to Horn clauses, I don't think you can convert them to Prolog.

So, convert them to Horn clauses first, and then see the answer to this question:

Horn clause to Prolog

edom
  • 73
  • 7