identifying reversible functions from an robdd adam macdonald

Post on 28-Dec-2015

223 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Identifying Reversible FunctionsFrom 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

Background

000

001

010

011

100

101

110

111

001

011

000

101

110

111

010

100

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

Project Outline

BDD library implementation

Implement efficient method for detecting if a given BDD is reversible

Analysis

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

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

“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

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”

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)

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

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

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

Optimization

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

101 0 010101 0 011101 0 100

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

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

Analysis Testing on reversible functions

Worst case times Slow traversal method vs. Fast method

Analysis Isolate time for each ‘traversal’ call

Divide by n2n

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

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

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

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

top related