CSE 311: Foundations of Computing

Slides:



Advertisements
Similar presentations
CS 3240: Languages and Computation
Advertisements

Modeling Computation Chapter 13.
CSE 311 Foundations of Computing I
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
CSE 311: Foundations of Computing Fall 2013 Lecture 23: Finite state machines and minimization.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
Lecture # 14 Theory Of Automata By Dr. MM Alam 1.
String Recognition Simple case: recognize 1101 “ ” 0 “1” 0 “11” 0 Reset 1 “110” “1101”
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
1 The scanning process Goal: automate the process Idea: –Start with an RE –Build a DFA How? –We can build a non-deterministic finite automaton (Thompson's.
1 Languages and Finite Automata or how to talk to machines...
Aho-Corasick String Matching An Efficient String Matching.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
CS Chapter 2. LanguageMachineGrammar RegularFinite AutomatonRegular Expression, Regular Grammar Context-FreePushdown AutomatonContext-Free Grammar.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Rosen 5th ed., ch. 11 Ref: Wikipedia
Finite-State Machines with No Output
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Finite-State Machines with Output
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions.
CSE 311 Foundations of Computing I Lecture 23 Finite State Machines Autumn 2012 CSE 3111.
CSE 311 Foundations of Computing I Lecture 21 Finite State Machines Autumn 2011 CSE 3111.
CSE 311 Foundations of Computing I Lecture 21 Finite State Machines Spring
Lexical Analysis Constructing a Scanner from Regular Expressions.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
1 Closures of Relations: Transitive Closure and Partitions Sections 8.4 and 8.5.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CSE 311: Foundations of Computing Fall 2014 Lecture 20: Relations and Directed Graphs.
CSE 311 Foundations of Computing I Lecture 22 Relations, Database Autumn 2012 CSE TexPoint fonts used in EMF. Read the TexPoint manual before you.
CSE 311 Foundations of Computing I Lecture 27 FSM Limits, Pattern Matching Autumn 2012 CSE
CSE 311 Foundations of Computing I Lecture 24 Finite State Machines Autumn 2012 CSE 3111.
CSCI 115 Chapter 8 Topics in Graph Theory. CSCI 115 §8.1 Graphs.
CSE 311 Foundations of Computing I Lecture 20 Relations, Graphs, Finite State Machines Autumn 2011 CSE 3111 TexPoint fonts used in EMF. Read the TexPoint.
Finite State Machines 1.Finite state machines with output 2.Finite state machines with no output 3.DFA 4.NDFA.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
using Deterministic Finite Automata & Nondeterministic Finite Automata
CSE 311 Foundations of Computing I Lecture 24 FSM Limits, Pattern Matching Autumn 2011 CSE 3111.
Fall 2004COMP 3351 Finite Automata. Fall 2004COMP 3352 Finite Automaton Input String Output String Finite Automaton.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
Finite State Machines Dr K R Bond 2009
Generalized Transition Graphs
Lexical analysis Finite Automata
Non Deterministic Automata
FORMAL LANGUAGES AND AUTOMATA THEORY
CSE 311 Foundations of Computing I
Chapter 2 Finite Automata
Two issues in lexical analysis
Equivalence, DFA, NDFA Sequential Machine Theory Prof. K. J. Hintz
CSE 311 Foundations of Computing I
CSE322 Finite Automata Lecture #2.
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
CSE 311 Foundations of Computing I
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Non-Deterministic Finite Automata
Closures of Relations: Transitive Closure and Partitions
CSE 311: Foundations of Computing
Finite Automata.
4b Lexical analysis Finite Automata
CSE 321 Discrete Structures
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
CSE 321 Discrete Structures
4b Lexical analysis Finite Automata
CSE 311 Foundations of Computing I
Lecture 20 Logistics Last lecture Today HW6 due Wednesday
Richard Anderson Winter 2019 Lecture 6
NFAs and Transition Graphs
Announcements - P1 part 1 due Today - P1 part 2 due on Friday Feb 1st
Presentation transcript:

CSE 311: Foundations of Computing Fall 2013 Lecture 22: Finite state machines (aka DFAs)

highlights: directed graphs G = (V, E) V – vertices E – edges, order pairs of vertices Path: v0, v1, …, vk, with (vi, vi+1) in E Simple Path Cycle Simple Cycle

highlights: relations Let R be a relation on a set A. There is a path of length n from a to b if and only if (a,b) Rn Let R be a relation on a set A. The connectivity relation R* consists of the pairs (a,b) such that there is a path from a to b in R. Transitive-Reflexive closure: Add the minimum possible number of edges to make the relation transitive and reflexive The transitive-reflexive closure of a relation R is the connectivity relation R*

n-ary relations Let A1, A2, …, An be sets. An n-ary relation on these sets is a subset of A1 A2  ⋯  An.

relational databases STUDENT Student_Name ID_Number Office GPA Knuth 328012098 022 4.00 Von Neuman 481080220 555 3.78 Russell 238082388 3.85 Einstein 238001920 2.11 Newton 1727017 333 3.61 Karp 348882811 3.98 Bernoulli 2921938 3.21

relational databases What’s not so nice? STUDENT Student_Name ID_Number Office GPA Course Knuth 328012098 022 4.00 CSE311 CSE351 Von Neuman 481080220 555 3.78 Russell 238082388 3.85 CSE312 CSE344 Newton 1727017 333 3.61 Karp 348882811 3.98 Bernoulli 2921938 3.21 What’s wrong: Redundant data: we repeat all the GPAs and all the Office numbers Missing data: we lost Einstein What’s not so nice?

relational databases Better STUDENT TAKES Student_Name ID_Number Office GPA Knuth 328012098 022 4.00 Von Neuman 481080220 555 3.78 Russell 238082388 3.85 Einstein 238001920 2.11 Newton 1727017 333 3.61 Karp 348882811 3.98 Bernoulli 2921938 3.21 ID_Number Course 328012098 CSE311 CSE351 481080220 238082388 CSE312 CSE344 1727017 348882811 2921938 Better

database operations: projection Office 022 555 333 Find all offices: Π Office STUDENT Office GPA 022 4.00 555 3.78 3.85 2.11 333 3.61 3.98 3.21 Find offices and GPAs: Π Office, GPA STUDENT

database operations: selection Find students with GPA > 3.9 : σGPA>3.9(STUDENT) Student_Name ID_Number Office GPA Knuth 328012098 022 4.00 Karp 348882811 3.98 Retrieve the name and GPA for students with GPA > 3.9: ΠStudent_Name,GPA(σGPA>3.9(STUDENT)) Student_Name GPA Knuth 4.00 Karp 3.98

database operations: natural join Student ⋈ Takes Student_Name ID_Number Office GPA Course Knuth 328012098 022 4.00 CSE311 CSE351 Von Neuman 481080220 555 3.78 Russell 238082388 3.85 CSE312 CSE344 Newton 1727017 333 3.61 Karp 348882811 3.98 Bernoulli 2921938 3.21

finite state machines States Transitions on inputs Start state and final states The language recognized by a machine is the set of strings that reach a final state State 1 s0 s1 s2 s3 1 1 1 s0 s1 s2 s3 0,1

applications of FSMs (a.k.a. finite automata) Implementation of regular expression matching in programs like grep Control structures for sequential logic in digital circuits Algorithms for communication and cache-coherence protocols Each agent runs its own FSM Design specifications for reactive systems Components are communicating FSMs

applications of FSMs (a.k.a. finite automata) Formal verification of systems Is an unsafe state reachable? Computer games FSMs provide worlds to explore Minimization algorithms for FSMs can be extended to more general models used in Text prediction Speech recognition

what language does this machine recognize? 1 s0 s1 1 1 s2 s3 1

3 bit shift register 001 011 111 110 101 010 000 100 1 1 1 1 1 1 1

1 1 1 1 00 10 11 01 1 1 1 1 001 1 011 1 1 1 1 1 000 010 101 111 1 100 110

goal: FSM that accepts strings with a 1 three positions from the end

question How does the size of a DFA to recognize “10th character is a 1” compare with the size of a DFA to recognize “10th character from the end is 1”?

strings over {0, 1, 2}* M1: Strings with an even number of 2’s M2: Strings where the sum of digits mod 3 is 0 s0 s1 t1 t0 t2

strings with an even number of 2’s and a mod 3 sum of 0

state machines with output “Tug-of-war” Input Output State L R s1 s2 Beep s3 s4 R R R S1 S2 S3 S4 L R L L L

vending machine Enter 15 cents in dimes or nickels Press S or B for a candy bar

vending machine, v0.1 5 10 15 D D N N N, D B, S N 5 N 10 N, D 15 B, S Basic transitions on N (nickel), D (dime), B (butterfinger), S (snickers)

vending machine, v0.2 15 0’ B 5 10 0” S 15’ N D N 15 D D B S 0’ B 5 10 N N N D 15’ N B S N D 0” S Adding output to states: N – Nickel, S – Snickers, B – Butterfinger

vending machine, v1.0 15 0’ B 5 10 0” S 15’ N 15” D D N 15 B,S B,S B,S D B D D S 0’ B 5 N 10 N N N D 15’ N B N S B,S D N D N 0” S B 15” D S D Adding additional “unexpected” transitions