General
Material
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5

Hints

  1. Harry is a wizard.
    This sentence assigns a property (being a wizard) to a specific individual (Harry). It hence states a fact. Properties are ususally encoded as Prolog predicates, and specific individuals as atoms. Remember that atoms cannot start with a capital letter; i.e., Harry is not an atom, while harry and 'Harry' are atoms.
  2. Hagrid scares Dudley. This sentence says that a particular relation (scare) holds between two specific individuals (Hagrid and Dudley). Hence, it states a fact.
  3. All wizards are magical. This sentence does not talk about a specific individual, but about all individuals with a certain property (all individuals with the property of being a wizard). It expresses a general rule about wizards. The sentence could be reformulated as if somebody is a wizard, then he/she is magical or as for all X, if X is a wizard, then X is magical.
  4. Uncle Vernon hates anyone who is magical. This sentence states that a particular relation (hate) holds between a specific individual (Uncle Vernon) and any other individual with the property of being magical. You need a rule to express this. The sentence could be reformulated as for all X, if X is magical, then Uncle Vernon hates X.
  5. Aunt Petunia hates anyone who is magical or scares Dudley. This sentence is very similar to the above. It states that Aunt Petunia hates anyone who is magical and in addition, she hates anyone who scares Dudley. This can be reformulated as follows: for all X, if X is magical or scares Dudley, then Aunt Petunia hates X, which is the same as saying for all X, if X is magical, then Aunt Petunia hates X, and for all X, if X scares Dudley, then Aunt Petunia hates X. That is, we express the disjunction by specifying two rules: one for each disjunct.

Solutions

Back to the exercise.