artificial intelligence lecture no. 10 dr. asad ali safi assistant professor, department of...
TRANSCRIPT
Artificial IntelligenceLecture No. 10
Dr. Asad Ali Safi
Assistant Professor,Department of Computer Science,
COMSATS Institute of Information Technology (CIIT) Islamabad, Pakistan.
Summary of Previous Lecture
• A knowledge-based agent• The Wumpus World• Syntax , semantics• Entailment• Logic as a KR language
Today’s Lecture
• Logic• Propositional logic• Pros and cons of propositional logic• First-order logic• Syntax of FOL: Basic elements• Atomic/complex sentences• Connections between Quantifiers
4
No independent access to the world • The reasoning agent often gets its knowledge about
the facts of the world as a sequence of logical sentences and must draw conclusions only from them without independent access to the world.
• Thus it is very important that the agent’s reasoning is sound!
LANGUAGES
What is logic?
• We can also think of logic as an “algebra” for manipulating only two values: true (T) and false (F)
• We will cover:– Propositional logic--the simplest kind
Propositional logic• Propositional logic consists of:
– The logical values true and false (T and F)– Propositions: “Sentences,” which
• Are atomic (that is, they must be treated as indivisible units, with no internal structure), and
• Have a single logical value, either true or false
– Operators, both unary and binary; when applied to logical values, yield logical values
• The usual operators are and, or, not, and implies
Propositional logic: Syntax• Propositional logic is the simplest logic – illustrates basic
ideas• The proposition symbols P1, P2 etc are sentences
– If S is a sentence, ¬S is a sentence (negation, not)– If S1 and S2 are sentences, S1 S2 is a sentence (conjunction, ∧
AND)– If S1 and S2 are sentences, S1 S2 is a sentence (disjunction, ∨
OR)– If S1 and S2 are sentences, S1 S2 is a sentence (implication, ⇒
IMPLIES)– If S1 and S2 are sentences, S1 S2 is a sentence ⇔
(biconditional)
Truth tables• Logic, like arithmetic, has operators, which apply to
one, two, or more values (operands)• A truth table lists the results for each possible
arrangement of operands– Order is important: x op y may or may not give the
same result as y op x
• The rows in a truth table list all possible sequences of truth values for n operands, and specify a result for each sequence– Hence, there are 2n rows in a truth table for n
operands
Unary operators• There are four possible unary operators:
Only the last of these (negation) is widely used (and has a symbol,¬ ,for the operation
X Constant T Constant F
Identity ¬X
T T F T F
F T F F T
Useful binary operators• Here are the binary operators that are traditionally used:
Notice in particular that material implication (⇒) only approximately means the same as the English word “implies”
Any other binary operators can be constructed from a combination of these (along with unary not, ¬)
X YANDX ∧ Y
ORX ∨ Y
IMPLIESX ⇒ Y
BICONDITIONAL
X ⇔ YT T T T T T
T F F T F F
F T F T T F
F F F F T T
Logical expressions• All logical expressions can be computed with some combination
of and (∧), or (∨ ), and not (¬) operators• For example, logical implication can be computed this way:
Notice that ¬X ∨ Y is equivalent to X ⇒ Y
X Y ¬X ¬X ∨ Y X ⇒ Y
T T F T T
T F F F F
F T T T T
F F T T T
Pros and cons of propositional logic
Propositional logic is declarative
Propositional logic allows partial/disjunctive/negated information(unlike most data structures and databases)
–– Propositional logic is compositional:
meaning of B1,1 P1,2 is derived from meaning of B1,1 and of P1,2
–– Meaning in propositional logic is context-independent
(unlike natural language, where meaning depends on context)–– Propositional logic has very limited expressive power
– (unlike natural language)– E.g., cannot say "pits cause breezes in adjacent squares“
• except by writing one sentence for each squar
First-order logic• While propositional logic assumes the world contains
facts,• first-order logic (like natural language) assumes the world
contains• Objects: people, houses, numbers, colors, baseball games, wars, …
–– Relations: red, round, prime, brother of, bigger than, part of, comes
between, …
– Functions: father of, best friend, one more than, plus, …–“Evil King John ruled England in 1200.”– Object: John, England, 1200; Relation; ruled; Properties: evil, king
Logics in General
• Ontological Commitment: – What exists in the world — TRUTH– PL : facts hold or do not hold.– FOL : objects with relations between them that hold or do
not hold
• Epistemological Commitment: – What an agent believes about facts — BELIEF
Syntax of FOL: Basic elements
• Constant Symbols:– Stand for objects– e.g., KingJohn, 2, UCI,...
• Predicate Symbols– Stand for relations– E.g., Brother(Richard, John), greater_than(3,2)...
• Function Symbols– Stand for functions– E.g., Sqrt(3), LeftLegOf(John),...
Syntax of FOL: Basic elements• Constants KingJohn, 2, UCI,...
• Predicates Brother, >,...
• Functions Sqrt, LeftLegOf,...
• Variables x, y, a, b,...
• Connectives , , , ,
• Equality =
• Quantifiers ,
Relations
• Some relations are properties: they state some fact about a single object: Round(ball),
Prime(7).
• n-ary relations state facts about two or more objects: Married(John,Mary), LargerThan(3,2).
• Some relations are functions: their value is another object: Plus(2,3), Father(Dan).
Atomic sentencesTerm = function (term1,...,termn) or constant or variable• A logical expression that refers to an object
– LeftLegOf(Richard)
• There are 2 kinds of terms:– constant symbols: Table, Computer– function symbols: LeftLeg(Pete), Sqrt(3), Plus(2,3) etc
Atomic sentence = predicate (term1,...,termn) or term1 = term2
• An Atomic sentence is formed from a predicate symbol followed by list of terms. • Examples: LargerThan(2,3) is false. Brother_of(Mary,Pete) is false.
Married(Father(Richard), Mother(John)) could be true or false
• Note: Functions do not state facts and form no sentence: – Brother(Pete) refers to John (his brother) and is neither true nor false.
• Brother_of(Pete,Brother(Pete)) is True. Binary relation Function
Complex Sentences• We make complex sentences with connectives
(just like in propositional logic).( ( ), ) ( ( ))Brother Lef tLeg Richard J ohn Democrat Bush
binary relation
function
property
objects
connectives
More Examples• Brother(Richard, John) Brother(John, Richard)
• King(Richard) King(John)
• King(John) => King(Richard)
• LessThan(Plus(1,2) ,4) GreaterThan(1,2)
(Semantics are the same as in propositional logic)
Variables
• Person(John) is true or false because we give it a single argument ‘John’
• We can be much more flexible if we allow variables which can take on values in a domain. e.g., all persons x, all integers i, etc.– E.g., can state rules like Person(x) => HasHead(x) or Integer(i) => Integer(plus(i,1)
Universal Quantification • means “for all”
• Allows us to make statements about all objects that have certain properties
• Can now state general rules:
x King(x) => Person(x)
x Person(x) => HasHead(x) " i Integer(i) => Integer(plus(i,1))
Note that " x King(x) Person(x) is not correct! This would imply that all objects x are Kings and are People
x King(x) => Person(x) is the correct way to say this
Existential Quantification • x means “there exists an x such that….” (at least one object x)
• Allows us to make statements about some object without naming it
• Examples:
x King(x)
x Lives_in(John, Castle(x))
i Integer(i) GreaterThan(i,0)
Note that is the natural connective to use with
(And => is the natural connective to use with )
Combining Quantifiers
x y Loves(x,y) – For everyone (“all x”) there is someone (“y”) who
loves them
$ y x Loves(x,y) - there is someone (“y”) who loves everyone
Clearer with parentheses: y ( x Loves(x,y) )
Connections between Quantifiers
• Asserting that all x have property P is the same as asserting that does not exist any x that don’t have the property P
x Likes(x, 271 class) x Likes(x, 271 class)
In effect: - is a conjunction over the universe of objects - is a disjunction over the universe of objects Thus, DeMorgan’s rules can be applied
De Morgan’s Law for Quantifiers( )
( )
( )
( )
x P x P
x P x P
x P x P
x P x P
( )
( )
( )
( )
P Q P Q
P Q P Q
P Q P Q
P Q P Q
De Morgan’s Rule Generalized De Morgan’s Rule
Rule is simple: if you bring a negation inside a disjunction or a conjunction,always switch between them (or and, and or).
Summery of Today’s Lecture• logic• Propositional logic• Pros and cons of propositional logic• First-order logic• Syntax of FOL: Basic elements• Atomic/complex sentences• Connections between Quantifiers