Vous êtes sur la page 1sur 20

4CC503 Computational Mathematics

Week 8: Boolean types and truth tables

Dr Ovidiu Bagdasar

Department of Computing & Mathematics


Email: o.bagdasar@derby.ac.uk
Autumn Semester, Week 8

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

1 / 18

Lecture Outline

Boolean datatype
I
I
I

boolean set
boolean functions
equivalence with sets

Truth tables
Logical sentences

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

2 / 18

Boolean types
Boolean datatype: the set B, and the operations on B.
Boolean types: The set of Boolean values B has the definition:
B = {true, false }
Boolean Operations:

:BB
: BB B
: BB B
: B B B
: B B B

NOT (some older books may use )


OR
AND
IMPLIES
EQUIVALENT (when pq AND qp)

Truth tables: Binary representation of boolean operations with tables.


Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

3 / 18

George Boole (2 November 1815 - 8 December 1864)


The inventor of Boolean variables George Boole
English mathematician,
philosopher and logician
author of The Laws of Thought
father of Boolean logic
(a) founder of computer science
Applications of boolean logic
electrical switches process logic functions
foundation of practical digital circuit design

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

4 / 18

George Boole (2 November 1815 - 8 December 1864)


The inventor of Boolean variables George Boole
English mathematician,
philosopher and logician
author of The Laws of Thought
father of Boolean logic
(a) founder of computer science
Applications of boolean logic
electrical switches process logic functions
foundation of practical digital circuit design
Binary joke...
There are 10 kinds of mathematicians.
Those who can think binarily and those who cant...
Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

4 / 18

Truth tables: NOT


Function NOT ( unary)
NOT :B B
p 7 q.
where
true 7 false if p = true then q = false
false 7 true if p = false then q = true.
Truth table: NOT
p
T
F

Dr Ovidiu Bagdasar (Comp&Maths)

p
F
T

4CC503 Computational Mathematics

Autumn Semester, Week 8

5 / 18

Truth tables: OR
Function: OR ( binary)
OR :B B B

(p, q ) 7 r .
where
(true, true ) 7 true
(true, false ) 7 true
(false, true ) 7 true
(false, false ) 7 false
Truth table: OR

Dr Ovidiu Bagdasar (Comp&Maths)

pq

T
T
F
F

T
F
T
F

T
T
T
F

4CC503 Computational Mathematics

Autumn Semester, Week 8

6 / 18

Truth tables: AND


Function: AND ( binary)
AND :B B B

(p, q ) 7 r .
where
(true, true ) 7 true
(true, false ) 7 false
(false, true ) 7 false
(false, false ) 7 false
Truth table: AND

Dr Ovidiu Bagdasar (Comp&Maths)

pq

T
T
F
F

T
F
T
F

T
F
F
F

4CC503 Computational Mathematics

Autumn Semester, Week 8

7 / 18

Truth tables: IMPLIES


Function: IMPLIES (binary)
IMPLIES :B B B

(p, q ) 7 r .
where
(true, true ) 7 true
(true, false ) 7 false
(false, true ) 7 true
(false, false ) 7 true
Truth table: IMPLIES

Dr Ovidiu Bagdasar (Comp&Maths)

pq

T
T
F
F

T
F
T
F

T
F
T
T

4CC503 Computational Mathematics

Autumn Semester, Week 8

8 / 18

Truth tables: EQUIVALENT


Function: EQUIVALENT (binary)
EQUIVALENT :B B B

(p, q ) 7 r .
where
(true, true ) 7 true
(true, false ) 7 false
(false, true ) 7 false
(false, false ) 7 true
Truth table: EQUIVALENT (pq AND qp)

Dr Ovidiu Bagdasar (Comp&Maths)

pq

qp

pq

T
T
F
F

T
F
T
F

T
F
T
T

T
T
F
T

T
F
F
T

4CC503 Computational Mathematics

Autumn Semester, Week 8

9 / 18

Logical equivalence
Remark: Logical variables can be connected by , , , ...

Definition (Logical equivalence)


Two expressions are said to be equivalent if they have the same truth table.
Exercise 1 Show using tables that

(i ) p q p q
(ii )(p q ) = p q
(iii )(p q ) = p q
Last two equivalences are known as De Morgans Laws.
Exercise 2 Prove the following results for sets )(using Venn diagrams)

(i ) (A B )c = Ac B c (de Morgan law for )


(ii ) (A B )c = Ac B c (de Morgan law for ).
Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

10 / 18

Equivalence with set operations: NOT


Let A be a subset of universe U and p be defined as

p (x ) is true if and only ifx A


Prove that the following relation holds:

p (x ) is true if and only if x Ac = {A = A = U \ A.


Truth table NOT
p
T
F

Venn diagram

p
F
T

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

11 / 18

Equivalence with set operations: OR


Let A, B be two sets and p and q be defined as
p (x ) is true if and only if x A
q (x ) is true if and only if x B
Prove that the following relation holds:
p q (x ) is true if and only if x A B.
Truth table OR

Venn diagram

pq

T
T
F
F

T
F
T
F

T
T
T
F

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

12 / 18

Equivalence with set operations: AND


Let A, B be two sets and p and q be defined as
p (x ) is true if and only if x A
q (x ) is true if and only if x B
Prove that the following relation holds:
p q (x ) is true if and only if x A B.
Truth table AND

Venn diagram

pq

T
T
F
F

T
F
T
F

T
F
F
F

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

13 / 18

Sentences
Definition (Sentence)
A sentence is a statement that takes a value true or false.
Examples:
Alan Turing was a great computer scientist is a true sentence
Alan Turing could not add 2 + 2 is a false sentence
Note: Two or more sentences may be combined by NOT, AND and OR!
Examples: For sentences p, q
pq is the sentence p AND q
pq is the sentence p OR q

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

14 / 18

Examples
Let us consider the propositions:
p stand for x 0
q stand for y = 16
r stand for x is prime
Then
pq stands for x 0 and y = 16 ;
qr stands for y = 16 or x is prime ;

r stands for not x is prime (or x is not prime).


Suppose we know that x = 9 and y = 10. Then
p is true

pq is false

q is false

qr is false

r is false

r is true

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

15 / 18

Propositions and predicates


Definitions:
A sentence with no variables is a proposition.
A sentence which contains variables, it is called a predicate.
Examples:
it is raining (proposition - usually true)
Dave is a Doctor (proposition)
3 > 5 (proposition with value false)
x > 5 (predicate). If x N then for
I x = 0, 1, ..., 5 the predicate is false
I x = 6, 7, ... the predicate is true
X is the mother of Y
Special predicates:
Tautology - always true
Contradiction - always false
Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

16 / 18

Maths Jokes

Q: What is the difference between a mathematician and a philosopher?


A: Mathematicians only need
paper
pencil and
a trash bin
for their work.

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

17 / 18

Maths Jokes

Q: What is the difference between a mathematician and a philosopher?


A: Mathematicians only need
paper
pencil and
a trash bin
for their work.
Philosophers can do without the trash bin...

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

17 / 18

To do
Assessed work:
Take CM Test 1 before the deadline!
Get the best mark you can!
Weekly Homework: First problems in the tutorial sheet for Lecture 4.
Next week:
Logical formulae and operations
Quantifiers and their negation
Useful reading:
Truth tables - digital logic
BBC Bitesize - Logic Gates
Khan Academy - Logic Gate puzzler

Dr Ovidiu Bagdasar (Comp&Maths)

4CC503 Computational Mathematics

Autumn Semester, Week 8

18 / 18

Vous aimerez peut-être aussi