Presentation is loading. Please wait.

Presentation is loading. Please wait.

Identifying Reversible Functions From an ROBDD Adam MacDonald.

Similar presentations


Presentation on theme: "Identifying Reversible Functions From an ROBDD Adam MacDonald."— Presentation transcript:

1 Identifying Reversible Functions From an ROBDD Adam MacDonald

2 Background Reversible functions  Number of inputs = number of outputs  Mapping from output to input Each output configuration is unique  n variables: 2 n inputs and 2 n outputs possible  Outputs = reordered truth table in 2 in 1 out 2 out 1

3 Background 000 001 010 011 100 101 110 111 001 011 000 101 110 111 010 100

4 Background Binary Decision Diagrams  Function is represented by a tree of decisions Pros  Output to N variable function found in N time  Simplified to eliminate redundancy Cons  NP-hard construction  Takes about 2 minutes for n = 15 10

5 Project Outline BDD library implementation Implement efficient method for detecting if a given BDD is reversible Analysis

6 BDD Implementation “Node” class  Pointers to other ‘low’ and ‘high’ Nodes “BDD” class  Nodes stored in a large table  Functions point to a “root” Node  All functions share common Nodes  Hash table for looking up Nodes by attributes

7 Construction Adding a function  Start with a list of terms (eg. 01-10-11-01) “Build”  Recursively apply Shannon’s decomposition  Uses co-factor operation (single AND and OR operation) “Make”  Build and link nodes using hash table lookup  Separate table for each level  Hash key from ‘low’ and ‘high’ attributes

8 “Reversible” Class BDD’s constructed for testing  Fast-random Adds a random number of random terms  Slow-random Randomly assigns each value of the truth table  Reversible Randomly re-orders the truth table itself

9 Reversibility Algorithm Initial checks  Number of outputs = number of inputs  For each output bit, equal number of 1’s and 0’s Sat-Count: linear time Less than 1% of functions pass (for n > 3)  For testing, need to filter these out and continue  BDD’s after this point are “almost-reversible”

10 Reversibility Algorithm Search the entire truth table  When a duplicate is found, quit If the function is reversible:  Need to check 2 n inputs  n output bits in each row  n time to calculate each output bit  Algorithm is O(n 2 2 n )

11 Randomization Statistics If the function is not reversible:  Assume outputs are randomly assigned  Algorithm terminates once a duplicate is found  Problem resembles the “birthday” problem  n = 10, 2 n = 1024: need to check 41  n = 20, 2 n = 1 million: need to check 1284  Grows like 2 n/2 = 1.414 n

12 Optimization Faster method for finding output values  All possible inputs are traversed in order  Variable assignments = sequential binary values Can maintain a ‘cursor’ on the tree  Move around the BDD in small steps  Faster than starting at the root each time  Takes constant time

13 Optimization Implementation  Maintain a Stack of decisions made  Can move upwards  Can make decisions from any point Last decision = “current” bit  Occurs at a terminal node

14 Optimization Case 1: Current bit is unchanged  Return the same output value as before 101 0 010 101 0 011 101 0 100

15 Optimization Case 2: Current bit is a 1  It must have been 0 previously  Step backwards a level in the stack  Make decisions from here 101 0 111 101 1 000

16 Optimization Case 3: Current bit is a 0  It must have been 1 previously  Step backwards to the most recent 0-1 transition  Make decisions from here 011 1 111 100 0 000

17 Analysis Testing on reversible functions  Worst case times  Slow traversal method vs. Fast method

18 Analysis Isolate time for each ‘traversal’ call  Divide by n2 n

19 Analysis Practical performance  The new method is faster for n > 15  Still, both methods are terribly slow  Factor of n has little effect Extrapolated running time: n = 20: 2.3 seconds n = 30: 1 hour n = 50: 196 years n = 75: 10 billion years

20 Analysis The good news  Random functions are rarely reversible  Finding the first duplicate is FAST Running time on a random function  n = 15: 4 microseconds  n = 50: 4 minutes (compared to 196 years)  n = 70: 4 days

21 Analysis This algorithm can very quickly:  Prove that a function is not reversible A duplicate will probably be found very quickly If a duplicate is not found quickly, then it will…  Prove that a function is reversible… … within some statistical accuracy 95% accuracy: run for twice the average

22 Conclusion This algorithm is practical when:  100% accuracy is not required  You don’t think the function is reversible The longer the algorithm is run for, the more sure you are that a function is reversible 2, 3 or 4 times a ‘suggested’ running time is a practical amount, giving > 99% accuracy. My optimizations are helpful, but not necessary


Download ppt "Identifying Reversible Functions From an ROBDD Adam MacDonald."

Similar presentations


Ads by Google