0% found this document useful (0 votes)
12 views10 pages

Unity 1 - Logic

The document discusses the fundamentals of logic, emphasizing its importance in mathematical reasoning and computer science. It covers the representation of statements, logical operators, and the construction of truth tables, providing examples of propositions and their truth values. Additionally, it introduces concepts such as tautology, contradiction, and the use of connectives in logical expressions.
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)
12 views10 pages

Unity 1 - Logic

The document discusses the fundamentals of logic, emphasizing its importance in mathematical reasoning and computer science. It covers the representation of statements, logical operators, and the construction of truth tables, providing examples of propositions and their truth values. Additionally, it introduces concepts such as tautology, contradiction, and the use of connectives in logical expressions.
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

Unity 1: FUNDAMENTALS OF LOGIC

Logic is the basis of all mathematical reasoning, and of all automated reasoning. It has practical applications
to the design of computing machines, to the specification of systems, to artificial intelligence, to computer
programming, to programming languages, and to other areas of computer science, as well as to many other
fields of study.
The study of logic as a part of philosophy has been in existence since the earliest days of scientific thinking.
Logic (or mathematical logic, from now logic) was developed in the 19th century by Gottlob Frege. Logic
has become an interdisciplinary language of computer science.
In this chapter we take a close look at what constitutes a valid argument and a more conventional proof.
When a mathematician wishes to provide a proof for a given situation, he or she must use a system of logic.
This is also true when a computer scientist develops the algorithms needed for a program or system of
programs. The logic of mathematics is applied to decide whether one statement follows from, or is a logical
consequence of one or more other statements.
1.1. Representation of simple verbal arguments

Logic is concerned with statements and the relationship between them.

A statements (proposition) is clear affirmation sentence which has only one logic value ‘True’ or ’False’.

The two values of statements are “true” and “false” and are denoted by the symbols T and F respectively.
Occasionally they are also denoted the logic value ‘True’ by 1, if not then is denoted by 0 [Link]
general proposition are denoted and represented by the small letters, p,q,r,s,t,….

There is two logic value and only two: T and F. The set of logics values is {0,1}.

Examples:

• The sentence “ Kigali is the capital of Rwanda” is a statement which truth its value is “true” (T)
• The sentence “Rwanda is an USA country” is astatement whose truth value is “false” (F)
• The equality “ x+y=9” is not a statement because for some values of x and y, the equality is true,
whereas for others it is false.

A diagram can be sometimes be used to view statements .

Example: Use a Venn diagram to express the following statements:

p: A cat has fur

q: A carrot is a vegetable

Animal with Carrot


fur
Cat
Vegetable
Remarks:

• The exists a truth value as:

Consider the propostion p and p is true

Consider the propostion q and q is false

We have: or
p q p q
1 0 T F

• A propostion can not at the same time false and true.

If p is true, then we write: p 1

If q is false, then we write: q 0

The symbol is readden as : ‘has logic value’.

p.
.0
q.
P £ .1 E
r.

Where P is a set of all propositions, E is a set of all truth value, and ℒ is a relationship between set of
propostions and set of truth values.

Complex proposition

A fundamental complex proposition is a set compounded by the simples propositions which we put
together.

Example: A student of this class say: ‘I need to be promoted; Iwill have a good life in the future.’

It is a complex proposition which is compounded by two simples propositions:

P:’I need to be promoted’

Q:’I will have a good life in the future’

The truth table of complex proposition of 3 simples propositions


p q r
1 1 1
1 1 0
1 0 1
1 0 0
0 1 1
0 1 0
0 0 1
0 0 0

1.2. Logics operators or statements calculus

Propositions are combined by means of such connectives as and, or, if. . ., then and if and only if (iff) ; and they
are modified by the word not. These five main types of connectives can be defined in terms of thr three: and,
or and not.

1.2.1. Negation(┐,~)

Example: p:‘John is a student at INES’

┐p:’John is not a student at INES.’

The truth table of negation

p ┐p
1 0
0 1

[Link] conjunction of propositions: ^ (and)

Example: p:‘Peter is a boy’

q:’Peter is a student’

p ∧ q: ’Peter is a boy and a student’

The truth tabe of conjunction

p q p∧q
1 1 1
1 0 0
0 1 0
0 0 0

Remark: The conjunction is false if one of their components is false.


[Link] disjunction :v(or)

Example: p:‘Peter is a boy’

q:’Peter is a student’

p v q: ’Peter is a boy or a student’

The truth tabe of disjunction

p q pvq
1 1 1
1 0 1
0 1 1
0 0 0

Remark: The disjunction is false if all of their components are false.

Example of truth table in complex propositions

P q ~q p∧~q ~(p∧~q) ~p ~(p∧~q)v~(~p)


1 1 0 0 1 0 1
1 0 1 1 0 0 0
0 1 0 0 1 1 1
0 0 1 0 1 1 1

1.2.4. Logic implication(→)

Example: If you drive, then don’t drink

C onsider E: Set of drives

p(x):’x drive’

q(x):’x don’t drink’

We write p(x) →q(x); Here we have 4 cases

1) x drive and x don’t drink: p(x) →q(x) →1,

2) x drive and x drink: p(x) →q(x) →0,

3) x don’t drive and x drink: p(x) →q(x) →1,

4) x don’t drive and x don’t drink: p(x) →q(x) →1.


The truth tabe of implication

p q p→q
1 1 1
1 0 0
0 1 1
0 0 1

Remarks:
• The implication is false if the first proposition is truth and the second is false;
• p→q is reding as if p then q;
• If we have this express p→q, then:
1. q is a necessary for p;
2. p is sufficient for q;
3. q if p;
4. p only if q;
5. p implies q
Example: Write the following statement in symbolic form
If either John takes mathematics or Peter takes algorithm, then Frank will take web design.
Answer: Denote the statements as:
p: John takes mathematics
q: Peter takes algorithm
r: Frank will take web design
This statement can be symbolized as( pvq) →r

Compare the truth table of p→q and of ~(𝑝 ⋀ ~𝑞)

p∧~q ~(p∧~q)
P Q ~q p→q

1 1 0 0 1 1

1 0 1 1 0 0

0 1 0 0 1 1

0 0 1 0 1 1

1.2.5. Equivalence(↔) Biconditional


~
↔ means that → and ←

↔ we read if and only if, then we denote iff.

p↔q is truth iff p→q is truth and q→p is also truth.


P q p→q q→p (p→q)^( q→p) or p↔q

1 1 1 1 1

1 0 0 1 0

0 1 1 0 0

0 0 1 1 1

Remark: The equivalente is truth if p and q are truth at the same time and also are false at the same time
.p→q we read p iff q.

1.2.6. Contraposition of implication

The contraposition of p→q is a new propositionwhich is ~q →~p.

Verifying that p→q and ~q →~p are [Link], we have:

p q p→q ~q ~p ~q →~p (p→q)↔( ~q →~p)

1 1 1 0 0 1 1
1 0 0 1 0 0 1
0 1 1 0 1 1 1
0 0 1 0 1 1 1

1.2.7. De Morgan’s law and equivalent Statements

First Law: ~ (p∧q) ↔ ~p v ~q

Second Law: ~ (p v q) ↔ ~p∧~q

1.2.8. Tautology, contradiction and contingency

• Tautology

This is a propositional function whose truth value is true for all possible values of the propositional function.
Example: Show that ( p  q )  ( p  q ) is a tautology.

p q pq pq ( p  q)  ( p  q)
T T T T T

T F F T T

F T F T T

F F F F T

Conclusion: ( p  q )  ( p  q ) is a tautology.

• Contradiction or absurdity

This is a propositional function whose truth value is always false.


P ~p p  (~p)
1 0 0

0 1 0

• Contingency

This is a propositional function that is neither a tautology nor a contradiction.


Logical equivalence

Symbolic form Name


Rules of inference related to the language of
propositions
p  ~ (~ p ) Double negation

p  q  q  p; p  q  q  p Commutative law

( p  q )  r  p  (q  r ) Associative laws

( p  q )  r  p  (q  r ) Associative laws

~ ( p  q )  (~ p )  (~ q ) De Morgan’s laws

~ ( p  q )  (~ p )  (~ q )
p  (q  r )  ( p  q )  ( p  r ) Distributive laws

p  (q  r )  ( p  q )  ( p  r )
p  p  p; p  p  p Idempotent laws

( p  q)  (~ p  q ) Law of implication

( p  q )  (~ q ~ p ) Contrapositive

Meaning of double
implication
( p  q )  ( p  q )  (q  p )
p  ( p  q)  p Absorption law

Symbolic form Name

( p  q )  p   q Modus ponens

( p  q ) ~ p  ~ p Modus tallens
(indirect
reasoning)

( p  q )  p ; ( p  q )  q simplification

p  ( p  q) Addition

( p  q )  (~ p )  q Disjunctive
syllogism

( p  q )  (~ q )  p One-or-the-
other

( p  q )  (q  r )  ( p  r ) transitivity

1.2.9. Other connectives

a) Exclusive disjunction

Let p and q be two formulas. Then the formula p∇𝑞, in which the connective ∇ is called an exclusive OR, is
true whenever either p or q, but not both, is true.
The truth- table of exclusive OR is given as follows:

p q p∇𝑞

1 1 0

1 0 1

0 1 1

0 0 0

b) Connective NAND

The word NAND is a combination of NOT and AND. It is denoted by the symbol ↑. For any formula p
and q: 𝒑 ↑ 𝒒 ⇔⌉(𝒑 ⋀ 𝒒) ≡ ~(𝒑 ⋀ 𝒒)

c) Connective NOR

The word NOR is a combination of NOT and OR. It is denoted by the symbol ↓. For any formula p and q:
𝒑 ↓ 𝒒 ⇔⌉(𝒑 ⋁ 𝒒) ≡ ~(𝒑 ⋁ 𝒒)

Properties of NAND and NOR

The connectives ↓ and ↑ have been defined in terms of the connectives ∨, ∧, and ∼. Therefore, any formula
containing the connectives ↓ or ↑, one can obtain an equivalent formula containing the connectives ∨, ∧, and
∼ only.

Note that ↓ and ↑ are duals of each other.

The following equivalences express ∼, ∧, and ∨ in terms of ↑ alone.

1) 𝑝 ↑ 𝑝 ⇔ ~𝑝
2) (𝑝 ↑ 𝑞) ↑ (𝑝 ↑ 𝑞) ⇔ 𝑝 ⋀ 𝑞
3) (𝑝 ↑ 𝑝) ↑ (𝑞 ↑ 𝑞) ⇔ 𝑝 ⋁ 𝑞

In the same manner, the following equivalence express ∼, ∧, and ∨ in terms of ↓ alone

1) 𝑝 ↓ 𝑝 ⇔ ~𝑝
2) (𝑝 ↓ 𝑞) ↓ (𝑝 ↓ 𝑞) ⇔ 𝑝 ⋁ 𝑞
3) (𝑝 ↓ 𝑝) ↓ (𝑞 ↓ 𝑞) ⇔ 𝑝 ⋀ 𝑞
Exercises
1) Prove that ( p  ~ q )  r  p  (q  r ) is a tautology
2) Construct a Truth table for the following
a ) ( p  q )  (~ r )  q
b) ( p  q )  (~ p )  (~ r )
c ) ( p  q )  (~ p  r ) (q  r )
d ) ( p  q )  (~~ r )  ( p  r )
3) Prove that the following are tautologies
a ) ~ ( p  q )  (~ p )  q  p
b) ( p  p )  (r  s )  ( p  r )  q  s
c ) ( p  r )  (q  r )  ( p  q )  r 
d )  p  (q  r )  (~ q )  ( p  r )
e) ( p  q )  r   (~ p )  (q  r )
4) Prove the following equivalence whose illustrate properties of exclusive disjunction:
a) 𝑝∇𝑞 ⟺ 𝑞∇p commutative
b) (𝑝∇𝑞)∇r ⟺ 𝑝∇(𝑞∇r) associative
c) 𝑝∇(𝑞∇r) ⟺ (𝑝∇𝑞)∇(𝑝∇𝑟) distribution
d) (𝑝∇𝑞) ⟺ (𝑝 ⋀ ~𝑞) ⋁(~𝑝 ⋀ 𝑞)
e) (𝑝∇𝑞) ⟺ ~(𝑝 ⟺ 𝑞)
5) Show the following equivalences:
a) 𝑝 → (𝑞 → 𝑝) ≡ (𝑝 → 𝑞)
b) 𝑝 → (𝑞 ⋁ 𝑟) ≡ (𝑝 → 𝑞) ⋁(𝑝 → 𝑟)
c) (𝑝 → 𝑞) ⋀(𝑟 → 𝑞) ≡ (𝑝 ⋁ 𝑟) → 𝑞
d) ~(𝑝 ⟺ 𝑞) ≡ (𝑝 ⋁ 𝑞) ⋀ ~(𝑝 ⋀ 𝑞)
e) ~(𝑝 → 𝑞) ≡ 𝑝 ⋀ ~𝑞
f) ~(𝑝 ⟺ 𝑞) ≡ (𝑝 ⋀ ~𝑞) ⋁(~𝑝 ⋀ 𝑞)

Corrected exercises

1) Using the truth table values, show that p  q and ~ p  q are equivalent.

Then p  q  p  q

2) Prove:
a) ~ ( p  q )  (~p)  (~q)
~( p  q )  (~p)  (~q) De Morgan Laws
b) p  ~ (~ p) Law of double negation
c) ( p  q )  (~ q ) (~ p ) Law of contraposition
d) p  p  p and p  p  p absorption law
e) p  q  ( p  q )  (q  p ) Equivalence biconditional
3) Do True Table
a) ( p  q )  q   q modus ponens or direct reasoning
b) ( p  q )  (~ q )  (~ p ) modus tallens or indirect reasoning
4) Do True Table.
( p  q )  (~ p )  q 
a)  disjunction syllogism or one or-the-other
b) ( p  q )  (~¨q )  p 
5) Do True Table.
( p  q )  (q  r )  ( p  r ) transitivity or hypothesis syllogism
Solutions

1) ( p  q )  (~ p  q)
p Q pq p ~p Q ~ pq
T T T
T F T T
T F F
T F F F
F T T
F T T T
F F T
F T F T

p ~ Q ~q p  q ~ ( p  q) (~ p )  (~ q )
p p ~p q ~ q p  q ~ ( p  q) (~ p )  (~ q )
1 0 1 0 1 0 0
1 0 1 0 1 0 0
1 0 0 1 1 0 0
1 0 0 1 0 1 1
0 1 1 0 1 0 0
0 1 1 0 0 1 1
0 1 0 1 0 1 1
0 1 0 1 0 1 1

p ~p Q pq ~ pq
1 0 1 1 1

1 0 0 0 0

0 1 1 1 1

0 1 0 1 1

You might also like