University of Wisconsin - MadisonCS 540 Lecture NotesC. R. Dyer

Logic (Chapter 7)

Logic for Knowledge Representation and Reasoning

Representation Languages


Propositional Logic (PL)

Logical (Deductive) Inference

Let KB = { S1, S2,..., SM } be the set of all sentences in our Knowledge Base, where each Si is a sentence in Propositional Logic. Let { X1, X2, ..., XN } be the set of all the symbols (i.e., variables) that are contained in all of the M sentences in KB. Say we want to know if a goal (aka query, conclusion, or theorem) sentence G follows from KB.

Since the computer doesn't know the interpretation of these sentences in the world, we don't know whether the constituent symbols represent facts in the world that are True or False. So, instead, consider all possible combinations of truth values for all the symbols, hence enumerating all logically distinct cases:

X1 X2 ... XN | S1 S2 ... SM | S1 ^ S2 ^...^ SM | G | (S1 ^...^ SM) => G
F  F  ... F  |              |                  |   |
F  F  ... T  |              |                  |   |
...          |              |                  |   |
T  T  ... T  |              |                  |   | 

Using the "weather" sentences from above, let KB = (((P ^ Q) => R) ^ (Q => P) ^ Q) corresponding to the three facts we know about the weather: (1) "If it is hot and humid, then it is raining," (2) "If it is humid, then it is hot," and (3) "It is humid." Now let's ask the query "Is it raining?" That is, is the query sentence R entailed by KB? Using the truth-table approach to answering this query we have:

P Q R | (P ^ Q) => R | Q => P | Q | KB | R | KB => R
T T T         T           T     T   T    T      T
T T F         F           T     T   F    F      T
T F T         T           T     F   F    T      T
T F F         T           T     F   F    F      T
F T T         T           F     T   F    T      T
F T F         T           F     T   F    F      T
F F T         T           T     F   F    T      T
F F F         T           T     F   F    F      T
Hence, in this problem there is only one model of KB, when P, Q, and R are all True. And in this case R is also True, so R is entailed by KB. Also, you can see that the last column is all True values, so the sentence KB => R is valid.

Instead of an exponential length proof by truth table construction, is there a faster way to implement the inference process? Yes, using a proof procedure or inference procedure that uses sound rules of inference to deduce (i.e., derive) new sentences that are true in all cases where the premises are true. For example, consider the following:

    P   Q | P   P => Q | P ^ (P => Q) | Q | (P ^ (P => Q)) => Q
    F   F | F      T   |       F      | F |       T
    F   T | F      T   |       F      | T |       T
    T   F | T      F   |       F      | F |       T
    T   T | T      T   |       T      | T |       T
Since whenever P and P => Q are both true (last row only), Q is true too, Q is said to be derived from these two premise sentences. We write this as KB |- Q. This local pattern referencing only two of the M sentences in KB is called the Modus Ponens inference rule. The truth table shows that this inference rule is sound. It specifies how to make one kind of step in deriving a conclusion sentence from a KB.

Therefore, given the sentences in KB, construct a proof that a given conclusion sentence can be derived from KB by applying a sequence of sound inferences using either sentences in KB or sentences derived earlier in the proof, until the conclusion sentence is derived. This method is called the Natural Deduction procedure. (Note: This step-by-step, local proof process also relies on the monotonicity property of PL and FOL. That is, adding a new sentence to KB does not affect what can be entailed from the original KB and does not invalidate old sentences.)

Sound Rules of Inference

Here are some examples of sound rules of inference. Each can be shown to be sound once and for all using a truth table. The left column contains the premise sentence(s), and the right column contains the derived sentence. We write each of these derivations as A |- B , where A is the premise and B is the derived sentence.

NamePremise(s)Derived Sentence
Modus PonensA, A => BB
And IntroductionA, BA ^ B
And EliminationA ^ BA
Double Negation~~AA
Unit ResolutionA v B, ~BA
ResolutionA v B, ~B v CA v C

Using Inference Rules to Prove a Query/Goal/Theorem

A proof is a sequence of sentences, where each sentence is either a premise or a sentence derived from earlier sentences in the proof by one of the rules of inference. The last sentence is the query (also called goal or theorem) that we want to prove.

Example for the "weather problem" given above.

2.Q => PPremise
3.PModus Ponens(1,2)
4.(P ^ Q) => RPremise
5.P ^ QAnd Introduction(1,3)
6.RModus Ponens(4,5)

Two Important Properties for Inference

Propositional Logic is Too Weak a Representational Language

Propositional Logic (PL) is not a very expressive language because:

Consider the problem of representing the following information:

How can these sentences be represented so that we can infer the third sentence from the first two? In PL we have to create propositional symbols to stand for all or part of each sentence. For example, we might do:

That is, we have used four symbols to represent the three given sentences. But, given this representation, the third sentence is not entailed by the first two.

A different representation would be to use three symbols to represent the three sentences as

In this case the third sentence is entailed by the first two, but we needed an explicit symbol, Confucius, to represent an individual who is a member of the classes "person" and "mortal." So, to represent other individuals we must introduce separate symbols for each one, with means for representing the fact that all individuals who are "people" are also "mortal." First-Order Logic (abbreviated FOL or FOPC) is expressive enough to concisely represent this kind of situation.

Copyright © 1996-2003 by Charles R. Dyer. All rights reserved.