Unit-3 - A - Logic Intro and Propositional Logic

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Logic

• Logic
– is the study of the logic relationships between objects
and
– forms the basis of all mathematical reasoning and all
automated reasoning

– Propositional Logic (PL)


– First-Order Logic (FOL) aka Predicate Logic
Introduction: Propositional Logic (PL)

• Propositional Logic (PL) = Propositional Calculus =


Sentential Logic
• In PL, the objects are called propositions
• Definition: A proposition is a statement that is
either true or false, but not both
• We usually denote a proposition by a letter:
P, Q, R, S, …
Introduction: Proposition
• Definition: The value of a proposition is called its truth
value; denoted by
– T or 1 if it is true or
– F or 0 if it is false
• Opinions, interrogatives, and imperatives are not
propositions
• Truth table
P
0
1
Propositions: Examples
• The following are propositions
– Today is Monday M
– The grass is wet W
– It is raining R
• The following are not propositions
– C++ is the best language Opinion
– When is the pretest? Interrogative
– Do your homework Imperative
Logical connectives
• Connectives are used to create a compound
proposition from two or more propositions
– Negation (e.g., P or !P or )
– And or logical conjunction (denoted )
– OR or logical disjunction (denoted )
– XOR or exclusive or (denoted )
– Implication (denoted  or )
– Biconditional (denoted  or )

• We define the meaning (semantics) of the logical


connectives using truth tables
Logical connectives
• P, the negation of a proposition P, is also a proposition
• The logical connective And is true only when both of the
propositions are true. It is also called a conjunction.
• The logical disjunction, or logical OR, is true if one or both
of the propositions are true.
• The exclusive OR, or XOR, of two propositions is true
when exactly one of the propositions is true and the other
one is false
• The implication PQ is the proposition that is false when
P is true and Q is false and true otherwise
– P is called the hypothesis, antecedent, premise
– Q is called the conclusion, consequence
Logical Connective: Implication and
Biconditional
• The implication of PQ can be also read as
– If P then Q
– P implies Q
– If P, Q
– P only if Q
– Q if P
– Q when P
– Q whenever P
– Q follows from P
– P is a sufficient condition for Q (P is sufficient for Q)
– Q is a necessary condition for P (Q is necessary for P)
Logical Connective: Biconditional
• The biconditional PQ is the proposition that is true when
P and Q have the same truth values. It is false otherwise.
• Note that it is equivalent to (PQ)(QP)
• The biconditional PQ can be equivalently read as
– P if and only if Q
– P is a necessary and sufficient condition for Q
– if P then Q, and conversely
– P iff Q
• Examples
– x>0 if and only if x2 is positive
– The alarm goes off iff a burglar breaks in
– You may have pudding iff you eat your meat
Converse, Inverse, Contrapositive
• Consider the proposition P  Q
– Its converse is the proposition Q  P
– Its inverse is the proposition P  Q
– Its contrapositive is the proposition Q  P
Precedence of Logical Operators
• As in arithmetic, an ordering is imposed on the use of
logical operators in compound propositions
• However, it is preferable to use parentheses to disambiguate
operators and facilitate readability
 P  Q   R  (P)  (Q  (R))
• To avoid unnecessary parenthesis, the following
precedences hold:
1. Negation ()
2. Conjunction ()
3. Disjunction ()
4. Implication ()
5. Biconditional ()
Truth tables
• Truth tables are used to define logical connectives
• And to determine when a complex sentence is true
given the values of the symbols in it
Truth tables for the five logical connectives

Example of a truth table used for a complex sentence


Terminology:
Tautology, Contradictions, Contingencies
• Definitions
– A compound proposition that is always true, no matter
what the truth values of the propositions that occur in it
is called a tautology
– A compound proposition that is always false is called a
contradiction
– A proposition that is neither a tautology nor a
contradiction is a contingency
• Examples
– A simple tautology is p  p
– A simple contradiction is p  p
Resolution principle/rule
Resolution plays an important role
in AI and is used in Prolog.

Corresponding Tautology:
(( p

Example:
Let p be “I will study discrete math.”
Let r be “I will study English literature.”
Let q be “I will study databases.”

“I will not study discrete math or I will study English literature.”


“I will study discrete math or I will study databases.”

“Therefore, I will study databases or I will study English literature.”


Resolution
• Resolution is a valid inference rule producing a
new clause implied by two clauses containing
complementary literals
– A literal is an atomic symbol or its negation, i.e., P, ~P
• Amazingly, this is the only interference rule needed
to build a sound & complete theorem prover
– Based on proof by contradiction and usually called
resolution refutation
• The resolution rule was discovered by Alan
Robinson (CS, U. of Syracuse) in the mid 1960s
Resolution
• A KB is actually a set of sentences all of which
are true, i.e., a conjunction of sentences.
• To use resolution, put KB into conjunctive
normal form (CNF) where each is a disjunction
of (one or more) literals (positive or negative
atoms)
• Every KB can be put into CNF, it's just a matter
of rewriting its sentences using standard
tautologies, e.g.
–PQ ≡ ~PQ
Conjunctive Normal Form
• Any propositional formula can be put into conjunctive
normal form (clause form).
• Example:
• (p  q  r)  (p  r)  (q  r)
• Represent as clauses:
• {p  q  r}, {p  r}, {q  r}

clause clause clause

• A formula in conjunctive normal form is unsatisfiable if for every


interpretation I, there is a clause C that is false in I.
• A formula in CNF is satisfiable if there is an interpretation I that makes all
clauses true.
Resolution Example
• KB: [PQ , QRS]
• KB in CNF: [~PQ , ~QR , ~QS]
• Resolve KB(1) and KB(2) producing:
~PR (i.e., PR)
• Resolve KB(1) and KB(3) producing:
~PS (i.e., PS)
• New KB: [~PQ , ~QR, ~QS, ~PR, ~PS]
Tautologies
(AB)↔(~AB)
(A(BC)) ↔(AB)(AC)
Resolution Example
• Binary Resolution Step
– For any two clauses C1 and C2, if there is a literal L1 in C1
that is complementary to a literal L2 in C2, then delete L1 and
L2 from C1 and C2 respectively, and construct the disjunction
of the remaining clauses. The constructed clause is a
resolvent of C1 and C2.
• Examples of Resolution Step
– C1=a b, C2=b c
• Complementary literals : b,b
• Resolvent: a c
– C1=a b c, C2=b d
• Complementary literals : b, b
• Resolvent : a c d
Resolution in Propositional Logic

1. (b c)  a c1: a b c


2. b c2: b
3. (d  e)  c c3: c  d  e
4. e  f c4: e  f
5. d   f c5: d
c6:  f

When two more propositions are connected with then remove  by


separating formula into separate clauses
e.g. P T Q R) would result to 3 clauses – P, T, Q R
Resolution in Propositional Logic
(Resolution Refutation Method)
– First, the goal to be proved,
a , is negated and added to Resolution Tree
the premises list [Refutation a a  b c
Step]
– All premises are converted b c b
to CNF.
– Apply resolution c c d e
principle/rule iteratively.
The derivation of /Null e f d e
indicates that the database of
clauses is inconsistent and d f  d
therefore, Given Premises
leads to the conclusion f f
statement. 
Resolution Refutation: Steps
1. Add the negation of what is to be proved (conclusion)
to the set of axioms/premises.
2. Convert all the premises/axioms (including negation of
the conclusion) into clause form (CNF).
3. Resolve these clauses together, producing new clauses
that logically follow from them. [Only apply resolution
principle at every step]
4. Produce a contradiction by generating the empty
clause.
– This is possible if and only if the theorem is valid.
(Completeness)
Important Notes:
• You can use any clause for resolution step any number of times.
• It’s possible that you can reach to contradiction (empty clause) without using all the
clauses.
Usefulness of Logic
• Logic is more precise than natural language
– You may have cake or ice cream.
• Can I have both?
– If you buy your air ticket in advance, it is cheaper.
• Are there not cheap last-minute tickets?
• For this reason, logic is used for hardware and
software specification or verification
– Given a set of logic statements,
– One can decide whether or not they are satisfiable
(i.e., consistent), although this is a costly process…
Propositional logic: pro and con
• Advantages
– Simple KR language sufficient for some problems
– Lays the foundation for higher logics (e.g., FOL)
– Reasoning is decidable, though NP complete, and
efficient techniques exist for many problems
• Disadvantages
– Not expressive enough for most problems
– Even when it is, it can very “un-concise”

You might also like