Professional Documents
Culture Documents
10 Lecture CSC462
10 Lecture CSC462
10 Lecture CSC462
Lecture 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
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!
4
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:
T T F T F
F T F F T
Only the last of these (negation) is widely used (and has a symbol,¬ ,for the
operation
Useful binary operators
• Here are the binary operators that are traditionally used:
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
Notice that X Y is equivalent to X Y
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, …
• 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,...
• 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).
• Brother_of(Pete,Brother(Pete)) is True.
Binary relation Function
Complex Sentences
• We make complex sentences with connectives
(just like in propositional logic). property
Brother (LeftLeg (Richard ), John ) (Democrat (Bush ))
binary function
relation
objects
connectives
More Examples
• Brother(Richard, John) Brother(John, Richard)
• King(Richard) King(John)
Note that
x King(x) Person(x) is not correct!
This would imply that all objects x are Kings and are People
• Examples:
x King(x)
x Lives_in(John, Castle(x))
i Integer(i) GreaterThan(i,0)
y x Loves(x,y)
- there is someone (“y”) who loves everyone
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
De Morgan’s Rule Generalized De Morgan’s Rule
P Q (P Q ) x P x (P )
P Q (P Q ) x P x (P )
(P Q ) P Q x P x (P )
(P Q ) P Q x P x (P )