kunstig intelligens (it-2702) forelesning 2 emner: problemløsning - søking i tilstandsrom (intro,...

37
Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) • Predikatlogikk Kunnskapsrepresentasjon - intro • Utsagnslogikk

Upload: horatio-holmes

Post on 29-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Kunstig intelligens (IT-2702) Forelesning 2

Emner:

• Problemløsning- søking i tilstandsrom (intro, begrepsdefinisjon)

• Predikatlogikk

• Kunnskapsrepresentasjon - intro

• Utsagnslogikk

Page 2: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Kunnskapsrepresentasjon - basis

Kunnskapsrepresentasjon i AI vil si å representere

kunnskap i et system, og for dette systemet. Det er altså

det intelligente systemets kunnskap - enten dette systemet

er et menneske eller en maskin.

En kunnskapsrepresentasjon består derfor av en

kunnskaps-struktur i et visst språk, samt en tolkning som

gjør at kunnskapen får mening for den som 'eier'

kunnskapen.

En representasjonsmetode består av en språk-syntaks, og

en underliggende semantikk definert av inferens-metoden.

Uttrykkskraften av språket bestemmes av begge disse i

sammen.

En kunnskaps-struktur får mening ved at den gis en

tolkning i den sammenhengen der den utnyttes.

Kunnskapens meningsinnhold er derfor sjelden helt

uavhengig av det formålet kunnskapen benyttes for og

den sammenhengen den benyttes i.

Hvorvidt representasjonen har den mening vi ønsker, kan

testes ved å stille spørsmål til systemet.

Page 3: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Requirements of knowledge representation languages:

• Handle qualitative knowledge

• Enable inference of new knowledge

• Represent general principles as well as specific situations

• Capture complex semantics

• Enable meta-level reasoning

Page 4: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Representasjonsmetoder

• Predikatlogikk- matematisk syntaks; deduktiv inferens - deklarativ semantikk - typisk eks.: Teorembevis-system

• Regel-basert- syntaks er If-Then sammenhenger, med AND, OR, NOT operatorer og evt. usikkerhetsanslag; inferens er regel-lenking og usikkerhets- beregning.- eks.: Produksjonssystem

• Nettverk - begreper er noder, relasjoner er lenker; inferens er bl.a. arving langs utvalgte lenker, ellers i utganspunktet uspesifisert - prosedural semantikk.

- eks.: Taksonomisk hierarki

• Rammebaserte systemer- kan ses på som et nettverk der nodene er komplekse objekter; inferens som for nettverk, og typisk default arving, 'constraint propagation', og demoner (tilknyttede prosedyrer).

Page 5: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

propositional and predicate calculus

• representation of knowledge

• reasoning about this knowledge

representation and reasoning

predicate calculus

propositional calculus and

todays topic

-Propositional and Predicate calculus:

appropriate for representing and reasoning about some types of symbolic knowledge

Page 6: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Propositional Calculus

• is a representation language that can represent simple properties of the world,

• can reason about that knowledge.

Propositional Calculus

Syntax Semantics

Symbols Sentences

• propositional symbols

• truth variables

• connectives

• are formed from symbols and connectives

• meaning

Page 7: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Symbols: the pieces that make up the language

• propositional symbols : P,Q,R.

• truth symbols : true, false

• connectives :

Propositions

• are declarative sentences (facts),• are either true or false.

Examples:

P: Today is wednesday. Q: The earth is round.

Page 8: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Sentences:

• propositions are atomic sentences

• more complex sentences are formed from atomic sentences and connectives.

Legal sentence:s

• atomic sentences (P,Q,R. . )

• combination of atomic sentences and connectives:

P Q (conjunction) ¬ P (negation) P Q (disjunction) P Q (implication) P = Q (equivalence)

Page 9: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon
Page 10: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Semantics

• Propositional calculus is also a method for determining whether a sentence is true or false.

- the semantic(behaviour) of the connectives is captured in a diagram called a truth table

On determination of truth value:

• Truth value of a proposition is determined according to a given state of the world.

• Truth value assignment to a set of propositions is called an interpretation(a mapping from propositional sentences into the set { T,F}

• Truth value of a compound expression depends on the propositions and operators it contains.

• The precedence of logical operators for evaluation in a sentence is:

NOT, AND, OR, IMPLY, EQUAL.

• The truth assignment of compound propositionas are often described

in truth tables.

Page 11: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon
Page 12: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

For propositional expressions P, Q and R:

Page 13: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Truth table for the operator .

Page 14: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Truth table demonstrating the equivalence of P Q and ¬ P Q.

Page 15: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Predicate Calculus: - is an extension of propositional calculus.

differences from Propositional calculus:

• PREDICATES instead of representing entire proposition with a single symbol such as

P: ball´s color is red,

the predicate calculus permits a representation that describes the relationship of the knowledge, in the form of

color(ball,red).

• QUANTIFIERS In propositional calculus it is not possible to represent sentences having the words all or some. Example : It is not possible to perform the following reasoning in Propositional calculus:

Premises: All children like chocolate.

Mette is a child.

Conclusion: Mette likes chocolate.

Page 16: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

The syntax of predicate calculus :

- ALPHABET -letters (both upper & lower English l.)

-the set of digits-underscore.

SYMBOLS -begin with a letter- may represent

• constants (begin with lowercase letter, represent specific objects & properties in the world, e.g. mette, blue, long.

• variables (begin with uppercase letters, denote general classes of objects or properties; X,Y

• functions (begin with lowercase letters,denote a mapping of one or more elements (argument) into an element in the domain.

father (mette) maps to Arne (suppose he is her father)

• predicates (begins with lowercase letters) names a relationship be tween objects in the world.

For functions & Predicates :

f(t1,.........tn) , t1, ........tn are terms

p(t1,.........tn) a term can be - a constant- a variable- a function expression

• the truth symbols: true, false , which are reserved symbols.

Page 17: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Predicate :

- The concept of predicate results from analyzing propositions or statements.

-Consider the statement: Mette likes chocolate.

likes (mette, chocolate) in predicate calculus, where ‘mette’ and ‘chocolate’ are constant symbols and

‘likes’ is a binary predicate symbol.

• the predicate symbol, ‘likes’, once defined can be applied to arbitrary pairs of constants to produce other propositions.likes (kirstin, flowers)

• it is even possible to use variables for argumentslikes (kirstin, X)

• argument can also be filled with function symbols friend (father (mette), father (kirstin))

Page 18: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon
Page 19: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

quantifiers: two new symbols

-Universal : (for all)

-Existential : for some)

-A quantifier is followed by a variable and a sentence

y friends (y, peter)

x likes (x, ice _cream)

GRAMMAR:

- Predicates & truth values are atomic sentences

- more complicated formulas can be constructed from atomic formulas by combining them with connectives (S, S1, S2 are sentences, x is a variable)

- S1S2- S1- S1S2- S1 S2

- S1 = S2

- x S- x S

ex : equal (plus (2, 3), seven)

x foo (x, two, plus(two, tree))

- With connectives we can say things like

‘ If Clyde is an elephant, then Clyde is gray’ .

But if we want to say something much more general:

‘ If anything is an elephant, then it is gray ’.

we need to use quantifiers

.

Page 20: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Universal quantifiers :

• say that something is true for all possible values of a variable.

X is a universally quantified variable in the formula (X f), we say that f is in the scope of the variable x.

-ex: 1) Natural language: all elephants are gray: predicate logic: Z (elephant(Z) color( Z , gray)).

(For all Z, if Z is an elephant, then Z is gray)

2) X (X+X=2X) states that for every X (where X is a number) the sentence X+X=2X is true.

Existential Quantifier:

• say that something is true for at least one member of the domain.

examples:

1) X( X * X =1) 2) X(elephant(X) ̂ name(clyde))

3) X (philosopher(X) ̂ computer_scientist(X))

Page 21: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon
Page 22: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

The Semantics of the predicate Logic:

The truth of an expression depends on the mapping of predicate calculus symbols into objects and relations in a given domain.

How to determine the truth values?

- represent objects and relatioships of the domain in the form of predicate calculus sentences

- the truth of relationships in the domain determines the truth of the calculus expressions.

Page 23: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Once a formula has been given an interpretation, the truth value of that formula can be evaluated.

Page 24: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Truth Value of Expressions for a given interpretation I and a domain D:

1. The value of a constant is an element in D

2. The value of a variable is a subset of elements of D

3. The value of a function is the result of its evaluation

4. The value of an atomic sentence is determined by the interpretation

5. The value of connected sentences is determined from the value operators as we have seen before.

6. The value of X S is true if S is true for all assignments to X under the interpretation, and is false otherwise

7. The value of X S is true if there is at least one assignment to X in the interpretation under which S is true, and is false otherwise.

Page 25: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

First order predicate calculus:

- the predicate logic we have described is also called first order logic.

* In first order logic, quantified variables may refer only to objects(constants) in the domain of discourse.

if p and f are predicates and function symbols respectively, then

p(p(X)) and f(p(f(X))) are not permitted to be formulae. For example likes (likes(george,kate) ) is not a wff.

Page 26: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Example: Blocks world

c

a

b

d

on(c,a)on(b,d)ontable(a)ontable(d)clear(b)clear(c)hand_empty

predicate calculus representation of the blocks world.

- define a test which determines if a block is clear(does not have any block on top of it):

- The following rule describes when a block is clear: X ( Y (on(Y,X)) clear(X))

- We can define a new rule to put a block on top of another : stack(X,Y);

XY((hand_empty ̂ clear(X) ̂ clear(Y) ̂ pick_up(X) ̂ put_down(X,Y))

stack(X,Y)

where pick_up, put_down and stack are newly defined predicates.

Page 27: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Using inference rules to produce predicate calculus expressions:

- Inference rules

• are means to produce new sentences from already existing ones.

• are means to determine whether a consequence logically follows from particular premisses.

- New expression must be consistent with existing ones.

Defn:A new expression is said to be consistent or satisfiable if there is an interpretation that makes it true.

ex: The assignment B=T, C=F, D=T satisfies the formula

(((B OR C) AND NOT C) OR D)

Defn: An expression is inconsistent or unsatisfiable if the wff is false in all interpretations.

ex: inconsistent : p AND NOT P. Defn: Formula G is said to logically follow from formulae F1, F2,...., Fn if, and only if, every interpretation that satisfies the formula (F1 AND

F2 AND....AND Fn) also satisfies G.

Page 28: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Defn: If the inference rule is able to produce every expression that logically follows from premisses, then it is said to be complete.

Defn: A wff is valid if it is true in all interpretations, else it is invalid. ex: X(p(X) p(X)) is valid.

p q is not valid since it is not true for p=T and q=F.

Defn: a model is an interpretation in which the wff is true.

ex: a model of p q is p=T and g=T.

Defn: a wff is proved if it can be shown to be valid. A proof procedure is a combination of an inference rule and and algorithm which applies that rule to a set of logical expressions to generate new expressions.

Page 29: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

- Defn: If we prove in general that an inference rule applied to a set of premisses produces a formula that is a logical consequence of the premisses, then we say we have verified that the rule is sound (modus ponens is a sound rule). Ex: Modus ponens : P Q P --------- QIf we are given that P implies Q and if P is true, modes ponens infer that Q is true .

Some other inference rules

--modus tollens: P Q Q ---------- P-- elimination: if (P AND Q) is true , then both P and Q are also true.

-- introduction: IF P and Q are true then the rule infers that (P AND Q) is also true. -- universal instantiation: If a formula is true for all elements in a domain, then it is true for specific elements in the domain. This rule infers p(a) from X p(X), where a is a constant in the domain.

Page 30: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

-Some examples on MODUS PONENS: 1) Premisses: If it is raining then the ground will be wet. it is raining ---------------------- the ground is wet.

2) Premisses: All men are mortal Socrates is a man -------------------- Socrates is mortal

This can be written in predicate logic as follows:

X (man(X) mortal(X)) man(socrates) -------------------- mortal(socrates).

Page 31: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

UNIFICATION A method that attempts to make two expressions match,by substituting variables with other terms from the domain.These variables then get a binding to other terms.

Universally quatified variables allow full freedom of substitution.

Existentially quantified variables have local dependencies on other variables,A method called Skolemization (after the Norwegian matematician Toralf Skolem),solves the problem by replacing existentially quantified variables with functionsthat that keep track of the dependencies.

Example:

X (man(X) mortal(X)) man(socrates)

substitution {socrates/X} -------------------- mortal(socrates).

”unifier”

Page 32: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

We want a unifier to be as general as possible, and we always seek themost general unifier (mgu) for two expressions.

Example: For the expressions P(X), P(Y)

{anton/X, anton/Y} is a unifier,

{Z/X, Z/Y} is the mgu.

The mgu for a set of expressions is unique.

UNIFICATION together with INFEERENCE RULES (e.g. Modus Ponens)enables a system to infer new facts from existing ones.

Page 33: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

Steps in the unification of (parents X (father X) (mother bill)) and (parents bill (father bill) Y)

Page 34: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon
Page 35: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

A logic-based financial advisor

Page 36: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

TILSTANDSROM

st art -t ilst and

mål-t ilst ander

mellom-t ilst ander

Et t ilst andsrom er en represent asjon av en problemløsnings-st rukt ur.

Et t ilst andsrom er def inert ved:

• en st art -t ilst and• en eller f lere mål-t ilst ander• et set t av mellomt ilst ander• et set t av operat orer som anvendt på en t ilst and gir et set t av mulige et t erfølgende t ilst ander

Page 37: Kunstig intelligens (IT-2702) Forelesning 2 Emner: Problemløsning - søking i tilstandsrom (intro, begrepsdefinisjon) Predikatlogikk Kunnskapsrepresentasjon

SØKING I TILSTANDSROM

start-tilstand

mål-tilstander

mellom-tilstander

traverserte søkeveiermislykkede noderaktive nodernode der testing pågår

• Sentralt i enhver AI-metode er en eller flere søkestrategier for traversering av tilsstandsrommet (søkerommet) fra en starttilstand til en egnet måltilstand.