3
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ There are no trivial prolog questions, so don't despair! $\endgroup$ Commented Jan 1, 2019 at 13:36
  • $\begingroup$ Why do you think you can convert arbitrary first-order formulas into Prolog? $\endgroup$ Commented Jan 1, 2019 at 13:43
  • $\begingroup$ @DerekElkins If I can't convert the FOL into Prolog .. what would I do to convert the previous English sentences into Prololg? $\endgroup$
    – Nagham
    Commented Jan 1, 2019 at 15:04
  • 2
    $\begingroup$ Again, why do you think that's something you can do? $\endgroup$ Commented Jan 1, 2019 at 22:29

1 Answer 1

2
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.