bab2b

43
1 Predicate Logic A Logic is a formal language, with precisely defined syntax and semantics, which supports sound inference. Independent of domain of application. Different logics exist, which allow you to represent different kinds of things, and which allow more or less efficient inference. Ch02 / 1 propositional logic, predicate logic, temporal logic, modal logic, description logic.. But representing some things in logic may not be very natural, and inferences may not be efficient. More specialised languages may be better.

Upload: mulubrhan-asefa

Post on 22-Oct-2014

34 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: bab2b

1

Predicate Logic

A Logic is a formal language, with precisely defined syntax and semantics, which supports sound inference. Independent of domain of application. Different logics exist, which allow you to represent different kinds of things, and which allow more or less efficient inference.

Ch02 / 1

propositional logic, predicate logic, temporal logic, modal logic, description logic..

But representing some things in logic may not be very natural, and inferences may not be efficient. More specialised languages may be better.

Page 2: bab2b

2

Review of Proposition Logic

We need formal notation to represent knowledge, allowing automated inference and problem solving.

syntax: what expressions are allowed in the language.

Ch02 / 2

Semantics: what they mean, in terms of a mapping to real world proof theory: how we can draw new conclusions from existing statements in the logic. Propositional logic is the simplest.. Propositional logic is the simplest.

Symbols represent facts: P, Q, etc.. These are joined by logical connectives (and,

or, implication) e.g., P Q; Q R Given some statements in the logic we can

deduce new facts (e.g., from above deduce R)

In general a logic is defined by One popular choice is use of logic.

Page 3: bab2b

3

Review of Proposition Logic

Propositional Logic/Calculus Sentences:

Ch02 / 3

Every propositional symbol and truth symbol is a sentences. E.g.: true, false, P, Q, and R The negation of a sentence is a sentence. E.g.: Q and true

The conjunction, or and, of two sentences is a sentence. E.g.: P Q, P P The disjunction, or or and, of two sentences is a sentence. E.g.: P Q, P P The implication of one sentence from another is a sentence. E.g.: P Q The equivalence of two sentences is a sentence. E.g.: P Q ⇔ R An expression is a sentence, or well-formed

formula (WFF), of the propositional logic if and only if it can be formed of legals symbol through some sequence of rules. E.g.:

((P Q ) R) ⇔ P Q R Why?

Page 4: bab2b

4

Review of Proposition Logic: Syntax

Ch02 / 4

Symbols (e.g., letters, words) are used to represent facts about the world, e.g., “P” represents the fact “Ahmad likes

chocolate” “Q” represents the fact “Ahmad has chocolate” Simple facts above are called atomic

propositions. Complex facts can be built by combining atomic propositions with the logical connectives: and: , conjunction of two sentences or: , disjunction of two sentences if-then: (implication), P Q where P premise

& Q conclusion ⇔ : equivalence not: negation Statements or sentences in the language are constructed from atomic propositions and logical connectives. P Q “Ahmad likes chocolate and he doesn’t

have any.” P Q “If Ahmad likes chocolate then Ahmad has chocolate” P ⇔ Q “If Ahmad likes chocolate then Ahmad has chocolate, and vice versa”

Q “ Ahmad doesn’t have chocolate”

Page 5: bab2b

5

Review of Proposition Logic: Semantics

Ch02 / 5

What does it all mean? Sentences in propositional logic tell you about

what is true or false. P Q means that both P and Q are true. P Q means that either P or Q is true (or

both) P Q means that false if P is true and Q is false, otherwise true.

To determine whether the sentences are truth or falsity, truth tables will be used.

X Y X Y X Y X XY X Y (X Y)⇔(XY) T T T T F T T T T F T F F F F T F T T F T T T T F F F F T T T T

We now know exactly what is meant in terms of the truth of the elementary propositions when we get a sentence in the language (e.g., P Q R).

P ⇔ Q means that true if both P and Q are have the same truth value

Page 6: bab2b

6

Review of Proposition Logic: Proof Theory

Ch02 / 6

How do we draw new conclusions from existing supplied facts? We can define inference rules, which are guaranteed to give true conclusions given true premises. For propositional logic useful one is modus ponens:

If A is true and A B is true, then conclude B is true.

A, A B—————————

B

Page 7: bab2b

7

Review of Proposition Logic: Proof Theory

Proof Theory and Inference So, let P mean “It is raining”, Q mean “I carry

my umbrella”.

Ch02 / 7

If we know that P is true, and P Q is true

think about P Q and P Q. Other rules of inference can be used, e.g.,:

This is essentially the resolution rule of inference, used in Prolog.

We can conclude that Q is true. Note that certain expressions are equivalent

A B, B C———————————————

A C

Page 8: bab2b

8

Review of Proposition Logic: Proof Theory

Consider:

Ch02 / 8

What can we conclude?

sunny raining raining umbrella

We can use the rule of inference, given the first two sentences, to conclude sunny carryumbrella. Proof:

Suppose we want to try and prove that a certain proposition is true, given some sentences that are true. It turns out that the resolution rule is sufficient to do this. We put all the sentences into a standard or “normal” form (replacing A B with A B)

There is then a standard procedure that lets you determine if the proposition in question is true.

Page 9: bab2b

9

Predicate Logic

Propositional logic isn’t powerful enough as a general knowledge representation language.

Ch02 / 9

Impossible to make general statements. E.g., “It rained on Tuesday”.

In proposition logic, each atomic symbol (P, Q, etc) denotes a proposition of some complexity.

Through inference rule we can manipulate predicate logic expressions, accessing their individual components and inferring new sentences.

Instead of letting a single propositional symbol, P, denote the entire sentence “It rained on Tuesday,” we can create a predicate weather that describes a relationship between a date and the weather: weather(Tuesday,rain)

No way to access the components of an individual assertion.

Predicate logic provides this ability. How?

Page 10: bab2b

10

Predicate Logic

Ch02 / 10

In predicate logic the basic unit is a predicate/argument structure called an atomic sentence:

Predicate(Argument1,Argument2,..,ArgumentN)- Predicate like constants and function names, begin with a

lowercase letter- Predicate names a relationship between zero or more object in

the world- Number of object related is the arity of the object

Suppose Arguments can be any of: constant symbol, such as ‘Ahmad’ variable symbol, such as X function expression, e.g., motherof(Abu)

Advantages: well defined formal sentences. sound and complete inference rules.

E.g.: likes(Ahmad, chocolate) tall(Abu)

So we can have: likes(X, Abdullah) friends(motherof(Abu), motherof(Lim))

Page 11: bab2b

11

Predicate Logic: Syntax

Ch02 / 11

Syntax

Symbols must begin with a letter and are followed by any sequence of these legal characters. Not include special characters (#,%,@,/,&,”

”,#) Valid symbols:

George fire3 tom_and_jerry bill XXXX friends_of

Symbols include: Truth symbols – true and false (reserved

symbols) Constant symbols – symbols expressions

having the first character lowercase Variable symbols – symbols expressions

beginning with an uppercase character Function symbols – symbols expressions

having the first character lowercase. Have arity indicates the number of elements of the domain mapped onto each element of the range.

The set of letters, both upper- and lowercaseThe set of digits, 0,1,…,9The underscore, _

Predicate logic symbols consist of

Page 12: bab2b

12

Predicate Logic: Syntax

Ch02 / 12

Sentences can also be formed using quantifiers (forall) and (there exists) to indicate how to treat variables: X lovely(X) Everything is lovely. X lovely(X) Something is lovely. X in(X, garden) lovely(X) Everything in

the garden is lovely. Can have several quantifiers, e.g.,

X Y loves(X, Y) Everything loves something

X handsome(X) Y loves(Y, X) Every handsome has something that they

love.

These atomic sentences can be combined using logic connectiveslikes(john, mary) tall(mary)tall(john) nice(john)

Page 13: bab2b

13

Predicate Logic:Syntax

So we can represent things like: All men are mortal. No one likes brussel sprouts. Everyone taking SAK4602 will pass their

exams. Every race has a winner. John likes everyone who is tall. John doesn’t like anyone who likes brussel

sprouts. There is something small and slimy on the

table.

Ch02 / 13

Term Either constant, variable, or expression. May used to denote objects and properties in a

problem domain. Examples: Cat, times(2,3), X, blue, mother(jane), kate

Page 14: bab2b

14

Predicate Logic:Syntax

Atomic sentences

Ch02 / 14

A predicate constant of arity n followed by n terms, t1,t2,..,tn enclosed in parentheses and separated by commas. Examples: Truth values, true and false likes(ahmad, aminah) helps(bill, george) Friends(bill, george) friends(father_of(ahmad), father_of(abu))

Describes a relationship between two objects in a domain discourse.

Arguments are represented as function expressions whose mappings (given that the father_of ahmad is salleh and the father_of abu is bakar) form the parameters of the predicate

Page 15: bab2b

15

Predicate Logic:Syntax

Complex sentences

Ch02 / 15

Combination of atomic sentences with logical connectives: , , , , ⇔, and . , Universal quantifier – indicates that the

sentence is true for all values of the domain. , Existential quantifier – indicates that the

sentence is true for at leats one value in the domain.Examples 1:

Y friends(Y, abdullah) True if there is at least one object ,

indicated by Y that is a friend of abdullah. X likes(X, ice_cream)

True for all values in the domain of the definition of X

X(likes(usman, X) eats(usman, X) Usman eate everything that he likes.

X (bird(X) flies(X)) There exists some bird that doesn’t fly.

X (person(X) Y loves(X, Y)) Every person has something that they love.

Page 16: bab2b

16

Predicate Logic:Syntax

Ch02 / 16

Examples 2: Set of family relationshipmother(rokiah, salleh)mother(rokiah, usman)father(abdullah, salleh)father(abdullah, usman)

X Y (father(X,Y) mother(X,Y) parent(X, Y))X Y Z (parent(X,Y) parent(X,Z)

sibling(Y,Z)) In this example, we use the predicates mother

and father to define a set of parent-child relationships Implications give general definitions of other relationships parent sibling Implications above can be used to infer facts sibling(usman,salleh)

Page 17: bab2b

17

Predicate Logic:Semantics

Ch02 / 17

Semantics There is a precise meaning to expressions in

predicate logic.

Like in propositional logic, it is all about determining whether something is true or false.

X P(X) means that P(X) must be true for every object X in the domain of interest.

X P(X) means that P(X) must be true for at least one object X in the domain of interest.

So if we have a domain of interest consisting of just two people, john and mary, and we know that tall(mary) and tall(john) are true, we can say that X tall(X) is true.

It determine their meaning in terms of objects, properties, and relationship in the world. The truth of expressions depends on the

mapping of constants, variables, predicates, and functions into objects and relationship in the domain of interest.

Page 18: bab2b

18

Predicate Logic:Semantics

Ch02 / 18

Examples 1: “If it doesn’t rain tomorrow, ahmad will go

fishing.” ¬weather(rain, tomorrow) ⇒ go(ahmad,

fishing). “All basketball players are tall.”

∀X(basketball_players(X) ⇒ tall(X) ). “Nobody likes taxes.”

¬∃X likes(X, taxes).

da

bc

Examples 2: Blocks World with its predicate logic description

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

)ontable(d

)clear(b)clear(c)hand_em

pty

Page 19: bab2b

19

Predicate Logic:Semantics

Ch02 / 19

We need to represent knowledge based on:Does a given block have a clear top surface?Can we pick up block a? etc.

Assume that the computer has knowledge of the location of each block and the arm and is able to keep track of these location as the hand moves blocks about the table. The arm can move blocks, change the state,

and clear. Example 2.1: Pick up a block and stack it on

another block. Is block a clear ? Remove block c.Delete the knowledge of on(c,a).Pick up block a.

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

For all X, X is clear if there does not exist a Y such that Y is on X.

Page 20: bab2b

20

Predicate Logic:Semantics

Ch02 / 20

Example 2.2: To stack X on Y First empty the hand, Clear XClear YPick up XPut down X on Y

The following rule describes when a block is clear:X Y((hand_empty clear(X) clear(Y) pick_up(X)

put_down(X,Y)) stack(X,Y)) For all X and Y, if hand empty, and X and Y

is clear, and pick up X and put X on Y such that X stack on Y.

Page 21: bab2b

21

Predicate Logic:Semantics

Ch02 / 21

Examples 3: Mapping of symbols into objects and relations in the domain of definition

friends(ali, bakar)

friends(ali, ismail)

Objects and relations

Asking expression :? friends(ali, bakar)? friends(ali,

ali)

TrueFalseFirst-Order Predicate

LogicUniversally and existentially quantified variables may refer only to objects (constants) in the domain of discourse.Predicate and function names may not be replaced by quantified variables.

Examples of valid sentences for predicate p and q and variables X and Y:¬ ∃ p(X) = ∀ X ¬

p(X)¬∀ X p(X) = ∃ X

¬ p(X)∃ X p(X) = ∃ Y

p(Y)

∀X q(X) = ∀ Y q(Y)∀X(p(X) ∧ q(X)) = ∀Xp(X)

∧ ∀Yq(Y)∃X(p(X) ∨ q(X)) = ∃Xp(X) ∨

∧ ∃Yq(Y)

Page 22: bab2b

22

Predicate Logic: Proof and Inference

Ch02 / 22

Proof and Inference There again we can define inference rules

allowing us to say that if certain things are true, certain other things are sure to be true, e.g. X P(X) Q(X) P(something) ----------------- (so we can conclude)Q(something)

This involves matching P(X) against P(something) and binding the variable X to the symbol something. What can we conclude from the following? X tall(X) strong(X) tall(john) X strong(X) loves(mary, X)

Proof Procedure A combination of an inference rule and an

algorithm for applying that rule to a set of logical expressions to generate new sentences.

Page 23: bab2b

23

Predicate Logic: Proof and Inference

Ch02 / 23

A predicate logic expression X logically follows from a set S of predicate logic expressions if every interpretation and variable assignment that satisfies S also satifies X. Logically follows mean that X is true for

every interpretation that satisfies S Inference rule

sound If every predicate logic expression

produced by the rule from a set S of predicate logic expressions also logically follows from S. Two examples: Modus ponens Resolution

Essentially a mechanical means of producing new predicate logic sentences from other sentences. Its produce new sentences based on the syntactic form of given logical assertion.

Page 24: bab2b

24

Predicate Logic: Proof and Inference

Ch02 / 24

Complete If, given a set S of predicate logic

expressions, the rule can infer every expression that logically follows from S. Modus ponens.

Sound inference rule. If the premise is true then the conclusions are

guaranteed true. If we are given an expression of the form PQ and another expression of the form P such that both are true under an interpretation I, then modus ponens allows us to infer that Q is also true for that interpretation. Because modus ponens is sound, Q is true

for all interpretations for which P and PQ are true. Example 1: Assume the following observations

P denotes “it is raining.”Q denotes “the ground is wet.”P ⇒ Q denotes “if it is raining then the ground is wet.”How to proof Q is true? Now is raining (P is true) and P ⇒ Q generally true, then Q is true.

Page 25: bab2b

25

Predicate Logic: Proof and Inference

Ch02 / 25

Example 2: Expression containing variables“all men are mortal and Socrates is a men; therefore Socrates is mortal.”

man(socrates) mortal(socrates) – conclusionThis is added to the set of expressions that logically follow from the original assertions.

Represents the ”all men are mortal” in predicate calculus:X(man(X) mortal(X)Represents the ”Socrates is a man” in predicate calculus:man(socrates)Because the X in the implication is universally quantified, we may substitute any value in the domain for X.By subtituting socrates for X in the implication, then we can infer:

Page 26: bab2b

26

Predicate Logic: Unification

Ch02 / 26

To apply inference rule, modus ponens, an inference system must be able to determine when two expressions are the same or match.

Its require a decision process for determining the variable substitutions under which two or more expressions can be made identical.

In propositional logic, they match if and only if they are syntactically identical.

In predicate logic, the process of matching two expressions is complicated because the expression contains variables that may be replaced from the domain by any terms of arbitrary complexity.

Unification is an algorithm for determining the substitutions needed to make two predicate logic expressions match.

Example 1: Simple substitutionSubstituting socrates with X to infer mortal(socrates).

Unification is critically important for any AI problem solver that uses the PreC as a representation language.

Page 27: bab2b

27

Predicate Logic: Unification

Ch02 / 27

Example 2: Some instances of the expressionfoo(X,a,goo(Y))

Generated by legal substitutions are given below:1. foo(fred, a, goo(Z))2. foo(W, a, goo(jack))3. foo(Z, a, goo(moo(Z)))

In the example above, the substitution instances or unification that would make the initial expression identical to each of the other three are written as1. {fred/X, Z/Y}

2. {W/X, jack/Y}3. {Z/X, moo(Z)/Y}

The notation X/Y, … indicates that X is substituted for the variable Y in the original expression.

Page 28: bab2b

28

Predicate Logic: Application

Ch02 / 28

Example 1: A Logic-Based Financial AdvisorThe function of the advisor is to help a user decide whether to invest in a savings account or the stock market. The investment that will be recommended for individual investors depends on their income and the current amount they have saved according to the following criteria:1. Individuals with an inadequate savings

account should always increasing the amount saved the priority, regardless of their income 2. Individuals with an adequate savings account and an adequate income should consider a riskier but potentially more profitable investment in the stock market.3. Individuals with a lower income who already have an savings account may want to consider splitting their surplus income between savings and stocks, to increase the cushion in savings while attempting to increase their income through stocks.

Page 29: bab2b

29

Predicate Logic: Application

Ch02 / 29

The adequacy of both is determined by the number of dependents an individual must support. Our rule:1. At least RM5000 in the bank for each

dependent.2. An adequate income must be steady income and supply at least RM15,000 per year plus an additional RM4000 for each dependent. To automate this advice, we translate these

guidelines into sentences in the predicate logic.1.Determines the major features that must be

considered. Here, they are the adequacy of the savings and the income. They are represented by: savings_account(adequate).

savings_account(inadequate).income(adequate).income(inadequate).

2. Conclusion are represented by the unary predicate investment, with possible values of its argument being stock, savings or combination (implying that the investment should be split)

Page 30: bab2b

30

Predicate Logic: Application

Ch02 / 30

The different investment strategies are represented by implications:

savings_account(inadequate) investment(savings)savings_account(inadequate) income(adequate)

investment(savings)savings_account(inadequate) income(inadequate)

investment(savings)3. The advisor must determines when savings

and income are adequate or inadequate: ∀Xamount_saved(X)∧∃Y(dependents(Y)∧ greater(X,minsavings(Y) ) ) ⇒

savings_account(adequate).∀Xamount_saved(X)∧∃Y(dependents(Y) ∧ ¬greater(X, minsavings(Y)))⇒savings_account(inadequate).

minsavings(Y) is a function : minsavings(Y) = 5000*Y;

Page 31: bab2b

31

Predicate Logic: Application

Ch02 / 31

4. Determines when income are adequate or inadequate: ∀Xearnings(X,steady)∧∃Y(dependents(Y)∧

greater(X, minincome(Y)) ) ⇒ income(adequate).

∀Xearnings(X,steady)∧∃Y(dependents(Y)∧ ¬greater(X, minincome(Y) ) ) ⇒

income(inadequate).∀X earnings(X,unsteady) ⇒

income(inadequate). Where minincome(Y) = 15000+(4000*Y)

Inorder to perform a consultation, a description of a particular investor is added to this set of sentences using:amount_saved(22000).

earnings(25000, steady).dependents(3).

Page 32: bab2b

32

Predicate Logic: Application

Ch02 / 32

This yield a logical system consisting:

Page 33: bab2b

33

Predicate Logic: Application

Ch02 / 33

Unification Process: Unify the conjunction of 10 and 11 with the

first two components of the premise of 7 under substitution {25000/X, 3/Y} i.e.,

earnings(25000,steady) ∧(dependents(3) ∧

¬greater(25000, minincome(3) ) ⇒ income(inadequate). Evaluating the function minincome yielding:

earnings(25000,steady) ∧ dependents(3) unify with

earnings(X,steady) ∧ dependents(Y) under substitution {25000/X, 3/Y}

yields the new implication:

earnings(25000,steady) ∧(dependents(3) ∧ ¬greater(25000, 27000) ⇒

income(inadequate). Since premises are true by applying modus ponen the conclusion is true. This is added as assertion 12:

12. income(inadequate).

Page 34: bab2b

34

Predicate Logic: Application

Ch02 / 34

Similarly, unify sentence 9 and 10 with sentence 4, under the substitution {22000/X, 3/Y}, yielding the implication amount_saved(22000)∧(dependents(3)∧ greater(22000,

minsavings(3))⇒savings_account(adequate).

Evaluating the function minsavings(3) yields the expression:

amount_saved(22000)∧(dependents(3)∧greater(22000,15000)

⇒ savings_account(adequate). Again, since premises are true by applying

modus ponen the conclusion is true. This is added as assertion 13:

13. Savings_account(adequate). Finally by examining 3, 12, and 13 indicates, the premise of implication 3 is true. When we apply modus ponens a third time, the conclusion is investment(combination). This is the suggested investment for this

individual.

Page 35: bab2b

35

Logic Programming

Ch02 / 35

Logic programming languages view a computer program as a set of statements in logic.

Contradict to procedural languages, we can give the system statements to try to prove.

Prolog is a logic programming language that the most widely used. Prolog is based on predicate logic, but with slightly different notation/syntax.

We can ask Prolog to prove that grandfather(joe,fred) was true

Example 1:a(X) :- b(X), c(X). Equivalent to X a(X) b(X) c(X) Or equivalently X b(X) c(X) a(X)

Example 2:father(jim, fred).father(joe, jim).grandfather(X, Y) :- father(X, Z), father(Z, Y).

Equivalent to∀XYZ ( (father(X,Z) ∧ father(Z,Y)) ⇒

grandfather(X,Y)) ?grandfather(joe,fred) yes

Page 36: bab2b

36

Logic Programming

Ch02 / 36

Prolog has a built in proof/inference procedure, that lets you determine what is true given some initial set of facts. Proof method called “resolution”.Knowledge Representation using Predicate Logic

Representing Facts in Logic We must know how to represent things in

predicate logic and what expressions mean. Outline how you get from a statement

expressed in English to a statement in predicate logic: Use the verb as predicate and the nouns as

the argumentsExample:“Ahmad likes ice-cream”

likes(ahmad,ice_cream)“Johan loves Sarah” loves(johan,sarah) Use logical connective to represent complex

statements and its cannot be used within an argument of a predicate.Example:

“Ahmad likes ice-cream likes(ahmad,ice_cream)

and chocolate” likes(ahmad,chocolate)

Page 37: bab2b

37

Representing Facts in Logic

Ch02 / 37

“Atheer is tall and slim” tall(atheer) slim(atheer) Statements of the form “If X then Y” can be

translated into X YExample:

“Hassan is thirsty then thirsty(hassan) he drinks coffee”

drinks(hassan,coffee)“Malik is thirsty then thirsty(malik)

he drinks coffee or tea”

drinks(malik,coffee) drinks(malik,tea)

Use to represent the facts that not true/nothingExample:

“Safuan doesn’t like drinks coffee” like(safuan,coffee) Use quantifiers (for all thing) and (there

exists) Example:“All students study” Xstudent(X)

study(X)- Thing is a student then that thing will

study

“Someone strange likes Xstrange(X) likes(brusselsprouts)

brussel sprouts”

Page 38: bab2b

38

Representing Facts in Logic

Ch02 / 38

“There is some table that doesn’t have 4 legs” X(table(X) snumlegs(X,4))“All elephants are grey” X(elephant(X) grey(X))

“All Glaswegians support either Celtic or Rangers” X(glaswegian(X) (supports(X,rangers)

supports(X,celtic)))“There is something small and slimy on the table” X(small(X) slimy(X) on(X,table))“There is no brussel sprout which is tasty” X(brusselsprout(X) tasty(X))

Page 39: bab2b

39

The use of Logic in AI

Ch02 / 39

Predicate logic provides a powerful way to represent and reason with knowledge.

Its can represent knowledge that cannot represented using frame such as negation, disjunction and quantification. Its provide much wider range of inference because of the predicate logic have inference rules and proof procedures compare to a frame system that has the simple inheritance inference.

Predicate logic is used to: Representing knowledge Communicate AI theories with the community.

As the basis of AI programming languages Give the meaning of natural language

sentences in a natural language understanding system Define the semantics of other simpler representation languages

Logic used to describe new theory of human reasoning or language use some people

Page 40: bab2b

40

The use of Logic in AI

Ch02 / 40

Predicate logic hard to represent facts that involve uncertainty, defaults, beliefs, and time/change, for example: It will probably rain tomorrow. -

uncertainty It normally rains in Glasgow. - defaults John believes it will rain, but I don’t. - beliefs It will get wetter and wetter as you near

Glasgow. - time/change For complex problem solving, AI programmer have to Choose between a logic-based approach, with

clear semantics and guranteed sound reference, and a more ad hoc procedural approach which might be more efficient fot the particular problem.

Page 41: bab2b

41

Logic and Frames

Ch02 / 41

For a simple frame system, without defaults, one way to translate thing into logic is as follows: For an object o with slot s and value v we get:

∀X∃Y (o(X) ⇒ (v(Y) ∧ s(X,Y) ) ) Example:

“Elephant has_part head” ∀X∃Y (elephant(X) ⇒ (head(Y) ∧

haspart(X,Y))) For one object o is an instance of class c we get: c(o) Example:

“Nellie’s an elephant” elephant(nellie)

If one class c1 is subclass of another class c2 we get: ∀X (c1(X) ⇒ c2(X) ). Example:

“All elephants are mammal” ∀Xelephant(X) ⇒ mammal(X)

Page 42: bab2b

42

Logic and Frames

Ch02 / 42

Inheritance still works in the logic-based version by applying the inference rule modus ponens:Example:

“Elephant has_part head” ∀X∃Y (elephant(X) ⇒ (head(Y) ∧ haspart(X,Y)))

and“Nellie’s an elephant” elephant(nellie)

to conclude that “Nellie has a head” ∃Y head(Y) ∧ haspart(nellie,Y)

Page 43: bab2b

43

Summary

Intelligent systems require that we have Knowledge formally represented New inferences/conclusions possible.

Formal languages have been developed to support knowledge representation.

Ch02 / 43

One important one is the use of logic - very general purpose way to formally represent truths about the world, and draw sound conclusions from these. Predicate logic provides well defined language for knowledge rep supporting inference.

But representing some things in logic may not be very natural, and inferences may not be efficient. More specialised languages may be better. Frames/Networks/Objects more natural, but only explicitly support inheritance, and may not have well defined semantics. Current trend is either to just use OO, or to use logic, but specialises non-logic-based languages still exist.