Example: NFA to DFA Conversion

Similar documents
Summary of Course Coverage

CSE 20 DISCRETE MATH. Fall

DISCRETE MATHEMATICS

CSE 20 DISCRETE MATH. Winter

MATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).

r=1 The Binomial Theorem. 4 MA095/98G Revision

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

CPSC 121: Models of Computation

Introduction to Sets and Logic (MATH 1190)

LOGIC AND DISCRETE MATHEMATICS

Computer Organization and Levels of Abstraction

CSC Discrete Math I, Spring Sets

Computer Organization and Levels of Abstraction

A Survey of Mathematics with Applications 8 th Edition, 2009

CPSC 121: Models of Computation. Module 6: Rewriting predicate logic statements

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS

CSL105: Discrete Mathematical Structures. Ragesh Jaiswal, CSE, IIT Delhi

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

CS103 Handout 13 Fall 2012 May 4, 2012 Problem Set 5

Section 2.4: Arguments with Quantified Statements

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

CE161-4-AU UNIVERSITY OF ESSEX. Undergraduate Examinations 2014 DIGITAL SYSTEMS ARCHITECTURE. Time allowed: TWO hours

MATHEMATICAL STRUCTURES FOR COMPUTER SCIENCE

CPSC 121 Midterm 2 Friday November 13th, 2015

CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F

Chapter 3. Set Theory. 3.1 What is a Set?

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

COMS 1003 Fall Introduction to Computer Programming in C. Bits, Boolean Logic & Discrete Math. September 13 th

Today s Topics. What is a set?

11/22/1999 7pm - 9pm. Name: Login Name: Preceptor Name: Precept Number:

Introduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Discrete Mathematics Lecture 4. Harper Langston New York University

1/31/2017. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

CPSC 121: Models of Computation. Module 5: Predicate Logic

9/2/2016. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

Practice Final. Read all the problems first before start working on any of them, so you can manage your time wisely

CMPSCI 250: Introduction to Computation. Lecture #1: Things, Sets and Strings David Mix Barrington 22 January 2014

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability)

About the Author. Dependency Chart. Chapter 1: Logic and Sets 1. Chapter 2: Relations and Functions, Boolean Algebra, and Circuit Design

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

6.080 / Great Ideas in Theoretical Computer Science Spring 2008

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Database Management System Prof. Partha Pratim Das Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

CSC 501 Semantics of Programming Languages

Chapter 2 Working with Data Types and Operators

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

Von Neumann Architecture

CS314: FORMAL LANGUAGES AND AUTOMATA THEORY L. NADA ALZABEN. Lecture 1: Introduction

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

LECTURE 4. Logic Design

(Refer Slide Time: 0:19)

correlated to the Michigan High School Mathematics Content Expectations

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

CDS Computing for Scientists. Midterm Exam Review. Midterm Exam on October 22, 2013

Problems, Languages, Machines, Computability, Complexity

The three faces of homotopy type theory. Type theory and category theory. Minicourse plan. Typing judgments. Michael Shulman.

Midterms Save the Dates!

Chapter 3 Data Representation

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Bits, Words, and Integers

Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee

SIR C.R.REDDY COLLEGE OF ENGINEERING, ELURU DEPARTMENT OF INFORMATION TECHNOLOGY LESSON PLAN

1. [5 points each] True or False. If the question is currently open, write O or Open.

EE292: Fundamentals of ECE

CSE 105 THEORY OF COMPUTATION

Slides for Faculty Oxford University Press All rights reserved.

The Language of Sets and Functions

Section 2.2: Introduction to the Logic of Quantified Statements

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 01, SPRING 2013

THE LOGIC OF QUANTIFIED STATEMENTS

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng

Introduction to dependent types in Coq

MATH 22 MORE ABOUT FUNCTIONS. Lecture M: 10/14/2003. Form follows function. Louis Henri Sullivan

Read this before starting!

KING FAHD UNIVERSITY OF PETROLEUM & MINERALS COMPUTER ENGINEERING DEPARTMENT

CPSC 121: Models of Computation Assignment #4, due Thursday, March 16 th,2017at16:00

UNCA CSCI 255 Exam 1 Spring February, This is a closed book and closed notes exam. It is to be turned in by 1:45 PM.

Introduction II. Sets. Terminology III. Definition. Definition. Definition. Example

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

Computer Science /21/2000

Midterm Exam Review. CS 2420 :: Fall 2016 Molly O'Neil

Implementation of Lexical Analysis. Lecture 4

EDAA40 At home exercises 1

Propositional Logic. Part I

Lecture 6,

Digital Fundamentals

Information Science 1

Software and Hardware

-SQA- SCOTTISH QUALIFICATIONS AUTHORITY HIGHER NATIONAL UNIT SPECIFICATION GENERAL INFORMATION

Final Course Review. Reading: Chapters 1-9

Binary. Hexadecimal BINARY CODED DECIMAL

Logic, Words, and Integers

Transcription:

CPSC 121 Lecture 36 April 8, 2009 Menu April 8, 2009 Topics: Example: NFA to DFA Conversion Final Reading List Summary The End! Reminders: On-line Quiz 12 deadline 5:00pm TODAY Teaching evaluation survey now available on-line deadline 23:00 April 12 Review session (Steve): Thu April 9, 9:00, DMP 310 Review session (Bob): Thu April 16, 14:00, DMP 110 Final exam Friday, April 17, 7:00pm, SRC A READ the WebCT Vista course announcements board Example: NFA to DFA Conversion The proof given in Lecture 35 that NFAs are not more powerful than DFAs shows explicitly how to construct a DFA corresponding to any given NFA. Let s demonstrate that construction for the specific example of the decimal number NFA (also first given in Lecture 35). The slides version of the lecture animates the construction, step by step. The figure given here in the with notes version shows only the final result. The steps, however, are described in words. Recall the NFA... Recall: Decimal Number NFA S S 0 1 int dot real The NFA has five (named) states: s 0, s 1, int, dot and real. Two of the states, s 0 and s 1, are initial states. Two of the states, int and real, are accepting states. Each state in the DFA corresponds to an element of the power set of the sets of states in the NFA. Thus, our DFA (potentially) has 2 5 = 32 states. Fortunately, as is the case in our example, not all states in the resulting DFA always are reachable. (Non reachable states are eliminated in the construction). We name each state in the DFA explicitly, using set notation, according to which element it is in the power set of the sets of states in the NFA. For example, the state in the DFA corresponding to the states s 1 and int in the NFA is named {s 1, int} We begin with the start state of the DFA and continue adding reachable states until the entire DFA is constructed.

1. The start state of the DFA is the state corresponding to the subset of all start states in the NFA. The start states in the NFA are s 0 and s 1. Thus, the start state in the DFA is {s 0, s 1 }. Create this as a state in the DFA and label it accordingly. (This is shown as the first step in the slides version animation). 2. We now consider possible next states when the DFA is in state {s 0, s 1 }. That is, we consider possible next states when the NFA is in either state s 0 or in state s 1. For input 0 9 and the NFA in state s 0 or s 1, the next states are either s 1 or int. Create a state in the DFA named {s 1, int} and add the associated labelled arc from the start state. The state {s 1, int} in the DFA is designated as an accepting states since one of its members, int, is an accepting state in the NFA. For input and the NFA in state s 0 or s 1, the only next state is s 1. Create a state in the DFA named {s 1 } and add the associated labelled arc from the start state. For input. and the NFA in state s 0 or s 1, there is no next state. Create a state in the DFA named { } (for the empty set) and add the associated label from the start state. (These three new states, with their arcs from the start state, are shown as the second step in the slides version animation). There are now three new states in the DFA to consider, {s 1 }, {s 1, int} and { }. 3. Consider possible next states when the DFA is in state {s 1 }. For input 0 9 and the NFA in state s 1, the next states are either s 1 or int. The state in the DFA named {s 1, int} already exists. Add the associated labelled arc from the state {s 1 }. For inputs. or and the NFA in state s 1, there is no next state. The state in the DFA named { } (for the empty set) already exists. Add the associated labelled arc from the state {s 1 }. (These two new labelled arcs are shown as the third step in the slides version animation). 4. Consider possible next states when the DFA is in state {s 1, int}. For input 0 9 and the NFA in state s 1 or int, the next states are either s 1 or int. The state in the DFA named {s 1, int} already exists. Add the associated labelled arc from the state {s 1, int} to itself. For input. and the NFA in state s 1 or int, the only next state is dot. Create a state in the DFA named {dot} and add the associated labelled arc from the state {s 1, int}. For input and the NFA in state s 1 or int, there is no next state. The state in the DFA named { } (for the empty set) already exists. Add the associated labelled arc from the state {s 1, int}. (This new state, {dot}, and the three new labelled arcs are shown as the fourth step in the slides version animation). 5. Consider possible next states when the DFA is in state {dot}. For input 0 9 and the NFA in state dot, the only next state is real. Create a state in the DFA named {real} and add the associated labelled arc from the state {dot}. The state {real} in the DFA is designated as an accepting states since real, is an accepting state in the NFA. For inputs. or and the NFA in state dot, there is no next state. The state in the DFA named { } (for the empty set) already exists. Add the associated labelled arc from the state {dot}. (This new state, {real}, and the two new labelled arcs are shown as the fifth step in the slides version animation). 6. Consider possible next states when the DFA is in state {real}. For input 0 9 and the NFA in state real, the only next state is real. The state in the DFA named {real} already exists. Add the associated labelled arc from the state {real} to itself. 2

For inputs. or and the NFA in state real, there is no next state. The state in the DFA named { } (for the empty set) already exists. Add the associated labelled arc from the state {real}. (The two new labelled arcs are shown as the sixth step in the slides version animation). 7. Finally, consider possible next states when the DFA is in state { }. For any input 0 9,. or and the DFA in state { }, there is no next state. The state in the DFA named { } (for the empty set) already exists. Add the associated labelled arc from the state { } to itself. The final (complete) DFA is shown as the seventh (and last) step in the slides version animation and is given here in the with notes version. In this (simple) example, the NFA had five states and the corresponding DFA has only six (reachable) states. In general, things are not so simple. It s important to note that, owing to the power set construction of the states of the DFA from the states of the NFA, we may indeed need up to 2 n states in the DFA constructed from a given n state NFA. Example 1: Build the DFA... Construct the DFA corresponding to the decimal number NFA {s,s } 0 1 { s 1,int} {dot} {real} {s } 1 { } Final Reading List All textbook readings are from Epp (3rd edition). (You should be able to solve the textbook problems given in each section). Final Exam Coverage 1. Section 203 Lectures 1 36 cumulative [slides] and [with notes] versions provided 2. Epp: Chapter 1 Chapter 2 Sections 3.1, 3.6, and 3.7 plus Theorem 3.4.1 and pages 159 163 3

Section 4.1 (purely as background reading) Sections 4.2 4.4 Sections 5.1 5.3 Section 7.1 and Section 7.2 (excluding Application: Hash Functions and Properties of Exponential and Logarithmic Functions ) Section 12.1 12.2 3. Labs 0 8 Note that while the textbook readings are a crucial part of the course, material from the labs, lectures, assignments, and tutorials that is not drawn directly from the textbook also is assessable on the final exam. Lab topics often complement but are not directly drawn from textbook material. Specifically, Labs 3, 7 and 8 were assigned as readings for Section 203 lectures. The rules for aides during the final exam are the same as they were for the midterm exam. They are repeated here for reference. Final Exam Aides The final exam is open book You may bring and access during the exam: any (reasonable) number of textbooks one binder or folder of notes The binder or folder may contain any notes you like (e.g., handwritten notes, printouts of practice finals, midterms, recipes for chocolate cake, etc.) We recommend carefully organizing and thinking through the material beforehand In a timed situation, you ll likely want to access your notes and books as infrequently as possible Finally, you may not have any other aides during the exam. (In particular, you may not use any electronic device such as a calculator) Summary Here is the cumulative set of learning goals for the course. 1. Propositional logic, combinational circuits and number representations: 1. Evaluate the truth of simple propositional logic statements using truth tables 2. Translate back and forth between simple natural language statements and propositional logic 3. Translate back and forth between propositional logic statements and combinational circuits built using standard logic gates (NOT, AND, OR, XOR, NAND, NOR) 4. Design combinational circuits based on propositional logic expressions and their equivalent logic circuits to solve real problems (e.g., a 7 segment LED numerical display) 5. Evaluate propositional logic as a model of computation for combinational circuits, identifying at least one explicit shortfall (e.g., timing based on gate delays, fan-out, wire length, instabilities, shared sub-circuits, etc.) 4

6. Translate back and forth between simple natural language statements and propositional logic, including conditionals and biconditionals 7. Evaluate the truth of simple propositional logic statements using truth tables, including conditionals and biconditionals 8. Given a propositional logic statement and a logical equivalence rule, apply the rule to create the equivalent statement 9. Transform propositional logic statements by application of logical equivalence rules in order to: simplify complex statements prove the logical equivalence of two statements represent statements in a standard canonical form 10. Convert integers from octal or hexadecimal to binary and back 11. Convert positive integers from decimal to binary by repeated division (octal/hex as intermediary) 12. Convert positive integers from binary to decimal 13. Take the 2 s complement of a fixed width binary number 14. Convert signed (either positive or negative) integers to binary and back 15. Add and subtract fixed width, 2 s complement (signed) binary integers 16. Convert decimal fractions (in positional notation) to binary fractions (in positional notation) by repeated multiplication (octal/hex as intermediary) 17. Critique different number representations describing their strengths and weaknesses (finite representation, overflow, etc.). Representations include: positional notation (binary, octal, decimal, hexadecimal); binary coded decimal (BCD); fixed-width, 2 s complement (signed) binary; IEEE 754 floating point (single and double precision) 18. Use truth tables to establish or refute the validity of a proposed rule of inference 19. Given a rule of inference and propositional logic statements that correspond to the rule s premises, apply the rule to infer a new statement implied by the original statements 20. Explore the logical consequences of a set of propositional statements by application of both equivalence and inference rules, especially in order to transform statements into a desired canonical form 2. Predicate calculus: 1. Understand the definition of a predicate and its associated domain of discourse 2. Evaluate the truth of predicates applied to particular values 3. Understand what it means for a predicate to be universally quantified or existentially quantified 4. Show predicate logic statements are true by enumerating examples (i.e., all examples in the domain of discourse for a universally quantified statement or at least one example for an existentially quantified statement) 5

5. Show predicate logic statements are false by enumerating counterexamples (i.e., one counterexample for a universally quantified statement or all for an existentially quantified statement) 6. Translate between statements in formal predicate logic notation and equivalent statements in closely matching informal language (i.e., informal statements with clear and explicitly stated quantifiers) 7. Construct predicate logic statements to capture the relationships between properties of various objects both real-world like and computing related 8. Determine the negation of any quantified statement, including multiply quantified statements, using generalized De Morgan 9. Given a quantified statement and a logical equivalence rule, apply the rule to create an equivalent statement 10. Apply additional rules of inference for quantified statements including universal instantiation, universal generalizarion, existential instantiation, existential generalization, universal modus ponens, universal modus tollens, and universal transitivity 11. Prove (or disprove) conjectures involving quantified statements using basic proof techniques, both direct and indirect, including proof by contradiction and proof by contrapositive 3. Proof techniques: 1. Understand the following basic proof strategies: constructive/nonconstructive proofs of existence ( witness ) disproof by counterexample exhaustive proof generalizing from the generic particular ( WLOG ) direct proof ( antecedent assumption ) proof by contradiction proof by contrapositive proof by cases well enough to identify the strategy when it is encountered in a given proof and well enough to apply it as a strategy in a novel proof 2. Devise and attempt multiple different, appropriate proof strategies for a given theorem including all those listed above that use definitions, premises, logical equivalences, rules of inference and rules of inference for quantified variables 3. Prove theorems requiring only simple insights beyond choice of proof strategy or for which the necessary insight is given as a hint/suggestion 4. Sequential circuits and the simple computer: 6

1. To design and analyze simple sequential circuits: circuits that perform sequences of steps and remember information from previous steps 2. To define a finite state machine (FSM) (aka a Deterministic Finite State Automaton (DFA)) both in terms of a state transition diagram and a state transition table 3. To implement any specific FSM (of modest complexity) as a sequential circuit 4. To specify the overall architecture of a (Von Neumann) stored program computer an architecture that instantiates the principle that both program and data are bits (i.e., state) loaded and stored in (common) memory 5. To interpret the (Von Neumann) stored program computer as a universal FSM (i.e., as a FSM that can implement any other FSM via changes to the program and data) 6. To analyze the (TKGate simulated) operation of a specific simple computer design. This includes understanding the basic fetch-decode-execute instruction cycle and the data flow to/from the arithmetic logic unit (ALU), the main memory, the Instruction Register (IR) and the Program Counter (PC) under control of the microcontroller 7. To run a provided program on the (TKGate simulated) simple computer. To test the behaviour of the program by monitoring values displayed in key registers during program execution. To modify the provided program to achieve other specified functionality 8. To complete CPSC 121 s bottom up treatment of circuits: demonstrating that: switch logic gate combinational sequential FSM simple circuit circuit computer (a) We can specify each one of these stages completely, both formally (i.e., as theory) and practically (i.e., as a constructive implementation) (b) There are no significant gaps between stages (i.e., we can build each successive stage using elements from the previous stage) 5. Mathematical induction: 1. Recognize mathematical induction as a proof technique for statements universally quantified over the positive integers, Z + 2. Given a theorem to prove expressed in terms of a variable, n, universally quantified over Z +, write out the skeleton of an inductive proof including: the base case(s) that need to be proved, the induction hypothesis, and the inductive step that needs to be proved 3. Complete all the steps of a formal proof by induction using either regular (weak) or strong induction, as needed 4. Critique formal inductive proofs to determine whether they are valid or where the error(s) lie if they are invalid 6. Sets: 7

1. Define basic set operations: union, intersection, complement, and set difference 2. Define logical operations on sets: subset, proper subset and set equality (in terms of predicate logic and set membership, e.g., x X) 3. Translate between sets represented explicitly, possibly using ellipses..., e.g., {4, 6, 8,... }, and using set builder notation, e.g., {x Z + x 2 > 10 x is even} 4. Compute union, intersection, complement, set difference, subset and set equality operations on sets expressed explicitly, expressed using set builder notation, or expressed as a combination of these and set operations 5. Interpret the empty set (symbol { } or ), including the fact that the empty set has no members and that it is a subset of any set 6. Define an n-tuple 7. Define the power set and Cartesian product operations one sets in terms of predicate logic and set membership/subset relations 8. Compute the power set, Cartesian product, and cardinality operations on sets expressed in any of the set notations considered 9. Apply proof techniques learned earlier to proofs involving sets 7. Functions: 1. Define the terms domain, codomain, range, image, and pre-image 2. Use appropriate function syntax to relate these terms, e.g., f : A B indicates that f is a function mapping domain A to codomain B 3. Determine whether f : A B is a function given a definition of f as an equation or as a bipartite graph (i.e., arrow diagram) 4. Define the terms injective (one-to-one), surjective (onto), bijective (one-to-one correspondence) and inverse 5. Determine whether a given function is injective, surjective, and/or bijective 6. Apply proof techniques learned earlier to proofs about the properties (e.g., injectiveness, surjectiveness, bijectiveness, and function-ness) of functions and their inverses 8. DFAs and regular expressions: 1. Specify a DFA formally as a 5-tuple defined using set and function notation 2. Define regular expressions and their associated regular language 3. Identify the regular language recognized by a particular DFA 4. Build a DFA to recognize a particular regular language 5. Connect the graphical (state transition diagram) and formal (5-tuple) representations of DFAs and illustrate how each part works 8

6. Use the formalisms that we ve learned (especially power sets and set union) to illustrate that a nondeterministic finite state automaton (NFA) is no more powerful than a deterministic finite state automaton (DFA) The End! Think Big! I have encouraged you to think big : Be curious Be academically adventurous (explore new ideas/topics/areas) Be tolerant/resilient to failure (but learn from your mistakes and the mistakes of others) develop your discernment (i.e., noticing) skills Four Big Ideas of Computer Science Big Idea #1: Finite State Machines (FSMs) Big Idea #2: Turing Machines Big Idea #3: Computability Big Idea #4: Universality Models of Computation: Summary Formal models (computability, Turing Machines, Universality) provide the basis for modern computer science: Fundamental limits (on what can not be done, even given plenty of memory and time) Fundamental equivalence of computation models Representation of algorithms as data, rather than as machinery Programs, Software, Interpreters, Compilers,... There remain many practical issues to deal with: Cost: memory size, time performance, power consumption Programmability Thanks! You have learned a lot! Be proud of what you have, and can, accomplish I had fun (and I hope most of you did too)! Feedback always is very welcome. I particularly like to hear from students 3 5 years down the road (after graduation) Special thanks to: Gwen Echlin My (few) after class, email and office hour regulars 9