foundations of computational agents
When a variable appears in a clause, the clause is true in an interpretation only if the clause is true for all possible values of that variable.
To formally define semantics of variables, a variable assignment, , is a function from the set of variables into the domain . Thus, a variable assignment assigns an element of the domain to each variable. Given interpretation and variable assignment , each term denotes an individual in the domain. If the term is a constant, the individual is given by . If the term is a variable, the individual is given by . Given an interpretation and a variable assignment, each atom is either true or false, using the same definition as earlier. Thus, given an interpretation and a variable assignment, each clause is either true or false.
A clause is true in an interpretation if it is true for all variable assignments. The variables are said to be universally quantified in the scope of the clause. Thus, a clause is false in an interpretation means there is a variable assignment under which the clause is false.
is false in the interpretation of Example 13.5, because under the variable assignment with denoting Kim and denoting Room 123, the clause’s body is true and the clause’s head is false.
is true, because in all variable assignments where the body is true, the head is also true.
Logical consequence is defined in the same way as it was for propositional definite clauses in Section 5.1: ground body is a logical consequence of , written , if is true in every model of .
Suppose the knowledge base is
The interpretation defined in Example 13.5 is a model of , because each clause is true in that interpretation.
, because this is stated explicitly in the knowledge base. If every clause of is true in an interpretation, then must be true in that interpretation.
. The interpretation defined in Example 13.5 is a model of , in which is false.
is a model of in which is false.
. If the clauses in are true in interpretation , it must be the case that is true in , otherwise, there is an instance of the third clause of that is false in – a contradiction to being a model of .
The following example shows how the semantics treats variables appearing in a clause’s body but not in its head.
In Example 13.8, the variable in the clause defining is universally quantified at the level of the clause; thus, the clause is true for all variable assignments. Consider particular values for and for . The clause
is true for all variable assignments to . If there exists a variable assignment for such that is true in an interpretation, then must be true in that interpretation. Therefore, you can read the last clause of Example 13.8 as “for all and for all , is true if there exists a such that is true.”
The definite clause language makes universal quantification implicit. Sometimes it is useful to make quantification explicit. There are two quantifiers that are used in logic:
, read “for all , ” means is true for every variable assignment for . is said to be a universally quantified.
, read “there exists an such that ” means is true for some variable assignment for . is said to be existentially quantified.
The clause means
which is equivalent to
Thus, free variables that only appear in the body are existentially quantified in the scope of the body.
It may seem as though there is something peculiar about talking about a clause being true for cases where it does not make sense, as in the following example.
Consider the clause
where denotes a course, denotes an abstract concept, and denotes the sky. Here, the clause is vacuously true in the intended interpretation according to the truth table for , because the clause’s right-hand side is false in the intended interpretation.
As long as whenever the head is nonsensical, the body is also, the rule can never be used to prove anything nonsensical. When checking for the truth of a clause, you must only be concerned with those cases in which the clause’s body is true. The convention that a clause is true whenever the body is false, even if it strictly does not make sense, makes the semantics simpler and does not cause any problems.
The formal description of semantics does not tell us why semantics is interesting or how it can be used as a basis to build intelligent systems. The methodology for using semantics for propositional logic programs can be extended to Datalog:
Select the task domain or world to represent. This could be some aspect of the real world, for example, the structure of courses and students at a university or a laboratory environment at a particular point in time, some imaginary world, such as the world of Alice in Wonderland, or the state of the electrical environment if a switch breaks, or an abstract world, for example, the world of money, numbers and sets. Within this world, let the domain be the set of all individuals or things that you want to be able to refer to and reason about. Also, select which relations to represent.
Associate constants in the language with individuals in the world that you want to name. For each element of you want to refer to by name, assign a constant in the language. For example, you may select the name “” to denote a particular professor, the name “” for a particular introductory AI course, the name “” for the number that is the successor of the number one, and the name “” for the color of stoplights. Each of these names denotes the corresponding individual in the world.
For each relation that you may want to represent, associate a predicate symbol in the language. Each -ary predicate symbol denotes a function from into , which specifies the subset of for which the relation is true. For example, the predicate symbol “” of two arguments (a teacher and a course) may correspond to the binary relation that is true when the individual denoted by the first argument teaches the course denoted by the second argument. These relations need not be binary. They could have any number of arguments (zero or more). For example, “” may be a predicate that has one argument.
These associations of symbols with their meanings form an intended interpretation.
Write clauses that are true in the intended interpretation. This is often called axiomatizing the domain, where the given clauses are the axioms of the domain. If the person who is denoted by the symbol actually teaches the course denoted by the symbol , you can assert the clause as being true in the intended interpretation.
Ask queries about the intended interpretation. The system gives answers that you can interpret using the meaning assigned to the symbols.
Following this methodology, the knowledge base designer does not actually tell the computer anything until step 4. The first three steps are carried out in the head of the designer. Of course, the designer should document the denotations to make their knowledge base understandable to other people, so that they remember each symbol’s denotation, and so that they can check the truth of the clauses.
The world itself does not prescribe what the individuals are.
In one conceptualization of a domain, may be a predicate symbol of one argument that is true when the individual denoted by that argument is pink. In another conceptualization, may be an individual that is the color pink, and it may be used as the second argument to a binary predicate , which says that the individual denoted by the first argument has the color denoted by the second argument. Alternatively, someone may want to describe the world at a level of detail where various shades of are not distinguished, and so the color would not be included. Someone else may describe the world in more detail, and decide that is too general a term, and use the terms and .
When the individuals in the domain are real physical things, it is usually difficult to give the denotation without physically pointing at the individual. When the individual is an abstract individual – for example, a university course or the concept of love – it is virtually impossible to write the denotation. However, this does not prevent the system from representing and reasoning about such concepts.
Example 5.7 represented the electrical environment of Figure 5.2 using propositions. Using individuals and relations can make the representation more intuitive, because the general knowledge about how switches work can be clearly separated from the knowledge about a specific house.
To represent this domain, the first step is to decide what individuals exist in the domain. In what follows, assume that each switch, each light, and each power outlet is an individual. Each wire between two switches and between a switch and a light is also an individual. Someone may claim that, in fact, there are pairs of wires joined by connectors and that the electricity flow must obey Kirchhoff’s laws. Someone else may decide that even that level of abstraction is inappropriate because we should model the flow of electrons. However, an appropriate level of abstraction is one that is useful for the task at hand. A resident of the house may not know the whereabouts of the connections between the individual strands of wire or even the voltage. Therefore, we assume a flow model of electricity, where power flows from the outside of the house through wires to lights. This model is appropriate for the task of determining whether a light should be lit or not, but it may not be appropriate for other tasks.
Next, give names to each individual to which we want to refer. This is done in Figure 5.2. For example, the individual is the wire between light and switch .
Next, choose which relationships to represent. Assume the following predicates with their associated intended interpretations:
is true if the individual denoted by is a light.
is true if the light is lit and emitting light.
is true if there is power coming into ; that is, is live.
is true if switch is up.
is true if switch is down.
is true if is not faulty; can be either a circuit breaker or a light.
is true if component is connected to such that current would flow from to .
At this stage, the computer has not been told anything. It does not know what the predicates are, let alone what they mean. It does not know which individuals exist or their names.
Before anything about the particular house is known, the system can be told general rules such as
Recursive rules let you state what is live from what is connected to what:
For the particular house and configuration of components and their connections, the following facts about the world can be told to the computer:
These rules and atomic clauses are all that the computer is told. It does not know the meaning of these symbols. However, it can now answer queries about this particular house.