460 likes | 610 Views
www.nskinfo.com && www.nsksofttch.com Department of nskinfo-i education. CS2303-THEORY OF COMPUTATION. An Introduction to Automata Theory. Components of computer Science. Computer Science (systematized body of knowledge concerning computation). Fundamental ideas + Computing models.
E N D
www.nskinfo.com && www.nsksofttch.comDepartment of nskinfo-i education CS2303-THEORY OF COMPUTATION An Introduction to Automata Theory
Components of computer Science • Computer Science • (systematized body of knowledge concerning computation) • Fundamental ideas + Computing models • Hardware + software + application of theory to design • Theoretical Computer Science
Branches in TCS… Theoretical Computer Science(Twin branches) • Automata Theory • Formal Languages Had beginning from diff. fields • Biology – neuron nets • Electronics – switching circuits • Logic – natural languages Notion of automaton originated from neuron nets and switching circuits in mind – mid 30’s [Allan Turing] Notion of formal languages originated from logic, linguistics – late 50’s [Noam Chomsky]
Automata Theory Automaton – abstract mathematical model for computing Turing Machine – hypothetical model – Allen Turing – 1936 – Mathematical formulation to perform complex calculations, functions, etc. • Proceeds in discrete steps (as events occur in discrete steps – clock!) • Describes completely structure and behavior • Highest end of complexity and power Other simpler modelsFinite state Automaton(FSA), Mealy Machine, Moore Machine, Pushdown Automata(PDA), Linear Bounded Automaton (LBA)
Finite State Machines • Also called Finite Automata (or Finite State Automaton FSA) • These are Machines having a finite number of states.
Example1 – On/Off Button • Finite automata are the most simple (language accepting) machine that is not just a finite list of words. • The machine reads the input string only once, after which it immediately accepts or rejects it. There is no write possibility. Think On/Off button, elevator door, etc.
Example1 – On/Off Button States Transition Rules The On/Off button accepts the language {Pushn| n is odd} The corresponding automation is… Push On Off Push Rejecting State Starting State Accepting State
Example1 – On/Off Button Transition of States State diagram Push On Off Push
Example2 – Goat in a boat !! • Man with wolf, goat and cabbage is on left side of a river • Has a small rowboat, just big enough for him & one other thing • Can’t leave goat and wolf together • Can’t leave goat and cabbage together • Can he get them to right side
Example2 – Goat in a boat !! • Current state is list of what things are on which side of river • All are left • Man and goat on right • All on right (desired state) MWGC - WC - MG - MWGC
Example2 – Goat in a boat !! • We’ll indicate with arrows the changes between states Letter indicating what happened g – man took goat c – man took cabbage w – man took wolf m – man went alone g MWGC - WC - MG
Example2 – Goat in a boat !! Transition in both ways g MWGC - WC - MG g
Example2 – Goat in a boat !! Dangerous ! We will avoid those dangerous attempts ! c MWGC - WG - MC
Example2 – Goat in a boat !! g MWGC - WC - MG g - MWGC
m m c G - MWC MWC - G m m w w c Start W - MGC C - MWG g g g g g MWGC - - MWGC MG - WC WC - MG g WGM - C MGC - W g g c w c w
m m c m m w w c Start g g g g g g g g c w c w
States and inputs involved States Input Start state Transition(mapping from state to state on input)
Finite State Automaton - FSA • An FSA consists of • A set of “states” • “Control” moves from state to state in response to some ‘input” • Deterministic Automaton • The machine is in only state at a given time. • Non-deterministic Automaton • The machine can be in multiple state at a given time
Finite State Automaton - FSA FSA, • Finite set of states, Q • Start state, • Set of transitions from one state to another Occur on input from alphabet • Exactly one transition out of each state for each symbol in • A subset of final state,
We denote a run in the following way r : s0 s1 . . . sn-2 sn-1 sn Set of runs of x is denoted as r(x) L(M) = { x X* : run of x ends in F} where M is a finite state automata xn-1 x1 x2 xn x3
Finite State AutomataDeterministic Type Transition rules States 1 1 0 0 0,1 Starting State Accepting States
Finite State AutomataDeterministic Type 1 0 0,1 0 1
m m c G - MWC MWC - G m m w w c Start W - MGC C - MWG g g g g g MWGC - - MWGC WG - MC WC - MG g WGM - C MGC - W g g c w c w
FSA to Recognize alphanumeric on a token b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
FSA to Recognize only Numeric token _12 b s Key: d – digit, b – blank, s – other symbol B b Start b,d NG d,b,s d S OK b s OK d s d s
FSA to Recognize only Numeric token _12 b s Key: d – digit, b – blank, s – other symbol B b Start b,d NG d,b,s d S OK b s OK d s d s
FSA to Recognize only Numeric token _12 b s Key: d – digit, b – blank, s – other symbol B b Start b,d NG d,b,s d S OK b s OK d s d s
FSA to Recognize token _12 b s Key: d – digit, b – blank, s – other symbol B b Start b,d NG d,b,s d S OK b s OK d s d s
FSA to Recognize only Numeric token _12 b s Key: d – digit, b – blank, s – other symbol B b Start b,d NG d,b,s d S OK b s OK d s d s Accept !
How about alphanumeric…? (_z34) _z34 b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
How about alphanumeric…? (_z34) _z34 b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
How about alphanumeric…? (_z34) _z34 b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
How about alphanumeric…? (_z34) _z34 b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
How about alphanumeric…? (_z34) _z34 b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s FAIL !
FSA to Recognize Integers (1___) 1___ b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
FSA to Recognize Integers (1___) 1___ b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
FSA to Recognize Integers (1___) 1___ b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
FSA to Recognize Integers (1___) 1___ b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s
FSA to Recognize Integers (1___) 1___ b s Key: d – digit, b – blank, s – other symbol B b Start b,d d,b,s NG d S OK b s OK d s d s Accept !
Example X = {a, b} S = {q0, q1} z0 = q0 F = {q1} a a b q0 q1 b
X = { a, b } S = { q0 , q1 } z0 = q0 F = { q1 } L(M) = A*b* Example a, b b q0 b q1
Example = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} 0,3,6,9 1, 4,7 q1 0,3,6,9 q0 2,5,8 1, 4,7 1, 4,7 2,5,8 2,5,8 q2 0,3,6,9
Language L X* isregularif there exists a finite state automata M such that L = L(M) Result For each regular language there exists a deterministic finite state automata M such that L = L(M).