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

representing integer multiplication using bdds
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Representing integer multiplication using BDDs

Håvard Raddum and Srimathi Varadharajan Simula@UiB

slide-2
SLIDE 2

What is a BDD?

Can be defined and understood in different ways Only one description given here

slide-3
SLIDE 3

BDD explained

A BDD is a directed acyclic graph, drawn from top to bottom

1 2 4 3 5 6

slide-4
SLIDE 4

BDD explained

Every node can have two outgoing edges, the 0-edge and the 1-edge

1

  • e

d g e 1

  • e

d g e

3 2

slide-5
SLIDE 5

BDD explained

Nodes are arranged in horizontal levels

1 6 5 4 3 2 7 8 9

Level i Level i+1 Level i+2

No edges between nodes on same level

slide-6
SLIDE 6

BDD explained

Only one node on highest and lowest levels

T

Top node, source node Bottom node, sink node

slide-7
SLIDE 7

BDD explained

1 6 5 4 3 2 7 8 9

x1+x5 x2 x0+x2+x3+x6

Linear combination of variables associated with each level, except bottom level

Other descriptions: only single variables associated with levels

slide-8
SLIDE 8

BDD Examples

slide-9
SLIDE 9

BDD examples

slide-10
SLIDE 10

Paths

1 1 1 1 1 1

slide-11
SLIDE 11

Assigning values

Values in path assigned to linear combinations associated with levels

  • x0 = 0

x1 + x2 = 1 x0 + x2 + x3 = 0 x2 + x3 = 0

slide-12
SLIDE 12

Integer multiplication as BDD

How to construct multiplication BDD?

slide-13
SLIDE 13

N, p and q in binary

  • RSA modulus N=pq
  • p=pn-1 pn-2 … p2 p1 p0
  • q=qn-1 qn-2 … q2 q1 q0
  • N=N2n-1 N2n-2 … N2 N1 N0
  • Ni,pi,qi ∈ {0,1}
slide-14
SLIDE 14

Multiplication

1 2 n-1 n n+1 2n-2 columns Column k consists of all terms piqj where i+j=k Column k contributes 2k∑piqj to the value of N

slide-15
SLIDE 15

Building multiplication BDD

  • BDD built column by column, starting with

column 0

  • One level of nodes constructed from each

variable pi, qj appearing in column k Basic building block: pi qj piqj=0 piqj=1

slide-16
SLIDE 16

Column 0

1

p0 q0 p0q0=0 p0q0=1 keep track of value of N computed so far

When construction of column k is complete, delete nodes with values inconsistent with Nk

1

p0 q0 N=…011

slide-17
SLIDE 17

Column 1

N=…011

1 3 1

p0 q0

col 0

p0 p1 q0 q1

col 1

3 1 5

col 2

1

p0 q0

1 3 3

p0 p1 q0 q1

col 0 col 1 col 2

slide-18
SLIDE 18

Column 2

3

N=…011

3 7 7 3 11 7 3 11 15

col 2

p0 q2 p1 p2 q1 q0

col 3

3

col 2

3 7 7 3 11 3 11

p0 q2 p1 p2 q1 q0

col 3

slide-19
SLIDE 19

Column k

col k-1

v v+2k v+t*2k v v+2k v+2*2k v+t*2k v+(t+1)*2k v v+2k v+2*2k v+(s-1)*2k v+s*2k

col k col k+1

pi qj

slide-20
SLIDE 20

Column 2n-2

col 2n-3

v v+22n-2 v+t*22n-2 v v+22n-2 v+2*22n-2 v+t*22n-2 v+(t+1)*22n-2

pn-1 qn-1

col 2n-2

Only keep node with value N. This becomes the bottom node of the BDD

slide-21
SLIDE 21

BDD for multiplication of two 8-bit numbers

891 nodes > 2110 paths N=31439

slide-22
SLIDE 22

General properties of multiplication-BDD

  • BDD for n-bit numbers p and q has:
  • 2n different variables
  • 2n2 levels (each variable occurring n times)
  • ≤ 2n3 - 9/2n + 5 nodes
slide-23
SLIDE 23

Using BDD for factoring

How to find values of p and q?

slide-24
SLIDE 24

Finding lsb’s of p and q

  • When N is odd, top of

BDD will always be

1

p0 q0 The two top levels give p0=q0=1 Fix p0=q0=1 in whole BDD by deleting 0-edges going out from levels with p0 or q0

slide-25
SLIDE 25

Finding lsb’s of p and q

p1 q1 p2 p1 q1 q2

Gives p1=q1 Replace q1 with p1

  • n all levels

Depending on value of N, some more linear equations can be extracted from top of BDD

slide-26
SLIDE 26

Swapping levels

  • There exists an algorithm for swapping adjacent levels

x y x y

  • Number of nodes may increase on affected level
slide-27
SLIDE 27

Absorbing dependency

  • Two adjacent levels with equal variables can be merged

x x x

slide-28
SLIDE 28

Factoring algorithm

  • Repeat until each pi, qj 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 pi and

qj such that pq=N

slide-29
SLIDE 29

p=211 and q=149

  • r

p=149 and q=211 Only two paths remain Number of nodes in BDD was never above 891 during solving

p0 p1 p2 p3 p4 p5 p6 p7 q0 q1 q2 q3 q4 q5 q6 q7

slide-30
SLIDE 30

Factoring larger numbers?

  • Experiments show that simple swap-and-merge

algorithm has complexity ≈ √N ≈ 2n, measured as maximum number of nodes in BDD during solving

  • However, BDD representation allows to try other

tricks

slide-31
SLIDE 31

All levels with p4 merged and moved to the top

p4

p4

slide-32
SLIDE 32

All levels with q7 merged and moved to the top

q7 p0 q0

q6 p5 q5 p6 q4 p7 q3 p5 q6 p6 q5 p7 q4 p6 q6 p7 q5 p7 q6

q7=0 ⇓ q6=1 p5=1 q5=1 p6=1 q4=1 p7=1 q3=1