State Minimization and Determinization EECS 290A Sequential Logic Synthesis and Verification.

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

Lexical Analysis IV : NFA to DFA DFA Minimization
CSE 311 Foundations of Computing I
4b Lexical analysis Finite Automata
Finite Automata CPSC 388 Ellen Walker Hiram College.
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.
1 CIS 461 Compiler Design and Construction Fall 2012 slides derived from Tevfik Bultan et al. Lecture-Module 5 More Lexical Analysis.
CS 267: Automated Verification Lecture 10: Nested Depth First Search, Counter- Example Generation Revisited, Bit-State Hashing, On-The-Fly Model Checking.
Languages. A Language is set of finite length strings on the symbol set i.e. a subset of (a b c a c d f g g g) At this point, we don’t care how the language.
Penn ESE 535 Spring DeHon 1 ESE535: Electronic Design Automation Day 13: March 4, 2009 FSM Equivalence Checking.
ECE C03 Lecture 111 Lecture 11 Finite State Machine Optimization Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Subset Construction 290N: The Unknown Component Problem Lecture 13.
ECE C03 Lecture 131 Lecture 13 Finite State Machine Optimization Prith Banerjee ECE C03 Advanced Digital Design Spring 1998.
Penn ESE 535 Spring DeHon 1 ESE535: Electronic Design Automation Day 22: April 23, 2008 FSM Equivalence Checking.
A New Approach to Structural Analysis and Transformation of Networks Alan Mishchenko November 29, 1999.
Computing with Finite Automata 290N: The Unknown Component Problem Lecture 9.
Computation Engines: BDDs and SAT (part 2) 290N: The Unknown Component Problem Lecture 8.
ECE Synthesis & Verification - L211 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Verification Equivalence checking.
Languages. A Language is set of finite length strings on the symbol set i.e. a subset of (a b c a c d f g g g) At this point, we don’t care how the language.
ECE Synthesis & Verification - Lecture 10 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.
ECE 667 Synthesis & Verification - BDD 1 ECE 667 ECE 667 Synthesis and Verification of Digital Systems Binary Decision Diagrams (BDD)
Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10.
CSCI 3301 Transparency No. 9-1 Chapter #9: Finite State Machine Optimization Contemporary Logic Design.
CSE 311: Foundations of Computing Fall 2014 Lecture 23: State Minimization, NFAs.
Zvi Kohavi and Niraj K. Jha 1 Capabilities, Minimization, and Transformation of Sequential Machines.
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions.
An ordered n-tuple is a set of n objects with an order associated with them. If n objects are represented by x 1, x 2,..., x n, then we write the ordered.
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.
CALTECH CS137 Spring DeHon CS137: Electronic Design Automation Day 9: May 6, 2002 FSM Equivalence Checking.
Decidable Questions About Regular languages 1)Membership problem: “Given a specification of known type and a string w, is w in the language specified?”
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
Copyright © Curt Hill Finite State Automata Again This Time No Output.
1 Verification of FSM Equivalence Goal: Verify that two sequential circuit implementations always produce the same sequence of outputs given the same sequence.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
98 Nondeterministic Automata vs Deterministic Automata We learned that NFA is a convenient model for showing the relationships among regular grammars,
Nondeterministic Finite State Machines Chapter 5.
June 13, 2016 Prof. Abdelaziz Khamis 1 Chapter 2 Scanning – Part 2.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Capabilities, Minimization, and Transformation of Sequential Machines
Sequential Flexibility
Lexical analysis Finite Automata
Table-driven parsing Parsing performed by a finite state machine.
Modeling Arithmetic, Computation, and Languages
CSE 311 Foundations of Computing I
Two issues in lexical analysis
Chapter 2 FINITE AUTOMATA.
Models of Sequential Systems
ESE535: Electronic Design Automation
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
THEORY OF COMPUTATION Lecture One: Automata Theory Automata Theory.
Synthesis of sequential circuits
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Minimal DFA Among the many DFAs accepting the same regular language L, there is exactly one (up to renaming of states) which has the smallest possible.
Finite Automata.
4b Lexical analysis Finite Automata
Discrete Math II Howon Kim
Automating Scanner Construction
Lexical Analysis — Part II: Constructing a Scanner from Regular Expressions Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved.
Implement FSM with fewest possible states • Least number of flip flops
MA/CSSE 474 Theory of Computation
ESE535: Electronic Design Automation
4b Lexical analysis Finite Automata
Finite-State Machines with No Output
ECE 667 Synthesis and Verification of Digital Systems
Presentation transcript:

State Minimization and Determinization EECS 290A Sequential Logic Synthesis and Verification

Overview  Finite automata and finite state machines  State minimization  Determinization

A finite automaton (FA) is where S is a set of states, is an input alphabet, is a transition relation, r is the initial state, and is the set of accepting states. Finite Automata

A finite state machine (FSM) is where S is a set of states, are input/output alphabets, is the transition relation, is the set of initial states. Finite State Machines is the output relation

FA and FSM  FSM  FA Complete by adding a non-accepting state Complete by adding a non-accepting state  FA  FSM Make prefix-closed and progressive Make prefix-closed and progressive FSM FA

Outline of State Minimization  Requirements for the automaton Deterministic (if not, first determinize) Deterministic (if not, first determinize) Complete (if not, first complete) Complete (if not, first complete)  Definition of state equivalence  Two ways of computing equivalence classes Implicit Implicit Explicit Explicit  The explicit algorithm in detail  Example

State Equivalence of FA  Definition. A string is accepted by the automation in state s iff when started in state s, it drives the automaton into an accepting state.  Definition. Two states s1 and s2 are distinguishable iff there exists a string, which when started from these states, is accepted in state s1 and not accepted in state s2.  Definition. States s1 and s2 are equivalent if they are not distinguishable. Example: States A and C are distinguishable States B and C are equivalent

Outline of the Algorithm  The automaton is given by State transition graph State transition graph The set of accepting states The set of accepting states  Compute the set of distance-0 distinguishable pairs by combining each accepting state with each non-accepting state  For each pair, find all the pairs reachable in backward traversal from the distinguishable pairs, under all input combinations Collect these pairs and explore them until no new pairs can be found Collect these pairs and explore them until no new pairs can be found  The remaining pairs are pairs of equivalent states  Reduce the automaton by replacing each state by one selected representative of its equivalence class

Implicit Implementation  The automaton is given by Transition relation R(x,cs,ns) Transition relation R(x,cs,ns) Characteristic function of accepting states A(cs) Characteristic function of accepting states A(cs)  Compute the set of distance-0 distinguishable pairs (when one state is accepting while the other is not) D 0 (cs,cs’) = A(cs)  A(cs’) D 0 (cs,cs’) = A(cs)  A(cs’)  Compute the pair transition relation P(cs,cs’,ns,ns’) =  x [R(x,cs,ns) & R(x,cs’,ns’)] P(cs,cs’,ns,ns’) =  x [R(x,cs,ns) & R(x,cs’,ns’)]  Starting from the distance-0 distinguishable pairs, iteratively compute distance-k distinguishable pairs, until convergence D i+1 (cs,cs’) =  ns,ns’ [P(cs,cs’,ns,ns’) & D i (ns,ns’)] D i+1 (cs,cs’) =  ns,ns’ [P(cs,cs’,ns,ns’) & D i (ns,ns’)]  The equivalence relation is E(cs,cs’) = NOT[D i+1 (cs,cs’)] E(cs,cs’) = NOT[D i+1 (cs,cs’)]  Reduce the automaton by replacing each state by one representative taken from its equivalence class P(cs,cs’) = CompatibleProjection( E(cs,cs’), {cs} ) P(cs,cs’) = CompatibleProjection( E(cs,cs’), {cs} ) R(x,cs,ns) =  cs’,ns’[ R(x,cs’,ns’) & P(cs,cs’) & P(ns,ns’) ] R(x,cs,ns) =  cs’,ns’[ R(x,cs’,ns’) & P(cs,cs’) & P(ns,ns’) ]

Explicit Implementation  The automaton The linked list of states The linked list of states The accepting states are marked The accepting states are marked  Additional data structures Q: The FIFO queue of distinguishable state pairs to be explored Q: The FIFO queue of distinguishable state pairs to be explored H: The hash table hashing every pair into {visited, not visited} H: The hash table hashing every pair into {visited, not visited}  Initialization for each accepting state s for each non-accepting state s’ for each non-accepting state s’ insert pair (s,s’) into Q and H insert pair (s,s’) into Q and H  Computation while Q is not empty, extract one pair (s,s’) from Q for each pair (t,t’), which transits into (s,s’) under some input for each pair (t,t’), which transits into (s,s’) under some input if (t,t’) is not in H (that is, (t,t’) has not been visited) if (t,t’) is not in H (that is, (t,t’) has not been visited) insert pair (t,t’) into Q and into H insert pair (t,t’) into Q and into H

Reducing the Automaton  The automaton The linked list of states The linked list of states The accepting states are marked The accepting states are marked  The equivalence relation Maps pair (s,s’) into {distinguishable, equivalent} Maps pair (s,s’) into {distinguishable, equivalent} The same as hash table H: visited = distinguishable; not visited = equivalentThe same as hash table H: visited = distinguishable; not visited = equivalent  Computation Construct the equivalence classes of states using the equivalence relation Construct the equivalence classes of states using the equivalence relation Select one representative state from each equivalence class Select one representative state from each equivalence class Create the mapping of each state in the original automaton into the representative state from its equivalence class Create the mapping of each state in the original automaton into the representative state from its equivalence class start the new automaton add a new state for each representative state of the old automaton for all representative states s1 for each transition (s1->s2) from the representative state s1 into some other state s2 add transition from the new state corresponding to s1 into the new state corresponding to s2 Set the new initial state to be the new state corresponding to the representative of the class, to which the original initial state belongs Set the new initial state to be the new state corresponding to the representative of the class, to which the original initial state belongs

Example of State Minimization  Distinguishable pairs after initialization (A,DC), (C,DC), (B,DC) (A,DC), (C,DC), (B,DC)  Computed distinguishable pairs (A,DC)  (A,C) (A,DC)  (A,C) (A,DC)  (A,B) (A,DC)  (A,B)  Remaining equivalent pairs (B,C) (B,C)  The derived reduced graph

Outline of Determinization  Subset construction  General flow of the algorithm  Examples When the number of states is exponential (2^n-1) When the number of states is exponential (2^n-1) When the number of states is reduced When the number of states is reduced  Computing reachable subsets of states Explicit Explicit Enumerating mintermsEnumerating minterms Partitioning Boolean spacePartitioning Boolean space Implicit Implicit Cofactoring monolithic transition relationCofactoring monolithic transition relation Hybrid Hybrid Using the transition relations for each stateUsing the transition relations for each state

Determinization by Subset Construction  Assume that ND transitions in the ND automaton happen at the same time It means that, at any moment, the ND automaton is in a subset of its states It means that, at any moment, the ND automaton is in a subset of its states The subset may contain more than one state The subset may contain more than one state  The point of determinization is to enumerate through all the subsets of states reachable from the initial state under any possible inputs Each subset of states of the ND automaton becomes a single state of the new deterministic automaton Each subset of states of the ND automaton becomes a single state of the new deterministic automaton The languages accepted by the ND automaton and its determinized version are the same The languages accepted by the ND automaton and its determinized version are the same

Determinization Algorithm  The automaton The linked lists of states {s}, with the accepting states marked The linked lists of states {s}, with the accepting states marked  Additional data structures Q: The FIFO queue of reached subsets of states Sk Q: The FIFO queue of reached subsets of states Sk H: The hash table mapping each reached subsets of states Sk into the corresponding state of the determinized automaton H: The hash table mapping each reached subsets of states Sk into the corresponding state of the determinized automaton  Initialization Create the initial state of the determinized automaton by creating the subset of states {s0} composed of the initial state of the ND automaton Create the initial state of the determinized automaton by creating the subset of states {s0} composed of the initial state of the ND automaton insert {s0} into Q and H insert {s0} into Q and H  Computation while Q is not empty, extract one subset of states Si from Q for all subsets of states Sj reachable in one transition from Si for all subsets of states Sj reachable in one transition from Si if Sj is not in H (that is, Sj has not been visited) if Sj is not in H (that is, Sj has not been visited) create the new state of the determinized automaton create the new state of the determinized automaton make the new state accepting if some state of Sj is accepting make the new state accepting if some state of Sj is accepting insert Sj into Q and into H insert Sj into Q and into H else find the new state corresponding to Sj using the hash table H else find the new state corresponding to Sj using the hash table H add the transition from Si into Sj add the transition from Si into Sj

Example when Subset Construction Leads to Exponential Number of States

Example when Subset Construction Reduces Number of States

Computing Reachable Subsets  Given a subset of states, what are other subsets of states that can be reached in one transition from the given subset?  Naïve explicit approach (using STG) Enumerate the minterms of the Boolean space of conditions Enumerate the minterms of the Boolean space of conditions For each minterm, find the subset of states reachable from the given subset in one iteration For each minterm, find the subset of states reachable from the given subset in one iteration Collect unique subsets Collect unique subsets State subset {2,3} Minterm 00: 2  {1} 3  {1} {2,3}  {1} Minterm 01: 2  {3} 3  {1} {2,3}  {1,3} Minterm 10: 2  {3} 3  {1} {2,3}  {1,3} Minterm 11: 2  {3} 3  {1,3} {2,3}  {1,3}

Computing Reachable Subsets  Improved explicit approach (using STG) Compute partitioning on the condition space defined by states in the subset Compute partitioning on the condition space defined by states in the subset Compute the product of partitions for all states in the subset Compute the product of partitions for all states in the subset Each partition corresponds to one subset of next states Each partition corresponds to one subset of next states Collect unique subsets Collect unique subsets This approach does not require enumerating through the minterms This approach does not require enumerating through the minterms State subset {2,3} State 2 partition: (00)  {1} (01,10,11)  {3} State 3 partition: (00,01,10)  {1} (11)  {1,3} Product of partitions: (00)  {1} (01,10)  {1,3} (11)  {1,3} Unique next state subsets: {1} and {1,3} (00)  {1} (01,10,11)  {1,3}

Transition Relation of the Subset  Given the subset si, compute Rsi(x,s) This relation for each input x, gives the set of next states {sj} This relation for each input x, gives the set of next states {sj}   Example: State subset {2,3} Input variables {x1,x2} State variables {s1,s2} Transition relation of state 2: R2(x1,x2,s1,s2) = x1’x2’s1’s2 + (x1+x2)s1s2 Transition relation of state 3: R3(x1,x2,s1,s2) = x1x2s1s2 + s1’s2 Transition relation of state subset {2,3}: R(x1,x2,s1,s2) = R2 + R3 = x1’x2’s1’s2+ (x1 + x2)s2 Code 01 Code 11 Code 10

Computing Transition Relation of the Subset  Implicit approach The monolithic transition relation R(x,cs,ns) is available The monolithic transition relation R(x,cs,ns) is available Restrict the monolithic transition relation R(x,cs,ns) to the given subset of states Si(cs): R(x,s) =  cs [R(x,cs,ns) & Si(cs)] ns  s Restrict the monolithic transition relation R(x,cs,ns) to the given subset of states Si(cs): R(x,s) =  cs [R(x,cs,ns) & Si(cs)] ns  s  Hybrid approach The individual state transition relations Ri(x,s) are available The individual state transition relations Ri(x,s) are available Add the transition relations for all states in the subset R(x,s) = Si Ri(x,s) Add the transition relations for all states in the subset R(x,s) =  i  Si Ri(x,s)

Computing Reachable Subsets using Transition Relation of the Subset  Compute orthonormal expansion of the transition relation of the subset R(x,s) w.r.t. variables in {x} R(x,s) =  i [ fi(x) & gi(s) ], where (1) fi(x) & fj(x) = 0, i  j (2) gi(s) = gj(s)  i = j  In the orthonormal expansion, functions gi(s) are sets of next states reachable under conditions fi(x) from the given subset

Computing Orthonormal Expansion using BDD Variable Ordering   Orthonormal expansion is R(x,s) =  i [ fi(x) & gi(s) ], where (1) fi(x) & fj(x) = 0, i  j (2) gi(s) = gj(s)  i = j  BDD represents the function as a set of disjoint paths - condition (1)  BDD reduction guarantees merging identical cofactors - condition (2)  Building BDD with variables {x1,x2} on top lead to the orthonormal expansion  Example:  Example: R(x1,x2,s1,s2) = x1’x2’s1’s2 + (x1+x2)s2 s1’s2 encodes state {1} (condition x1’x2’) s2 encodes state subset {1,3} (condition x1+x2) x1 x2 s1 s2 Code 01 Code 11 Code 10

Computing Orthonormal Expansion using General Method  Given a state subset Si and its transition relation R(x,s) while R(x,s) is not empty, enumerate through the elements of the expansion (reachable subsets): while R(x,s) is not empty, enumerate through the elements of the expansion (reachable subsets): Extract one minterm m(x,s) from R(x,s) Extract one minterm m(x,s) from R(x,s) Restrict m(x,s) to only input variables x (call it m(x)) Restrict m(x,s) to only input variables x (call it m(x)) Find Sj reachable from Si under m(x): Sj(s) =  x[R(x,s) & m(x)] Find Sj reachable from Si under m(x): Sj(s) =  x[R(x,s) & m(x)] Find Cij(x) labeling transition Si  Sj: Cij(x)=  s[R(x,s)  Sj(s)] Find Cij(x) labeling transition Si  Sj: Cij(x)=  s[R(x,s)  Sj(s)] Subtract this transition from R(x,s): R(x,s) = R(x,s) & NOT(Cij(x)) Subtract this transition from R(x,s): R(x,s) = R(x,s) & NOT(Cij(x))

Example R(x1,x2,s1,s2) = x1’x2’s1’s2 + (x1+x2)s2 Extract minterm: m(x,s) = Extract minterm: m(x,s) = x1x2s1s2 Restrict to variables x: m(x) = x1x2 Sj(s) = Find the related set of states: Sj(s) = s2 (subset {1,3}) Find the related condition: Cij(x) = x1+x2 Subtract this transition from the relation: R(x1,x2,s1,s2) = x1’x2’s1’s2 Extract minterm: m(x,s) = Extract minterm: m(x,s) = x1’x2’s1’s2 Restrict to variables x: m(x) = x1’x2’ Sj(s) = Find the related set of states: Sj(s) = s1’s2 (subset {1}) Find the related condition: Cij(x) = x1’x2’ Subtract this transition from the relation: R(x1,x2,s1,s2) = 0 Quit the while-loop