Computers and Logic/Boolean Operators

Download Report

Transcript Computers and Logic/Boolean Operators

Great Ideas

Alan Turing –



What is computable?
A task is computable if one can specify a sequence of
instructions which when followed will result in the completion of
the task.
John Von Neumann –


Stored program concept
Developed the concept of storing a program in the computer’s
memory rather than it’s circuitry
Copyright © 2008 by Helene G. Kershner
Great Ideas

Technological advances






Vacuum tube  transistor  integrated circuits (multiple
transistors on a chip)  VLSI (very large scale integration)
Microprocessor chip – computer on a chip
High level programming language – people can build “user
friendly” software”
Changes in memory device hardware
Storing information digitally, making use of the concept
that computers work with two states: on/off, 1/0, yes/no,
high current/low current
The computer is a binary machine
Copyright © 2008 by Helene G. Kershner
Great Ideas

The computer is a binary machine




Perform mathematics
Perform operations on letters that form words
Represent images in grayscale and color
Represent sound
Copyright © 2008 by Helene G. Kershner
The computer is a binary machine
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra


Boolean Algebra (Boolean Logic) is an algebra for
symbolically representing problems in logic & analyzing
them mathematically.
Based on work of George Boole





English mathematician
An Investigation of the Laws of Thought
Published in 1854
Reduced logic of human thought to mathematical operations
An analysis of how natural language works if it were
logical
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra

In 1938 Claude E. Shannon of MIT

Showed that Boolean logic could be applied to the design of
relay networks in telephone systems (the ability to switch
signals from one place to another automatically)
 Invented branch of mathematics called Information


Theory
Information Theory applied Boolean algebra to certain
engineering problems systems
Today, boolean algebra, as applied to computer
hardware design is also known as Switching Theory.
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra

Boolean Logic is an abstraction.

Definition -- Abstraction:



Is the process of taking away or removing characteristics
from something in order to reduce it to a set of essential
characteristics (Whatis.com)
not concrete: not relating to concrete objects but
expressing something that can only be appreciated
intellectually (Encarta.msn.com)
Considered apart from concrete existence: an abstract
concept (www.thefreedictionary.com)
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra
Applying Boolean Logic to computers allows them to
handle very complex problems using complicated
connections of simple components.

Designing hardware and software is very
complicated because we are using them to deal
with complex tasks.
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra
Abstraction allows the designer to be separated from the
machine to get a clearer picture of what needs to be
done.
 allows us to drive a car without knowing how the
engine works
 allows computer users to work with the hardware
without knowing exactly how the machine does what
it does.



Add a flash stick, the software will recognize it
Plug in a digital camera and the software will find it
Move music onto my iPod from the hard-drive without having
any real idea what the computer is doing.
Computers: Complex tasks with Simple
Components

Basic Computer Components
 Switches


On/off, high current / low current, 1/0
Connectors


Wires that connect switches – pipes
Must be able to branch, one or more paths
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra

Logic Gates


Hardware interpretation of boolean logic
Universal building blocks, special circuits that
perform the operation of:
AND
OR
NOT

From these basic elements, computer engineers can
design “anything”
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra

Different and equal ways to represent this kind of logic

Using the English works
AND, OR, NOT

Using Mathematical symbols
Λ, ۰
(means AND)
V, +
~, ¯
(means OR)
(means NOT)
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra

Different and equal ways to represent this kind of logic
 Engineering symbols
inverter/flipper
http://www.ee.surrey.ac.uk/Projects/Labview/gatesfunc/index.html#andgate
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra

Look at statements that can be determined to
be true or false.

I think therefore I am.


Yesterday my daughter in college called needing money.


This can be either true or false
This can be either true or false
My son lives in Washington DC.

This can also be either true or false
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra
Look at statements that cannot be to be true or false.
 A Question is not a statement:



While an answer to a question may be Yes or No, the statement is
neither true or false: Is it 3 o’clock?
A command is not a statement:



What time is it?
You MUST get an A in this class!
Turn at the next corner.
Wishes are not statements:


I’d like to make a million dollars.
Have a Happy Thanksgiving.
http://www.informatik.htw-dresden.de/~nestleri/logic/01/index.html
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra

Different and equal ways to represent this kind of logic
 Truth Tables



Visually shows true/false values and the results (inputs
and outputs) of a logic example.
Describes what is happening in a logic gate or logic
statement
Uses T/F, 1/0
Copyright © 2008 by Helene G. Kershner
Boolean Logic / Boolean Algebra



Logic can be applied to statements.
Statements have the property of either being True (T, 1)
or False (F, 0).
Not everything we say is a statement because it cannot
be thought of as having the value of either True or
False.
Copyright © 2008 by Helene G. Kershner
Venn Diagrams: A, B
Boolean Logic


The set A is mutually exclusive from set B
They have nothing in common
http://cs.uni.edu/~campbell/stat/venn.html
Copyright © 2009 by Helene G. Kershner
Venn Diagrams: A AND B
Boolean Logic


The set A and the set B have a common area.
The pink area labeled 2, is represented by A AND B
A
B
http://www.purplemath.com/modules/venndiag2.htm
Copyright © 2009 by Helene G. Kershner
Logic -- AND
AND combines two statements/inputs either one
of which can be True or False

A statement using AND is only true if both parts of the
sentence are true
John has a sub-prime mortgage AND John cannot pay his
mortgage.
Copyright © 2009 by Helene G. Kershner
Logic -- AND
John has a sub-prime mortgage AND John cannot pay his mortgage.
Truth table identifies the possibilities for AND:
sub-prime mortgage AND cannot pay mortgage Result
F
F
F
F
T
F
T
F
F
T
T
T
Copyright © 2009 by Helene G. Kershner
Logic -- AND
A: sub-prime mortgage
B: cannot pay mortgage
A AND B
F
F
F
T
T
F
T
T
Result
F
F
F
T
Copyright © 2009 by Helene G. Kershner
Venn Diagram: A OR B
Boolean Logic
A OR B represents the area covered by all of A as well as all of
B.
A
B
http://www.purplemath.com/modules/venndiag2.htm
Copyright © 2009 by Helene G. Kershner
Logic – OR
OR combines two statements/inputs either one of which
can be True or False
 A statement using OR is true if either parts of the
sentence is true.




I like mango OR chocolate ice cream.
John has a sub-prime mortgage OR John has a traditional
mortgage.
John can afford his mortgage OR John is unable to pay his
mortgage. .
John has a sub-prime mortgage OR John is unable to pay his
mortgage.
Copyright © 2009 by Helene G. Kershner
Logic – OR





I like mango OR chocolate ice cream.
John has a sub-prime mortgage OR John has a traditional mortgage.
John can afford his mortgage OR John is unable to pay his mortgage. .
John has a sub-prime mortgage OR John is unable to pay his
mortgage.
A OR B
A OR B
F
F
F
T
T
F
T
T
R
F
T
T
T
Copyright © 2008 by Helene G. Kershner
Logic – OR
A: John has a sub-prime mortgage
B: John is unable to pay his mortgage.
A OR B
F
F
F
T
T
F
T
T
Result
F
T
T
T
A OR
0
0
1
1
B R
0 0
1 1
0 1
1 1
Copyright © 2009 by Helene G. Kershner
Venn Diagram: NOT A
Boolean Logic

NOT A is the same as ~ A

NOT A is everything that is outside of A.
A
B
http://www.purplemath.com/modules/venndiag2.htm
Copyright © 2009 by Helene G. Kershner
Logic – NOT/Invert


A
NOT
R
The NOT command, flips or Inverts the value it is given.
The operation switches that statement between True and False

I have a traditional mortgage. I do NOT have a sub-prime mortgage.
 NOT a sub-prime mortgage INVERTs or is the opposite sub-prime
mortgage which is a traditional mortgage.

A = I eat peanut-butter



NOT A means I do NOT eat peanut-butter
If A is True, then NOT A is False
If A is False, then NOT A is True


A = I love peanut-butter
For me A is False, so NOT A would be True
Copyright © 2009 by Helene G. Kershner
Logic – NOT/Invert

A
NOT
R
Truth Table
A NOT A = ~A
0
1
1
0
Copyright © 2009 by Helene G. Kershner
Logic Symbols – Order of Operations

Order of Operations: In a logic statement using the three
operators we have learned the order is

Parenthesis ()

NOT  NOT,


~ ¯¯
AND  AND, ۰, Λ
OR  OR, +, V
Copyright © 2009 by Helene G. Kershner
Venn Diagram: NOT (A AND B)
Boolean Logic

NOT (A OR B) is the same as area labeled 4. It is the area
that is NOT or outside of (A OR B).
A
B
http://www.purplemath.com/modules/venndiag2.htm
Copyright © 2009 by Helene G. Kershner
VENN Diagrams: NOT (A OR B)
Boolean Logic

NOT (A AND B) is the pink area. (A AND B) is the white area,
so NOT (A AND B) is all the area outside of (A AND B).
A
B
http://www.purplemath.com/modules/venndiag2.htm
Copyright © 2009 by Helene G. Kershner
Using Boolean Algebra in the “Real World”

Boolean Operators

http://www.youtube.com/watch?v=xsSZps3NH-M
Logic
Logic problems can relate back to English statements:
A newly constructed building has three types of security alarms. It has
an intrusion alarm, a fire alarm and a flood alarm. If the intrusion or
fire alarm goes off then the police department is called. If the fire or
flood alarm goes off then the fire department is called. But if the
flood alarm goes off don’t call the police. And if the intrusion alarm
goes off don’t call the fire department.
A = intrusion alarm
A OR B = Police
B = fire alarm
C = flood alarm
B OR C = Fire Department
Copyright © 2008 by Helene G. Kershner