32
Computer Science 210 Computer Organization Introduction to Boolean Algebra

Computer Science 210 Computer Organization

Embed Size (px)

DESCRIPTION

Computer Science 210 Computer Organization. Introduction to Boolean Algebra. Interview with President Ruscio. http://news.blogs.wlu.edu/2013/01/14/wls-ruscio-on-wmras-virginia-insight-monday/ “ I want a programmer with a liberal arts degree. ”. George Boole. - PowerPoint PPT Presentation

Citation preview

  • Computer Science 210Computer Organization

    Introduction to Boolean Algebra

  • George BooleEnglish mathematician (1815-1864)

    Boolean algebra Logic Set Theory Digital circuits Programming: Conditions in while and if statements

  • Boolean ConstantsIn Boolean algebra, there are only two constants, true and false

    Boolean constantBinary digitState of a switchVoltage leveltrue1On+5Vfalse0Off0V

  • Boolean VariablesBoolean variables are variables that store values that are Boolean constants.Let A be true

    Let B be false

    Etc.

  • Boolean Operator ANDIf A and B are Boolean variables (or expressions) then A AND B is true if and only if both A and B are true.

  • Boolean Operator ANDIf A and B are Boolean variables (or expressions) then A AND B is false if and only if either A or B are false or theyre both false.

  • Boolean Operator ANDWe denote the AND operation like multiplication in ordinary algebra: AB or A.B

  • Boolean Operator ORIf A and B are Boolean variables (or expressions) then A OR B is true if and only if at least one of A and B is true.

  • Boolean Operator ORIf A and B are Boolean variables (or expressions) then A OR B is false if and only if both A and B are false.

  • Boolean Operator ORWe denote the OR operation like addition in ordinary algebra: A+B

  • Boolean Operator NOTIf A is a Boolean variable (or expression) then NOT A has the opposite value from A.

  • Boolean Operator NOTWe denote the NOT operation by putting a bar over the variable (or expression)

    _ A

  • Boolean Expressions As with ordinary algebra, a Boolean expression is a well-formed expression made from Boolean constants Boolean variables Operators AND, OR and NOTParenthesesExample: __ ____ AB + (A+C)B

  • Evaluating a Boolean expressionAt any time, the value of a BE can be computed using the current values of the variables. __AB + (CD)

    Let A = trueLet B = falseLet C = trueLet D = false

    Then the resulting value is true

  • Operator precedenceNOT comes first, then AND, and finally OR

    (Like arithmetic negation, product, and addition) A + BC is not the same as

    (A + B)C

  • Evaluating a Boolean expressionUnlike ordinary algebra, for a BE, there are only finitely many possible assignments of values to the variables; so, theoretically, we can make a table, called a truth table, that shows the value of the BE for every possible set of values of the variables.

    For convenience, use 0 = false 1 = true

  • Truth Table for AND

    ABAB000010100111

  • Truth Table for OR

    ABA+B000011101111

  • Truth Table for NOT

    A_A0110

  • Filling in a Truth TableIf there are N variables, there are 2N possible combinations of values

    Thus, there are 2N rows in the truth table

    Fill in the values by counting up from 0 in binary

  • Construct a truth table for _ ___ E = AB + (A+C)B Example

  • _ ___ E = AB + (A+C)BAssign the values of the variables first

    ABC000001010011100101110111

  • _ ___ E = AB + (A+C)BThen add columns for each operation

    ABC000001010011100101110111

    _B11001100

  • _ ___ E = AB + (A+C)B

    ABC000001010011100101110111

    _B11001100

    _AB00001100

  • _ ___ E = AB + (A+C)B

    ABC000001010011100101110111

    _B11001100

    _AB00001100

    A+C01011111

  • _ ___ E = AB + (A+C)B

    ABC000001010011100101110111

    _B11001100

    _AB00001100

    A+C01011111

    ___(A+C)10100000

  • _ ___ E = AB + (A+C)B

    ABC000001010011100101110111

    _B11001100

    _AB00001100

    A+C01011111

    ___(A+C)10100000

    ___(A+C)B00100000

  • _ ___ E = AB + (A+C)B

    ABC000001010011100101110111

    _B11001100

    _AB00001100

    A+C01011111

    ___(A+C)10100000

    ___(A+C)B00100000

    E00101100

  • Laws of Boolean Algebra

    Identity

    Zero Element

    A+0=A, A.1=A

    A.0=0, A+1=1

    Idempotent

    Commutative

    A+A=A, AA=A

    A+B=B+A, AB=BA

    Associative

    Distributive

    (A+B)+C=A+(B+C)

    A(B+C)=AB+AC

    (AB)C=A(BC)

    A+BC=(A+B)(A+C)

  • Laws of Boolean Algebra

    Absorption

    DeMorgan

    A+AB=A,

    EQ \O(A+B,\S\UP25(____)) = EQ \O(A,\S\UP25(_))

    EQ \O(B,\S\UP25(_)) ,A(A+B)=A

    EQ \O(AB,\S\UP25(___)) = EQ \O(A,\S\UP25(_)) + EQ \O(B,\S\UP25(_))

    Complement

    Double Complement

    A+ EQ \O(A,\S\UP25(_)) =1, A EQ \O(A,\S\UP25(_)) =0

    EQ \O(A,\S\UP25(_),\S\UP30(_)) = A

  • Boolean Expression Simplification

    (A+ EQ \O(B,\s\up30(_)) )C + A EQ \O(C,\s\up30(_)) + ( EQ \O(B+C,\s\up30(____)) )

    = (A+ EQ \O(B,\s\up30(_)) )C + A EQ \O(C,\s\up30(_)) + EQ \O(B,\s\up30(_))

    EQ \O(C,\s\up30(_)) (DeMorgan)

    = (A+ EQ \O(B,\s\up30(_)) )C + (A+ EQ \O(B,\s\up30(_)) ) EQ \O(C,\s\up30(_)) (Distributive)

    = (A+ EQ \O(B,\s\up30(_)) )(C+ EQ \O(C,\s\up30(_)) )

    (Distributive)

    = (A+ EQ \O(B,\s\up30(_)) )1

    (Complement)

    = A+ EQ \O(B,\s\up30(_))

    (Identity)

  • Boolean Expression Simplification

    EQ \O(A,\s\up30(_))

    EQ \O(B,\s\up30(_)) + A EQ \O(B,\s\up30(_)) + AB

    = EQ \O(A,\s\up30(_))

    EQ \O(B,\s\up30(_)) + A EQ \O(B,\s\up30(_)) + A EQ \O(B,\s\up30(_)) + AB (Idempotent)

    = EQ \O(B,\s\up30(_)) ( EQ \O(A,\s\up30(_)) +A) + A( EQ \O(B,\s\up30(_)) +B) (Distributive)

    = EQ \O(B,\s\up30(_)) 1 + A 1

    (Complement)

    = EQ \O(B,\s\up30(_)) + A

    (Identity)