0% found this document useful (0 votes)
298 views22 pages

Computational Logic PT 1

This document discusses the topic of computational logic. It provides background on the foundations of logic as established by Boolean, Frege, Russell, and Whitehead. Logic can be divided into propositional logic and predicate logic. Propositional logic deals with simple statements that are either true or false, while predicate logic also analyzes the meanings within statements. The document defines key terms and concepts in propositional logic like propositions, truth values, and logical connectives. It also establishes formation rules for well-formed formulas and precedence rules for logical connectives in propositional logic.

Uploaded by

Vibhas Bogra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
298 views22 pages

Computational Logic PT 1

This document discusses the topic of computational logic. It provides background on the foundations of logic as established by Boolean, Frege, Russell, and Whitehead. Logic can be divided into propositional logic and predicate logic. Propositional logic deals with simple statements that are either true or false, while predicate logic also analyzes the meanings within statements. The document defines key terms and concepts in propositional logic like propositions, truth values, and logical connectives. It also establishes formation rules for well-formed formulas and precedence rules for logical connectives in propositional logic.

Uploaded by

Vibhas Bogra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

21-08-2020

18CSE351T – Computational Logic


Dr. R. Rajkamal

8/21/2020 Dr. R. Rajkamal 1

 Logic is a language for reasoning.

 It is a collection of rules.

 The foundation of the logic laid by


 British mathematician George Boole
 German mathematician Gottlob Frege,
 British philosopher/mathematician, Bertrand
Russell, & Alfred Whitehead,

Dr. R. Rajkamal 2

1
21-08-2020

Example
 True or false of statements, and how the
truth/falsehood of a statement can be
determined from other statements.

 However, instead of dealing with individual


specific statements, use of symbols to represent
arbitrary statements so that the results can be
used in many similar but different cases.

 The formalization also promotes the clarity of


thought and eliminates mistakes.

Dr. R. Rajkamal 3

Example
 Logic in computer science covers the overlap
between the field of logic and that of computer
science.

 The topic can essentially be divided into three main


areas:
 Theoretical foundations and analysis
 Use of computer technology to aid logicians
 Use of concepts from logic for computer applications

Dr. R. Rajkamal 4

2
21-08-2020

There are various types of logic such as


 logic of sentences (propositional logic),
 logic of objects (predicate logic), Propositional logic & Predicate logic,
 logic involving uncertainties, are fundamental to all types of logic
 logic dealing with fuzziness, temporal logic etc.

Dr. R. Rajkamal 5

 Propositional logic is a logic at the sentential level.


 The smallest unit we deal with in propositional logic is a sentence.
 We do not go inside individual sentences and analyze or discuss their
meanings.
 We are going to be interested only in true or false of sentences, and major
concern is whether or not the truth or falsehood of a certain sentence
follows from those of a set of sentences, and if so, how.
 Thus sentences considered in this logic are not arbitrary sentences but are
the ones that are true or false.
 This kind of sentences are called propositions.
Dr. R. Rajkamal 6

3
21-08-2020

Sentences considered in propositional logic are not arbitrary sentences but are
the ones that are either true or false, but not both.

This kind of sentences are called propositions.

Dr. R. Rajkamal 7

 If a proposition is true, then we  But "Close the door", and "Is it hot
say it has a truth value of "true"; outside ?"are not propositions.
 if a proposition is false, its truth
value is "false".
Example "x is greater than 2",

where x is a variable representing a
 "Grass is green", and "2 + 5 = 5" are
number, is not a proposition, because
propositions.
unless a specific value is given to x we
can not say whether it is true or false,
 The first proposition has the truth
nor do we know what x represents.
value of "true" and the second
"false".
Dr. R. Rajkamal 8

4
21-08-2020

Dr. R. Rajkamal 9

What about the proposition?


 I like logic and you like logic, then I like logic and you like logic or you
we must agree that the proposition do not like logic?
“I and you like logic” is true. This is problematic, for we do not
know exactly how this compound
proposition has been composed of
or formed.

Solution
(I like logic and you like logic) or (you do not like logic)
(I like logic) and (you like logic or you do not like logic)

Use parentheses for disambiguating compound propositions


Dr. R. Rajkamal 10

5
21-08-2020

Dr. R. Rajkamal 11

Connectives

Dr. R. Rajkamal 12

6
21-08-2020

Formation Rules
T and ⊥ Propositional Constants. They 1. T and ⊥ are propositions
stand for propositions which are ‘true’ 2. Each pi is a proposition, where i ∈ N.
and ‘false’ 3. If x is a proposition, then ¬x is a
proposition.
 Both propositional variables (p) and 4. If x,y are propositions, then (x∧y),
propositional constants are (x∨y), (x→y), (x↔y) are propositions.
commonly called atomic propositions 5. Nothing is a proposition unless it
or atoms. satisfies some or all of the rules (1)-
(4). – Clousure Rule
 The alphabet of Propositional Logic,
PL, is the set The set of all propositions is written as PROP.
“PROP is the smallest set that satisfies (1)-(4)”
{ ), (, ¬, ∧, ∨, →, ↔, T, ⊥, p0, p1, p2, . . .}
Dr. R. Rajkamal 13

Not well-formed Well-formed


 P (P1  (P2  P3))
 P1P2 (P3  ( P1  P2))
 P (P2  (P3  P2))
 P (P1  (P2  P3))
  P) (P1  (P2  P3))
Consider ((p1 ∧ p2) ⇒ (p3 ∨ p1))
We may drop outermost parenthesis without any confusion
(p1 ∧ p2) ⇒ (p3 ∨ p1)
If ∧ and ∨ get precedence over ⇒ in unfolding during parsing
then we do not need the rest of parenthesis
p1 ∧ p2 ⇒ p3 ∨ p1
Dr. R. Rajkamal 14

7
21-08-2020

Precedence rules are the following. Precedence Order

 ¬ has the highest precedence.

 ∧,∨ have the next precedence, their precedence being equal.

 →,↔ have the lowest precedence, their precedence being equal.

Instead of writing p0, p1, p2, . . .


 Write propositional variables as p, q, r, s, t, . . . .
 Write u, v, w, x, . . . for propositions

Dr. R. Rajkamal 15

Proposition or not?

1 p0, (p5 →T), ((p100 ↔⊥)∧¬p7), (p8 →((¬p4 ∨ p9)↔(p2 ∧(T→⊥))))

2 p0 ∧ p1, p0 →⊥), (¬¬(p0 ∨ p1)), (p8 →((¬p4 ∨ p9)↔(p2 ∧(T→⊥)))

p0 ∧ p1, a surrounding pair of parentheses is required;


In (¬¬(p0 ∨ p1)) there is an extra pair of parentheses and etc.

Dr. R. Rajkamal 16

8
21-08-2020

Using precedence rules, the proposition


((p1 ∨(p3 ∧ p6))→(p100 ↔¬p1))

can be abbreviated to
p1 ∨(p3 ∧ p6) → (p100 ↔ ¬p1)

Using abbreviations p,q, r, s for p1, p3, p6, p100, respectively, the abbreviated
proposition is

p∨(q∧r)→(s↔¬p)

Dr. R. Rajkamal 17

In General Parse Tree


 The key fact is that any object that has
been formed (generated) by this grammar
can also be parsed.

 It is easy to find out the last rule that has


been applied to form a proposition and
then proceed backward.

 Such an unfolding of the formation of a


proposition can be depicted as a tree,
called a parse tree.
Dr. R. Rajkamal 18

9
21-08-2020

¬((p0 ∧¬p1)→(p2 ∨(p3 ↔¬p4)))

last rule applied


w ::= ¬w

(p0 ∧¬p1)→(p2 ∨(p3 ↔¬p4)))


is a proposition if both the expressions
(p0 ∧¬p1) and (p2 ∨(p3 ↔¬p4))
are propositions
(the rule w ::= (w→w)).
Dr. R. Rajkamal 19

Other way to define the set PROP


In the declarative version, PROP is, the set of all propositions, is the smallest set
of expressions satisfying the following conditions.
1. {T, ⊥, p0, p1, . . .} ⊆ PROP
2. If x, y ∈ PROP, then ¬x, (x∧y), (x∨y), (x→y), (x↔y) ∈ PROP

Another alternative follows an inductive construction of PROP


Dr. R. Rajkamal 20

10
21-08-2020

Theorem:
Let w be a proposition. Then exactly one of the following happens:
(1) w ∈ {T, ⊥, p0, p1, . . .}.
(2) w = ¬x for a unique x ∈ PROP.
(3) w = (x ◦ y) for a unique ◦ ∈ {∧, ∨,→,↔} and unique x, y ∈ PROP.

Proof
Due to the formation rules of a proposition, either w is atomic, or it is in one
of the forms ¬x or (x◦y).

We must show that in the two cases, the propositions x and y are unique.

Dr. R. Rajkamal 21

First Case Second Case


 suppose w = (x ◦ y) for some ◦ ∈
Suppose that w = ¬x. {∧,∨,→,↔} and some propositions x
and y.
 The first symbol of w is ¬.  The first symbol of w is the left
 So, w is neither atomic nor is in the parenthesis (.
form (y ∗ z).  Hence w is neither atomic nor in the
 However, w can be equal to ¬z for form ¬z.
some z.  So, suppose that w = (u∗v) for some
 In that case, ¬x = ¬z forces x = z. propositions u,v and connective ∗ ∈
 That is, x is a unique proposition {∧,∨,→,↔}. Then x ◦ y) = u ∗ v).
determined from w.  Now, x is a prefix of u or u is a prefix
of x.
Dr. R. Rajkamal 22

11
21-08-2020

Let u and v be propositions. If u is a prefix of v, then u = v.


1 implies that x = u. Then ◦y) = ∗v). It gives ◦ = ∗ and then y = v.

The unique parse tree for a proposition has only atomic propositions on
its leaves.
2
Whereas if an expression is not a proposition, in any parse tree for the
expression some leaf will contain an expression other than an atomic
proposition.

Dr. R. Rajkamal 23

PROCEDURE PropDet
Input : Any string x over the alphabet of PL.
Output : ‘yes’, if x is a proposition, else, ‘no’.

1. If x is a (single) symbol and x ∈ { ), (, ¬, ∧, ∨, →, ↔}, then


report ‘yes’; else, report ‘no’; and stop.

2. Otherwise, scan x from left to right to get a substring w in one of the forms
¬p, (p∧q), (p∨q), (p→q), (p↔q);
where p,q are symbols not in the set { ), (, ¬, ∧, ∨, →, ↔}.
If not found, then report ‘no’; and stop.
If found, then replace w by p0; go to Step 1.

Dr. R. Rajkamal 24

12
21-08-2020

(∨(p1 ∧ p2)→(¬p1 ↔ p2)) (∨→¬p1 ↔ p2)


In (∨(p1∧ p2)→(¬p1↔ p2)) the substring Similarly, in (∨ → ¬p1 ↔ p2), the
(p1∧ p2) is replaced by p0 resulting proposition ¬p1 is replaced by p0
in the string (∨p0 →(¬p1 ↔ p2)). resulting in (∨→ p0 ↔ p2). No more
replacements can be done.
Next, the substring ¬p1 is replaced by p0;
and then (p0 ↔ p2) is replaced by p0. Since (∨→ p1 ↔ p2) is not a symbol,
We obtain (∨p0 → p0). the original string (∨→¬p1 ↔ p2) is
not a proposition.
The algorithm stops here reporting ‘no’. It
means (∨(p1 ∧ p2)→(¬p1 ↔ p2))
is not a proposition.
Dr. R. Rajkamal 25

Propositions are built from the atomic propositions with the help of connectives.
Negate Bi-Conditional

The problematic case is x→y.


“If I have got an umbrella, then I would not have been wet”.

“if x then y” is true, if its antecedent x is false.

Dr. R. Rajkamal 26

13
21-08-2020

An interpreta on is any func on i : PROP→{0,1} sa sfying the following


properties for all x,y ∈ PROP:
1. i(T) = 1.
2. i(⊥) = 0.
3. i(¬x) = 1 if i(x) = 0, else, i(¬x) = 0.
4. i(x∧y) = 1 if i(x) = i(y) = 1, else, i(x∧y) = 0.
5. i(x∨y) = 0 if i(x) = i(y) = 0, else, i(x∨y) = 1.
6. i(x→y) = 0 if i(x) = 1, i(y) = 0, else, i(x→y) = 1.
7. i(x↔y) = 1 if i(x) = i(y), else, i(x↔y) = 0.

Dr. R. Rajkamal 27

(p→(¬p→ p))→(p→(p→¬p)) u = ¬(p ∧ q) → (p ∨ (r ↔ ¬q))


u = p→(¬p→ p), v = p→(p→¬p),

Dr. R. Rajkamal 28

14
21-08-2020

Boolean valuations can also be


¬(p ∧ q) → (p ∨ (r ↔ ¬q))
computed using parse trees.

P=0, q=1, r=0


Dr. R. Rajkamal 29

Let w be a proposition. A model of w is an interpretation i with i(w) = 1.


 The fact that i is a model of w is written as i ⊨w (satisfies).
 The fact that i is not a model of w is written as i ⊭ w (falsifies)
⊨ is read as i verifies w; i satisfies w

let i be the interpretation as given in the first row.


 That is, i(p) = i(q) = i(r) = 0.
 The table says that i ⊭ u.

Check for
The interpretation j with j(p) = 1, j(q) = j(r) = 0
The table says that j ⊨ u.

Dr. R. Rajkamal 30

15
21-08-2020

A proposition w is called
 valid, written as ⊨w, iff each interpretation of w is its model;
 invalid iff it is not valid, and we write ⊭ w;
 satisfiable iff it has a model;
 unsatisfiable iff it is not satisfiable;
 contingent iff it is both invalid and satisfiable;
 the proposition T is defined to be satisfiable;
 the proposition ⊥ is defined to be invalid.

Valid propositions are also called tautologies, and


unsatisfiable propositions are called contradictions

Dr. R. Rajkamal 31

16
25-08-2020

18CSE351T – Computational Logic


Dr. R. Rajkamal

Unit 1
Part 2 of 2
8/25/2020 Dr. R. Rajkamal 26

Propositions are built from the atomic propositions with the help of connectives.
Negate Bi-Conditional

The problematic case is x→y.


“If I have got an umbrella, then I would not have been wet”.

“if x then y” is true, if its antecedent x is false.

Dr. R. Rajkamal 27

1
25-08-2020

An interpreta on is any func on i : PROP→{0,1} sa sfying the following


properties for all x,y ∈ PROP:
1. i(T) = 1.
2. i(⊥) = 0.
3. i(¬x) = 1 if i(x) = 0, else, i(¬x) = 0.
4. i(x∧y) = 1 if i(x) = i(y) = 1, else, i(x∧y) = 0.
5. i(x∨y) = 0 if i(x) = i(y) = 0, else, i(x∨y) = 1.
6. i(x→y) = 0 if i(x) = 1, i(y) = 0, else, i(x→y) = 1.
7. i(x↔y) = 1 if i(x) = i(y), else, i(x↔y) = 0.

Dr. R. Rajkamal 28

(p→(¬p→ p))→(p→(p→¬p)) u = ¬(p ∧ q) → (p ∨ (r ↔ ¬q))


u = p→(¬p→ p), v = p→(p→¬p),

Dr. R. Rajkamal 29

2
25-08-2020

Boolean valuations can also be


¬(p ∧ q) → (p ∨ (r ↔ ¬q))
computed using parse trees.

p=0, q=1, r=0


Dr. R. Rajkamal 30

Let w be a proposition. A model of w is an interpretation i with i(w) = 1.


 The fact that i is a model of w is written as i ⊨w (satisfies).
 The fact that i is not a model of w is written as i ⊭ w (falsifies)
⊨ is read as i verifies w; i satisfies w

let i be the interpretation as given in the first row.


 That is, i(p) = i(q) = i(r) = 0.
 The table says that i ⊭ u.

Check for
The interpretation j with j(p) = 1, j(q) = j(r) = 0
The table says that j ⊨ u.

Dr. R. Rajkamal 31

3
25-08-2020

A proposition w is called
 valid, written as ⊨w, iff each interpretation of w is its model;
 invalid iff it is not valid, and we write ⊭ w;
 satisfiable iff it has a model;
 unsatisfiable iff it is not satisfiable;
 contingent iff it is both invalid and satisfiable;
 the proposition T is defined to be satisfiable;
 the proposition ⊥ is defined to be invalid.

Valid propositions are also called tautologies, and


unsatisfiable propositions are called contradictions

Dr. R. Rajkamal 32

 In general, each valid proposition is satisfiable and each unsatisfiable


proposition is invalid.

 Validity and unsatisfiability are dual concepts.

 Further, if i is an interpretation, then i(w) = 1 iff i(¬w) = 0.

Theorem A proposition is valid iff its negation is unsatisfiable.


A proposition is unsatisfiable iff its negation is valid.

Dr. R. Rajkamal 33

4
25-08-2020

Determine whether ?
 Propositions u and v are called equivalent,
p ∨ q ≡ (p→q)→q
u ≡ v,
iff each model of u is a model of v, and
each model of v is also a model of u.

 u ≡ v when u is not equivalent to v.

Dr. R. Rajkamal 34

“If the band performs, then the hall will be full provided that the tickets are
not too costly. However, if the band performs, the tickets will not be too
costly. Therefore, if the band performs, then the hall will be full.”
Check the given argument is correct or not?
 p : the band performs
The hypotheses are the propositions
 q : the hall is (will be) full
p→(r→q), p→r, and the
 r : tickets are not too costly
conclusion is p→q

Dr. R. Rajkamal 35

5
25-08-2020

 Find out all (common) models of both p→(r →q) and p→r.

 In order that the argument is correct, you must check


whether p→q is true (evaluated to 1) in all these rows.

 This is the case.

 Therefore, p→(r→q), p→r ⊨ p→q; the argument is correct.

 Evaluate p→q in the rows 2, 4, 6 since it does not matter whether p→q receives the truth
value 0 or 1 in these cases.

 But if one of the rows 1, 3, 5, 7, 8 had 0 for p→q, then the consequence would not be valid

Dr. R. Rajkamal 36

Monotonicity
Paradox of Material Implication
Let Σ and Γ be sets of propositions, Σ ⊆ Γ, and
let w be a proposition.
A set of propositions Σ is unsatisfiable
(1) If Σ is unsatisfiable, then Γ is unsatisfiable.
iff Σ ⊨ w for each proposition w.
(2) If Σ ⊨ w, then Γ ⊨ w.

Reductio ad Absurdum
(DT: Deduction Theorem)
Let Σ be a set of propositions, and let
Let Σ be a set of propositions, and let x,y
w be a proposition.
be propositions. Then, Σ ⊨ x→y iff Σ∪{x} ⊨ y.
(1) Σ ⊨ w iff Σ∪{¬w} is unsatisfiable.
(2) Σ ⊨ ¬w iff Σ∪{w} is unsatisfiable.

Dr. R. Rajkamal 37

You might also like