a rtificial i ntelligence propositional and predicate logic

62
ARTIFICIAL INTELLIGENCE Propositional and Predicate Logic

Upload: matilda-jackson

Post on 03-Jan-2016

230 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

ARTIFICIAL INTELLIGENCE

Propositional and Predicate Logic

Page 2: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

MOTIVATION

formal methods to perform reasoning are required when dealing with knowledge propositional logic is a simple mechanism for basic

reasoning tasks it allows the description of the world via sentences new sentences can be generated by inference rules applied to

existing sentences

predicate logic is more powerful, but also considerably more complex it is very general, and can be used to model or emulate many

other methods

2

Page 3: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

KNOWLEDGE BASE

Knowledge Base : set of sentences represented in a knowledge representation language and represents assertions about the world.

Inference rule: when one ASKs questions of the KB, the answer should follow from what has been TELLed to the KB previously.

3

Page 4: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

LOGICAL INFERENCE also referred to as deduction

validity a sentence is valid if it is true under all possible

interpretations in all possible world states

satisfiability a sentence is satisfiable if there is some

interpretation in some world state (a model) such that the sentence is true

4

Page 5: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

COMPUTATIONAL INFERENCE computers cannot reason informally (“common

sense”) they don’t know the interpretation of the sentences they usually don’t have access to the state of the

real world to check the correspondence between sentences and facts

5

Page 6: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

COMPUTATIONAL APPROACHES TO INFERENCE

model checking based on truth tables generate all possible models and check them for validity or

satisfiability exponential complexity, NP-complete

all combinations of truth values need to be considered

search use inference rules as successor functions for a search

algorithm also exponential, but only worst-case

in practice, many problems have shorter proofs

6

Page 7: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

PROPOSITIONAL LOGIC a relatively simple framework for reasoning

important aspects syntax semantics validity and inference models inference rules complexity

7

Page 8: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

SYNTAX symbols

logical constants True, False propositional symbols P, Q, … logical connectives

conjunction , disjunction , negation , implication , equivalence

parentheses , sentences

constructed from simple sentences conjunction, disjunction, implication, equivalence,

negation

8

Page 9: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

PROPOSITIONAL LOGICSentence AtomicSentence |

ComplexSentenceAtomicSentence True | False | P | Q | R | ...ComplexSentence (Sentence )

| Sentence Connective Sentence

| Sentence

Connective | | |

ambiguities are resolved through precedence or parenthesese.g. P Q R S is equivalent to (( P) (Q R)) S

9

Page 10: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

SEMANTICS

Interpretation of the propositional symbols and constants symbols can stand for any arbitrary fact

the value of the symbol can be True or False

Specification of the logical connectives frequently explicitly via truth tables

10

Page 11: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

TRUTH TABLES FOR CONNECTIVES

11

Page 12: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

VALIDITY AND INFERENCE

truth tables can be used to test sentences for validityone row for each possible combination of

truth values for the symbols in the sentencethe final value must be True for every

sentencenot very practical for large sentences

sometimes used with customized improvements in specific domains, such as VLSI design

12

Page 13: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

WUMPUS WORLD DESCRIPTION

Performance measure gold +1000, death -1000 -1 per step, -10 for using the arrow

Environment Squares adjacent to wumpus are smelly Squares adjacent to pit are breezy Glitter iff gold is in the same square Shooting kills wumpus if you are facing it Shooting uses up the only arrow Grabbing picks up gold if in same square Releasing drops the gold in same square

Sensors: Stench, Breeze, Glitter, Bump, Scream Actuators: Left turn, Right turn, Forward, Grab, Release, Shoot

13

Page 14: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXPLORING A WUMPUS WORLD

14

Page 15: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXPLORING A WUMPUS WORLD

15

Page 16: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXPLORING A WUMPUS WORLD

16

Page 17: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXPLORING A WUMPUS WORLD

17

Page 18: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXPLORING A WUMPUS WORLD

18

Page 19: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXPLORING A WUMPUS WORLD

19

Page 20: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXPLORING A WUMPUS WORLD

20

Page 21: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXPLORING A WUMPUS WORLD

21

Page 22: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

VALIDITY EXAMPLE known facts about the Wumpus World

there is a wumpus in [1,3] or in [2,2] there is no wumpus in [2,2]

question (hypothesis) is there a wumpus in [1,3]

task prove or disprove the validity of the question

approach construct a sentence that combines the above

statements in an appropriate manner so that it answers the questions

construct a truth table that shows if the sentence is valid incremental approach with truth tables for sub-sentences

22

Page 23: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

VALIDITY EXAMPLE

Interpretation:W13 Wumpus in [1,3]W22 Wumpus in [2,2]

Facts:• there is a wumpus in [1,3] or in [2,2]

23

Page 24: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

VALIDITY EXAMPLE

Interpretation:W13 Wumpus in [1,3]W22 Wumpus in [2,2]

Facts:• there is a wumpus in [1,3] or in [2,2]• there is no wumpus in [2,2]

24

Page 25: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

VALIDITY EXAMPLE

Question: • can we conclude that the wumpus is in [1,3]?

25

Page 26: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

VALIDITY EXAMPLE

Valid Sentence:For all possible combinations, the value of the sentence is true.

26

Page 27: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

VALIDITY AND COMPUTERS The computer has no access to the real world,

and can’t check the truth value of individual sentences (facts) humans often can do that, which greatly decreases

the complexity of reasoning humans also have experience in considering only

important aspects, neglecting others

If a conclusion can be drawn from premises, independent of their truth values, then the sentence is valid

27

Page 28: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

INFERENCE AND DERIVATION

Inference rules allow the construction of new sentences from existing sentences notation: a sentence can be derived from

an inference procedure generates new sentences on the basis of inference rules

|- or

28

Page 29: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

INFERENCE RULES

modus ponens from an implication and its

premise one can infer the conclusion

and-elimination from a conjunct, one can

infer any of the conjuncts and-introduction

from a list of sentences, one can infer their conjunction

or-introduction from a sentence, one can

infer its disjunction with anything else

,

1 2 ... n

i

1, 2, … , n

1 2 ... n

i

1 2 ... n

29

Page 30: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

INFERENCE RULES

double-negation elimination a double negations infers

the positive sentence unit resolution

if one of the disjuncts in a disjunction is false, then the other one must be true

resolution cannot be true and false,

so one of the other disjuncts must be true

can also be restated as “implication is transitive”

,

,

,

30

Page 31: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

WUMPUS LOGIC

An agent can use propositional logic to reason about the Wumpus world knowledge base contains

percepts rules

S1,1

S2,1

S1,2

B1,1

B2,1

B1,2

R1: S1,1 W1,1 W1,2 W2,1

R2: S2,1 W1,1 W2,1 W2,2 W3,1

R3: S1,2 W1,1 W1,2 W2,2 W1,3

R4: S1,2 W1,1 W1,2 W2,2 W1,3

. . .31

Page 32: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

FINDING THE WUMPUS Two options

construct truth table to show that W1,3 is a valid sentence rather tedious

use inference rules apply some inference rules to sentences already in the

knowledge base

32

Page 33: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

ACTION IN THE WUMPUS WORLD

Additional rules are required to determine actions for the agent

RM: A1,1 EastA W2,1 ForwardA

RM + 1: . . .. . .

the agent also needs to Ask the knowledge base what to do must ask specific questions

Can I go forward?

general questions are not possible in propositional logic Where should I go? 33

Page 34: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

PROPOSITIONAL WUMPUS AGENT The size of the knowledge base even for a small

wumpus world becomes huge explicit statements about the state of each square additional statements for actions easily reaches thousands of sentences

34

Page 35: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

LIMITATIONS OF PROPOSITIONAL LOGIC Number of propositions

since everything has to be spelled out explicitly, the number of rules is huge

Dealing with change even in very simple worlds, there is change the agent’s position changes

Propositional logic has only one representational device, the proposition difficult to represent objects and relations,

properties, functions, variables, ...

35

Page 36: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

BRIDGE-IN TO PREDICATE LOGIC Limitations of propositional logic in the Wumpus

World Large list of statements change proposition as representational device

Usefulness of objects and relations between them properties functions

36

Page 37: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

FORMAL LANGUAGES AND COMMITMENTS

Language

Propositional Logic facts true, false, unknown

First-order Logic facts, objects, relations

true, false, unknown

Temporal Logic facts, objects, relations, times

true, false, unknown

Probability Theory facts degree of belief [0,1]

Fuzzy Logic facts with degree of truth [0,1]

known interval value

Page 38: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic
Page 39: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

PREDICATE LOGIC New concepts

complex objects terms

relations predicates quantifiers

syntax semantics inference rules

40

Page 40: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXAMPLES OF OBJECTS, RELATIONS “The smelly wumpus occupies square [1,3]”

objects: wumpus, square1,3

property: smelly relation: occupies

“Two plus two equals four” objects: two, four relation: equals function: plus

41

Page 41: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

OBJECTS Distinguishable things in the real world

e.g. people, cars, computers, programs, ... in contrast to physical objects

Properties describe specific aspects of objects

green, round, heavy, visible, … can be used to distinguish between objects

42

Page 42: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

RELATIONS

Establish connections between objects unary relations refer to a single object

e.g. mother-of(John), brother-of(Jill), spouse-of(Joe) often called functions

binary relations relate two objects to each other e.g. twins(John,Jill), married(Joe, Jane)

n-ary relations relate n objects to each other e.g. triplets(Jim, Tim, Wim), seven-dwarfs(D1, ..., D7)

Relations can be defined by the designer or user neighbor, successor, next to, taller than, younger than, …

Functions are a special type of relation often distinguished from similar binary relations by appending -of e.g. brothers(John, Jim) vs. brother-of(John)

43

Page 43: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

SYNTAX Based on sentences

more complex than propositional logic constants, predicates, terms, quantifiers

Constant symbols A, B, C, Franz, Square1,3, … stand for unique objects ( in a specific context)

Predicate symbols Adjacent-To, Younger-Than, ... describes relations between objects

Function symbolsFather-Of, Square-Position, … the given object is related to exactly one other

object

44

Page 44: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

GRAMMAR PREDICATE LOGIC

Sentence AtomicSentence | (Sentence Connective Sentence) | Quantifier Variable, ... Sentence | Sentence

AtomicSentence Predicate(Term, …) | Term = TermTerm Function(Term, …) | Constant | VariableConnective | | | Quantifier | Constant A, B, C, X1 , X2, Jim, JackVariable a, b, c, x1 , x2, counter, positionPredicate Adjacent-To, Younger-Than, Function Father-Of, Square-Position, Sqrt, Cosine

ambiguities are resolved through precedence or parentheses

45

Page 45: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

TERMS Logical expressions that specify objects

Constants and variables are terms

More complex terms are constructed from function symbols and simpler terms, enclosed in parentheses basically a complicated name of an object

46

Page 46: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

ATOMIC SENTENCES State facts about objects and their relations

Specified through predicates and terms the predicate identifies the relation, the terms

identify the objects that have the relation

An atomic sentence is true if the relation between the objects holds

47

Page 47: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXAMPLES ATOMIC SENTENCES

Father(Jack, John), Mother(Jill, John),

Sister(Jane, John)

Parents(Jack, Jill, John, Jane)

Married(Jack, Jill)

Married(Father-Of(John), Mother-Of(John))

Married(Father-Of(John), Mother-Of(Jane))

Married(Parents(Jack, Jill, John, Jane))

48

Page 48: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

COMPLEX SENTENCES

Logical connectives can be used to build more complex sentences

49

Page 49: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXAMPLES COMPLEX SENTENCES

Father(Jack, John) Mother(Jill, John)

Sister(Jane, John)

Sister(John, Jane)

Parents(Jack, Jill, John, Jane)

Married(Jack, Jill)

Parents(Jack, Jill, John, Jane)

Married(Jack, Jill)

Older-Than(Jane, John) Older-Than(John,

Jane)

Older(Father-Of(John), 30) Older (Mother-

Of(John), 20)50

Page 50: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

QUANTIFIERS can be used to express properties of collections

of objects eliminates the need to explicitly enumerate all

objects

predicate logic uses two quantifiers universal quantifier existential quantifier

51

Page 51: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

UNIVERSAL QUANTIFICATION states that a predicate P is holds for all objects x

in the universe under discourse x P(x)

the sentence is true if and only if all the individual sentences where the variable x is replaced by the individual objects it can stand for are true

52

Page 52: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXAMPLE UNIVERSAL QUANTIFICATION assume that x denotes the squares in the

wumpus worldx Is-Empty(x) Contains-Agent(x) Contains-

Wumpus(x) is true if and only if all of the following sentences are true:

Is-empty(S11) Contains-Agent(S11) Contains-Wumpus(S11)Is-empty(S12) Contains-Agent(S12) Contains-Wumpus(S12)Is-empty(S13) Contains-Agent(S13) Contains-Wumpus(S13). . . Is-empty(S21) Contains-Agent(S21) Contains-Wumpus(S21) . . . Is-empty(S44) Contains-Agent(S44) Contains-Wumpus(S44)

53

Page 53: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

USAGE OF UNIVERSAL QUALIFICATION

universal quantification is frequently used to make statements like “All humans are mortal”, “All cats are mammals”, “All birds can fly”, …

this can be expressed through sentences like x Human(x) Mortal(x) x Cat(x) Mammal(x) x Bird(x) Can-Fly(x)

these sentences are equivalent to the explicit sentence about individuals Human(John) Mortal(John) Human(Jane) Mortal(Jane) Human(Jill) Mortal(Jill) . . .

54

Page 54: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXISTENTIAL QUANTIFICATION states that a predicate P holds for some objects

in the universe x P(x)

the sentence is true if and only if there is at least one true individual sentence where the variable x is replaced by the individual objects it can stand for

55

Page 55: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXAMPLE EXISTENTIAL QUANTIFICATION

assume that x denotes the squares in the wumpus world x Glitter(x) is true if and only if at least one of the

following sentences is true:Glitter(S11) Glitter(S12) Glitter(S13). . . Glitter(S21) . . . Glitter(S44)

56

Page 56: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

USAGE OF EXISTENTIAL QUALIFICATION

existential quantification is used to make statements like“Some humans are computer scientists”, “John has a sister who is a computer scientist”“Some birds can’t fly”, …

this can be expressed through sentences like x Human(x) Computer-Scientist(x) x Sister(x, John) Computer-Scientist(x) x Bird(x) Can-Fly(x)

these sentences are equivalent to the explicit sentence about individualsHuman(John) Computer-Scientist(John) Human(Jane) Computer-Scientist(Jane) Human(Jill) Computer-Scientist(Jill) . . .

57

Page 57: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

MULTIPLE QUANTIFIERS

more complex sentences can be formulated by multiple variables and by nesting quantifiers the order of quantification is important variables must be introduced by quantifiers, and belong to

the innermost quantifier that mention them examples

x, y Parent(x,y) Child(y,x) x Human(x) y Mother(y,x) x Human(x) y Likes(x,y) x Human(x) y Likes(x,y) x Human(x) y Likes(y,x)

58

Page 58: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

CONNECTIONS BETWEEN AND all statements made with one quantifier can be

converted into equivalent statements with the other quantifier by using negation De Morgan’s rules apply to quantified sentences

x P(x) x P(x) x P(x) x P(x) x P(x) x P(x) x P(x) x P(x)

strictly speaking, only one quantifier is necessary using both is more convenient

59

Page 59: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EQUALITY equality indicates that two terms refer to the

same object e.g. Father(Jane) = Jim

60

Page 60: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

DOMAINS a section of the world we want to reason about

assertion a sentence added to the knowledge about the

domain

axiom a statement with basic, factual information about the

domain

theorem statement entailed by the axioms it follows logically from the axioms

61

Page 61: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

EXAMPLE: FAMILY RELATIONSHIPS objects: people properties: gender, …

expressed as unary predicates Male(x), Female(y) relations: parenthood, brotherhood, marriage

expressed through binary predicates Parent(x,y), Brother(x,y), …

functions: motherhood, fatherhood Mother-of(x), Father-of(y) because every person has exactly one mother and one

father there may also be a relation Mother(x,y), Father (x,y)

62

Page 62: A RTIFICIAL I NTELLIGENCE Propositional and Predicate Logic

FAMILY RELATIONSHIPS

m,c Mother-of(c) = m Female(m)

Parent(m,c)

w,h Husband(h,w) Male(h) Spouse(h,w)

x Male(x) Female(x)

g,c Grandparent(g,c) p Parent(g,p)

Parent(p,c)

x,y Sibling(x,y) (x=y) p Parent(p,x)

Parent(p,y)

. . . 63