universiti tenaga nasional 1 csnb234 artificial intelligence chapter 3 propositional logic &...

43
UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Instructor: Alicia Tang Y. C. (Chapter 2, pp. 45-76, Textbook) (Chapter 8, pp. 240-253, Ref. #3) Read online supplementary slides

Upload: amelia-lucas

Post on 16-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 1

CSNB234ARTIFICIAL INTELLIGENCE

Chapter 3Propositional Logic& Predicate Logic

Chapter 3Propositional Logic& Predicate Logic

Instructor: Alicia Tang Y. C.

(Chapter 2, pp. 45-76, Textbook)(Chapter 8, pp. 240-253, Ref. #3)Read online supplementary slides

Page 2: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 2

Early Development of Symbolic Logic

• English mathematician DeMorgan criticised traditional logic because it was written in natural language.

• He thought that the formal meaning of a syllogistic statement was confused by the semantics of natural language.

• DeMorgan and Boole both contributed to the development of Propositional Logic (or Propositional Calculus).

• Using familiar algebraic symbols, they showed how certain algebraic rules were equally applicable to numbers, set and truth values of propositions.

Page 3: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 3

Propositional Logic (I) Definition

– Propositional Logic Sentences• Every propositional symbol and truth symbol is

a sentence.– For example: true, P, Q, and R are four

sentences• The negation of a sentence is a sentence

– For example: P and false are sentences• The conjunction (and) of two sentences is a

sentence– For example: P P is a sentence

Page 4: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 4

Propositional Logic (II)

Propositional Logic Sentences• The disjunction (or) of two sentence s is a

sentence– For example: P P is a sentence

• The implication of one sentence for another is a sentence

– For example: P Q is a sentence

• The equivalence of two sentences is a sentence

– for example: P Q = R is a sentence

Page 5: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 5

Propositional Logic Semantics – An interpretation of a set of propositions is

the assignment of a truth value, either T of F, to each propositional symbol.

– The interpretation or truth value for sentences is determined by:

• The truth assignment of negation, P, where P is any propositional symbol, is F if the assignment to P is T and T if the assignment to P is F.

• The truth assignment of conjunction, , is T only when both conjuncts have truth value T; otherwise it is F.

Propositional Logic (III)

Page 6: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 6

Propositional Calculus Semantics – The truth assignment of disjunction, , is F

only when both conjuncts have truth value F; otherwise it is T.

– The truth assignment of implication, , is F only when the premise or symbol before the implication is T and the truth value of the consequent or symbol after the implication is F; otherwise it is always T.

– The truth assignment of equivalence, =, is T only when both expressions have the same truth assignment for all possible interpretations; otherwise it is F.

Propositional Logic (IV)

Page 7: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 7

Prove that ((PQR) = P Q R is a well-formed sentence in the propositional calculus.

Answer. Since:– P, Q and R are propositions and thus

sentences– P Q, the conjunction of two sentences, is

a sentence– (P Q) R, the implication of a sentence

for another, is a sentence

A Worked Example

Page 8: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 8

P, Q and R are propositions and thus sentences

P and Q , the negation of two sentences, are sentences

P Q, the disjunction of two sentences, is a sentence

P Q R, the disjunction of two sentences, is a sentence

((P Q) R) = P Q R, the equivalence of two sentences, is a sentence

A Worked Example ..cont

We get back the

original sentence

Page 9: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 9

Conclusion for the worked example

The above is our original sentence, which has been constructed

through a series of applications of legal rules and is therefore

well-formed.

Page 10: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 10

Constant & Compound Sentences in Propositional Logic

Constants refer to atomic propositions.raining snowing eating hungry wet

Compound sentences capture relationships among propositions.

raining snowing wet

Page 11: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 11

Compound Sentences Negations: ¬ raining The argument of a negation is called the

target . Conjunctions: (raining snowing ) The arguments of a conjunction are called

conjuncts . Disjunctions: (raining snowing ) The arguments of a disjunction are called

disjuncts .

Page 12: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 12

Compound Sentences

Implications: (raining cloudy )– The left argument of an implication is the

antecedent .– The right argument of an implication is called the

consequent . Reductions: cloudy raining

– The left argument of a reduction is the consequent .

– The right argument of a reduction is called the antecedent .

Equivalences: raining cloudy

Page 13: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 13

x y = y x Commutativity x y = y x

x (y z) = (x y) z Associativity x (y z) = (x y) z

x (y z) = (x y) (x z) Distributivity x (y z) = (x y) (x z)

Rules of Algebraic Manipulation

Some Laws for Logic Use

Page 14: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 14

Semantics of Logical Operators

Negation:

Conjunction:

P P

T FF T

P Q P Q

T T TT F FF T FF F F

Page 15: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 15

Semantics of Logical Operators

Disjunction:

P Q P Q

T T TT F TF T TF F F

Page 16: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 16

More Semantics of Logical Operators

Implication:

Reverse Implication:

Equivalence:

P Q P Q

T T TT F FF T TF F T P Q Q P

T T TT F TF T FF F T

P Q Q P

T T TT F FF T FF F T

Page 17: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 17

SatisfactionAn interpretation i satisfies a sentence φ (written |=i φ ) if and only if φ i =T .

A sentence is satisfiable if and only if there is some interpretation that satisfies it.

A sentence is valid if and only if every interpretation satisfies it.

A sentence is unsatisfiable if and only if there is no interpretation that satisfies it.

Page 18: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 18

Truth Tables

A truth table is a table of all possible values for a set of propositional constants.

p q rT T TT T FT F TT F FF T TF T FF F TF F F

Each interpretation of a language is a row in the truth table for that language.

For a propositional language with n logical constants,there are 2 n interpretations.

Page 19: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 19

Logical Equivalence

Two sentences are logically equivalent if and only if they logically entail each other.

Examples:¬(¬p) p¬(p q ) ¬p ¬q de Morgan’s law¬(p q ) ¬p ¬q de Morgan’s law(p q ) ¬p q

Page 20: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 20

Problems

There can be many, many interpretations for a propositional language.

Remember that, for a language with n constants, there are 2n

possible interpretations. Sometimes there are many constants among premises that are irrelevant to the conclusion. ---- Much work wasted.Solution: use other kind of proof theory,

such as refutation proof (later part)

Page 21: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 21

The interpretation of any expression in propostional logic can be specified in a truth table. An example of a truth table is shown here:

Truth Tables

Page 22: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 22

Example of validity: Problem to solve

Problem: (p q) (q r)?

Solution:p q r (p q) (q r) (p q ) (q r )T T T T T TT T F T F TT F T F T TT F F F T TF T T T T TF T F T F TF F T T T TF F F T T T

Allvalues

are“true”

It is a valid sentence!

Page 23: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 23

Clausal Form

Propositional resolution works only on expressions in clausal form.

Fortunately, it is possible to convert any set of propositional calculus sentences into an equivalent set of sentences in clausal form.

Page 24: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 24

Conversion to Clausal Form

Implications Out: P Q P QP Q P QP Q P Q) (P Q )

Negations In:P P (P Q) P Q(P Q ) P Q

Page 25: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 25

Predicate Calculus(=Predicate Logic)

Page 26: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 26

Predicate Calculus (I)

In Proposition Logic, each atomic symbol (P, Q, etc) denotes a proposition of some complexity. There is no way to access the components of an individual assertion. Through inference rules we can manipulate predicate calculus expressions, accessing their individual components and inferring new sentences.

Page 27: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 27

Predicate Calculus (II)

In Predicate Calculus, there are two ways variables may be used or quantified. In the first, the sentence is true for all constants that can be substituted for the variable under the intended interpretation. The variable is said to be universal quantified. Variables may also be quantified existentially. In this case the expression containing the variable is said to be true for at least one substitution from the domain of definition. Several relationships between negation and the universal and existential quantifiers are given below:

Page 28: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 28

Predicate calculus sentences– Every atomic sentence is a sentence

• if s is a sentence, then so is its negation, s

• if s1 and s2 are sentences, then so is their conjunction, s1 s2

• if s1 and s2 are sentences, then so is their disjunction, s1 s2

• if s1 and s2 are sentences, then so is their implication, s1 s2

• if s1 and s2 are sentences, then so is their equivalence, s1 = s2

Predicate Calculus (III)

Page 29: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 29

If X is a variable and s is a sentence, then X s is a sentence

If X is a variable and s is a sentence, then X s is a sentence

Predicate Calculus (IV)

Page 30: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 30

English sentences represented in Predicate Calculus:

Some people like fried chicken. X (people(X) likes(X, fried_chicken)).

Nobody likes income taxes. X likes(X, income_taxes). X likes(X, income_taxes).

Page 31: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 31

Rule:

All purple mushrooms are poisonous.X (purple(X) mushroom(X) poisonous(X))

Fact:

Tom loves Jerry.loves(tom, Jerry).

Page 32: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 32

Quiz: Translate the following English Statements

into Predicate Expressions

All people that are not poor and are intelligent are happy.

Students who like to read books are not stupid.

Batman is knowledgeable and he is wealthy.

Tweety can fly if it is not fried and has wings.

Page 33: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 33

Exercise #1

Everybody likes something.

There is something whom everybody likes.

Page 34: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 34

Answers to Exercise #1

Everybody likes something. x.y. likes(x,y) There is something whom everybody

likes. y.x. likes(x,y)

Page 35: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 35

Exercise #2

X p(X) = X p(X)

Y q(Y) = Y q(Y)

For predicates p & q, and variables X and Y:

Write the following in English

Page 36: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 36

Answers to Exercise #2

Page 37: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 37

Quiz: Convert each of the following predicate logic to English sentences

X loves(X, superman) loves(superman, X)

food(laksa) X food(X) like(arul, X) X Y eat(X, Y) alive(X) food(Y)

X eat(haswan, X) eat(hasman, X)

Page 38: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 38

Stages involved in Proof Theory

Stage 1– convert all axioms into prenex form

• i.e. all quantifiers are at the front

Stage 2– purge existential quantifiers– this process is known as skolemization

Stage 3– drop universal quantifiers

• as they convey no information

Page 39: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 39

An ExampleConsider the argument:

All men are mortal (given premise)Superman is a man (given premise)Superman is mortal (goal to test)

The argument gets formalised as:X man(X) mortal(X) man(Superman) mortal(Superman) (goal)

And has, as its conflict set in Clausal form: man(X) mortal(X) ---- (1) man(Superman) ---- (2) mortal(Superman) ---- (3)

Negation of goal

Page 40: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 40

Apply resolution to derive at a contradiction:

We get:man(Superman) from (1) & (3)and,direct contradiction from (2) & (4)

The conclusion is that “the goal is true”(i.e. superman is mortal)

Page 41: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 41

Exercise #3 Convert each of the following into Predicate

Calculus equivalence:– Marcus was a man– Marcus was a Pompeian– All Pompeians were Romans– Caesar was a ruler– All Romans were either loyal to Caesar or hated

him– Everyone is loyal to someone– people only try to assassinate rulers they are not

loyal to– Marcus tried to assassinate Caesar

Page 42: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 42

Predicate logic for the 8 facts in Exercise #3

1. man(Marcus)2. pompeian(Marcus)3. X. pompeian(X) roman(X)4. ruler(Caesar)5. X. roman(X) loyalto(X, Caesar) hate(X, Caesar)6. X. Y. loyalto(X,Y)7. X. Y. person(X) ruler(Y) tryassassinate(X,Y)

loyalto(X,Y)8. tryassasinate(Marcus, Caesar)

9. X. man(X) person(X)

Page 43: UNIVERSITI TENAGA NASIONAL 1 CSNB234 ARTIFICIAL INTELLIGENCE Chapter 3 Propositional Logic & Predicate Logic Chapter 3 Propositional Logic & Predicate

UNIVERSITI TENAGA NASIONAL 43

Answers to Exercise #3

loyato(Marcus, Caesar) (using 7, substitution, & apply M.P)

person(Marcus) tryassassinate(Marcus, Caesar) ruler(Caesar)

using (4)

person(Marcus) tryassassinate(Marcus, Caesar) using (8)

person(Marcus)

(using 9, substitution & apply M.P) man(Marcus) using (1)

nil