LANGUAGES

AND
MACHINES
NOTES FOR MATH237
4th EDITION 2010

by Dr C. D. H. Cooper

At this stage we discuss proofs. Both of these are important applications to the computing and communications industries. 2 .INTRODUCTION The unifying theme in this book is the concept of a language as a system of strings of characters obeying certain rules. Proofs are a stumbling block to many students. Since languages are just sets of strings we need to develop ways of talking about sets and the associated concepts of relations and functions. Then we study the connection between languages and machines that manipulate them. Strings are fundamental to computing science. Error-correcting codes on the other hand deal with the problem of transmitted data being accidentally corrupted by random noise in the transmission channel. words and pictures. Then we develop a language for talking about languages in general. Both of these involve transforming strings of symbols. As well as helping you to write sound mathematical proofs this training will give you some insight into automated proofs of program correctness. thinking of proofs as sequences of strings of symbols related to each other in a mechanical way. At the same time. words or pictures. Although we tend to think of computers as devices for manipulating numbers. But routine proofs — the sort that you might be called upon to construct — can be generated in a routine. it is more accurate to think of them as machines for manipulating strings of symbols which in turn represent numbers. With encryption the concern is with electronic data being intercepted by an unauthorised party. We will investigate the nature of proof from the syntactic point of view. both make real use of interesting parts of mathematics — the mathematics of integers and of polynomials. Finite-state machines and Turing Machines are important mathematical models of the computing process and they are used to answer a number of important theoretical questions such as: * How does one give a finite description of a language if it contains infinitely many possible strings? * Are there any calculations which are theoretically impossible for a computer to perform? Finally we look briefly at encryption and coding. that is. We begin by discussing a special-purpose language — the language of logic. mechanical way from the definitions and the logical structure of the statements to be proved. This is not the whole picture since significant proofs require insight and imagination. using yet another special-purpose language.

.................. 1............ 3. 1.................................... 3....................................... 3......1 The Languages of Mathematics .............................6 Formal Grammars .….........................…..................... Solutions for Chapter 3 ……………………………………………………….................................................................................................................................................................................… 3......................9 Equivalence Classes ...... Solutions for Chapter 2 ……………………………………………………… 3..............................................................................................…...................... 2...................................… 1......................... 1.......................................... 1...................…..............7 Laws of Logic ..............................................................................… 1........8 Quantifiers ...................................................11 One-to-one and Onto Functions ..….......... 2..............9 The Order of Quantifiers ...................................2 Languages and Computing Science ....................CONTENTS 1... Exercises for Chapter 2 ..................................… 1.....…. 3...................4 Venn Diagrams .......................8 Equivalence Relations .................................…......................…......................................… 2.....................................................7 Regular Expressions .............. 3.. 1....................... 1............. 3........................................ SETS....................................................................................… 2..6 Relations ................. LANGUAGES 2.....13 Counting Infinite Sets ……………………………………………………....................................10 Quantifiers in Mathematics .............................................................................................................. 2...............1 Sets in Mathematics and Computing Science .........14 The Importance of Definitions …………………………………………… Exercises for Chapter 1 .....…...... 1......3 Basic Set Functions ....................3 Strings ..........5 Extended Set Functions .............................................. 2.................................. 1........... LOGIC PART A: FUNDAMENTAL CONCEPTS 1..........….....................11 Negation Rules .... Solutions for Chapter 1 ………………………………………………………........ 1..................................... 3 7 7 8 9 11 12 12 14 15 15 16 16 17 20 22 26 35 36 36 37 39 40 41 43 45 47 47 49 49 50 51 51 52 53 54 55 55 58 61 63 ......................................................................5 String Substitution ........................................10 Functions .................. Exercises for Chapter 3 .................…........4 Languages ...........1 The Role of Logic in Mathematics .............….....…..........................................................................................................5 Tautologies ............... 3.................... 3.........…..................6 Translating From English ............................…............................................................….......13 Patterns of Proof …………………………………………………………................. FUNCTIONS AND RELATIONS 3.....................................................…… 3..............................................…............................2 The Role of Logic in Computing Science ...........................................…................ 2............................................................7 The Sum and Product of Relations ……………………………………… 3...............................................................................................… 1...2 Defining a Set .................................12 Counting Finite Sets .....3 Propositions and Truth Functions ...........…...................……… 3.....4 Compound Propositions ....12 Writing Proofs ……………………………………………………………...................................

..... 7.... 7.......... 4......2 The Languages 0..........................5 The Reduction Algorithm — Locating Equivalent States............................................3 Multiple Initial States ........ λ and ∅ ................ REDUCTION OF FINITE-STATE MACHINES 5.................................................................................................................PART B: FINITE-STATE MACHINES 4.................. 4............................... 5......................….................... Solutions for Chapter 7 ………………………………………………………........….......… 7........... 6......1 Multiple Transitions ...............……………………………… 6....4 k-equivalence of States...................... 7............................................................…...................................1 Regular Languages ....................................................................................................... 7..............................................3 Mealy Machines .. ………........….................................. 7..... 6............. 5............. 5..... 4 67 69 70 71 72 73 74 75 79 85 86 88 90 91 93 94 95 96 100 109 110 111 111 113 115 118 120 122 127 127 128 129 130 130 131 132 137 139 ..…........................ The Simplest Possible Computer ..........7 Black Holes ............................3 The Product of Two Languages ......................... 7................1 Cyclops... 4........... 7.....................4 The Sum of Two Languages .... Exercises for Chapter 7 .............................................…............ 5..............5 Finite State Acceptors .................................. Exercises for Chapter 6 ...........4 Moore Machines ....................….. 4...........7 A Worked Example .................................................. Exercises for Chapter 5 ........…............8 Set Operations and Regular Languages ……………………………………........................... 1...4 Completing the Nulls ……………………………………………………… 6..................................................................................…................................... INTRODUCTION TO FINITE-STATE MACHINES 4.......................................................................................... Solutions for Chapter 4 ……………………………………………………….......1 Equivalent Machines ....................... NON-DETERMINISTIC FINITE-STATE ACCEPTORS 6.....................................................................…....…............6 Additional Examples ..................................................…..................…................................7 Example of a Non-Regular Language ..…....….....2 Null Transitions .......................5 The Kleene Star of a Language ..............................................................................… 5....……………………………… 6.......................................... 4.................................................. Exercises for Chapter 4 .................................…..... Solutions for Chapter 6 ………………………………………………………...... 4................…..................................... 6...........................7 Standard Form ..................................................6 The Reduction Process — Identifying States.................................................8 Reduction of Mealey and Moore Machines ...........2 The Reduction Process — Removing Inaccessible States................... 5........................3 Equivalent States...6 Combining Multiple Transitions ...................................…............................... 5.............6 State Diagrams ...............................................………………………………....... FSA's AND REGULAR LANGUAGES 7...............................… 5.............................…................. Solutions for Chapter 5 ………………………………………………………...............5 Removing the Nulls ..........................2 Finite State Machines . 6...

.....6 Euler's ϕ-Function...…..................... 11................................................................….......... 8................................…..................................... 11..............................................................................….............2 The Halting Problem ........................................5 A Universal Turing Machine ……………………………………………….…. 8.................3 Definition of a Turing Machine .....................................................................................2 Multiple Tracks ...................10 Cracking the RSA Code ………………………………………………… 11.................9 Why it is Secure ..............................................................6 Adding Turing Machines ........................................................................................3 The Halting Problem .... 10..... TURING MACHINES 8................. Solutions for Chapter 12 ………………………………………………………..................... 11..................................5 Powers in Zm .......................................PART C: COMPUTABILITY 8.... 9..................…...........4 Inverses in Zm ……………………………………………………………...................................................................7 The RSA Code: How it Works ..... 5 195 196 198 200 202 204 205 207 208 208 209 210 213 ..........… 8............… Exercises for Chapter 8 ............ Exercises for Chapter 11 .................. 9. 10........................................................... Solutions for Chapter 9 ……………………………………………………….....3 The System Zm .... 10........7 Sample Turing Machines .............................................. 11..................................................................................5 Unary Representation of Numbers ..............…......................….... Exercises for Chapter 9 ................... Exercises for Chapter 10 ............................ Solutions for Chapter 10 ………………………………………………………........ 11.............................................................................................. 9......… 8...............1 The Basic Turing Machine and Its Extensions ...…................................ 11............................................................................................…..... Solutions for Chapter 8 ………………………………………………………........ 10..8 The RSA Code: Why it Works ...........…....4 Multiple Characters ……………………………………............ 143 143 144 145 146 147 148 151 154 161 162 165 166 168 171 173 175 177 179 181 184 185 188 PART D: CODING THEORY 11....3 Multiple Heads .................................................................................………… 9..... 11........ EXTENDED TURING MACHINES 9...........1 Days of the Week ...….....4 Example of a Turing Machine ...….2 The System Z7 ......................................11 Signature Verification ………………………………………………….....…........ 9......................4 Deciding Whether a Given Turing machine Will Halt …………………................ 11............... 11..………………….................... INTEGERS MOD m AND CRYPTOGRAPHY 11... 8.................................................................................................................5 The Flying Dutchman Problem …………………………………………... THE BUSY BEAVER AND HALTING PROBLEMS 10......................…...................................…........ 8......………..................................1 The Limits of Computing .................1 The Problem .................2 Why it is Unsolvable ..... 10..........................

..................... POLYNOMIAL CODES 12.....................………......... 225 225 227 APPENDIX A: DICTIONARY OF TERMS ………………………………...................................… 12............................................................................................... INDEX ………………………………………………………………………… 231 235 237 239 6 219 219 222 222 224 ........................... 12..........................................3 Complete Polynomials ....4 Polynomial Codes: How they Work ....................................................... APPENDIX B: PATTERNS OF PROOF ………………………………….........12.......6 Analysis of Probabilities ...................................................5 Polynomial Codes: Why they Work ............... Exercises for Chapter 12 ............................................... 12....1 Error Detection and Error Correction ....... 12.............. SUMMARY …………………………………………………………………....2 Polynomials .......…...........… 12.................. Solutions for Chapter 12 ……………………………………………………….....