Discrete Structures

Total Page:16

File Type:pdf, Size:1020Kb

Discrete Structures Discrete Structures Harriet Fell Javed A. Aslam Rajmohan Rajaraman Eric Ropiak Chris Burrows Ravi Sundaram Discrete Structures Version 2.1 Harriet Fell Javed A. Aslam Rajmohan Rajaraman Eric Ropiak Chris Burrows Ravi Sundaram College of Computer and Information Science Northeastern University Boston, Massachusetts c Copyright 2009 by Harriet Fell and Javed A. Aslam. All rights reserved. On the cover: Pascal's triangle, mod 2. The figure represents 256 rows of Pascal's triangle: each odd entry is denoted by a dot, and each even entry is left blank. The resulting self-similar pattern of dots is closely related to the Sierpinski triangle fractal. Table of Contents I Computers and Computing: Numbers, Circuits, and Logic 1 1 Number Representations 3 1.1 Binary Representation . 4 1.1.1 Simple Binary Arithmetic . 5 1.2 Bytes . 8 1.3 Hexadecimal Representation . 9 1.4 Octal Representation . 10 1.5 Converting Between Decimal and Binary . 11 1.6 Representing Negative Numbers: Two's Complement . 12 Exercises . 15 2 Circuits 19 2.1 Transistors and Switches . 19 2.2 Basic Logic Gates: AND, OR, NOT . 20 2.2.1 AND Gate . 20 2.2.2 OR Gate . 21 2.2.3 NOT Gate . 21 2.3 Other Logic Gates: NAND, NOR, XOR, XNOR . 22 2.3.1 NAND Gate . 22 2.3.2 NOR Gate . 22 2.3.3 XOR Gate . 23 2.3.4 XNOR Gate . 24 2.4 Binary Arithmetic: Ripple Carry Adders . 24 iii Exercises . 24 3 Logic 27 3.1 Truth Values . 27 3.2 Basic Operators . 28 3.3 Truth Tables . 29 3.4 Logical Equivalence . 29 3.5 Normal Forms . 31 3.5.1 Conjunctive Normal Form . 32 3.5.2 Disjunctive Normal Form . 32 3.5.3 Truth Tables, Formulae, and Circuits . 33 3.6 Further Reading . 36 Exercises . 36 4 Design of a Simple Processor 39 4.1 Architecture . 39 4.1.1 Addition . 39 4.1.2 Negation . 40 4.1.3 Loading . 40 4.1.4 Jump If Zero . 40 4.1.5 Programming the CPU . 41 4.2 Multiplexers and demultiplexers . 42 4.3 Design of the processor . 43 4.3.1 Registers . 45 4.3.2 Extracting the instruction and incrementing the PC . 46 4.3.3 The add instruction . 47 4.3.4 The negate instruction . 48 4.3.5 The load instruction . 49 4.3.6 The jump-if-zero instruction . 50 4.3.7 Storing the new values into the data registers and PC . 51 II Cryptography: Integers and Modular Arithmetic 53 5 Cryptography and Modular Arithmetic 55 5.1 Simple Shift Ciphers . 55 5.1.1 Simple Shift Cipher Links . 56 5.2 Encoding . 57 5.3 The mod Function . 58 5.3.1 Properties of mod . 58 5.4 Simple Substitution Ciphers . 59 5.4.1 Shift Cipher . 59 5.4.2 Linear Ciphers . 60 5.5 Modular Arithmetic . 61 5.6 Powers mod n . 62 Exercises . 63 6 Integers and Division 67 6.1 Divides . 67 6.2 Primes . 68 6.2.1 Finding Primes . 68 6.2.2 Prime Number Decomposition . 69 6.2.3 More about Primes . 70 6.3 Division . 70 6.3.1 Scheme Functions Related to Division . 70 6.4 Greatest Common Divisor and Least Common Multiple . 71 6.4.1 Applications of gcd and lcm . 72 6.5 Euclidean Algorithm . 73 6.5.1 Using the Euclidean Algorithm . 74 6.5.2 Euclidean Algorithm Links . 75 6.6 Extended Euclidean Algorithm . 75 6.7 Inverses mod n . 78 6.8 The RSA (Rivest-Shamir-Adelman) cryptosystem . 79 6.8.1 Introduction . 79 6.8.2 How do public-key cryptosystems work? . 79 6.8.3 How does RSA work? . 79 6.8.4 Why does RSA work? . 81 6.8.5 Is RSA secure and efficient? . 82 Exercises . 83 III Combinatorics: Sets, Counting, and Probability 85 7 Sets 87 7.1 Set Basics . 88 7.2 Set-Builder Notation . 88 7.2.1 Examples . 89 7.3 Venn Diagrams . 89 7.4 Set Operations . 90 7.4.1 [ Union . 91 7.4.2 \ Intersection . 91 7.4.3 A Complement . 92 7.4.4 Difference . 92 7.4.5 Symmetric Difference . 93 7.4.6 Power Set . 93 7.4.7 Cartesian Product . 94 7.5 Computer Representation of Sets . 95 Exercises . 96 8 Counting 99 8.1 Basic Rules . 100 8.2 Inclusion-Exclusion Principle . 104 8.3 Pigeonhole Principle . ..
Recommended publications
  • Logisim Operon Circuits
    International Journal of Scientific & Engineering Research, Volume 4, Issue 8, August-2013 1312 ISSN 2229-5518 Logisim Operon Circuits Aman Chandra Kaushik Aman Chandra Kaushik (M.Sc. Bioinformatics) Department of Bioinformatics, University Institute of Engineering & Technology Chhatrapati Shahu Ji Maharaj University, Kanpur-208024, Uttar Pradesh, India Email: [email protected] Phone: +91-8924003818 Abstract: Creation of Logism Operon circuits for bacterial cells that not only perform logic functions, but also remember the results, which are encoded in the cell’s DNA and passed on for dozens of generations. This circuits is coded in JAVA Language. “Almost all of the previous work in synthetic biology that we’re aware of has either focused on logic components and logical circuits or on memory modules that just encode memory. We think complex computation will involve combining both logic and memory, and that’s why we built this particular framework for designing circuits Life Science. In one circuit described in the paper, one DNA sequences have three genes called Repressor, Operator (terminators) are interposed between the promoter (DNA Polymerase) and the output Proteins (Beta glactosidase, permease, Transacetylase in this case). Each of these terminators inhibits the transcription and Translation of the output gene and can be flipped by a different Promoter enzyme (DNA Polymerase), making the terminator inactive. Key words: Logical IJSERGate, JAVA, Circuits, Operon, AND, OR, NOT, NOR, NAND, XOR, XNOR, Operon Logisim Circuits. IJSER © 2013 http://www.ijser.org International Journal of Scientific & Engineering Research, Volume 4, Issue 8, August-2013 1313 ISSN 2229-5518 1. Introduction The AND gate is obtained from the E6 core module by extending both ends with hairpin M olecular Logic Gates Coding in Java modules, one complementary to input Language and circuits are designed in oligonucleotide x and the other Logisim complementary to input oligonucleotide y.
    [Show full text]
  • Chapter 1. Combinatorial Theory 1.3: No More Counting Please 1.3.1
    Chapter 1. Combinatorial Theory 1.3: No More Counting Please Slides (Google Drive) Alex Tsun Video (YouTube) In this section, we don't really have a nice successive ordering where one topic leads to the next as we did earlier. This section serves as a place to put all the final miscellaneous but useful concepts in counting. 1.3.1 Binomial Theorem n We talked last time about binomial coefficients of the form k . Today, we'll see how they are used to prove the binomial theorem, which we'll use more later on. For now, we'll see how they can be used to expand (possibly large) exponents below. You may have learned this technique of FOIL (first, outer, inner, last) for expanding (x + y)2. We then combine like-terms (xy and yx). (x + y)2 = (x + y)(x + y) = xx + xy + yx + yy [FOIL] = x2 + 2xy + y2 But, let's say that we wanted to do this for a binomial raised to some higher power, say (x + y)4. There would be a lot more terms, but we could use a similar approach. 1 2 Probability & Statistics with Applications to Computing 1.3 (x + y)4 = (x + y)(x + y)(x + y)(x + y) = xxxx + yyyy + xyxy + yxyy + ::: But what are the terms exactly that are included in this expression? And how could we combine the like-terms though? Notice that each term will be a mixture of x's and y's. In fact, each term will be in the form xkyn−k (in this case n = 4).
    [Show full text]
  • Lecture 6: Entropy
    Matthew Schwartz Statistical Mechanics, Spring 2019 Lecture 6: Entropy 1 Introduction In this lecture, we discuss many ways to think about entropy. The most important and most famous property of entropy is that it never decreases Stot > 0 (1) Here, Stot means the change in entropy of a system plus the change in entropy of the surroundings. This is the second law of thermodynamics that we met in the previous lecture. There's a great quote from Sir Arthur Eddington from 1927 summarizing the importance of the second law: If someone points out to you that your pet theory of the universe is in disagreement with Maxwell's equationsthen so much the worse for Maxwell's equations. If it is found to be contradicted by observationwell these experimentalists do bungle things sometimes. But if your theory is found to be against the second law of ther- modynamics I can give you no hope; there is nothing for it but to collapse in deepest humiliation. Another possibly relevant quote, from the introduction to the statistical mechanics book by David Goodstein: Ludwig Boltzmann who spent much of his life studying statistical mechanics, died in 1906, by his own hand. Paul Ehrenfest, carrying on the work, died similarly in 1933. Now it is our turn to study statistical mechanics. There are many ways to dene entropy. All of them are equivalent, although it can be hard to see. In this lecture we will compare and contrast dierent denitions, building up intuition for how to think about entropy in dierent contexts. The original denition of entropy, due to Clausius, was thermodynamic.
    [Show full text]
  • LOGIC GATESLOGIC GATES Logic Gateslogic Gates
    SCR 1013 : Digital Logic Module 3:Module 3:ModuleModule 3: 3: LOGIC GATESLOGIC GATES Logic GatesLogic Gates NOT Gate (Inverter) AND Gate OR Gate NAND Gate NOR Gate Exclusive-OR (XOR) Gate Exclusive-NOR (XNOR) Gate OutlineOutline • NOT Gate (Inverter) Basic building block • AND Gate • OR Gate Universal gate using • NAND Gate 2 of the basic gates • NOR Gate Universal gate using 2 of the basic gates • Exclusive‐OR (XOR) Gate • Exclusive‐NOR (XNOR) Gate NOT Gate (Inverter)NOT Gate (Inverter) • Characteriscs Performs inversion or complementaon • Changes a logic level to the opposite • 0(LOW) 1(HIGH) ; 1 0 • Symbol • Truth Table Input Output 1 0 0 1 NOT Gate (Inverter)NOT Gate (Inverter) • Operator – NOT Gate is represented by overbar • Logic expression AND GateAND Gate • Characteriscs – Performs ‘logical mul@plica@on’ • If all of the input are HIGH, then the output is HIGH. • If any of the input are LOW, then the output is LOW. – AND gate must at least have two (2) INPUTs, and must always have 1 (one) OUTPUT. The AND gate can have more than two INPUTs • Symbols OR GateOR Gate • Characteriscs – Performs ‘logical addion’. • If any of the input are HIGH, then the output is HIGH. • If all of the input are LOW, then the output is LOW. • Symbols NAND GateNAND Gate • NAND NOT‐AND combines the AND gate and an inverter • Used as a universal gate – Combina@ons of NAND gates can be used to perform AND, OR and inverter opera@ons – If all or any of the input are LOW, then the output is HIGH.
    [Show full text]
  • Designing Combinational Logic Gates in Cmos
    CHAPTER 6 DESIGNING COMBINATIONAL LOGIC GATES IN CMOS In-depth discussion of logic families in CMOS—static and dynamic, pass-transistor, nonra- tioed and ratioed logic n Optimizing a logic gate for area, speed, energy, or robustness n Low-power and high-performance circuit-design techniques 6.1 Introduction 6.3.2 Speed and Power Dissipation of Dynamic Logic 6.2 Static CMOS Design 6.3.3 Issues in Dynamic Design 6.2.1 Complementary CMOS 6.3.4 Cascading Dynamic Gates 6.5 Leakage in Low Voltage Systems 6.2.2 Ratioed Logic 6.4 Perspective: How to Choose a Logic Style 6.2.3 Pass-Transistor Logic 6.6 Summary 6.3 Dynamic CMOS Design 6.7 To Probe Further 6.3.1 Dynamic Logic: Basic Principles 6.8 Exercises and Design Problems 197 198 DESIGNING COMBINATIONAL LOGIC GATES IN CMOS Chapter 6 6.1Introduction The design considerations for a simple inverter circuit were presented in the previous chapter. In this chapter, the design of the inverter will be extended to address the synthesis of arbitrary digital gates such as NOR, NAND and XOR. The focus will be on combina- tional logic (or non-regenerative) circuits that have the property that at any point in time, the output of the circuit is related to its current input signals by some Boolean expression (assuming that the transients through the logic gates have settled). No intentional connec- tion between outputs and inputs is present. In another class of circuits, known as sequential or regenerative circuits —to be dis- cussed in a later chapter—, the output is not only a function of the current input data, but also of previous values of the input signals (Figure 6.1).
    [Show full text]
  • Performance Analysis of Adiabatic Logic Gate Circuits Using 4T Dram Cells
    PERFORMANCE ANALYSIS OF ADIABATIC LOGIC GATE CIRCUITS USING 4T DRAM CELLS by ANUPRIYA KRISHNAMOORTHY A THESIS Submitted in partial fulfillment of the requirements for the degree of Master of Science in Engineering in The Department of Electrical and Computer Engineering to The School of Graduate Studies of The University of Alabama in Huntsville HUNTSVILLE, ALABAMA 2016 iii iv ACKNOWLEDGEMENTS This thesis could not be completed without the assistance of several people who deserve special mention. First, I would like to thank Dr. Fat Duen Ho for his guidance throughout all the stages of the work. Second the members of my committee, Dr. David Wendi Pan and Dr. Jia Li, who have been helpful with comments and suggestions. I would like to thank my family especially my parents Krishnamoorthy Vanchinathan(Father), Umamaheswari Jagadeesan (Mother) and my elder sibling Abinaya Krishnamoorthy (Sister) and my friend Ashish Ramesh, for tolerating me through the whole process. v TABLE OF CONTENTS Page List of Figures ............................................................................................................................................ viii List of Symbols ............................................................................................................................................ xi 1. INTRODUCTION AND BACKGROUND 1.1 Overview ................................................................................................................................... 1 1.2 Tank Oscillator Operation ........................................................................................................
    [Show full text]
  • A New Design of XOR-XNOR Gates for Low Power Application
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by UTHM Institutional Repository 2011 International Conference on Electronic Devices, Systems & Applications (ICEDSA) A New Design of XOR-XNOR gates for low power application Nabihah Ahmad Rezaul Hasan Faculty of Electrical and Electronic, School of Engineering and Advanced Technology Universiti Tun Husseion Onn Malaysia Massey University Batu Pahat, Johor, Malaysia Auckland, New Zealand [email protected] [email protected] Abstract—XOR and XNOR gate plays an important role in network can be found in [4]. Each input is connected to both an digital systems including arithmetic and encryption circuits. This NMOS transistor and a PMOS transistor. It provide a full paper proposes a combination of XOR-XNOR gate using 6- output voltage swing but with a large number of transistors. transistors for low power applications. Comparison between a best existing XOR-XNOR have been done by simulating the Complementary pass transistor logic (CPL) is used in [1]. proposed and other design using 65nm CMOS technology in Wang et al. [2] report the XOR-XNOR circuits based on Cadence environment. The simulation results demonstrate the transmission gates. It uses eight transistors and complementary delay, power consumption and power-delay product (PDP) at inputs and has a drawback of loss of driving capability. Wang different supply voltages ranging from 0.6V to 1.2V. The results et al. also designed XOR-XNOR circuits based on inverter show that the proposed design has lower power dissipation and gates. It does not require a complementary inputs but it has no has a full voltage swing.
    [Show full text]
  • The Pigeonhole Principle
    The Pigeonhole Principle The pigeonhole principle is the following: If m objects are placed into n bins, where m > n, then some bin contains at least two objects. (We proved this in Lecture #02) Why This Matters ● The pigeonhole principle can be used to show a surprising number of results must be true because they are “too big to fail.” ● Given a large enough number of objects with a bounded number of properties, eventually at least two of them will share a property. ● The applications are extremely deep and thought-provoking. Using the Pigeonhole Principle ● To use the pigeonhole principle: ● Find the m objects to distribute. ● Find the n < m buckets into which to distribute them. ● Conclude by the pigeonhole principle that there must be two objects in some bucket. ● The details of how to proceeds from there are specific to the particular proof you're doing. Theorem: For any natural number n, there is a nonzero multiple of n whose digits are all 0s and 1s. Theorem: For any natural number n, there is a nonzero multiple of n whose digits are all 0s and 1s. 1 11 111 1111 11111 There are 10 objects here. 111111 1111111 11111111 111111111 1111111111 Theorem: For any natural number n, there is a nonzero multiple of n whose digits are all 0s and 1s. 0 1 11 1 111 2 1111 11111 3 111111 4 1111111 11111111 5 111111111 6 1111111111 7 8 Theorem: For any natural number n, there is a nonzero multiple of n whose digits are all 0s and 1s.
    [Show full text]
  • Combinational Logic Circuits
    CHAPTER 4 COMBINATIONAL LOGIC CIRCUITS ■ OUTLINE 4-1 Sum-of-Products Form 4-10 Troubleshooting Digital 4-2 Simplifying Logic Circuits Systems 4-3 Algebraic Simplification 4-11 Internal Digital IC Faults 4-4 Designing Combinational 4-12 External Faults Logic Circuits 4-13 Troubleshooting Prototyped 4-5 Karnaugh Map Method Circuits 4-6 Exclusive-OR and 4-14 Programmable Logic Devices Exclusive-NOR Circuits 4-15 Representing Data in HDL 4-7 Parity Generator and Checker 4-16 Truth Tables Using HDL 4-8 Enable/Disable Circuits 4-17 Decision Control Structures 4-9 Basic Characteristics of in HDL Digital ICs M04_WIDM0130_12_SE_C04.indd 136 1/8/16 8:38 PM ■ CHAPTER OUTCOMES Upon completion of this chapter, you will be able to: ■■ Convert a logic expression into a sum-of-products expression. ■■ Perform the necessary steps to reduce a sum-of-products expression to its simplest form. ■■ Use Boolean algebra and the Karnaugh map as tools to simplify and design logic circuits. ■■ Explain the operation of both exclusive-OR and exclusive-NOR circuits. ■■ Design simple logic circuits without the help of a truth table. ■■ Describe how to implement enable circuits. ■■ Cite the basic characteristics of TTL and CMOS digital ICs. ■■ Use the basic troubleshooting rules of digital systems. ■■ Deduce from observed results the faults of malfunctioning combina- tional logic circuits. ■■ Describe the fundamental idea of programmable logic devices (PLDs). ■■ Describe the steps involved in programming a PLD to perform a simple combinational logic function. ■■ Describe hierarchical design methods. ■■ Identify proper data types for single-bit, bit array, and numeric value variables.
    [Show full text]
  • Formalization of Some Central Theorems in Combinatorics of Finite
    Kalpa Publications in Computing Volume 1, 2017, Pages 43–57 LPAR-21S: IWIL Workshop and LPAR Short Presentations Formalization of some central theorems in combinatorics of finite sets Abhishek Kr Singh School of Technology and Computer Science, Tata Institute of Fundamental Research, Mumbai [email protected] Abstract We present fully formalized proofs of some central theorems from combinatorics. These are Dilworth’s decomposition theorem, Mirsky’s theorem, Hall’s marriage theorem and the Erdős-Szekeres theorem. Dilworth’s decomposition theorem is the key result among these. It states that in any finite partially ordered set (poset), the size of a smallest chain cover and a largest antichain are the same. Mirsky’s theorem is a dual of Dilworth’s decomposition theorem, which states that in any finite poset, the size of a smallest antichain cover and a largest chain are the same. We use Dilworth’s theorem in the proofs of Hall’s Marriage theorem and the Erdős-Szekeres theorem. The combinatorial objects involved in these theorems are sets and sequences. All the proofs are formalized in the Coq proof assistant. We develop a library of definitions and facts that can be used as a framework for formalizing other theorems on finite posets. 1 Introduction Formalization of any mathematical theory is a difficult task because the length of a formal proof blows up significantly. In combinatorics the task becomes even more difficult due to the lack of structure in the theory. Some statements often admit more than one proof using completely different ideas. Thus, exploring dependencies among important results may help in identifying an effective order amongst them.
    [Show full text]
  • Logic Families
    Logic Families PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Mon, 11 Aug 2014 22:42:35 UTC Contents Articles Logic family 1 Resistor–transistor logic 7 Diode–transistor logic 10 Emitter-coupled logic 11 Gunning transceiver logic 16 Transistor–transistor logic 16 PMOS logic 23 NMOS logic 24 CMOS 25 BiCMOS 33 Integrated injection logic 34 7400 series 35 List of 7400 series integrated circuits 41 4000 series 62 List of 4000 series integrated circuits 69 References Article Sources and Contributors 75 Image Sources, Licenses and Contributors 76 Article Licenses License 77 Logic family 1 Logic family In computer engineering, a logic family may refer to one of two related concepts. A logic family of monolithic digital integrated circuit devices is a group of electronic logic gates constructed using one of several different designs, usually with compatible logic levels and power supply characteristics within a family. Many logic families were produced as individual components, each containing one or a few related basic logical functions, which could be used as "building-blocks" to create systems or as so-called "glue" to interconnect more complex integrated circuits. A "logic family" may also refer to a set of techniques used to implement logic within VLSI integrated circuits such as central processors, memories, or other complex functions. Some such logic families use static techniques to minimize design complexity. Other such logic families, such as domino logic, use clocked dynamic techniques to minimize size, power consumption, and delay. Before the widespread use of integrated circuits, various solid-state and vacuum-tube logic systems were used but these were never as standardized and interoperable as the integrated-circuit devices.
    [Show full text]
  • Digital Logic Fundamentals
    Digital Logic Fundamentals Student Workbook 91573-00 Ê>{Y>èRÆ30Ë Edition 4 3091573000503 FOURTH EDITION Second Printing, March 2005 Copyright March, 2003 Lab-Volt Systems, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form by any means, electronic, mechanical, photocopied, recorded, or otherwise, without prior written permission from Lab-Volt Systems, Inc. Information in this document is subject to change without notice and does not represent a commitment on the part of Lab-Volt Systems, Inc. The Lab-Volt F.A.C.E.T.® software and other materials described in this document are furnished under a license agreement or a nondisclosure agreement. The software may be used or copied only in accordance with the terms of the agreement. ISBN 0-86657-210-4 Lab-Volt and F.A.C.E.T.® logos are trademarks of Lab-Volt Systems, Inc. All other trademarks are the property of their respective owners. Other trademarks and trade names may be used in this document to refer to either the entity claiming the marks and names or their products. Lab-Volt System, Inc. disclaims any proprietary interest in trademarks and trade names other than its own. Lab-Volt License Agreement By using the software in this package, you are agreeing to 6. Registration. Lab-Volt may from time to time update the become bound by the terms of this License Agreement, CD-ROM. Updates can be made available to you only if a Limited Warranty, and Disclaimer. properly signed registration card is filed with Lab-Volt or an authorized registration card recipient.
    [Show full text]