Download presentation
Presentation is loading. Please wait.
1
State Minimization and Determinization EECS 290A Sequential Logic Synthesis and Verification
2
Overview Finite automata and finite state machines State minimization Determinization
3
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
4
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
5
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
6
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
7
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
8
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
9
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’) ]
10
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
11
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
12
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
13
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
14
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
15
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
16
Example when Subset Construction Leads to Exponential Number of States
17
Example when Subset Construction Reduces Number of States
18
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}
19
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}
20
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
21
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)
22
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
23
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
24
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))
25
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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.