Upload
rafe-spencer
View
221
Download
0
Embed Size (px)
Citation preview
Computer Organization 1
Logic and Boolean Algebra
George Boole (1815 – 1864)
The original Working Class Boy Made Good, Boole was born in the wrong time, in the wrong place, and in the wrong class - he didn't have a hope of growing up to be a mathematical genius, but he did it anyway.
Born in Lincoln, Boole was lucky enough to have a father with a love of maths. Young George took to learning like a politician to a pay rise and, by the age of eight, had outgrown his father's self-taught limits.
George Boole (1815 – 1864)
Boole was translating Latin poetry by the age of twelve. By adolescence he was fluent in German, Italian and French. At 16 he became an assistant teacher, at 20 he opened his own school.
Depending on mathematical journals borrowed from the local Mechanic's Institute, Boole struggled with Newton's 'Principia' and the works of French mathematicians Laplace and Lagrange.
George Boole (1815 – 1864)
Boole's 1847 work, 'The Mathematical Analysis of Logic', expanded on Leibniz' earlier speculations on the correlation between logic and maths, and argued that logic was a discipline of mathematics, rather than philosophy.
This paper won him the admiration of the logician Augustus de Morgan (a mentor of Ada Byron's), and a place on the faculty of Queen's in Belfast.
Boole came up with a type of linguistic algebra, the three most basic operations of which are AND, OR and NOT. These three functions are the only operations necessary to perform comparisons or basic mathematical functions.
George Boole (1815 – 1864)
Boole's system was based on a binary approach, processing only two objects - the yes-no, true-false, on-off, zero-one approach.
His two value system, separating arguments into different classes which can then be processed according to the presence or absence of a certain property, enabled any proposition - regardless of the number of individual items - to draw logical conclusions.
Boolean algebra - Propositions and Predicates
The binary nature of logical propositions (True or False) means that Boolean algebra has applications in computing.
A proposition is a statement which can be either true or false. Propositions can be represented by letters.
Examples: 'p' stands for the proposition 'you are
listening to this lecture' 'q' stands for the proposition '3 + 4 = 9'
Propositions and Predicates
Negation The negation of proposition p is the
proposition which is false when p is true, and true when p is false.
We write the negation of p as p', -p, ~p, p, NOT p
Truth Tables
We can draw up representations of the possible values of propositions
p p’ OR p p’ T F 1 0
F T 0 1 The binary digit representation is
the accepted computer code for True (1) and False (0)
Predicates and propositions
Predicates are like propositions - they can be either true or false - but differ in that they contain variables which prevent the T or F value from being determined right away.
Example: 'X > 5' is a predicate because we need to know the value of X before we can
determine whether the predicate is true or false. Once a value is assigned, X = 8, say, then the predicate becomes a proposition, 8 > 5, which is true.
'It is red' is a predicate, because we need to know what 'It' is, before we can determine whether the predicate is true or false.
Conditions in selections (ifs) and repetitions (for loops) in programming are examples of predicates.
Boolean Operations (Logic operations)
Propositions and predicates may be combined using Boolean operators AND OR and NOT to make logical operations.
Examples 'p' stands for the proposition 'you are listening
to this talk' 'q' stands for ' you are chewing gum' p AND q is a logic operation which stands for 'you are listening to this talk' and ' you are
chewing gum'
AND Operator P(x) is a predicate which stands for x > 5 Q(y) is a predicate which stands for y
= 8 P(x) AND Q(y) is a logic operation with
P(x) and Q(y) as operands, and AND as operator
P(x) AND Q(y) stands for 'x > 5 AND y = 8‘
We can often abbreviate to ‘P AND Q’
AND operator The AND operation can be defined by a truth table -
using ^ as the symbol for AND : p q p ^ q 0 0 0 1 0 0 0 1 0 1 1 1 The AND operation is also known as the conjunction,
logical product or intersection. We can write p^q, p.q, pq to mean p AND q.
OR Operator The OR operation can be defined by a truth table -
using v as the symbol for OR : p q p v q 0 0 0 1 0 1 0 1 1 1 1 1 The OR operation is also known as the inclusive
OR, logical sum or union. Also written as p+q, means p OR q
Inclusive or Exclusive OR.
In everyday usage, OR has 2 possible meanings: OR can mean one or the other or both (inclusive OR) OR can mean one or the other, but not both (exclusive
OR) Inclusive OR: To get a Masters degree you have to
follow a postgrad programme or submit a thesis (You might do both)
Exclusive OR: You are rich or you are poor (you can't be both)
Our truth table above demonstrates inclusive OR Exclusive OR is also important in computing
Exclusive Or (EXOR) operation p q p EXOR q 0 0 0 1 0 1 0 1 1 1 1 0 That is, (p EXOR q) is true when
p and q are different.
Equivalence (Match) Operation
p q p q 0 0 1 1 0 0 0 1 0 1 1 1 That is, (pq) is True when p is the same as q. Two operations are equivalent if they have the
same truth table. For convenience, we use the = sign for cases where the equivalence operation is true, eg p = q means p q.
Equivalence Example: Show that (NOT p ^ NOT q) is equivalent to
NOT (p v q) Truth table: p q p’ q’ p’ ^ q’ (p v q) (p v q)’
0 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 1 0 1 1 0 0 0 1 0
Example Show that A + A’.B = A + B, using a
truth table A B A’ A’.B A + B A + A’.B 0 0 1 0 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 1 0 0 1 1
Example Show that A + 1 = 1 and that A.1
= A A 1 A + 1 A.1 1 1 1 1 0 1 1 0
Summary
Propositions and predicates may be combined using logic operations such as negation (‘ ~ not), Union ( + v OR), intersection (^ . AND) and Exclusive OR.
We can test (and possibly simplify) these logic operations using truth tables.