Escolar Documentos
Profissional Documentos
Cultura Documentos
Propositional Logic
1
Overview
In the last lecture we considered the
KR and search
importance of 2 focus of AI research??? Will look at logic as a method to formalize and reason about knowledge. Will consider the syntax and semantics of propositional logic. Will look at truth tables for compound propositions.
What is logic?
Logic is an algebra for manipulating only
two values: true (T) and false (F) Nevertheless, logic can be quite challenging This topic will cover:
3
Propositional logic--the simplest kind Predicate logic (a.k.a. predicate calculus)--an extension of propositional logic Resolution theory--a general way of doing proofs in predicate logic Possibly: Conversion to clause form Possibly: Other logics (just to make you aware that they exist)
(or "propositional calculus") A system of symbolic logic using symbols to stand for whole propositions and logical connectives. Propositional logic only considers whether a proposition is true or false. In contrast to predicate logic, it does not consider the internal structure of propositions. (2002-05-21)
Propositional logic
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
Propositions???
Najib is Prime Minister What is the time? 2 + 3 = 5 Phone has five letters. 2 + 3 = 6 Oh dear! Work has five letters. the reactor is on 2+3 All elephants have 4 legs I like AI class
10
Example
Given:
11
Connectives
Propositions may be combined with other propositions to
form compound propositions. These in turn may be combined into further propositions. The connectives that may be used are and conjunction (& or .) or disjunction (| or +) not negation (~) if . . .then implication ( ) if and only if equivalence ( ) Some books use different notations. Some of these are given in parentheses.
13
X Y T T T F
F T F F
AND OR XY XY T T F T F T F F
IMPLIES XY T F T T
BICONDITIONAL XY
T F
F T
approximately means the same as the English word implies All 14 the other operators can be constructed from a combination of these (along with unary not, )
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: X Y X X Y T T F T T F F F F T T T F F T T XY T F T T
Another example
Exclusive or (xor) is true if exactly one of its operands is
16
Worlds
A world is a collection of prepositions and logical
but since it is atomic (you cant look inside it to see component parts), propositions tend to be very specialized and inflexible
17
Models
A model is an assignment of a truth value to each proposition, for example:
true
MaryIsFemale MaryIsRich JohnLovesMary This expression is not valid: MaryIsFemale MaryIsRich JohnLovesMary because it is not satisfied by this model: JohnLovesMary: F, MaryIsFemale: T, MaryIsRich: T But this expression is valid: MaryIsFemale MaryIsRich MaryIsFemale
18
19
Implication elimination
A particularly important rule allows you to get
Y X Y
means is logically
equivalent to
20
Conjunction elimination
Another important rule for simplifying logical
expressions allows you to get rid of the conjunction (and) operator, : This rule simply says that if you have an and operator at the top level of a fact (logical expression), you can break the expression up into two separate facts: MaryIsFemale MaryIsRich becomes: MaryIsFemale MaryIsRich
21
Inference by computer
To do inference (reasoning) by computer is basically a
search process, taking logical expressions and applying inference rules to them
statement Example:
22
it_is_raining it_is_sunny it_is_sunny I_stay_dry it_is_rainy I_take_umbrella I_take_umbrella I_stay_dry To prove: I_stay_dry
expressions (premises), and you are trying to prove some additional logical expression (the conclusion) You can: Do forward reasoning: Start applying inference rules to the logical expressions you have, and stop if one of your results is the conclusion you want Do backward reasoning: Start from the conclusion you want, and try to choose inference rules that will get you back to the logical expressions you have With the tools we have discussed so far, neither is feasible
23
24
And
q, of two propositions is true when both p and q are true, false otherwise. We can summarise the operation of using a truth table. Rows in the table give all possible setting of the propositions to true (T) or false (F). p q
26
27
Or
Also called disjunction. The disjunction p OR q, written p q, of two propositions is true when p or q (or both) are true, false otherwise. Sometimes called inclusive or. p q
29
The word either is often useful eg. either its Monday or it is raining.
It also includes the case of rain on a Monday!
30
Not
Also known as negation The negation NOT p of a proposition (or p) is true when p is false and is false otherwise. p may be read that it is false that p.
Negation is a unary connective. It only takes one argument. Conjunction and disjunction were both binary connectives.
31
Logic is easy. It is false that logic is easy. It is not the case that logic is easy. Logic is not easy.
32
If . . . then . .
Also known as implication The implication p IMPLIES q, written p q, of two propositions is true when either p is false or q is true, and false otherwise. p q
33
34
35
Contrapositive
p q q p q p If I study hard then I get rich. If I get rich then I study hard. (the converse.) If I don't get rich then I don't study hard. (the contrapositive.)
36
Biconditional
Also known as iff or the biconditional. The biconditional, written as p q, of two
propositions is true when both p and q are true or when both p and q are false, and false otherwise.
37
WFF
The set of sentences or well-formed propositional formulae (WFF) is defined as: Any propositional symbol is in WFF. The nullary connectives, true and false are in WFF. If A and B are in WFF then so is ~A, A v B, A ^ B, A B and A 1 B. If A is in WFF then so is (A).
38
Example
The following are well formed formulae
whereas
are not.
39
40
41
Exercise
p.. (my breakfast is) eggs. q.. (my breakfast is) cereal. r.. (my breakfast is) toast.
The statement my breakfast is
either eggs or cereal, and toast may be written in symbolic form as ???
... So
The truth table gives results for all possible interpretations of p, q and r. The compound proposition is true if I eat cereal, eggs and toast; or I eat cereal and toast; or I eat eggs and toast.
From 2 and 3: by Modus Ponens, we infer: 4. H From 4: by ^-introduction, we infer: 5. H ^ D From 1 and 5: by Modus Ponens, we infer: 6. R (Goal -- It is raining)
45
Try this..
Complete the truth table for
Show that the formula is satisfiable Find an interpretation which satisfies Show
is valid.
46