then
KB entails A.
A => B, A
---------
B
A1 and A2 and ... An
--------------------
Ai
A1, A2, ... An -------------------- A1 and A2 and ... An
Ai
------------------
A1 or A2 or ... An
NOT(NOT(A))
-----------
A
A or B, NOT(B) --------------- A
A or B, NOT(B) or C ------------------- A or C
So far we have talked about the importance of goals and searching for solutions in an intelligent agent. Now we will begin discussing methods for describing states and actions and reasoning about the effects of those actions. This is referred to in AI as knowledge representation and reasoning.
Today we will discuss the basic ideas of logic, a mathematical language for stating and reasoning with knowledge.
All of the designs for intelligent agents we have discussed had some notion of "current world state".
We will now expand this idea to what is called a knowledge base (KB).
A KB is a set of representations of facts about the world.
A "logic" is a mathematical notation (also called a language) for stating knowledge. The main alternative to logic is called "natural language" i.e. English, Swahili, etc.
As you can guess, it is far easier to design algorithms that reason with mathematical languages than with natural languages, so we restrict attention to logical knowledge representation now.
As in natural language, the "sentence" is a fundamental unit in logic. For example: "I am hungry" "John loves Mary"
Remember the reflex agent architecture:

This agent keeps track of the state of the external world using its "update" function.
A knowledge-based agent represents the state of the world using a set of sentences called a knowledge base.

At each time instant, whatever the agent currently perceived is stated as a sentence, e.g. "I am hungry".
There are two fundamental operations on a knowledge base:
These are NOT simple operations. For example:
Section 6.2 describes a world where an agent needs to be knowledge-based and do reasoning, while Section 6.3 discusses logics in general. It's easier to understand these after seeing a concrete example of a very simple logic.
This logic is called "propositional", because "proposition" in English means "simple declarative sentence". This is the logic of propositions like "John loves Mary".
Propositional logic is NOT about the meaning or the content of propositions.
Instead, it is about how they combine to form more complicated sentences and about patterns of reasoning that are valid regardless of the content of the propositions involved.
So, let's use variables like P, Q, R etc. to designate propositions.
Given two propositions P and Q we can construct some more complex sentences as follows:
| P & Q | is notation for P AND Q |
|---|---|
| P v Q | is notation for P OR Q |
| ~P | is notation for NOT P |
Now if we pay no attention to the meaning of a proposition then there are really just two possibilities: it's true or false.
What are the possibilities for P & Q ?
When P is true and Q is true, then P & Q is true. Otherwise, P & Q is false.
We can indicate how & behaves with table called a "truth table".
| P | Q | P & Q |
|---|---|---|
| true | true | true |
| true | false | false |
| false | true | false |
| false | false | false |
The syntax of a logic specifies what the correct "well-formed" sentences are in the logic. Syntax can be given by a grammar. For propositional logic the grammar can be defined in Backus-Naur form:
The semantics of a logic specifies how the "meaning" of a sentence is built up from the meanings of its parts.
Truth tables are the usual way of specifying propositional logic semantics.
Note that neither grammars nor truth tables are part of propositional logic. They are ways of talking ABOUT it. In other words, there are alternative ways of describing the syntax and semantics of propositional logic.
Semantics is a slippery term. It is perhaps better to talk about the semantics of a sentence in a logic than the semantics of the logic itself.
When we talk about the semantics of a sentence, we are usually referring to the interpretation of the symbols in it in terms of facts in the world.
The interpretations of the propositions in a sentence in propositional logic, together with the meanings of the logical connectives (the semantics of the logic), together give the semantics of the sentence.
For convenience, the syntax of propositional logic contains the "implies" connective, written "->".
This connective could actually be replaced using only AND, OR and NOT.
We write P -> Q for "P implies Q". To explain the meaning of the -> connective, we give its truth table:
| P | Q | P -> Q |
|---|---|---|
| true | true | true |
| true | false | false |
| false | true | true |
| false | false | true |
The only case where P -> Q is false is when P is true and Q is false. This type of implication is called "material implication" (I don't know why).
P -> Q says that if P is true, then Q has to be true. When P is false, then P -> Q essentially says nothing.
Notice that P -> Q in propostional logic means exactly the same thing as ~P v Q.
Here are some examples of true sentences using ->:
"Clinton is president in 95" -> "Gore is vice-president in 95" "Bush is president in 95" -> "Quayle is vice-president in 95" "Bush is president in 95" -> "The weather is hot in 95"
Informally, the second sentence is sensible because the antecedent "Bush is president in 95" is relevant to the consequent "Quayle is vice-president in 95". However -> has nothing to do with relevance and other complicated notions of informal logic.
Now we can see how an agent with a propositional knowledge base can use it to represent knowledge.
In the Wumpus world there is a grid of sixteen squares labeled [1,1] to [4,4].

The Wumpus, a fearsome beast, lives in one square and eats all who venture there. The four squares adjacent to the Wumpus square stink.
In one square there is gold, the object of our agents desire.
A square may contain a pit. If so, the neighbouring squares are breezy.
The actions of an agent are to turn by 90 degrees left or right, go forward one square, grab or shoot.
When the agent is in a square, it learns things about its environment (receives percepts).

The agent could use propositional logic to build its KB about Wumpus world and reason about the state of the world and the effects of its actions.
Let P11 mean that [1,1] contains a pit and let B11 mean that [1,1] is breezy, and so on.
Note that P11, P12, etc. are each either true or false as required by propositional logic. Of course the agent initially does not know whether P12 is true or false.
We can state the knowledge about breeziness using -> sentences:
P11 -> B12 P12 -> B11
P11 -> B21 P12 -> B22 ...
P12 -> B13
Many sentences are needed just to represent this simple knowledge.
Suppose the agent is in [1,1] and it perceives "no-breeze". It updates its knowledge base with
kb := tell(kb,make-sentence("no-breeze"))
Remember the difference between a sensation like "I'm feeling the absence of breeze" and a logical sentence. Here:
make-sentence("no-breeze") = ~B1
Now the new knowledge-base
kb' = { ~B11, P11 -> B12, P12 -> B11, ... }
Suppose we want to know if there is a pit in [1,2]. We pose a query:
ask(kb',P12?)
Remember that the result of an "ask" operation is yes, no, or "I don't know."
Here the result is no.
"No" means that in every circumstance where the sentences in kb' are true, the sentence P12 is false.
We can prove this with a truth table. This a general method for proving sentences in in propositional logic.
| P12 | B11 | P12 -> B11 | |
|---|---|---|---|
| true | true | true | excluded because B11 is false |
| true | false | false | excluded because P12 -> B11 is true |
| false | true | true | excluded because B11 is false |
| false | false | true |
Given what is asserted in kb', the only possible (i.e. non-excluded) state of affairs has P12 false. Hence the answer to the "ask" is no.
We must write down rules for this. For example,
A11 & East_A & W21 -> ~Forward
To ask what action to take, propositional logic requires that we ask whether each possible action is OK.
The number of rules grows very fast with the size of the grid.
This is one of the main problems with propositional logic--too many rules.
Now we will look at logics in general.
Logics are one type of knowledge representation language.
A logic of a language may be defined from its syntax and semantics.
An interpretation of a sentence in a logic is a mapping of symbols to meanings.
Logics make different types of commitments about the world (reality) and the current state of the world (knowledge).
The ontological commitment of a logic to what values facts can have. Propostional logic allows facts to have only two possible values: true or false. Other logics such as fuzzy logic allow facts to have degrees of truth.
The epistemological commitment of a logic pertainins to the kinds (degrees) of belief an agent using the logic can have. Propositional logic allows three states of belief: true, false and "don't know". Other logics may allow more degrees of belief.
"Proper reasoning" manipulates internal symbols via syntax so as to maintain the represented truth in the semantics.
Entailment means sentences that must be true given an initial set of sentences.
"KB |= A" means "KB entails A"

The process of generating entailed sentences is called logical inference or deduction.
A proof is a record of sound inferences.
A proof procedure is a method for mechanically generating proofs.
sound or truth perserving procedures always give entailed sentences.
"KB |-i A" means "Procedure i can derive A"
complete procedures give any sentence that is entailed.
valid or necessarily TRUE sentences are true in all interpretations. There are also called analytic sentences or tautologies.
The validity of any sentence in propositional logic can easily be checked by constructing a truth table. The sentence is valid if and only if all rows are true.
satisfiable sentences are TRUE under some interpretation.
If any row in the truth table for the sentence is true, it is satisfiable.
Sometimes a better way to construct a proof is to use inference rules.
Here are seven (sound) inference rules for Propositional Logic:
A => B, A
---------
B
A1 and A2 and ... An
--------------------
Ai
A1, A2, ... An -------------------- A1 and A2 and ... An
Ai
------------------
A1 or A2 or ... An
NOT(NOT(A))
-----------
A
A or B, NOT(B) --------------- A
A or B, NOT(B) or C ------------------- A or C
Checking a set of propositional sentences for satisfiability is NP-complete, so inference in propositional logic is likely to always require exponential time in the worst case. In practice, proof of a given sentence usually goes very quickly.
An example of how to construct a proof using the above inference rules is given in the book
Propositional logic we have already discussed.
First order logic (FOL) expands on propositional logic by adding ways to talk about relationships and to quantify over all objects in the world.
FOL is much more expressive than propositional logic.
We will be discussing FOL next week.