Docsity

Artificial Intelligence chapter 2 d Logic, Lecture notes of Artificial Intelligence

Partial preview of the text

Download Artificial Intelligence chapter 2 d Logic and more Lecture notes Artificial Intelligence in PDF only on Docsity!

Logic

What is logic?

 Logic is an “algebra” for manipulating only two values:

true (T) and false (F)

 Nevertheless, logic can be quite challenging

 This topic will cover:

 Propositional logic--the simplest kind  Predicate logic (a.k.a. predicate calculus)--an extension of propositional logic  Resolution theory--a general way of doing proofs in predicate logic  Possibly: Conversion to clause form  Possibly: Other logics (just to make you aware that they exist)

Propositional logic

 Propositional logic consists of:

 The logical values true and false (T and F)  Propositions: “Sentences,” which  Are atomic (that is, they must be treated as indivisible units, with no internal structure), and  Have a single logical value, either true or false  Operators, both unary and binary; when applied to logical values, yield logical values  The usual operators are and, or, not, and implies

Useful binary operators

 Here are the binary operators that are traditionally used:

 Notice in particular that material implication () only approximately means the same as the English word “implies”

 All the other operators can be constructed from a combination of these (along with unary not, ¬ )

X Y

AND

X  Y

OR

X  Y

IMPLIES

X  Y

BICONDITIONAL

X  Y

T T T T T T

T F F T F F

F T F T T F

F F F F T T

Another example

 Exclusive or (xor) is true if exactly one of its operands is true

 Notice that (XY)(XY) is equivalent to X xor Y

X Y X Y X  Y X  Y (XY)(XY) X xor Y T T F F F F F F T F F T F T T T F T T F T F T T F F T T F F F F

Worlds

 A world is a collection of prepositions and logical

expressions relating those prepositions

 Example:

 Propositions: JohnLovesMary, MaryIsFemale, MaryIsRich  Expressions: MaryIsFemale  MaryIsRich  JohnLovesMary

 A proposition “says something” about the world, but

since it is atomic (you can’t look inside it to see

component parts), propositions tend to be very

specialized and inflexible

Inference rules in propositional logic

 Here are just a few of the rules you can apply when

reasoning in propositional logic:

From aima.eecs.berkeley.edu/slides-ppt, chs 7-

Implication elimination

 A particularly important rule allows you to get rid of the

implication operator,  :

 X  Y  X  Y

 We will use this later on as a necessary tool for

simplifying logical expressions

 The symbol  means “is logically equivalent to”

Inference by computer

 To do inference (reasoning) by computer is basically a search process, taking logical expressions and applying inference rules to them  Which logical expressions to use?  Which inference rules to apply?

 Usually you are trying to “prove” some particular statement

 Example:  it_is_raining  it_is_sunny  it_is_sunny  I_stay_dry  it_is_rainy  I_take_umbrella  I_take_umbrella  I_stay_dry  To prove: I_stay_dry

Forward and backward reasoning

 Situation: You have a collection of logical expressions

(premises), and you are trying to prove some additional

logical expression (the conclusion)

 You can:

 Do forward reasoning: Start applying inference rules to the logical expressions you have, and stop if one of your results is the conclusion you want  Do backward reasoning: Start from the conclusion you want, and try to choose inference rules that will get you back to the logical expressions you have

 With the tools we have discussed so far, neither is

feasible

Predicate Calculus

Predicate calculus

 Predicate calculus is also known as “First Order Logic”

(FOL)

 Predicate calculus includes:

 All of propositional logic  Logical values true, false  Variables x, y, a, b,...  Connectives , , , ,   Constants KingJohn, 2 , Villanova,...  Predicates Brother, >,...  Functions Sqrt, MotherOf,...  Quantifiers , 

Universal quantification

 The universal quantifier, , is read as “for each”

or “for every”

 Example: x, x^2  0 (for all x, x^2 is greater than or equal to zero)

 Typically,  is the main connective with :

x, at(x,Villanova)  smart(x) means “Everyone at Villanova is smart”

 Common mistake: using  as the main connective with :

x, at(x,Villanova)  smart(x) means “Everyone is at Villanova and everyone is smart”

 If there are no values satisfying the condition, the result is true

 Example: x, isPersonFromMars(x)  smart(x) is true

Existential quantification

 The existential quantifier, , is read “for some” or

“there exists”

 Example: x, x^2 < 0 (there exists an x such that x^2 is less than zero)

 Typically,  is the main connective with :

x, at(x,Villanova)  smart(x) means “There is someone who is at Villanova and is smart”

 Common mistake: using  as the main connective with :

x, at(x,Villanova)  smart(x) This is true if there is someone at Villanova who is smart... ...but it is also true if there is someone who is not at Villanova By the rules of material implication, the result of F  T is T