Practice Exercise 12.A
Datalog

## 2: Learning Goals

• Represent a simple domain using Datalog.
• Verify whether an interpretation is a model of a Datalog knowledge base.

## 3: Directed Questions

1. Is the expression in(building, Adam) ground? [solution]

2. How many terms are in the following definite clause? uffish(vorpal, tulgey)←slithy ∧burbled(Borogrove,raths). [solution]

3. Given a variable assignment ρ and a constant mapping φ, can you always generate a mapping from each variable to a constant? [solution]

## 4: Exercise: Rock-paper-scissors

In case you don't know how to play rock-paper-scissors, please read over the game play description provided by Wikipedia. Consider the following representation of rock-paper-scissors:
• constants: r, p, s
• predicate symbols: beats
• D={rock, paper, scissors}
• φ(r) = rock, φ(p) = paper, φ(s) = scissors
The knowledge base is defined by:
• beats(r,s).
• beats(s,p).
• beats(p,r).
1. Create an interpretation that is a model of the knowledge base and corresponds to the rules of rock-paper-scissors. Assume that "beats(X,Y)" means that X beats Y in a rock-paper-scissors game. [solution]
2. Create an interpretation that is a model of the knowledge base but does not correspond to the rules of rock-paper-scissors. [solution]
3. Create an interpretation that is a not a model of the knowledge base. [solution]
4. How many interpretations are there which satisfy the representation of rock-paper-scissors given above? [solution]
5. Of the possible interpretations, how many are models of the knowledge base? [solution]
6. Consider the following rule: "beats(X,Z) ← beats(X,Y) ∧ beats(Y,Z)". Is this rule consistent with the knowledge base? If not, modify the head of the rule to make it consistent. Is this rule true in the intended interpretation? If not, modify the head of the rule to make it true in the intended interpretation. [solution]

## 5: Learning Goals Revisited

• Represent a simple domain using Datalog.