computing with finite automata (part 2) 290n: the unknown component problem lecture 10

19
Computing with Finite Computing with Finite Automata Automata (part 2) (part 2) 290N: The Unknown Component 290N: The Unknown Component Problem Problem Lecture 10 Lecture 10

Post on 22-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Computing with Finite AutomataComputing with Finite Automata(part 2)(part 2)

290N: The Unknown Component 290N: The Unknown Component ProblemProblem

Lecture 10Lecture 10

Page 2: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

OutlineOutline Reachability analysisReachability analysis Product computation (“product”)Product computation (“product”) Verification by language containment (“check”)Verification by language containment (“check”) Determinization by subset construction (“determinize”)Determinization by subset construction (“determinize”) Don’t-care minimization (“dcmin”)Don’t-care minimization (“dcmin”)

Page 3: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Image ComputationImage Computation Given a mapping of minterms Given a mapping of minterms

from one Boolean space from one Boolean space ((input spaceinput space) into another ) into another Boolean space (Boolean space (output spaceoutput space))

For a set of minterms in the input For a set of minterms in the input spacespace

• The The imageimage of this set is the set of this set is the set of corresponding minterms in the of corresponding minterms in the output spaceoutput space

For a set of minterms in the For a set of minterms in the output spaceoutput space

• The The pre-imagepre-image of this set is the of this set is the set of corresponding minterms in set of corresponding minterms in the input spacethe input space

Input space

Output space

Image

Pre-image

Page 4: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Implicit Image ComputationImplicit Image Computation

Implements formula:Implements formula: Image(Y) = Image(Y) = x [R(X,Y) & C(X)]x [R(X,Y) & C(X)] Implicit methods by far outperform explicit onesImplicit methods by far outperform explicit ones

Successfully computing images with more than Successfully computing images with more than 2^1002^100 minterms in minterms in the input/output spacesthe input/output spaces

Operations Operations && and and are basic Boolean manipulationsare basic Boolean manipulations They are efficiently implemented in the BDD packageThey are efficiently implemented in the BDD package

To avoid large intermediate results (during and after the product To avoid large intermediate results (during and after the product computation), operation computation), operation AND-EXISTAND-EXIST can be used, which can be used, which performs product and quantification simultaneously (in one pass performs product and quantification simultaneously (in one pass over the BDDs)over the BDDs)

Page 5: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Improvements to Image ComputationImprovements to Image Computation

Represent the transition relation as a set of partitionsRepresent the transition relation as a set of partitions Natural when the FSM (automaton) is represented by the circuitNatural when the FSM (automaton) is represented by the circuit

Different approaches to computing the image (Coudert, 1989)Different approaches to computing the image (Coudert, 1989) Input splittingInput splitting Output splittingOutput splitting Quantification schedulingQuantification scheduling

Hybrid methodsHybrid methods Use partition clustering in addition to quantification scheduling Use partition clustering in addition to quantification scheduling

(Berkeley, IWLS 95)(Berkeley, IWLS 95) Use non-linear quantification scheduling (CMU, ICCAD 01)Use non-linear quantification scheduling (CMU, ICCAD 01) Partitioning (OR-decomposition) of the transition relationPartitioning (OR-decomposition) of the transition relation ““To split, or to conjoin” (mix the quantification scheduling and To split, or to conjoin” (mix the quantification scheduling and

input/output splitting) (Somenzi, DAC 2000)input/output splitting) (Somenzi, DAC 2000) ““The far side of image computation” (Somenzi, ICCAD 2003)The far side of image computation” (Somenzi, ICCAD 2003)

Tricks and speed-upsTricks and speed-ups Disjoint decompositionDisjoint decomposition Caching of intermediate results, etcCaching of intermediate results, etc

Page 6: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Reachability AnalysisReachability Analysis Many applications explore the reachable state spaceMany applications explore the reachable state space Given an FSM (automaton) with the transition relation, find all the Given an FSM (automaton) with the transition relation, find all the

states reachable from the initial statestates reachable from the initial state Apply image computation repeatedly to compute the sets of reachable Apply image computation repeatedly to compute the sets of reachable

states in the next iteration (“onion rings”) until convergencestates in the next iteration (“onion rings”) until convergenceReachedStates = InitialState;ReachedStates = InitialState;while ( there are new states )while ( there are new states )

ReachedStatesNew = Image( TransitionRelation, ReachedStates );ReachedStatesNew = Image( TransitionRelation, ReachedStates );if (ReachedStatesNew = ReachedStates ) stop;if (ReachedStatesNew = ReachedStates ) stop;ReachedStates = ReachedStatesNew ;ReachedStates = ReachedStatesNew ;

Reachability analysis uses sophisticated methods of image Reachability analysis uses sophisticated methods of image computationcomputation

Relies on numerous improvementsRelies on numerous improvements Simplification using don’t-caresSimplification using don’t-cares Iterative squaringIterative squaring Approximations, etcApproximations, etc

Page 7: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

OutlineOutline Reachability analysisReachability analysis Product computation (“product”)Product computation (“product”) Verification by language containment (“check”)Verification by language containment (“check”) Determinization by subset construction (“determinize”)Determinization by subset construction (“determinize”) Don’t-care minimization (“dcmin”)Don’t-care minimization (“dcmin”)

Page 8: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Product ComputationProduct Computation

Starting from the initial states, run two automata “in Starting from the initial states, run two automata “in parallel” and create a new automaton (parallel” and create a new automaton (product product automatonautomaton) whose states are labeled by the pairs of ) whose states are labeled by the pairs of states: one state from each automatonstates: one state from each automaton

A state of the product is accepting iff both component states are A state of the product is accepting iff both component states are acceptingaccepting

The maximum number of states in the product automaton The maximum number of states in the product automaton is equal to the product of the number of states of the is equal to the product of the number of states of the argumentargument

However, many of these states may not be reachable from the However, many of these states may not be reachable from the initial stateinitial state

Page 9: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Explicit AlgorithmExplicit Algorithm The two automata The two automata

The linked lists of states The linked lists of states {s} {s} and and {t}{t} The accepting states are markedThe accepting states are marked

Additional data structuresAdditional data structures Q:Q: The FIFO queue of reached product states The FIFO queue of reached product states H:H: The hash table hashing two component states into the product state The hash table hashing two component states into the product state

InitializationInitialization Create the initial state of the product automaton Create the initial state of the product automaton (s0,t0)(s0,t0) by putting by putting

together the initial states of the argument automata, together the initial states of the argument automata, s0s0 and and t0t0 insert this state into insert this state into QQ and and HH

ComputationComputationwhile while QQ is not empty, extract one product state is not empty, extract one product state (s,t)(s,t) from from QQ for all product states for all product states (s’,t’)(s’,t’) reachable in one transition from reachable in one transition from (s,t)(s,t) if if (s’,t’)(s’,t’) is not in is not in HH (that is, (that is, (s’,t’)(s’,t’) has not been visited) has not been visited) create the new product state create the new product state (s’,t’)(s’,t’) insert insert (s’,t’)(s’,t’) into into QQ and into and into HH else find else find (s’,t’)(s’,t’) using the hash table using the hash table HH add the transition from add the transition from (s,t)(s,t) into into (s’,t’)(s’,t’)

Page 10: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Example of ProductExample of Product

Page 11: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Verification by Language Verification by Language ContainmentContainment

Works for deterministic, complete automataWorks for deterministic, complete automata Create the product of two automata, Create the product of two automata, SS and and TT While visiting product states, keep track of the While visiting product states, keep track of the

acceptance attribute of the component statesacceptance attribute of the component states Case 1:Case 1: If we reach product state If we reach product state (s,t)(s,t), in which , in which s s S S is is

acceptingaccepting while while t t T T is is non-acceptingnon-accepting, the language of , the language of TT cannot cannot contain the language of contain the language of SS

Case 2:Case 2: A symmetric case applies when the language of A symmetric case applies when the language of SS cannot contain the language of cannot contain the language of TT

If we encounter both If we encounter both Case 1Case 1 and and Case 2Case 2, there is no language , there is no language containment among containment among SS and and TT

• Can terminate the product computation immediatelyCan terminate the product computation immediately If we do not encounter either If we do not encounter either Case 1Case 1 or or Case 2Case 2, the languages , the languages

accepted by accepted by SS and and TT are identical are identical• Need to complete the product computation to prove thisNeed to complete the product computation to prove this

Page 12: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Example of Language Containment Example of Language Containment CheckCheck

Page 13: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Determinization by Subset Determinization by Subset ConstructionConstruction

Assume that ND transitions in the ND automaton happen Assume that ND transitions in the ND automaton happen at the same timeat the same time

It means that, at any moment, the ND automaton is in a subset It means that, at any moment, the ND automaton is in a subset of its states of its states

The subset may contain more than one stateThe subset may contain more than one state The point of determinization is to enumerate through all The point of determinization is to enumerate through all

the subsets of states reachable from the initial state the subsets of states reachable from the initial state under any possible inputsunder any possible inputs

Each subset of states of the ND automaton becomes a single Each subset of states of the ND automaton becomes a single state of the new deterministic automatonstate of the new deterministic automaton

The languages accepted by the ND automaton and its The languages accepted by the ND automaton and its determinized version are the samedeterminized version are the same

Page 14: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Determinization AlgorithmDeterminization Algorithm The automaton The automaton

The linked lists of states The linked lists of states {s}{s}, with the accepting states marked, with the accepting states marked Additional data structuresAdditional data structures

Q:Q: The FIFO queue of reached subsets of states The FIFO queue of reached subsets of states Sk Sk H:H: The hash table mapping each reached subsets of states The hash table mapping each reached subsets of states Sk Sk into the into the

corresponding state of the determinized automatoncorresponding state of the determinized automaton InitializationInitialization

Create the initial state of the determinized automaton by creating the Create the initial state of the determinized automaton by creating the subset of states subset of states {s0}{s0} composed of the initial state of the ND automaton composed of the initial state of the ND automaton

insert insert {s0}{s0} into into QQ and and HH ComputationComputation

while while QQ is not empty, extract one subset of states is not empty, extract one subset of states SiSi from from QQ for all subsets of states for all subsets of states SjSj reachable in one transition from reachable in one transition from SiSi if if SjSj is not in is not in HH (that is, (that is, SjSj has not been visited) has not been visited) create the new state of the determinized automatoncreate the new state of the determinized automaton make the new state accepting if some state of make the new state accepting if some state of SjSj is accepting is accepting insert insert SjSj into into QQ and into and into HH else find the new state corresponding to else find the new state corresponding to SjSj using the hash table using the hash table HH add the transition from add the transition from SiSi into into SjSj

Page 15: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Example of DeterminizationExample of Determinization

Regular expression: 0*100*1(00*1)*

Page 16: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Computing Reachable SubsetsComputing Reachable Subsets Given a subset of states, what are other subsets of states that can be Given a subset of states, what are other subsets of states that can be

reached in one transition from the given subset?reached in one transition from the given subset? Naïve explicit approach (using STG)Naïve explicit approach (using STG)

Enumerate the minterms of the Boolean space of conditionsEnumerate the minterms of the Boolean space of conditions For each minterm, find the subset of states reachable from the given For each minterm, find the subset of states reachable from the given

subset in one iterationsubset in one iteration Collect unique subsetsCollect unique subsets

Better explicit approach (using STG)Better explicit approach (using STG) Compute partitioning on the condition space defined by all the states from Compute partitioning on the condition space defined by all the states from

the given subset the given subset • Start by considering the partition defined by one state and gradually refine it by Start by considering the partition defined by one state and gradually refine it by

adding other statesadding other states Each partition corresponds to one subset of next statesEach partition corresponds to one subset of next states Collect unique subsetsCollect unique subsets This approach does not require enumerating through the mintermsThis approach does not require enumerating through the minterms

Page 17: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Computing Reachable Subsets Computing Reachable Subsets (continued)(continued)

Implicit approach (using the monolithic relation)Implicit approach (using the monolithic relation) Restrict the monolithic transition relation Restrict the monolithic transition relation Ri(x,cs,ns)Ri(x,cs,ns) to the to the

given subset of states given subset of states Si(cs)Si(cs): : Ri(x,s) = Ri(x,s) = cs [Ri(x,cs,ns) & cs [Ri(x,cs,ns) & Si(cs)]Si(cs)]ns ns ss

Given a state subsetGiven a state subset Si Si and and its transition relation its transition relation Ri(x,s),Ri(x,s), while while Ri(x,s) Ri(x,s) is not empty, enumerate through reachable subsets:is not empty, enumerate through reachable subsets:

• Extract one minterm Extract one minterm m(x,s) m(x,s) from from Ri(x,s)Ri(x,s)• Restrict Restrict m(x,s) m(x,s) to only input variables to only input variables x x (call it (call it m(x)m(x)))• Find Find SjSj reachable from reachable from SiSi under under m(x)m(x): : Sj(s) = Sj(s) = x[Ri(x,s) & m(x)]x[Ri(x,s) & m(x)]• Find Find Cij(x)Cij(x) labeling transition labeling transition Si Si Sj Sj: : Cij(x)=Cij(x)=s[Ri(x,s) s[Ri(x,s) Sj(s)] Sj(s)]• Subtract this transition from Subtract this transition from Ri(x,s): Ri(x,s) = Ri(x,s) & NOT(Cij(x))Ri(x,s): Ri(x,s) = Ri(x,s) & NOT(Cij(x))

Hybrid approach (using state transition relations)Hybrid approach (using state transition relations) Pre-compute BDDs of the transition relations for each statePre-compute BDDs of the transition relations for each state Given a state subsetGiven a state subset Si Si and and its transition relation its transition relation Ri(x,s),Ri(x,s), while while

Ri(x,s) Ri(x,s) is not empty, proceed as described above…is not empty, proceed as described above…

Page 18: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

Don’t-Care MinimizationDon’t-Care Minimization State minimization of pseudo-non-deterministic FSMs is State minimization of pseudo-non-deterministic FSMs is

a complex problema complex problem NP-complete, solved exactly for small FSMs onlyNP-complete, solved exactly for small FSMs only

A fast heuristic minimization is possible (“dcmin”)A fast heuristic minimization is possible (“dcmin”) Requires an accepting don’t-care state to be presentRequires an accepting don’t-care state to be present

• It is the case for most solutions to language equationsIt is the case for most solutions to language equations ComputationComputation

Complete with non-accepting state (if not complete)Complete with non-accepting state (if not complete) Define the don’t-care condition of each state to be the condition Define the don’t-care condition of each state to be the condition

of its transition into the accepting DC stateof its transition into the accepting DC state Create the incompatibility graphCreate the incompatibility graph

• One vertex for each stateOne vertex for each state• An edge exists between the two vertices if the care conditions of the An edge exists between the two vertices if the care conditions of the

two states do not overlaptwo states do not overlap Color the incompatibility graph Color the incompatibility graph Collapse the states, which have the same colorCollapse the states, which have the same color

Page 19: Computing with Finite Automata (part 2) 290N: The Unknown Component Problem Lecture 10

ExampleExample