identifying reversible functions from an robdd adam macdonald

22
Identifying Reversible Functions From an ROBDD Adam MacDonald

Upload: madison-crawford

Post on 28-Dec-2015

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Identifying Reversible Functions From an ROBDD Adam MacDonald

Identifying Reversible FunctionsFrom an ROBDD

Adam MacDonald

Page 2: Identifying Reversible Functions From an ROBDD Adam MacDonald

Background

Reversible functions Number of inputs = number of outputs Mapping from output to input

Each output configuration is unique n variables: 2n inputs and 2n outputs possible Outputs = reordered truth table

in2

in1

out2

out1

Page 3: Identifying Reversible Functions From an ROBDD Adam MacDonald

Background

000

001

010

011

100

101

110

111

001

011

000

101

110

111

010

100

Page 4: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

1 0

Page 5: Identifying Reversible Functions From an ROBDD Adam MacDonald

Project Outline

BDD library implementation

Implement efficient method for detecting if a given BDD is reversible

Analysis

Page 6: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 7: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 8: Identifying Reversible Functions From an ROBDD Adam MacDonald

“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

Page 9: Identifying Reversible Functions From an ROBDD Adam MacDonald

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”

Page 10: Identifying Reversible Functions From an ROBDD Adam MacDonald

Reversibility Algorithm

Search the entire truth table When a duplicate is found, quit

If the function is reversible: Need to check 2n inputs n output bits in each row n time to calculate each output bit Algorithm is O(n2 2n)

Page 11: Identifying Reversible Functions From an ROBDD Adam MacDonald

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, 2n = 1024: need to check 41 n = 20, 2n = 1 million: need to check 1284 Grows like 2n/2 = 1.414n

Page 12: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 13: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 14: Identifying Reversible Functions From an ROBDD Adam MacDonald

Optimization

Case 1: Current bit is unchanged Return the same output value as before

101 0 010101 0 011101 0 100

Page 15: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 16: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 17: Identifying Reversible Functions From an ROBDD Adam MacDonald

Analysis Testing on reversible functions

Worst case times Slow traversal method vs. Fast method

Page 18: Identifying Reversible Functions From an ROBDD Adam MacDonald

Analysis Isolate time for each ‘traversal’ call

Divide by n2n

Page 19: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 20: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 21: Identifying Reversible Functions From an ROBDD Adam MacDonald

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

Page 22: Identifying Reversible Functions From an ROBDD Adam MacDonald

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