Boolean Functions

Boolean Functions

Outline Functions of More Than One Variable Boolean Functions Boolean Functions Alice E. Fischer CSCI 1166 Discrete Mathematics for Computing February 2018 Alice E. Fischer L4. Boolean Functions. 1/16 Outline Functions of More Than One Variable Boolean Functions 1 Functions of More Than One Variable 2 Boolean Functions Basic Logical Functions Truth Tables Alice E. Fischer L4. Boolean Functions. 2/16 Outline Functions of More Than One Variable Boolean Functions Multiple inputs, one output. It is possible for a function to have more than one input variable. Until now we have been talking about one-argument functions. In math notation, we write f (x) = z, where x 2 X and z 2 Z. The type of this function is f : X ! Z We can generalize to two-argument functions. We write f (x; y) = z, where x 2 X , y 2 Y and z 2 Z. The type of this function is f : X × Y ! Z Often, we are interested in functions where X ; Y ; and Z are the same set. For example, addition: +: int × int ! int Alice E. Fischer L4. Boolean Functions. 3/16 Outline Functions of More Than One Variable Boolean Functions Binary functions. A binary function has two inputs and one output. Arithmetic is based on two binary functions (+; ×) and their inverses (−; ÷). A Boolean function is a function with truth-values as inputs and a truth-value as its output. For example, or : bool × bool ! bool A Boolean function is a function with truth-values as inputs and a truth-value as its output. For example, Recall that a function can be defined by a table. The tables on the next slide define the function not, and, or, and exor . In the tables, the inputs are to the left of the double bar, the outputs to the right. Alice E. Fischer L4. Boolean Functions. 4/16 Outline Functions of More Than One Variable Boolean Functions NOT, AND, OR, and EXOR NOT x answer T F F T AND OR EXOR x y answer x y answer x y answer TT T TT T TT F TF F TF T TF T FT F FT T FT T FF F FF F FF F Alice E. Fischer L4. Boolean Functions. 5/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions Functions and Gates A logic gate is a device that implements a Boolean function. Functions are mathematical abstractions and gates are a physical interpretation of that abstraction. Logic gates are primarily implemented electronically using diodes or transistors, but can also be constructed using electromagnetic relays, optics, or mechanical elements. Low or high input voltages are interpreted as false or true.A gate combines the input voltages according to the rule for the corresponding boolean function, then outputs a voltage that represents false or true Alice E. Fischer L4. Boolean Functions. 6/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions Digital Circuits Digital circuits are used to implement microprocessors. They are pervasive today, and are used in all kinds of devices, from cars to bread makers. Logic gates are used to make digital circuits. Because the output of a gate is a logical value, an output of one logic gate can be the input of one or more following gates. Collections of gates can be created that perform a single computation or have feedback loops that can iterate a computation and optimize the result. Alice E. Fischer L4. Boolean Functions. 7/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions Basic Logical Functions Several Boolean functions have names, symbols, and gate-diagrams (next slide). Some also have C operators. Function Logical C Logical C Bitwise Name Symbol Operator Operator Logical not ∼ ! ∼ And ^ && & Or _ jj | Exclusive or ⊕ != ^ Nand ∼∧ Nor ∼∨ Xnor ∼⊕ The symbols in the second column are used for symbolic logic. Alice E. Fischer L4. Boolean Functions. 8/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions Diagrams for Logic Gates These diagrams are used when sketching circuits. You will work with these gates in ELEC 1155. NOT AND NAND OR NOR XOR XNOR Alice E. Fischer L4. Boolean Functions. 9/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions NOR, EXOR, XNOR NAND NOR XNOR x y output x y output x y output TT F TT F TT T TF T TF F TF F FT T FT F FT F FF T FF T FF T Alice E. Fischer L4. Boolean Functions. 10/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions A Table can define a Function. When working with Boolean logic, we use a tool called a truth table both to define functions and to analyze the correctness of our reasoning. The tables used to define the Boolean functions are simple truth tables. Each has two inputs and one operation. Truth tables are also used for much more complex logical expressions. They can have more than two inputs, combined by several operators, to produce a single output. There is one row in a truth table for each possible combination of inputs. With one input, there are two lines, one for T and the other for F. With two inputs, there are four lines. With three, there are 8 lines. In general, with n inputs, a truth table needs 2n lines. Alice E. Fischer L4. Boolean Functions. 11/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions How to Build a Truth Table For n input variables, start by making n input columns and 2n + 1 rows. Column headings belong in the top row. Then add one column for each operator in the boolean expression. The last column is for the last operator executed. It shows the result of the function for each combination of inputs. Strictly speaking, there is no WRONG way to make a truth table, as long as it follows these rules. However, there is an easy way and ahard way to do it. The hard way is to put the 2n rows into the table in random order. (Error prone!) The easy way is to put the rows in in a regular patterned order. Alice E. Fischer L4. Boolean Functions. 12/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions Example-1a: x ^ ∼y Suppose we have this boolean expression: x ^ ∼y What values for x and z give the result true? There are two variable, so we need 4 rows + headings. There are two operations, so we need two columns for the variables + two for the operations. Write in the variable names and subexpressions. x y ∼y x ^ ∼y Alice E. Fischer L4. Boolean Functions. 13/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions Example-1b: x ^ ∼y Start at the column just to the left of the double bar, and write in T and F on alternating lines. Go to the next column on the left and write 2 T's and 2 F's. If there are three variables, write blocks of 4 T's and 4 F's in the next column. Etc. until all variable columns have been filled. x y ∼y x ^ ∼y T T F T F T F T F F F T Alice E. Fischer L4. Boolean Functions. 14/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions Example-1c: x ^ ∼y Now do the first operation and write in the results. Continue doing operations until all columns are full. The last column gives the results of the function. We see that this expression is True only when x is True and y is False. x y ∼y x ^ ∼y T T F F T F T T F T F F F F T F Alice E. Fischer L4. Boolean Functions. 15/16 Outline Basic Logical Functions Functions of More Than One Variable Truth Tables Boolean Functions Example-2:( x ⊕ y) _ ∼z Suppose we have this boolean expression: x ^ ∼y What values for x; y and z give the result true? x y z x ⊕ y ∼z (x ⊕ y) _ ∼z T T T F F F T T F F T T T F T T F T T F F T T T F T T T F T F T F T T T F F T F F F F F F F T T Note that an extra horizontal line was added to help guide the eyes. Alice E. Fischer L4. Boolean Functions. 16/16.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    16 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us