representing integer multiplication using bdds
play

Representing integer multiplication using BDDs Hvard Raddum and - PowerPoint PPT Presentation

Representing integer multiplication using BDDs Hvard Raddum and Srimathi Varadharajan Simula@UiB What is a BDD? Can be defined and understood in different ways Only one description given here BDD explained A BDD is a directed acyclic


  1. Representing integer multiplication using BDDs Håvard Raddum and Srimathi Varadharajan Simula@UiB

  2. What is a BDD? Can be defined and understood in different ways Only one description given here

  3. BDD explained A BDD is a directed acyclic graph, drawn from top to bottom 2 1 3 4 6 5

  4. BDD explained Every node can have two outgoing edges, the 0-edge and the 1-edge 1 e 1 g - d e e d - g 0 e 3 2

  5. BDD explained Nodes are arranged in horizontal levels Level i 1 2 3 Level i+1 4 5 Level i+2 6 7 8 9 No edges between nodes on same level

  6. BDD explained Only one node on highest and lowest levels Top node, source node Bottom node, sink node T

  7. BDD explained Linear combination of variables associated with each level, except bottom level x 1 +x 5 1 2 3 x 2 4 5 x 0 +x 2 +x 3 +x 6 6 7 8 9 Other descriptions: only single variables associated with levels

  8. BDD Examples

  9. BDD examples ��� � ������� � � ����������� � � ������� � � �

  10. Paths 0 1 0 1 0 0 0 0 1 0 1 0 0 1 1 0

  11. Assigning values Values in path assigned to linear combinations associated with levels ��� x 0 = 0 � x 1 + x 2 = 1 ������� � � x 0 + x 2 + x 3 = 0 ����������� � � x 2 + x 3 = 0 ������� � � �

  12. Integer multiplication as BDD How to construct multiplication BDD?

  13. N, p and q in binary • RSA modulus N=pq • p=p n-1 p n-2 … p 2 p 1 p 0 • q=q n-1 q n-2 … q 2 q 1 q 0 • N=N 2n-1 N 2n-2 … N 2 N 1 N 0 • N i ,p i ,q i ∈ {0,1}

  14. Multiplication n n-1 n+1 2 1 0 2n-2 columns Column k consists of all terms p i q j where i+j=k Column k contributes 2 k ∑ p i q j to the value of N

  15. Building multiplication BDD • BDD built column by column, starting with column 0 • One level of nodes constructed from each variable p i , q j appearing in column k p i q j Basic building block: p i q j =1 p i q j =0

  16. Column 0 N=…011 p 0 p 0 q 0 q 0 1 0 1 p 0 q 0 =0 p 0 q 0 =1 When construction of column k keep track of is complete, delete nodes with value of N values inconsistent with N k computed so far

  17. Column 1 N=…011 p 0 p 0 col 0 col 0 q 0 q 0 p 0 p 0 1 1 q 1 q 1 col 1 col 1 p 1 p 1 1 3 1 3 q 0 q 0 3 1 3 5 col 2 col 2

  18. Column 2 N=…011 p 0 p 0 3 3 q 2 q 2 p 1 p 1 3 7 3 7 col 2 col 2 q 1 q 1 p 2 p 2 3 7 11 3 7 11 q 0 q 0 3 7 3 11 15 11 col 3 col 3

  19. Column k col k-1 v v+2 k v+t*2 k p i q j v v+2*2 k v+2 k v+(t+1)*2 k v+t*2 k col k v v+2*2 k v+2 k v+s*2 k v+(s-1)*2 k col k+1

  20. Column 2n-2 col 2n-3 v v+2 2n-2 v+t*2 2n-2 p n-1 col 2n-2 q n-1 v v+2*2 2n-2 v+2 2n-2 v+(t+1)*2 2n-2 v+t*2 2n-2 Only keep node with value N. This becomes the bottom node of the BDD

  21. BDD for multiplication of two 8-bit numbers N=31439 891 nodes > 2 110 paths

  22. General properties of multiplication-BDD • BDD for n-bit numbers p and q has: • 2n different variables • 2n 2 levels (each variable occurring n times) • ≤ 2n 3 - 9/2n + 5 nodes

  23. Using BDD for factoring How to find values of p and q?

  24. Finding lsb’s of p and q p 0 • When N is odd, top of BDD will always be q 0 1 The two top levels give p 0 =q 0 =1 Fix p 0 =q 0 =1 in whole BDD by deleting 0-edges going out from levels with p 0 or q 0

  25. Finding lsb’s of p and q Gives p 1 =q 1 p 1 q 1 Replace q 1 with p 1 on all levels p 2 p 1 q 1 q 2 Depending on value of N, some more linear equations can be extracted from top of BDD

  26. Swapping levels • There exists an algorithm for swapping adjacent levels x y x y • Number of nodes may increase on affected level

  27. Absorbing dependency • Two adjacent levels with equal variables can be merged x x x

  28. Factoring algorithm • Repeat until each p i , q j only occurs once in whole BDD: • Swap levels repeatedly such that two adjacent levels get equal variables • Merge levels • Any path in resulting BDD gives values of p i and q j such that pq=N

  29. p 0 q 0 q 1 Only two paths remain p 1 q 2 p=211 and q=149 p 2 q 3 or p 3 q 4 p 4 p=149 and q=211 q 5 p 5 q 6 Number of nodes in p 6 BDD was never above q 7 891 during solving p 7

  30. Factoring larger numbers? • Experiments show that simple swap-and-merge algorithm has complexity ≈ √ N ≈ 2 n , measured as maximum number of nodes in BDD during solving • However, BDD representation allows to try other tricks

  31. All levels with p 4 merged and moved to the top p 4 p 4

  32. q 7 q 6 p 5 p 0 q 5 p 6 q 0 q 4 p 7 q 3 p 5 q 6 All levels with q 7 p 6 merged and q 5 p 7 moved to the top q 4 p 6 q 6 p 7 q 5 q 7 =0 ⇓ p 7 q 6 q 5 =1 q 4 =1 q 3 =1 q 6 =1 p 6 =1 p 7 =1 p 5 =1

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend