# 13.3.1 Semantics of Ground Datalog

The first step in giving the semantics of Datalog is to give the semantics for the ground (variable-free) case.

An interpretation is a triple $I=\left$

• $D$ is a non-empty set called the domain. Elements of $D$ are individuals.

• $\phi$ is a mapping that assigns to each constant an element of $D$.

• $\pi$ is a mapping that assigns to each n-ary predicate symbol a function from $D^{n}$ into $\{\mbox{true},\mbox{false}\}$.

$\phi$ is a function from names into individuals in the world. The constant $c$ is said to denote the individual $\phi(c)$. Here $c$ is a symbol but $\phi(c)$ can be anything: a real physical individual such as a person or a virus, an abstract concept such as a course, love, the number 2, or a symbol.

$\pi(p)$ specifies whether the relation denoted by the $n$-ary predicate symbol $p$ is true or false for each $n$-tuple of individuals. If predicate symbol $p$ has no arguments, then $\pi(p)$ is either true or false. Thus, for predicate symbols with no arguments, this semantics reduces to the semantics of propositional definite clauses.

###### Example 13.4.

Consider the world consisting of three individuals on a table:

✢   ✥         ✮

These are drawn in this way because they are things in the world, not symbols. ✢ is a pair of scissors, is a telephone, and ✮ is a pencil.

Suppose the constants in our language are $phone$, $pencil$, and $telephone$. We have the predicate symbols $noisy$ and $left\_of$. Assume $noisy$ is a unary predicate (it takes a single argument) and that $left\_of$ is a binary predicate (it takes two arguments).

An example interpretation that represents the individuals on the table is

• $D=\{\mbox{\mbox{\Pisymbol{pzd}{34}}},\mbox{\mbox{\Large\Pisymbol{pzd}{37}}},% \mbox{\mbox{\Pisymbol{pzd}{46}}}\}$.

• $\phi(phone)=\mbox{\mbox{\Large\Pisymbol{pzd}{37}}}$, $\phi(pencil)=\mbox{\mbox{\Pisymbol{pzd}{46}}}$, $\phi(telephone)=\mbox{\mbox{\Large\Pisymbol{pzd}{37}}}$.

• $\pi(noisy)$: $\langle\mbox{\mbox{\Pisymbol{pzd}{34}}}\rangle$ false $\langle\mbox{\mbox{\Large\Pisymbol{pzd}{37}}}\rangle$ true $\langle\mbox{\mbox{\Pisymbol{pzd}{46}}}\rangle$ false
$\pi(left\_of)$: $\langle\mbox{\mbox{\Pisymbol{pzd}{34}}},\mbox{\mbox{\Pisymbol{pzd}{34}}}\rangle$ false $\langle\mbox{\mbox{\Pisymbol{pzd}{34}}},\mbox{\mbox{\Large\Pisymbol{pzd}{37}}}\rangle$ true $\langle\mbox{\mbox{\Pisymbol{pzd}{34}}},\mbox{\mbox{\Pisymbol{pzd}{46}}}\rangle$ true $\langle\mbox{\mbox{\Large\Pisymbol{pzd}{37}}},\mbox{\mbox{\Pisymbol{pzd}{34}}}\rangle$ false $\langle\mbox{\mbox{\Large\Pisymbol{pzd}{37}}},\mbox{\mbox{\Large\Pisymbol{pzd}% {37}}}\rangle$ false $\langle\mbox{\mbox{\Large\Pisymbol{pzd}{37}}},\mbox{\mbox{\Pisymbol{pzd}{46}}}\rangle$ true $\langle\mbox{\mbox{\Pisymbol{pzd}{46}}},\mbox{\mbox{\Pisymbol{pzd}{34}}}\rangle$ false $\langle\mbox{\mbox{\Pisymbol{pzd}{46}}},\mbox{\mbox{\Large\Pisymbol{pzd}{37}}}\rangle$ false $\langle\mbox{\mbox{\Pisymbol{pzd}{46}}},\mbox{\mbox{\Pisymbol{pzd}{46}}}\rangle$ false

Because $noisy$ is unary, it takes a singleton individual and has a truth value for each individual.

Because $left\_of$ is a binary predicate, it takes a pair of individuals and is true when the first element of the pair is left of the second element. Thus, for example, $\pi(left\_of)(\langle\mbox{\mbox{\Pisymbol{pzd}{34}}},\mbox{\mbox{\Large% \Pisymbol{pzd}{37}}}\rangle)=true$, because the scissors are to the left of the telephone; $\pi(left\_of)(\langle\mbox{\mbox{\Pisymbol{pzd}{46}}},\mbox{\mbox{\Pisymbol{% pzd}{46}}}\rangle)=false$, because the pencil is not to the left of itself.

Note how the $D$ is a set of things in the world. The relations are among the individuals in the world, not among the names. As $\phi$ specifies that $phone$ and $telephone$ refer to the same individual, exactly the same statements are true about them in this interpretation.

###### Example 13.5.

Consider the interpretation of Figure 13.1.

$D$ is the set with four elements: the person Kim, room 123, room 023, and the CS building. This is not a set of four symbols, but it is the set containing the actual person, the actual rooms, and the actual building. It is difficult to write down this set and, fortunately, you never really have to. To remember the meaning and to convey the meaning to another person, knowledge base designers typically describe $D$, $\phi$, and $\pi$ by pointing to the physical individuals or a depiction of them (as is done in Figure 13.1) and describe the meaning in natural language.

The constants are $kim$, $r123$, $r023$, and $cs\_building$. The mapping $\phi$ is defined by the gray arcs from each of these constants to an individual in the world in Figure 13.1.

The predicate symbols are $person$, $in$, and $part\_of$. The meaning of these are meant to be conveyed in the figure by the arcs from the predicate symbols.

Thus, the person called Kim is in the room $r123$ and is also in the CS building, and these are the only instances of the $in$ relation that are true. Similarly, room $r123$ and room $r023$ are part of the CS building, and there are no other $part\_of$ relationships that are true in this interpretation.

Each ground term denotes an individual in an interpretation. A constant $c$ denotes in $I$ the individual $\phi(c)$.

A ground atom is either true or false in an interpretation. Atom $p(t_{1},\ldots,t_{n})$ is true in $I$ if $\pi(p)(\left)=\mbox{true}$, where $t_{i}^{\prime}$ is the individual denoted by term $t_{i}$, and is false in $I$ otherwise.

###### Example 13.6.

The atom $in(kim,r123)$ is true in the interpretation of Example 13.5, because the person denoted by $kim$ is indeed in the room denoted by $r123$. Similarly, $person(kim)$ is true, as is $part\_of(r123,cs\_building)$. The atoms $in(cs\_building,r123)$ and $person(r123)$ are false in this interpretation.

Logical connectives, models and logical consequences have the same meaning as in the propositional calculus:

• A ground clause is false in an interpretation if the head is false and the body is true (or is empty); otherwise, the clause is true in the interpretation.

• A model of a knowledge base $KB$ is an interpretation in which all the clauses in $KB$ are true.

• If $KB$ is a knowledge base and $g$ is a proposition, $g$ is a logical consequence of $KB$, written $KB\models g$, if $g$ is true in every model of $KB$. Thus $KB\not\models g$, meaning $g$ is not a logical consequence of $KB$, when there is a model of $KB$ in which $g$ is false.