KEMBAR78
Artificial intelligent Lec 5-logic | PPT
1
Lecture 5
Knowledge Representation ,
Logic, and inference
1. Knowledge-based Agents
2. Knowledge Representation Schemas
2-1 Propositional Logic
2-2 First order logic
2-3 Inference
2
Knowledge-based Agent
Central component of a knowledge-based agent
is its knowledge-base (KB)
A KB is a set of representations of facts about
the world
Each individual representation is called a
sentence
The sentences are expressed in a language
called a knowledge representation language
A knowledge-based agent should be able to
infer. Inference mechanism generates new
sentences that are necessarily true given that
the old sentences are true.
3
The Intelligent Agent as Black Box
Prior
knowledge
Past
Experience
Goals and
Values
Observations
ActionsReasoning (inference)
and Representation
System (RRS)
4
Inference example
Given:
“The red block is above the blue block”
“The green block is above the red block”
Infer:
“The green block is above the blue block”
“The blocks form a tower”
5
Knowledge Representation Schemas
(Symbolic)
1-Logic based representation – propositional
logic, first order predicate logic, Prolog
2-Procedural representation – rules, production
system
3-Network representation – semantic
networks, conceptual graphs
4-Structural representation – scripts, frames,
objects
6
Representation of Knowledge
There is no single most adequate knowledge
representation formalism/scheme for
everything.
Main points for selecting a representation
formalism: what should be represented, how
should the knowledge be processed.
There are many more representation formalisms.
All the above mentioned are symbolic. There
are non-symbolic ones, e.g. Neural networks.
7
What is Knowledge?
Data – primitive verifiable facts, of any
representation. Data reflects the current
world.
Knowledge – relation among sets of data
(information), that is very often used for
further information deduction.
Knowledge contain information about
behaviour of abstract models of the world.
8
Knowledge Representation
The object of KR is to express knowledge in a
computer-tractable form, so that it can be
used to help agents perform well.
A KR language is defined by two aspects:
Syntax: describes how to make sentences OR
describes the possible configurations that can
constitute sentences.
Semantics: determine the facts (meaning) in the
world to which the sentences refer OR the “things”
in the sentence.
9
Knowledge Representation
Example
The syntax of the language of arithmetic expressions
says that x and y are expressions denoting numbers,
the x  y is a sentence. The semantics of the
language say that x  y is false when y is a bigger
number than x, and true otherwise.
Inference:
The terms “inference” and “reasoning” are generally
used to cover any process by which conclusions are
reached.
Logical inference  deduction
10
Types of logic
Logic is a language for KR which tells us how to build up sentences in the
language.
Ontological commitment: what exists - facts? objects? time? beliefs?
Epistemological commitment: what states of knowledge?
Language
Ontological
Commitment
Epistemological
Commitment
Propositional
Logic
Facts True/false/unknown
First order logic
Facts, objects,
relations
True/false/unknown
Temporal logic
Facts, objects,
relations, time
True/false/unknown
Probability theory Facts Degree of belief 0…1
Fuzzy logic Degree of truth Degree of belief 0…1
11
Knowledge Representation
1- Logic
•Propositional Logic (Propositional Calculus):
Propositional Logic has limitations, - it is not
expressive enough.
•First-order Logic (First-order Predicate Calculus):
First-Order Logic is an improvement and is
useful.
12
Propositions(‫افتراض‬)
Statements that can be either true or false
The sky is blue
The moon is made of cheese
Artificial intelligence is my favourite subject
Each statement takes one of the truth-
values T or F (or, 1 and 0)
Each statement is represented by a
propositional variable such as p, q, r, …
13
Logical operators
We can use logical operators (or
connectives) to build more complex
statements from our simple propositions
The moon is not made of cheese
I am bored and I am tired
You are a man or you are a mouse
If it is snowing then it is cold
14
Negation
p represents “It is snowing”
The negation of p represents “It is not
snowing”
This is written p
pronounced “not p”
If p takes the value T then p takes the
value F, and vice versa
15
Conjunction
p represents “It is snowing”
q represents “It is cold”
The conjunction of p and q represents “It
is snowing and it is cold”
This is written as p  q
pronounced “p and q”
Commutative, associative
16
Disjunction
q represents “It is cold”
r represents “It is raining”
The disjunction of q and r represents “It is
cold or it is raining”
This is written as q  r
pronounced “q or r”
Commutative (q  r = r  q),
Associative (q  (r  p))=(q  r)  (q  p)
17
Implication
p represents “It is snowing”
q represents “It is cold”
Implication gives statements such as “If it
is snowing then it is cold”
This is written p  q
pronounced “p implies q”
Not commutative, not associative
18
19
Propositional Calculus -
example
Let, Fact P: "Ali likes chips''
Let, Fact Q: "Ali eats chips''
Other possible facts:
P  Q : "Ali likes chips or Ali eats chips”
P  Q : "Ali likes chips and Ali eats chips'’
 Q : "Ali doesn't eat chips'’
P  Q : "If Ali likes chips then Ali eats chips''
Read: Logic    
Nat. Lang. Or And Implies Not
20
Truth tables for logical connectives
TTFFTFF
FTTFTTF
FFTFFFT
TTTTFTT
~ QPQPQPQPPQP 
Ex: Give the truth table for: (p  q)  (p  q)
(p  q)  (p  q)
false
true
true
true
Solu:
21
Examples of PL sentences
P means "It is hot"
Q means "It is humid"
R means "It is raining"
P ^ Q => R
"If it is hot and humid, then it is raining"
Q => P
"If it is humid, then it is hot"
Q
"It is humid."
22
Propositional formulae
A formula can be built from propositions and
operators to represent a more complex
statement
We can construct a truth-table for any formula
Upper-case letters are used to represent
formulae
e.g. P might represent (p  q)  r
An interpretation of P is an assignment of truth-
values to all the propositional variables
i.e. it is a single row of the truth table
23
Example formula and truth-table
(p  q)  r
p q r q p  q (p  q)  r
T T T F T T
T T F F T F
T F T T T T
T F F T T F
F T T F F T
F T F F F T
F F T T T T
F F F T T F
24
Tautologies(‫المعنى‬ ‫تكرار‬)
A propositional formula P that takes the
truth-value T for every possible
interpretation is called a tautology.
This is written using the metasymbol╞
like this: ╞ P
e.g. ╞ ( p  p )
Any formula that is a tautology is said to
be a valid formula.
25
Establishing tautologies
An easy way to determine whether or not a
proposition is a tautology is to substitute
truth values for the atomic propositions.
For example, given the proposition p  p, if
we substitute true for p, then the overall
proposition is equivalent to true and if we
substitute false for p then the overall
proposition is equivalent to true
Therefore we conclude that p  p is a
tautology.
26
Questions
Which of the following
propositions are tautologies?
p  (p  q)
p  (q  p)
(p  q)  (q  p)
(p  q)  (p  q)
27
Contradictions and
contingencies(‫طارئ‬)
A proposition that is always false
is called contradiction
If a proposition is neither a
tautology nor a contradiction
then it is called a contingency
28
Propositional Inference: Enumeration Method
Let    and KB = (  C)  B  C)
Is it the case that KB  ?
I.e.,  is true in all worlds where KB is true.
Check all possible models --  must be true whenever KB is
true.
TrueTrueTrue
FalseTrueTrue
TrueFalseTrue
FalseFalseTrue
TrueTrueFalse
FalseTrueFalse
TrueFalseFalse
FalseFalseFalse
=
  
KB=
(  C) 
B  C)
CBA
╞
29 TrueTrueTrueTrue
TrueFalseTrueTrue
FalseTrueFalseTrue
TrueFalseFalseTrue
TrueTrueTrueFalse
FalseFalseTrueFalse
FalseTrueFalseFalse
FalseFalseFalseFalse

  
KB
(  C) 
B  C)
CBA
Propositional Inference: Enumeration Method
Let    and KB = (  C)  B  C)
Is it the case that KB  ?
I.e.,  is true in all worlds where KB is true
Check all possible models --  must be true whenever KB is true
╞
30
Propositional Inference: Enumeration Method
Let    and KB = (  C)  B  C)
Is it the case that KB  ?
Check all possible models --  must be true whenever KB is true
A B C
KB
(  C) 
B  C)

  
False False False False False
False False True False False
False True False False True
False True True True True
True False False True True
True False True False True
True True False True True
True True True True True
╞
31
Propositional Inference: Enumeration Method
Let    and KB = (  C)  B  C)
Is it the case that KB ╞  ?
Check all possible models --  must be true whenever KB is true
A B C
KB
(  C) 
B  C)

  
False False False False False
False False True False False
False True False False True
False True True True True
True False False True True
True False True False True
True True False True True
True True True True True
32
Reasoning in Propositional Logic
Similarly, if we assume a few things, we can
determine if something follows.
E.g., if we assume P, then PQ, say, degenerates
into True  Q, which a truth table will tell us is
always true.
So, we can always draw valid conclusions from
premises, regardless of what any of this
means
33
Rules of inference
There are rules of inference which can be
applied to logic, These follow the syntax:
A
B
When something in the knowledge base
matches the pattern above the line, then the
system concludes that the part below the line
is true.
or, sometimes we may write it, as
, , … |-  meaning, if we know , , …, it is
okay to conclude .
(‫المنطقية‬ ‫المقدمة‬)Premise
Conclusion
34
An Inference Rule: And - Elimination
From a conjunction, you can infer any of the
conjuncts.
1 2 … nPremise
_______________
iConclusion
An inference rule is sound if the conclusion is
true in all cases where the premises are true.
35
An Inference Rule: Modus Ponens
From an implication and the premise of the
implication, you can infer the conclusion.
  Premise
___________
Conclusion
An inference rule is sound if the conclusion is true in all
cases where the premises are true.
i.e. If    is true, and  is true, then  is true.
Generalized Modus Ponens (GMP)
36
Common Inference Rules
Modus Ponens:
,  |- 
And-Elimination:
1  2 |- i
And-Introduction:
1,2 |- 1  2
Or-Introduction:
 |-   
Double-Negation Elimination:
¬¬  |- 
Resolution:
   , ¬    |-   
37
Propositional Logic: Rules of Inference (cont.)
Or-Introduction:
From a sentence, you can infer its disjunction with anything
else at all.
i
1  2  ...  n
Double-Negation Elimination:
From a doubly negated sentence, you can infer a positive
sentence


And-Introduction:
From a list you can infer their conjunction.
1, 2 , ... , n
1  2  ...  n
38
Predicate Logic
or First-order logic (FOL)
39
Limitations of Propositional Logic
p represents ‘My car is red’
q represents ‘This pen is red’
r represents ‘The planet Mars is red’
Cannot work with lower-level objects like ‘my
car’, ‘this pen’, ‘the planet Mars’
For most practical applications, we need to be
able to talk about objects and properties
within our logical system
40
First-order logic
First-order logic (FOL) models the world in terms of
Objects, which are things with individual identities
Properties of objects that distinguish them from other
objects
Relations that hold among sets of objects
Functions, which are a subset of relations where there is
only one “value” for any given “input”
Examples:
Objects: Students, lectures, companies, cars ...
Properties: blue, oval, even, large, ...
Relations: Brother-of, bigger-than, outside, part-of, has-
color, occurs-after, owns, visits, precedes, ...
Functions: father-of, best-friend, second-half, one-more-
than ...
41
Syntax of FOL
Predicates: P(x[1], ..., x[n])
P: predicate name; (x[1], ..., x[n]):
argument list
Examples: human(x), /* x is a human */
father(x, y) /* x is the father of y */
When all arguments of a predicate is
assigned values , the predicate becomes
either true or false, i.e., it becomes a
proposition. Ex. Father(Fred, Joe)
42
Quantifiers
Quantification allows us to make statements
about more than one object at a time ,
Universal quantification  (or forall)
(x)P(x) means that P holds for all values of x in the
domain associated with that variable.
E.g., (x) dolphin(x) => mammal(x)
(x) human(x) => mortal(x)
Universal quantifiers often used with "implication (=>)"
to form "rules" about properties of a class
(x) student(x) => smart(x) (All students are smart)
Often associated with English words “all”, “everyone”,
“always”, etc.
43
Existential quantification 
This means “there exists at least one object x such that x
is a king and x is a person”
(x)P(x) means that P holds for some value(s) of x in the
domain associated with that variable.
E.g., (x) mammal(x) ^ lays-eggs(x)
(x) taller(x, Fred)
Existential quantifiers usually used with “^ (and)" to
specify a list of properties about an individual.
(x) student(x) ^ smart(x) (there is a student who is
smart.)
(x) student(x) => smart(x)
Mean that if there is a student x then he is smart
(wrong).
44
Nested Quantifiers
Same quantifier: Can reduce to one
x y Brother(x, y)  Brother(y, x)
Same as: x, y Brother(x, y)  Brother(y, x)
Same as: y, x Brother(x, y)  Brother(y, x)
Same as: y, x Brother(x, y)  Brother(y, x)
Example; Some dogs bark
 x. Dog x  Barks x
xy . Dog x  Bark y  makes_sound x
All barking dogs are irritating.
 x . Dog x  Barking x  Irritating x
45
Forward Chaining
Example: KB = All men like apples, men buy everything they
like, and Socrates is a man. In FOL, the KB is
1- (x) man(x) => likes(x, apples)
2- (x)(y) (man(x) ^ likes(x,y)) => buys(x,y)
3- Man(Socrates)
Goal query: Does Socrates buy apples?
Proof:
Use GMP with (1) and (3) to derive: “(4) likes(Socrates, apples)”
Use GMP with (3), (4) and (2)
man(Socrates) ^ likes(Socrates, apples) => buys(Socrates, apples)
to derive “(5) buys(Socrates, apples)”
Result: Yes, Socrates buys apples
Used to produce new facts Start from atomic sentences and fire rules
until no further inference is possible,
46
Example: KB = All cats like fish, cats eat
everything they like, and Ziggy is a cat.
In FOL, KB =
1. x cat(x) => likes(x, Fish)
2. x y (cat(x) ^ likes(x,y)) => eats(x,y)
3. cat(Ziggy)
Goal query: Does Ziggy eat fish?
Proof:
Use GMP with (1) and (3) to derive: 4. likes(Ziggy, Fish)
Use GMP with (3), (4) and (2) to derive eats(Ziggy, Fish)
So, Yes, Ziggy eats fish.
47
Backward chaining
Used to deduce whether statements are true
or not
Start backwards from the goal to find known
facts that support the goal
Used in advisory expert systems
User asks questions
System asks leading questions, then produces
answer if it can,
Backward chaining is the basis for “logic programming,” e.g.,
Prolog.

Artificial intelligent Lec 5-logic

  • 1.
    1 Lecture 5 Knowledge Representation, Logic, and inference 1. Knowledge-based Agents 2. Knowledge Representation Schemas 2-1 Propositional Logic 2-2 First order logic 2-3 Inference
  • 2.
    2 Knowledge-based Agent Central componentof a knowledge-based agent is its knowledge-base (KB) A KB is a set of representations of facts about the world Each individual representation is called a sentence The sentences are expressed in a language called a knowledge representation language A knowledge-based agent should be able to infer. Inference mechanism generates new sentences that are necessarily true given that the old sentences are true.
  • 3.
    3 The Intelligent Agentas Black Box Prior knowledge Past Experience Goals and Values Observations ActionsReasoning (inference) and Representation System (RRS)
  • 4.
    4 Inference example Given: “The redblock is above the blue block” “The green block is above the red block” Infer: “The green block is above the blue block” “The blocks form a tower”
  • 5.
    5 Knowledge Representation Schemas (Symbolic) 1-Logicbased representation – propositional logic, first order predicate logic, Prolog 2-Procedural representation – rules, production system 3-Network representation – semantic networks, conceptual graphs 4-Structural representation – scripts, frames, objects
  • 6.
    6 Representation of Knowledge Thereis no single most adequate knowledge representation formalism/scheme for everything. Main points for selecting a representation formalism: what should be represented, how should the knowledge be processed. There are many more representation formalisms. All the above mentioned are symbolic. There are non-symbolic ones, e.g. Neural networks.
  • 7.
    7 What is Knowledge? Data– primitive verifiable facts, of any representation. Data reflects the current world. Knowledge – relation among sets of data (information), that is very often used for further information deduction. Knowledge contain information about behaviour of abstract models of the world.
  • 8.
    8 Knowledge Representation The objectof KR is to express knowledge in a computer-tractable form, so that it can be used to help agents perform well. A KR language is defined by two aspects: Syntax: describes how to make sentences OR describes the possible configurations that can constitute sentences. Semantics: determine the facts (meaning) in the world to which the sentences refer OR the “things” in the sentence.
  • 9.
    9 Knowledge Representation Example The syntaxof the language of arithmetic expressions says that x and y are expressions denoting numbers, the x  y is a sentence. The semantics of the language say that x  y is false when y is a bigger number than x, and true otherwise. Inference: The terms “inference” and “reasoning” are generally used to cover any process by which conclusions are reached. Logical inference  deduction
  • 10.
    10 Types of logic Logicis a language for KR which tells us how to build up sentences in the language. Ontological commitment: what exists - facts? objects? time? beliefs? Epistemological commitment: what states of knowledge? Language Ontological Commitment Epistemological Commitment Propositional Logic Facts True/false/unknown First order logic Facts, objects, relations True/false/unknown Temporal logic Facts, objects, relations, time True/false/unknown Probability theory Facts Degree of belief 0…1 Fuzzy logic Degree of truth Degree of belief 0…1
  • 11.
    11 Knowledge Representation 1- Logic •PropositionalLogic (Propositional Calculus): Propositional Logic has limitations, - it is not expressive enough. •First-order Logic (First-order Predicate Calculus): First-Order Logic is an improvement and is useful.
  • 12.
    12 Propositions(‫افتراض‬) Statements that canbe either true or false The sky is blue The moon is made of cheese Artificial intelligence is my favourite subject Each statement takes one of the truth- values T or F (or, 1 and 0) Each statement is represented by a propositional variable such as p, q, r, …
  • 13.
    13 Logical operators We canuse logical operators (or connectives) to build more complex statements from our simple propositions The moon is not made of cheese I am bored and I am tired You are a man or you are a mouse If it is snowing then it is cold
  • 14.
    14 Negation p represents “Itis snowing” The negation of p represents “It is not snowing” This is written p pronounced “not p” If p takes the value T then p takes the value F, and vice versa
  • 15.
    15 Conjunction p represents “Itis snowing” q represents “It is cold” The conjunction of p and q represents “It is snowing and it is cold” This is written as p  q pronounced “p and q” Commutative, associative
  • 16.
    16 Disjunction q represents “Itis cold” r represents “It is raining” The disjunction of q and r represents “It is cold or it is raining” This is written as q  r pronounced “q or r” Commutative (q  r = r  q), Associative (q  (r  p))=(q  r)  (q  p)
  • 17.
    17 Implication p represents “Itis snowing” q represents “It is cold” Implication gives statements such as “If it is snowing then it is cold” This is written p  q pronounced “p implies q” Not commutative, not associative
  • 18.
  • 19.
    19 Propositional Calculus - example Let,Fact P: "Ali likes chips'' Let, Fact Q: "Ali eats chips'' Other possible facts: P  Q : "Ali likes chips or Ali eats chips” P  Q : "Ali likes chips and Ali eats chips'’  Q : "Ali doesn't eat chips'’ P  Q : "If Ali likes chips then Ali eats chips'' Read: Logic     Nat. Lang. Or And Implies Not
  • 20.
    20 Truth tables forlogical connectives TTFFTFF FTTFTTF FFTFFFT TTTTFTT ~ QPQPQPQPPQP  Ex: Give the truth table for: (p  q)  (p  q) (p  q)  (p  q) false true true true Solu:
  • 21.
    21 Examples of PLsentences P means "It is hot" Q means "It is humid" R means "It is raining" P ^ Q => R "If it is hot and humid, then it is raining" Q => P "If it is humid, then it is hot" Q "It is humid."
  • 22.
    22 Propositional formulae A formulacan be built from propositions and operators to represent a more complex statement We can construct a truth-table for any formula Upper-case letters are used to represent formulae e.g. P might represent (p  q)  r An interpretation of P is an assignment of truth- values to all the propositional variables i.e. it is a single row of the truth table
  • 23.
    23 Example formula andtruth-table (p  q)  r p q r q p  q (p  q)  r T T T F T T T T F F T F T F T T T T T F F T T F F T T F F T F T F F F T F F T T T T F F F T T F
  • 24.
    24 Tautologies(‫المعنى‬ ‫تكرار‬) A propositionalformula P that takes the truth-value T for every possible interpretation is called a tautology. This is written using the metasymbol╞ like this: ╞ P e.g. ╞ ( p  p ) Any formula that is a tautology is said to be a valid formula.
  • 25.
    25 Establishing tautologies An easyway to determine whether or not a proposition is a tautology is to substitute truth values for the atomic propositions. For example, given the proposition p  p, if we substitute true for p, then the overall proposition is equivalent to true and if we substitute false for p then the overall proposition is equivalent to true Therefore we conclude that p  p is a tautology.
  • 26.
    26 Questions Which of thefollowing propositions are tautologies? p  (p  q) p  (q  p) (p  q)  (q  p) (p  q)  (p  q)
  • 27.
    27 Contradictions and contingencies(‫طارئ‬) A propositionthat is always false is called contradiction If a proposition is neither a tautology nor a contradiction then it is called a contingency
  • 28.
    28 Propositional Inference: EnumerationMethod Let    and KB = (  C)  B  C) Is it the case that KB  ? I.e.,  is true in all worlds where KB is true. Check all possible models --  must be true whenever KB is true. TrueTrueTrue FalseTrueTrue TrueFalseTrue FalseFalseTrue TrueTrueFalse FalseTrueFalse TrueFalseFalse FalseFalseFalse =    KB= (  C)  B  C) CBA ╞
  • 29.
    29 TrueTrueTrueTrue TrueFalseTrueTrue FalseTrueFalseTrue TrueFalseFalseTrue TrueTrueTrueFalse FalseFalseTrueFalse FalseTrueFalseFalse FalseFalseFalseFalse    KB (  C)  B  C) CBA Propositional Inference: Enumeration Method Let    and KB = (  C)  B  C) Is it the case that KB  ? I.e.,  is true in all worlds where KB is true Check all possible models --  must be true whenever KB is true ╞
  • 30.
    30 Propositional Inference: EnumerationMethod Let    and KB = (  C)  B  C) Is it the case that KB  ? Check all possible models --  must be true whenever KB is true A B C KB (  C)  B  C)     False False False False False False False True False False False True False False True False True True True True True False False True True True False True False True True True False True True True True True True True ╞
  • 31.
    31 Propositional Inference: EnumerationMethod Let    and KB = (  C)  B  C) Is it the case that KB ╞  ? Check all possible models --  must be true whenever KB is true A B C KB (  C)  B  C)     False False False False False False False True False False False True False False True False True True True True True False False True True True False True False True True True False True True True True True True True
  • 32.
    32 Reasoning in PropositionalLogic Similarly, if we assume a few things, we can determine if something follows. E.g., if we assume P, then PQ, say, degenerates into True  Q, which a truth table will tell us is always true. So, we can always draw valid conclusions from premises, regardless of what any of this means
  • 33.
    33 Rules of inference Thereare rules of inference which can be applied to logic, These follow the syntax: A B When something in the knowledge base matches the pattern above the line, then the system concludes that the part below the line is true. or, sometimes we may write it, as , , … |-  meaning, if we know , , …, it is okay to conclude . (‫المنطقية‬ ‫المقدمة‬)Premise Conclusion
  • 34.
    34 An Inference Rule:And - Elimination From a conjunction, you can infer any of the conjuncts. 1 2 … nPremise _______________ iConclusion An inference rule is sound if the conclusion is true in all cases where the premises are true.
  • 35.
    35 An Inference Rule:Modus Ponens From an implication and the premise of the implication, you can infer the conclusion.   Premise ___________ Conclusion An inference rule is sound if the conclusion is true in all cases where the premises are true. i.e. If    is true, and  is true, then  is true. Generalized Modus Ponens (GMP)
  • 36.
    36 Common Inference Rules ModusPonens: ,  |-  And-Elimination: 1  2 |- i And-Introduction: 1,2 |- 1  2 Or-Introduction:  |-    Double-Negation Elimination: ¬¬  |-  Resolution:    , ¬    |-   
  • 37.
    37 Propositional Logic: Rulesof Inference (cont.) Or-Introduction: From a sentence, you can infer its disjunction with anything else at all. i 1  2  ...  n Double-Negation Elimination: From a doubly negated sentence, you can infer a positive sentence   And-Introduction: From a list you can infer their conjunction. 1, 2 , ... , n 1  2  ...  n
  • 38.
  • 39.
    39 Limitations of PropositionalLogic p represents ‘My car is red’ q represents ‘This pen is red’ r represents ‘The planet Mars is red’ Cannot work with lower-level objects like ‘my car’, ‘this pen’, ‘the planet Mars’ For most practical applications, we need to be able to talk about objects and properties within our logical system
  • 40.
    40 First-order logic First-order logic(FOL) models the world in terms of Objects, which are things with individual identities Properties of objects that distinguish them from other objects Relations that hold among sets of objects Functions, which are a subset of relations where there is only one “value” for any given “input” Examples: Objects: Students, lectures, companies, cars ... Properties: blue, oval, even, large, ... Relations: Brother-of, bigger-than, outside, part-of, has- color, occurs-after, owns, visits, precedes, ... Functions: father-of, best-friend, second-half, one-more- than ...
  • 41.
    41 Syntax of FOL Predicates:P(x[1], ..., x[n]) P: predicate name; (x[1], ..., x[n]): argument list Examples: human(x), /* x is a human */ father(x, y) /* x is the father of y */ When all arguments of a predicate is assigned values , the predicate becomes either true or false, i.e., it becomes a proposition. Ex. Father(Fred, Joe)
  • 42.
    42 Quantifiers Quantification allows usto make statements about more than one object at a time , Universal quantification  (or forall) (x)P(x) means that P holds for all values of x in the domain associated with that variable. E.g., (x) dolphin(x) => mammal(x) (x) human(x) => mortal(x) Universal quantifiers often used with "implication (=>)" to form "rules" about properties of a class (x) student(x) => smart(x) (All students are smart) Often associated with English words “all”, “everyone”, “always”, etc.
  • 43.
    43 Existential quantification  Thismeans “there exists at least one object x such that x is a king and x is a person” (x)P(x) means that P holds for some value(s) of x in the domain associated with that variable. E.g., (x) mammal(x) ^ lays-eggs(x) (x) taller(x, Fred) Existential quantifiers usually used with “^ (and)" to specify a list of properties about an individual. (x) student(x) ^ smart(x) (there is a student who is smart.) (x) student(x) => smart(x) Mean that if there is a student x then he is smart (wrong).
  • 44.
    44 Nested Quantifiers Same quantifier:Can reduce to one x y Brother(x, y)  Brother(y, x) Same as: x, y Brother(x, y)  Brother(y, x) Same as: y, x Brother(x, y)  Brother(y, x) Same as: y, x Brother(x, y)  Brother(y, x) Example; Some dogs bark  x. Dog x  Barks x xy . Dog x  Bark y  makes_sound x All barking dogs are irritating.  x . Dog x  Barking x  Irritating x
  • 45.
    45 Forward Chaining Example: KB= All men like apples, men buy everything they like, and Socrates is a man. In FOL, the KB is 1- (x) man(x) => likes(x, apples) 2- (x)(y) (man(x) ^ likes(x,y)) => buys(x,y) 3- Man(Socrates) Goal query: Does Socrates buy apples? Proof: Use GMP with (1) and (3) to derive: “(4) likes(Socrates, apples)” Use GMP with (3), (4) and (2) man(Socrates) ^ likes(Socrates, apples) => buys(Socrates, apples) to derive “(5) buys(Socrates, apples)” Result: Yes, Socrates buys apples Used to produce new facts Start from atomic sentences and fire rules until no further inference is possible,
  • 46.
    46 Example: KB =All cats like fish, cats eat everything they like, and Ziggy is a cat. In FOL, KB = 1. x cat(x) => likes(x, Fish) 2. x y (cat(x) ^ likes(x,y)) => eats(x,y) 3. cat(Ziggy) Goal query: Does Ziggy eat fish? Proof: Use GMP with (1) and (3) to derive: 4. likes(Ziggy, Fish) Use GMP with (3), (4) and (2) to derive eats(Ziggy, Fish) So, Yes, Ziggy eats fish.
  • 47.
    47 Backward chaining Used todeduce whether statements are true or not Start backwards from the goal to find known facts that support the goal Used in advisory expert systems User asks questions System asks leading questions, then produces answer if it can, Backward chaining is the basis for “logic programming,” e.g., Prolog.