1 Outline Division is central in many operations. –What is it (in the context of Boolean...

78
1 Outline Outline Division Division is central in many operations. is central in many operations. What What is it is it (in the context of (in the context of Boolean functions)? Boolean functions)? What to divide What to divide (divisor) (divisor) with? with? How to divide How to divide (quotient and (quotient and remainder) remainder) ? ? Applications Applications : factoring, : factoring, resubstitution, extraction resubstitution, extraction

Transcript of 1 Outline Division is central in many operations. –What is it (in the context of Boolean...

Page 1: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

1

OutlineOutline

DivisionDivision is central in many operations. is central in many operations.– WhatWhat is it is it (in the context of Boolean (in the context of Boolean

functions)? functions)? – What to divide What to divide (divisor)(divisor) with? with?– How to divide How to divide (quotient and (quotient and

remainder)remainder)??

ApplicationsApplications: factoring, resubstitution, : factoring, resubstitution, extractionextraction

Page 2: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

2

ProductProductDefinition 1:Definition 1: An An algebraic expressionalgebraic expression is a SOP is a SOP

representation of a logic function which is minimal representation of a logic function which is minimal w.r.t. single cube containment.w.r.t. single cube containment.

ExampleExample: ab + abc + cd is not an algebraic : ab + abc + cd is not an algebraic expression,expression,

ab + cd is. ab + cd is.

Definition 2:Definition 2: The The productproduct of two algebraic expressions of two algebraic expressions f and g, fg, is a f and g, fg, is a cciiddjj where {c where {cii} = f, {d} = f, {djj} = g, made } = g, made irredundant w.r.t single cube containment irredundant w.r.t single cube containment

e.g. ab + a = ae.g. ab + a = a

Page 3: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

3

ProductProduct

Algebraic product:Algebraic product: defineddefined only when f only when f and g have disjoint supports.and g have disjoint supports.– Boolean product:Boolean product: otherwise. otherwise.

Example:Example:– (a+b)(c+d) = ac + ad + bc + bd is an (a+b)(c+d) = ac + ad + bc + bd is an

algebraicalgebraic product product– (a+b)(a+c) = aa + ac + ab + bc = a (a+b)(a+c) = aa + ac + ab + bc = a

+ bc is a + bc is a BooleanBoolean product. product.

Page 4: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

4

DivisionDivisionDefinition 3:Definition 3: g is a g is a Boolean divisorBoolean divisor of f if h and r exist of f if h and r exist

such that f = gh + r, gh such that f = gh + r, gh 0. 0.

g is said to be a g is said to be a factorfactor of f if, in addition, r = 0, i.e., of f if, in addition, r = 0, i.e., f = gh.f = gh.– h is called the h is called the quotientquotient..– r is called the r is called the remainderremainder..– h and r may h and r may notnot be unique. be unique.

If gh is restricted to an algebraic product, h is the If gh is restricted to an algebraic product, h is the algebraic algebraic quotientquotient, denoted , denoted f//gf//g. Otherwise, h is a . Otherwise, h is a (non-unique)(non-unique) Boolean quotientBoolean quotient denoted denoted f f g g. . (We will reserve the (We will reserve the notation f/g for the more useful “weak division”, defined notation f/g for the more useful “weak division”, defined later).later).

Page 5: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

5

Division ( f = gh+r )Division ( f = gh+r )

If h If h 0, and h can be obtained using algebraic division, 0, and h can be obtained using algebraic division, then g is an then g is an algebraic divisoralgebraic divisor of f. Otherwise, g is a of f. Otherwise, g is a Boolean divisorBoolean divisor of f. of f.

Example:Example:f = ad + ae + bcd + jf = ad + ae + bcd + jgg11 = a + bc = a + bcgg22 = a + b = a + b

• Algebraic division f//a = d + e, f//(bc) = d Algebraic division f//a = d + e, f//(bc) = d (Also, (Also, f//a = d or f//a = e, i.e. algebraic division is not unique)f//a = d or f//a = e, i.e. algebraic division is not unique) hh11 = f//g = f//g11 = d, r = d, r11 = ae + j = ae + j

• Boolean division: hBoolean division: h22 = f = f g g22 = (a + c)d, r = (a + c)d, r22 = ae + j. = ae + j.i.e. f = (a+b)(a+c)d + ae + j i.e. f = (a+b)(a+c)d + ae + j

Page 6: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

6

DivisionDivision

DefinitionDefinition 4: 4: g is an g is an algebraic factoralgebraic factor of f of f if there exists an algebraic expression h if there exists an algebraic expression h such that such that

f = gh f = gh (using algebraic multiplication).(using algebraic multiplication).

Page 7: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

7

Why Use Algebraic Why Use Algebraic Methods?Methods?

• need need spectrumspectrum of operations - Algebraic of operations - Algebraic methods provide methods provide fastfast algorithms algorithms

• treat logic function like a treat logic function like a polynomialpolynomial• fastfast methods for manipulation of methods for manipulation of

polynomials availablepolynomials available• lossloss of optimality, but results quite good of optimality, but results quite good• can can iterateiterate and interleave with Boolean and interleave with Boolean

operationsoperations

Page 8: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

8

DivisionDivision

Theorem 5: Theorem 5: A logic function g is a A logic function g is a Boolean Boolean factorfactor of a logic function, f, if and only if f of a logic function, f, if and only if f g g (i.e. fg’ = 0, i.e. g’ (i.e. fg’ = 0, i.e. g’ f’). f’).

ffgg

Page 9: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

9

DivisionDivision

Proof:Proof::: g is a Boolean factor of f. Then g is a Boolean factor of f. Then h such that h such that

f = gh; Hence, f f = gh; Hence, f g g (as well as h).(as well as h).

:: f f g g f = gf = g(f + r) = gh. f = gf = g(f + r) = gh. (Here r is any function r (Here r is any function r g’.) g’.)

Notes:Notes:1.1. h = f works fine for the proof.h = f works fine for the proof.2.2. Given f and g, h is not unique. Given f and g, h is not unique. 3.3. To get a To get a smallsmall h is the same as getting a small f + h is the same as getting a small f +

r. Since rg = 0, this is the same as minimizing r. Since rg = 0, this is the same as minimizing (simplifying)(simplifying) f with DC = g’. f with DC = g’.

Page 10: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

10

DivisionDivision

Theorem 6:Theorem 6: g is a Boolean divisor of f if and only g is a Boolean divisor of f if and only if fg if fg 0. 0.

ggff gg

Page 11: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

11

DivisionDivision

Proof:Proof:

:: f = gh + r, gh f = gh + r, gh 0 0 fg = gh + gr. Since gh fg = gh + gr. Since gh 0, 0, fg fg 0. 0.

:: Assume that fg Assume that fg 0. f = fg + fg’ = g(f + k) + fg’. 0. f = fg + fg’ = g(f + k) + fg’. (Here k (Here k g’.) g’.) Then f = gh + r, with h = f + k, r = Then f = gh + r, with h = f + k, r = fg’. Since gh = fg fg’. Since gh = fg 0, then gh 0, then gh 0. 0.

Note:Note: f has f has manymany divisors. We are looking for a g divisors. We are looking for a g such that f = gh + r, where g, h, r are such that f = gh + r, where g, h, r are simplesimple functions. functions. (simplify f with DC = g’)(simplify f with DC = g’)

Page 12: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

12

Incompletely Specified Incompletely Specified FunctionsFunctions

FF = (f,d,r)= (f,d,r)

Definition 7: Definition 7: A completely specified logic function g A completely specified logic function g is a is a Boolean divisorBoolean divisor of of FF if there exist h,e if there exist h,e (completely specified)(completely specified) such that such that

f f gh + e gh + e f + d f + dand and gh gh d d..

Definition 8:Definition 8: g is a g is a Boolean factorBoolean factor of of FF if there exists if there exists h such thath such that

f f gh gh f + d f + d

Page 13: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

13

Incompletely Specified Incompletely Specified FunctionsFunctions

Lemma Lemma 9:9: f f g g if and only ifif and only if g is a Boolean factor of g is a Boolean factor of FF..

Proof.Proof.:: Assume that f Assume that f g . Let h = f + k where kg g . Let h = f + k where kg d. Then d. Then

hg = (f + k) g hg = (f + k) g (f + d). Since f (f + d). Since f g, fg = f and thus g, fg = f and thusf f (f + k) g = gh. (f + k) g = gh.ThusThus

f f (f + k) g (f + k) g f + d f + d

:: Assume the f = gh. Suppose Assume the f = gh. Suppose minterm m such that f(m) = minterm m such that f(m) = 1 but g(m) = 0. Then f(m) = 1 but g(m)h(m) = 0 implying 1 but g(m) = 0. Then f(m) = 1 but g(m)h(m) = 0 implying that f that f gh. Thus f(m) = 1 implies g(m) = 1, i.e. f gh. Thus f(m) = 1 implies g(m) = 1, i.e. f g g

Note:Note: Since kg Since kg d, k d, k (d + g’). Hence obtain (d + g’). Hence obtain h = f + k by h = f + k by simplifyingsimplifying f with DC = (d + g’). f with DC = (d + g’).

Page 14: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

14

Incompletely Specified Incompletely Specified FunctionsFunctions

Lemma 10:Lemma 10: fg fg 0 0 if and only ifif and only if g is a Boolean divisor of g is a Boolean divisor of FF..

Proof.Proof.

:: Assume fg Assume fg 0. Let fg 0. Let fg hh (f + d + g’) and (f + d + g’) andfg’ fg’ ee (f + d). Then (f + d). Thenf = fg + fg’ f = fg + fg’ gh + egh + e g(f + d + g’) + f + d = f + d g(f + d + g’) + f + d = f + dAlso, 0 Also, 0 fg fg gh gh ghf ghf 0. Now 0. Now gh gh d d, since otherwise , since otherwise ghf = 0 ghf = 0 (since fd = 0),(since fd = 0), verifying the conditions of Boolean verifying the conditions of Boolean division.division.

:: Assume that g is a Boolean divisor. Then Assume that g is a Boolean divisor. Then h such that gh h such that gh d and d and

f f gh + e gh + e f + d f + dSince gh = (ghf + ghd) Since gh = (ghf + ghd) d, then fgh d, then fgh 0 implying that fg 0 implying that fg 0. 0.

Page 15: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

15

Incompletely Specified Incompletely Specified FunctionsFunctions

fg fg hh (f + d + g’) fg’ (f + d + g’) fg’ ee (f + d) (f + d)

Recipe: Recipe: ( f ( f gh + e gh + e f + d )f + d )1.1. Choose g such that fg Choose g such that fg 0. 0.

2.2. Simplify fg with DC = (d + g’ ) to get h.Simplify fg with DC = (d + g’ ) to get h.

3.3. Simplify fg’ with DC = (d + fg) to get e. Simplify fg’ with DC = (d + fg) to get e. (could use DC = d + gh )(could use DC = d + gh )

ThusThusfg fg hh f + g’ + d f + g’ + dfg’ fg’ ee fg’ + d + fg = f + fg’ + d + fg = f +

d d

Page 16: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

16

Incompletely Specified Incompletely Specified FunctionsFunctions

FF = (f,d,r) = (f,d,r)Lemma 11.Lemma 11. Suppose g is an Suppose g is an algebraicalgebraic divisordivisor of F, a cover of of F, a cover of FF. .

If f If f e e (where e is the remainder in the algebraic division, (where e is the remainder in the algebraic division, i.e. F = gh + e)i.e. F = gh + e) then g is a then g is a BooleanBoolean divisordivisor of F. of F.

Proof. Proof. Assume F = gh + e, gh Assume F = gh + e, gh 0, f 0, f e. Since f e. Since f gh + e gh + e and f and f e, then fgh e, then fgh 0 implying that fg 0 implying that fg 0. Therefore, by 0. Therefore, by the Lemma 10, g is a Boolean divisor of f.the Lemma 10, g is a Boolean divisor of f.

Lemma 12.Lemma 12. If g is an If g is an algebraic factoralgebraic factor of F a cover of of F a cover of FF, then g is , then g is a a Boolean factorBoolean factor of F. of F.

Proof. Proof. Assume F = gh. Since f Assume F = gh. Since f F, then F, thenf f gh gh f f g. g.

By Lemma 9, g is a Boolean factor of By Lemma 9, g is a Boolean factor of FF..

Page 17: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

17

Algorithm for Boolean Algorithm for Boolean DivisionDivision

Given Given FF = (f,d,r), write a cover for = (f,d,r), write a cover for FF in the form in the form gh + egh + e where h, e are where h, e are minimalminimal in some sense. in some sense.Minimal may be minimum factored form.Minimal may be minimum factored form.

An algorithm:An algorithm:1.1. Create a Create a newnew variable x to “represent” g.variable x to “represent” g.

2.2. Form the Form the don’t caredon’t care set = xg’ + x’g. set = xg’ + x’g. (Since x =g we (Since x =g we don’t care if x don’t care if x g). g).

3.3. MinimizeMinimize (f , d + , r ) to get . (f , d + , r ) to get .

4.4. Return (h = /x, e) where e is the remainder of . Return (h = /x, e) where e is the remainder of . (These are simply the terms not containing x.)(These are simply the terms not containing x.)

Here we are using f/x to denote Here we are using f/x to denote “weak division”“weak division” a maximal a maximal form of algebraic division. This will be defined form of algebraic division. This will be defined laterlater..

d~

'~d '

~dd

~f~

f~

f~

Page 18: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

18

Algorithm for Boolean Algorithm for Boolean DivisionDivision

• Note that (f , d + , r ) is a partition. We can use Note that (f , d + , r ) is a partition. We can use ESPRESSO to minimize it. But the objective there is to ESPRESSO to minimize it. But the objective there is to minimize minimize number of cubesnumber of cubes - - not completely appropriate.not completely appropriate.

Example:Example:f = a + bcf = a + bcg = a + bg = a + b

= xa’b’ + x’(a+b) where x = g = (a+b)= xa’b’ + x’(a+b) where x = g = (a+b)– Minimize (a + bc) = (a + bc)(x’a’b’ + x(a+b)) = xa + xbc Minimize (a + bc) = (a + bc)(x’a’b’ + x(a+b)) = xa + xbc

with DC = xa’b’ + x ’(a+b) with DC = xa’b’ + x ’(a+b)– A minimum cover is a + bc A minimum cover is a + bc butbut it does not use x or x’ !! it does not use x or x’ !!– ForceForce x in the cover. This yields f = a + xc = a + (a + b)c x in the cover. This yields f = a + xc = a + (a + b)c

Heuristic:Heuristic: Try to find answer with x in it and which also Try to find answer with x in it and which also uses the least variables uses the least variables (or literals)(or literals)

'~d '

~d d

~

d~

'~d

Page 19: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

19

Two Algorithms for Two Algorithms for Boolean DivisionBoolean Division

Assume F is a cover for Assume F is a cover for FF = (f,d,r) and D is a cover for d. = (f,d,r) and D is a cover for d.First Algorithm:First Algorithm:

(H,E) (H,E) Boolean-Division(F,D,g) Boolean-Division(F,D,g)DD11 = D + xg’ + x’g = D + xg’ + x’g (don’t care)(don’t care)FF11 = FD’ = FD’11 (on-set)(on-set)RR11 = (F = (F11 + D + D11)’ = F’)’ = F’11D’D’11 = F’D’ = F’D’11 (off-set)(off-set)FF22 = remove x’ from F = remove x’ from F11

FF33 = = Minimum_LiteralMinimum_Literal(F(F22, R, R11, x), x)/* (minimum literal support including x) *//* (minimum literal support including x) */FF44 = ESPRESSO(F = ESPRESSO(F33,D,D11,R,R11))H = FH = F44/x /x (quotient)(quotient)E = FE = F44 - {xH} - {xH} (remainder)(remainder)

Thus GH + E is a cover for (f,d,r).Thus GH + E is a cover for (f,d,r).

Page 20: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

20

Two Algorithms for Two Algorithms for Boolean DivisionBoolean Division

Assume F is a cover for Assume F is a cover for FF = (f,d,r) and D is a = (f,d,r) and D is a cover for d.cover for d.

Second Algorithm:Second Algorithm:This is a slight variation of the first one. It uses This is a slight variation of the first one. It uses x’ also while dividing. x’ also while dividing.

(H1, H0, e) (H1, H0, e) Boolean-Division(F,D,g) Boolean-Division(F,D,g)

Thus we obtain a cover F = x H1 + x’ H0 + EThus we obtain a cover F = x H1 + x’ H0 + E

Page 21: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

21

Two Algorithms for Two Algorithms for Boolean DivisionBoolean Division

Second Algorithm:Second Algorithm:DD11 = D + xg’ + x’g = D + xg’ + x’g (don’t care)(don’t care)FF11 = FD’ = FD’11 (on-set)(on-set)RR11 = (F = (F11 + D + D11)’ = F’)’ = F’11D’D’11 = F’D’ = F’D’11 (off-set)(off-set) /* /* FF22 = remove x’ from F = remove x’ from F11 */ (this line is deleted) */ (this line is deleted)

FF33 = Minimum_Literal(F = Minimum_Literal(F11, R, R11, x, x’), x, x’) /* (minimum literal support including x) *//* (minimum literal support including x) */FF44 = ESPRESSO(F = ESPRESSO(F33,D,D11,R,R11))HH11 = F = F44/x/xHH00 = F = F44/x’/x’E = FE = F44 \ ( {xH \ ( {xH11} + (x’H} + (x’H00} )} )

Thus GHThus GH11 + G’H + G’H00 + E is a cover for (f,d,r). + E is a cover for (f,d,r).

Page 22: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

22

Minimum_Literal()Minimum_Literal()

Given Given FF = (f,d,r), find a cover which has the = (f,d,r), find a cover which has the smallest smallest variable supportvariable support (literal support). (literal support).

Definitions: Definitions: minimum supports forminimum supports for F = some cover of F = some cover of FF

v_sup v_sup (F) = { (F) = { v v ||vv c or c or v’v’ c for some c c for some c F} F}

l_sup l_sup (F) = { (F) = { l l | | ll c for some c c for some c F} F}

Definitions: Definitions: minimum supports for minimum supports for FF

v_sup v_sup ((FF ) = min{ ) = min{ v_sup v_sup (F) | F a cover of (F) | F a cover of F F }}

l_supl_sup ( (FF ) = min{ ) = min{ l_sup l_sup (F) | F a cover of (F) | F a cover of F F }}

Page 23: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

23

Minimum_Literal()Minimum_Literal()

FF = = (f,d,r),(f,d,r), F is any prime coverF is any prime coverLemma 13:Lemma 13: If d = 0, then If d = 0, then v_sup v_sup (F) = (F) = v_sup v_sup ((FF ) and ) and

l_sup l_sup (F) = (F) = l_sup l_sup ((FF ) for any prime cover F of ) for any prime cover F of FF..

Proof.Proof. Suppose FSuppose F11 and F and F22 are two prime covers of are two prime covers of FF. . Suppose x appears in FSuppose x appears in F22 but not in F but not in F11. Let xc . Let xc F F22. . Let c = mLet c = m11 + m + m22 + ... m + ... mkk. Since d = 0 and xm. Since d = 0 and xm ii is is an implicant of an implicant of FF, it is present in F, it is present in F11. However, F. However, F11 is is independent of x. Hence x’mindependent of x. Hence x’m ii is also an implicant is also an implicant of of FF. Hence m. Hence mii is an implicant of is an implicant of FF for all i. So xc for all i. So xc can be raised to c, contradicting the fact that xc can be raised to c, contradicting the fact that xc is prime.is prime.

Page 24: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

24

Minimum Variable Minimum Variable Algorithm (MINVAR)Algorithm (MINVAR)

Given:Given:FF = (f,d,r) = (f,d,r)F = {cF = {c11, c, c22, ...., c, ...., ckk} (a cover of } (a cover of FF ))R = {rR = {r11, r, r22, ..., r, ..., rmm} (a cover of r)} (a cover of r)1. Construct blocking matrix B1. Construct blocking matrix Bii for each c for each cii..2. Form “super” blocking matrix2. Form “super” blocking matrix

B

BB

B3

2

1

Page 25: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

25

Minimum Variable Minimum Variable Algorithm (MINVAR)Algorithm (MINVAR)

MINVAR continuedMINVAR continued

3. Find a minimum cover S of B, S = { j3. Find a minimum cover S of B, S = { j11, j, j22, ..., , ...,

jjv v }.}.

4. Modify where4. Modify where

kcc cF ~,...,~,~~ 21

otherwise 21,0

S j if ~~ ii cc j

j

Page 26: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

26

End of lecture 9End of lecture 9

Page 27: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

27

Minimum Variable Minimum Variable AlgorithmAlgorithm

Theorem 14: Theorem 14: The set The set {x{xj j | j | j S} S} is a minimum is a minimum variable set in the sense that no other cover of variable set in the sense that no other cover of FF, , obtained by expanding Fobtained by expanding F, has fewer variables, has fewer variables

Proof.Proof. Expand treats each c Expand treats each cii F and builds B F and builds Bii. Let . Let be any prime containing c be any prime containing cii. Then the . Then the variables in “cover” Bvariables in “cover” Bii. Thus the union of the . Thus the union of the set of variables in taken over all set of variables in taken over all ii cover B. cover B. Hence this set cannot be smaller than a Hence this set cannot be smaller than a minimum cover of B.minimum cover of B.

Note:Note: In general, there In general, there couldcould exist another cover exist another cover of of FF which has less variables, but that cover which has less variables, but that cover could could notnot be obtained by be obtained by expanding Fexpanding F

ic icic ic

Page 28: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

28

Minimum Literal SupportMinimum Literal Support

Given:Given:FF = (f,d,r) = (f,d,r)F = {cF = {c11, c, c22, ...., c, ...., ckk} } (a cover of (a cover of FF ))R = {rR = {r11, r, r22, ..., r, ..., rmm} } (a cover of r) (a cover of r)Literal Blocking MatrixLiteral Blocking Matrix

Example:Example: c cii = ad’e’, r = ad’e’, rqq = a’ce = a’ce

otherwise 0

r vand c v'if 1

otherwise 0

r v'and c vif 1

qj

ij

,

qj

ij

ˆ

ˆ

i

i

B

B

njq

qj

1

'

0

'

0

'

0

'

0

'

00001ˆ edcbaedcbaB i

q

Page 29: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

29

Minimum Literal SupportMinimum Literal Support

Use the same method - construct “Use the same method - construct “supersuper” ” blocking matrix and get its row cover J.blocking matrix and get its row cover J.

Theorem 15: Theorem 15: If x is a row cover of , then a If x is a row cover of , then a representation representation (expression or factored form)(expression or factored form) exists using only the literals exists using only the literals

{ { llii | | i i J} J} { { l’l’ii | i + n | i + n J } J }

Proof.Proof. Left as an exercise. Left as an exercise.

B

Page 30: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

30

Example of Literal Example of Literal Blocking MatrixBlocking Matrix

on-set cube:on-set cube: ccii = ab’d. = ab’d.off-set:off-set: r = a’b’d’ + abd’ + acd’ + bcd + c’d’.r = a’b’d’ + abd’ + acd’ + bcd + c’d’.

• Minimum row cover Minimum row cover {d,b’}.{d,b’}.• Thus b’d is Thus b’d is thethe maximum prime covering ab’d. maximum prime covering ab’d. NoteNote:: For one cube, minimum literal support is the For one cube, minimum literal support is the

samesame as minimum variable support. as minimum variable support.

a b c d a’ b’ c’ d’ a’b’d’ 1 0 0 1 0 0 0 0 abd’ 0 0 0 1 0 1 0 0 acd’ 0 0 0 1 0 0 0 0 bcd 0 0 0 0 0 1 0 0 c’d’ 0 0 0 1 0 0 0 0

Page 31: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

31

Boolean Division: ExampleBoolean Division: ExampleF = a + bcF = a + bc

algebraic division: algebraic division: F/(a + b) = 0F/(a + b) = 0Boolean division: Boolean division: F F (a + b) = a + c. (a + b) = a + c.

Let Let x = a + bx = a + b

Generate don’t care set: Generate don’t care set: DD11 = x’(a + b) + xa’b’ = x’(a + b) + xa’b’..Generate care on-set: Generate care on-set:

FF11 = F = F D’ D’11 = (a + bc)(xa + xb +x’a’b’) =ax + bcx = (a + bc)(xa + xb +x’a’b’) =ax + bcx..Let Let CC = {c = {c11 = ax, c = ax, c22 = bcx} = bcx}

Generate care off-set: Generate care off-set:

RR11 = F’D’ = F’D’11 = (a’b’ + a’c’)(xa + xb + x’a’b’) =a’bc’x + a’b’x’. = (a’b’ + a’c’)(xa + xb + x’a’b’) =a’bc’x + a’b’x’. Let Let R = {rR = {r11 = a’bc’x, r = a’bc’x, r22 = a’b’x’}. = a’b’x’}.

Form super-variable blocking matrix using column order (a, b, c, Form super-variable blocking matrix using column order (a, b, c, x).x).

1

0

1

0

0

1

0

0

1

0

0

0

0

0

1

1

2

1

B

BB

Page 32: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

32

Boolean Division: ExampleBoolean Division: Example

• Find minimum Find minimum covercover = {a, c, x}. = {a, c, x}.• Eliminate in FEliminate in F11 all variables associated with b. So all variables associated with b. So

FF11 = ax + bcx = ax + cx = x(a + c). = ax + bcx = ax + cx = x(a + c).• Simplifying Simplifying (applying expand, irredundant on (applying expand, irredundant on

FF1 1 ),), we get we getFF11 = a + xc = a + xc..

• Thus quotient = Thus quotient = FF11/x = c/x = c, remainder = , remainder = aa..F = a + bc = a + cx = a + c(a + b).F = a + bc = a + cx = a + c(a + b).

Question:Question: How to force How to force xx in the cover? in the cover?

1

0

1

0

0

1

0

0

1

0

0

0

0

0

1

1

2

1

B

BB

abcxabcx

Page 33: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

33

Algebraic DivisionAlgebraic DivisionAlgebraic divisionAlgebraic division, , Alg_DivAlg_Div, is any operation, , is any operation,

given F, G, returns H, R where given F, G, returns H, R where – GH is an algebraic product and GH is an algebraic product and – GH + R and F are the same expression GH + R and F are the same expression

(having the same set of cubes).(having the same set of cubes).

Weak divisionWeak division is a specific example of algebraic division. is a specific example of algebraic division.DEFINITION 16: DEFINITION 16: Given two algebraic expressions F and G, a Given two algebraic expressions F and G, a

division is called division is called weak divisionweak division if if 1.1. it is algebraic andit is algebraic and2.2. R has as few cubes as possible.R has as few cubes as possible.

The quotient H resulting from weak division is denoted by The quotient H resulting from weak division is denoted by F/GF/G..

THEOREMTHEOREM 17: 17: Given expressions F and G, H and R generated Given expressions F and G, H and R generated by weak division are by weak division are uniqueunique..

Page 34: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

34

AlgorithmAlgorithmWEAK_DIV(F,G): WEAK_DIV(F,G): G={ gG={ g11, g, g22,…, },…, }

1.1. U = {uU = {ujj} - cubes of F but only literals in G kept.} - cubes of F but only literals in G kept.

2.2. V = {vV = {vjj} - cubes of F but literals in G removed.} - cubes of F but literals in G removed./* note that u/* note that ujjvvjj is the j-th cube of F */ is the j-th cube of F */

3.3. VVggii = { v = { vj j V : u V : ujj = g = gi i }}/* one set for each cube of G *//* one set for each cube of G */

4.4. H = H = V Vggii /* those cubes found in all V/* those cubes found in all Vggii */*/

5.5. R = F \ GHR = F \ GH

6.6. return (H,R)return (H,R)

Note:Note: Time complexity of WEAK_DIV = Time complexity of WEAK_DIV = O(n log n),O(n log n), n = number of product terms in F and G.n = number of product terms in F and G.

Page 35: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

35

Example of WEAK_DIVExample of WEAK_DIV

Example:Example:F = ace + ade + bc + bd + be +a’b + abF = ace + ade + bc + bd + be +a’b + abG = ae + bG = ae + bU = ae + ae + b + b + b + b + abU = ae + ae + b + b + b + b + abV = c + d + c + d + 1 + a’ + 1V = c + d + c + d + 1 + a’ + 1VVaeae = c + d = c + d VVggii = { v = { vj j V : u V : ujj = g = gi i }}

VVbb = c + d + 1 + a’ = c + d + 1 + a’H = c + d = F/G H = c + d = F/G H = H = V Vggii

R = be + a’b + ab R = be + a’b + ab R = F \ GHR = F \ GH

F = (ae + b)(c + d) + be + a’b + abF = (ae + b)(c + d) + be + a’b + ab

Page 36: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

36

Efficiency IssuesEfficiency Issues

We use We use filtersfilters to prevent trying a division. to prevent trying a division.

The cover G is The cover G is notnot an algebraic divisor of F if an algebraic divisor of F if1.1. G contains a literal not in F.G contains a literal not in F.

2.2. G has more terms than F.G has more terms than F.

3.3. For any literal, its count in G exceeds that in F.For any literal, its count in G exceeds that in F.

4.4. F is in the transitive fanin of G.F is in the transitive fanin of G.

Proof.Proof. If G were an algebraic divisor of F, F = GH + E.If G were an algebraic divisor of F, F = GH + E.

Page 37: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

37

Division - What do we Division - What do we divide with?divide with?

So far, we learned So far, we learned howhow to divide a given to divide a given expression F by another expression G.expression F by another expression G.

But how do we find But how do we find G G ??– Too many Boolean divisorsToo many Boolean divisors– Restrict to algebraic divisors.Restrict to algebraic divisors.

Problem:Problem: Given a set of functions { F Given a set of functions { Fi i }, }, find find commoncommon weak weak (algebraic)(algebraic) divisors. divisors.

Page 38: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

38

Kernels and Kernel Kernels and Kernel IntersectionsIntersections

DEFINITION 18: DEFINITION 18: An expression is An expression is cube-freecube-free if no cube if no cube divides the expression evenly (i.e. there is no literal divides the expression evenly (i.e. there is no literal that is common to all the cubes).that is common to all the cubes).

(e.g., ab + c is cube-free; ab + ac and abc are (e.g., ab + c is cube-free; ab + ac and abc are not cube-free).not cube-free).

NoteNote: a cube-free expression : a cube-free expression mustmust have more than one have more than one cube.cube.

DEFINITION 19: DEFINITION 19: The The primary divisorsprimary divisors of an expression of an expression F are the set of expressionsF are the set of expressions

D(F) = {F/c | c is a cube}.D(F) = {F/c | c is a cube}.

Page 39: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

39

Kernels and Kernel Kernels and Kernel IntersectionsIntersections

DEFINITIONS 20: DEFINITIONS 20: The The kernelskernels of an expression F are of an expression F are the set of expressionsthe set of expressions

K(F) = {G | G K(F) = {G | G D(F) and G is cube-free}. D(F) and G is cube-free}.

In other words, the kernels of an expression F are the In other words, the kernels of an expression F are the cube-free primary divisorscube-free primary divisors of F. of F.

DEFINITION 21: DEFINITION 21: A cube c used to obtain the kernel K A cube c used to obtain the kernel K = F/c is called a = F/c is called a co-kernelco-kernel of K. of K.

C(F)C(F) is used to denote the is used to denote the setset of co-kernels of F. of co-kernels of F.

Page 40: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

40

ExampleExample

Example:Example:x = adf + aef + bdf + bef + cdf + cef + gx = adf + aef + bdf + bef + cdf + cef + g = (a + b + c)(d + e)f + g= (a + b + c)(d + e)f + g

kernelskernels co-kernelsco-kernels

a+b+ca+b+c df, efdf, ef

d+ed+e af, bf, cfaf, bf, cf

(a+b+c)(d+e)f+g(a+b+c)(d+e)f+g 11

Page 41: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

41

Fundamental TheoremFundamental Theorem

THEOREM 22: THEOREM 22: If two expressions F and G have the If two expressions F and G have the property thatproperty that

kkFF K(F), K(F), kkGG K(G) K(G) | k | kGG k kF F | | 1 1(k(kG G and kand kFF have at most one term in common), have at most one term in common),

then F and G have then F and G have no commonno common algebraic algebraic multiple divisors (i.e. with multiple divisors (i.e. with more than one more than one cube)cube)..

Important:Important: If we “kernel” all functions and there are If we “kernel” all functions and there are no nontrivial intersections, then the only common no nontrivial intersections, then the only common algebraic divisors left are algebraic divisors left are single cube divisors.single cube divisors.

Page 42: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

42

The Level of a KernelThe Level of a Kernel

It is nearly as effective to compute a certain It is nearly as effective to compute a certain subsetsubset of of K(F). This leads to the definition for the K(F). This leads to the definition for the levellevel of a of a kernel:kernel:

Notes:Notes: 1.1. KK00(F) (F) K K11(F) (F) K K22(F) (F) ... ... K Knn(F) (F) K(F). K(F).2.2. level-n kernels = Klevel-n kernels = Knn(F) \ K(F) \ Kn-1n-1(F) (F) 3.3. KKnn(F) is the set of kernels of level k or less.(F) is the set of kernels of level k or less.4.4. A A level-0level-0 kernel has no kernels except itself. kernel has no kernels except itself.5.5. A A level-nlevel-n kernel has at least one level kernel has at least one level n-1n-1 kernel but no kernel but no

kernels kernels (except itself)(except itself) of level n or greater. of level n or greater.

1

1( ) 1 1

( 0) ( ) | ( ) { }( )

( 0) ( ) | , ( ) ( )n

nk K k

n k K F K k kK F

n k K F k k k K F

Page 43: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

43

Level of a Kernel ExampleLevel of a Kernel Example

Example:Example:F = (a + b(c + d))(e + g)F = (a + b(c + d))(e + g)

kk11 = a + b(c + d) = a + b(c + d) K K11

KK00 ==> ==> level-1level-1 kk22 = c + d = c + d K K00

kk33 = e + g = e + g K K00

Page 44: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

44

Kerneling AlgorithmKerneling Algorithm

R R KERNELKERNEL( j, G )( j, G )R R 0 0if (G is cube-free) if (G is cube-free) R R {G} {G}For i = j + 1, ..., n {For i = j + 1, ..., n {

if (lif (lii appears only in one term) appears only in one term) continuecontinue

elseelse if (if (k k i, l i, lkk all cubes of G/l all cubes of G/lii ), ), continuecontinue

else, else,

R R R R KERNELKERNEL( i, cube_free(G/l( i, cube_free(G/lii) )) )}}

return Rreturn R

Page 45: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

45

Kerneling AlgorithmKerneling Algorithm

KERNEL(0, F)KERNEL(0, F) returns all the kernels of F. returns all the kernels of F.

Notes:Notes:

1.1. The test The test ((k k i, l i, lkk all cubes of G/l all cubes of G/lii )) is a is a majormajor efficiency factor. It also guarantees efficiency factor. It also guarantees that no co-kernel is tried more than once.that no co-kernel is tried more than once.

2.2. This algorithm has stood up to all attempts This algorithm has stood up to all attempts to find faster ones.to find faster ones.

3.3. Can be used to generate all co-kernels.Can be used to generate all co-kernels.

Page 46: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

46

Kerneling IllustratedKerneling Illustrated

abcd + abce + adfg + aefg + adbe + acdef + begabcd + abce + adfg + aefg + adbe + acdef + beg

aa bb

cc(a)(a)

ccdd ee

(a)(a)

(a)(a)ac+d+gac+d+g

gg

d+ed+ecd+gcd+g

ff

ce+gce+g

ff

b+cfb+cf

ee

dd

b+dfb+df

ee

b+efb+ef

dd

cc

d+ed+e

c+ec+e

c+dc+d

bb

cc dd ee

(bc + fg)(d + e) + de(b + cf)(bc + fg)(d + e) + de(b + cf)

c(d+e) + dec(d+e) + dea(d+e)a(d+e)

Page 47: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

47

Kerneling IllustratedKerneling Illustrated

co-kernelsco-kernels kernelskernels

11 a((bc + fg)(d + e) + de(b + cf))) + bega((bc + fg)(d + e) + de(b + cf))) + begaa (bc + fg)(d + e) + de(b + cf)(bc + fg)(d + e) + de(b + cf)abab c(d+e) + dec(d+e) + deabcabc d + ed + eabdabd c + ec + eabeabe c + dc + dacac b(d + e) + defb(d + e) + defacdacd b + efb + ef

Note:Note: f/bc = ad + ae = a(d + e)f/bc = ad + ae = a(d + e)

Page 48: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

48

Applications - FactoringApplications - Factoring

FACTOR FACTOR ( F ):( F ):1.1. if (F has no factor) return Fif (F has no factor) return F

/* e.g. if |F| = 1, or an OR of literals /* e.g. if |F| = 1, or an OR of literals

or no literal appears more that or no literal appears more that once */once */

1.1. D = CHOOSE_DIVISOR (F)D = CHOOSE_DIVISOR (F)

2.2. (Q, R) = DIVIDE (F, D)(Q, R) = DIVIDE (F, D)

3.3. return return FACTOR FACTOR (Q) (Q) FACTOR FACTOR (D) + (D) + FACTOR FACTOR (R)(R)

Page 49: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

49

Problems with FACTORProblems with FACTOR

Notation in following examples:Notation in following examples:F = the original function,F = the original function,D = the divisor,D = the divisor,Q = the quotient,Q = the quotient,P = the partial factored form,P = the partial factored form,O = the final factored form by FACTOR.O = the final factored form by FACTOR.Restrict to algebraic operations only.Restrict to algebraic operations only.

Page 50: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

50

Example and ProblemsExample and ProblemsExample 1:Example 1:

F = abc + abd + ae + af + gF = abc + abd + ae + af + gD = c + dD = c + dQ = abQ = abP = ab(c + d) + ae + af + gP = ab(c + d) + ae + af + gO = ab(c + d) + a(e + f) + gO = ab(c + d) + a(e + f) + g

O is O is notnot optimal since not maximally factored. optimal since not maximally factored.

Can be further factored toCan be further factored toa(b(c + d) + e + f) + ga(b(c + d) + e + f) + g

The problem The problem occursoccurs when when 1.1. quotient Q is a quotient Q is a singlesingle cube, and cube, and

2.2. some of the literals of Q also appear in the remainder R.some of the literals of Q also appear in the remainder R.

Page 51: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

51

Solving this ProblemSolving this Problem

1.1. Check if the quotient Q is not a single cube, then Check if the quotient Q is not a single cube, then done, else,done, else,

2.2. Pick a literal Pick a literal ll11 in Q which occurs most in Q which occurs most frequentlyfrequently in cubes of F.in cubes of F.

3.3. Divide F by Divide F by ll11 to obtain a new divisor D to obtain a new divisor D11..Now, F has a new partial factored formNow, F has a new partial factored form

(l(l11)(D)(D11) + (R) + (R11))and literal and literal ll11 does not appear in R does not appear in R11..

Note:Note: the new divisor D the new divisor D11 containscontains the original D as a the original D as a divisor because divisor because ll11 is a literal of Q. When recursively is a literal of Q. When recursively factoring Dfactoring D11, D can be discovered again., D can be discovered again.

Page 52: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

52

Second Problem with Second Problem with FACTORFACTOR

Example 2:Example 2:F = ace + ade + bce + bde + cf + dfF = ace + ade + bce + bde + cf + dfD = a + bD = a + bQ = ce + deQ = ce + deP = (ce + de)(a + b) + (c + d) fP = (ce + de)(a + b) + (c + d) fO = e(c + d)(a + b) + (c + d)fO = e(c + d)(a + b) + (c + d)f

Again, O is not maximally factored because Again, O is not maximally factored because (c + d)(c + d) is is common to both products common to both products e(c + d)(a + b)e(c + d)(a + b) and and remainder remainder (c + d)f(c + d)f. The final factored form should . The final factored form should have beenhave been

(c+d)(e(a + b) + f)(c+d)(e(a + b) + f)

Page 53: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

53

Second Problem with Second Problem with FACTORFACTOR

Solving the problem:Solving the problem:

1.1. Make Q Make Q cube-freecube-free to get Q to get Q11

2.2. Obtain a new divisor DObtain a new divisor D11 by dividing F by Q by dividing F by Q11

3.3. If DIf D11 is cube-free, the partial factored form is is cube-free, the partial factored form is F = (QF = (Q11)(D)(D11) + R) + R11, and can recursively factor , and can recursively factor QQ11, D, D11, and R, and R11

4.4. If DIf D11 is not cube-free, let D is not cube-free, let D11 = cD = cD22 and D and D33 = = QQ11DD22. We have the partial factoring F = cD. We have the partial factoring F = cD33 + + RR11. Now recursively factor D. Now recursively factor D33 and R and R11..

Page 54: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

54

End of lecture 10End of lecture 10

Page 55: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

55

Improving Vanilla FactoringImproving Vanilla FactoringGFACTORGFACTOR(F, DIVISOR, DIVIDE)(F, DIVISOR, DIVIDE)

D = DIVISOR(F) D = DIVISOR(F) if (D = 0) return F if (D = 0) return F Q = DIVIDE(F,D) Q = DIVIDE(F,D) if (|Q| = 1) return if (|Q| = 1) return LFLF(F, Q, DIVISOR, DIVIDE)(F, Q, DIVISOR, DIVIDE) else Q = make_cube_free(Q) else Q = make_cube_free(Q) (D, R) = DIVIDE(F,Q) (D, R) = DIVIDE(F,Q) if (cube_free(D)) { if (cube_free(D)) { Q = Q = GFACTORGFACTOR(Q, DIVISOR, DIVIDE)(Q, DIVISOR, DIVIDE) D = D = GFACTORGFACTOR(D, DIVISOR, DIVIDE)(D, DIVISOR, DIVIDE) R = R = GFACTORGFACTOR(R, DIVISOR, DIVIDE)(R, DIVISOR, DIVIDE) return Q x D + R } return Q x D + R }

else {else { C = common_cube(D) C = common_cube(D)

return return LFLF(F, C, DIVISOR, DIVIDE) (F, C, DIVISOR, DIVIDE)

}}

Page 56: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

56

Improving Vanilla FactoringImproving Vanilla Factoring

LFLF(F, C, DIVISOR, DIVIDE)(F, C, DIVISOR, DIVIDE) L = best_literal(F, C) L = best_literal(F, C) /* most frequent *//* most frequent */ (Q, R) = DIVIDE(F, L) (Q, R) = DIVIDE(F, L) C = common_cube(Q) C = common_cube(Q) /* largest one *//* largest one */ Q = cube_free(Q) Q = cube_free(Q) Q = GFACTOR(Q, DIVISOR, DIVIDE) Q = GFACTOR(Q, DIVISOR, DIVIDE) R = GFACTOR(R, DIVISOR, DIVIDE) R = GFACTOR(R, DIVISOR, DIVIDE) return L C Q + R return L C Q + R

Page 57: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

57

Improving the DivisorImproving the Divisor

Various kinds of factoring can be obtained by Various kinds of factoring can be obtained by choosing choosing differentdifferent forms of DIVISOR and forms of DIVISOR and DIVIDE.DIVIDE.

CHOOSE_DIVISOR:CHOOSE_DIVISOR:LITERAL - LITERAL - chooses most frequent literalchooses most frequent literal

QUICK_DIVISOR - QUICK_DIVISOR - chooses the chooses the firstfirst level-0 kernel level-0 kernel

BEST_DIVISOR - BEST_DIVISOR - chooses the chooses the bestbest kernel kernel

DIVIDE:DIVIDE:

Algebraic DivisionAlgebraic Division

Boolean DivisionBoolean Division

Page 58: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

58

Factoring algorithmsFactoring algorithms

x = ac + ad + ae + ag + bc + bd +be + bf + ce + cf + x = ac + ad + ae + ag + bc + bd +be + bf + ce + cf + df + dgdf + dg

LITERAL_FACTOR:LITERAL_FACTOR:x = a(c + d + e + g) + b(c + d + e + f) + c(e + f) + x = a(c + d + e + g) + b(c + d + e + f) + c(e + f) + d(f + g)d(f + g)

QUICK_FACTOR:QUICK_FACTOR:x = g(a + d) + (a + b)(c + d + e) + c(e + f) + f(b + d)x = g(a + d) + (a + b)(c + d + e) + c(e + f) + f(b + d)

GOOD_FACTOR:GOOD_FACTOR:(c + d + e)(a + b) + f(b + c + d) + g(a + d) + ce(c + d + e)(a + b) + f(b + c + d) + g(a + d) + ce

Page 59: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

59

QUICK_FACTORQUICK_FACTOR

QUICK_FACTORQUICK_FACTOR uses uses 1.1. GFACTOR, GFACTOR,

2.2. First level-0 kernel DIVISOR, and First level-0 kernel DIVISOR, and

3.3. WEAK_DIV.WEAK_DIV.

x = ae + afg + afh + bce + bcfg + bcfh + bde + bdfg + bcfhx = ae + afg + afh + bce + bcfg + bcfh + bde + bdfg + bcfh

D = c + d ---- D = c + d ---- level-0 kernel (level-0 kernel (hastily chosenhastily chosen))Q = x/D = b(e + f(g + h)) ---- Q = x/D = b(e + f(g + h)) ---- weak divisionweak divisionQ = e + f(g + h) ---- Q = e + f(g + h) ---- make cube-freemake cube-free(D, R) = WEAK_DIV(x, Q) ---- (D, R) = WEAK_DIV(x, Q) ---- second divisionsecond divisionD = a + b(c + d)D = a + b(c + d)x = QD + R x = QD + R R = 0R = 0

x =x = (e + f(g + h))(e + f(g + h)) (a + b(c + d))(a + b(c + d))

Page 60: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

60

Application - Application - DecompositionDecomposition

Recall:Recall: decomposition is the same as factoring decomposition is the same as factoring exceptexcept::1.1. divisors are added as divisors are added as newnew nodes in the network. nodes in the network.

2.2. the new nodes may the new nodes may fan outfan out elsewhere in the network in both positive and elsewhere in the network in both positive and negativenegative phases phases

DECOMPDECOMP(f(fii))k = CHOOSE_KERNEL(fk = CHOOSE_KERNEL(fii))if (k == 0) returnif (k == 0) returnffm+jm+j = k = k /* create new node m + j *//* create new node m + j */ffii = (f = (fii/k) y/k) ym+jm+j + (f + (fii/k’) y’/k’) y’m+jm+j + r + r /* change node i *//* change node i */

DECOMPDECOMP(f(fii))DECOMPDECOMP(f(fm+jm+j))

Similar to factoring, we can defineSimilar to factoring, we can defineQUICK_DECOMP:QUICK_DECOMP: pick a level 0 kernel and improve it. pick a level 0 kernel and improve it.

GOOD_DECOMP:GOOD_DECOMP: pick the best kernel. pick the best kernel.

Page 61: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

61

decompdecompdecomp[-gqd] [node-list]decompose all nodes in the decompose all nodes in the node-listnode-list. . If the node-list not specified, all nodes in network will be decomposed.If the node-list not specified, all nodes in network will be decomposed.

-q (defaultdefault) is specified, the quickquick decomp algorithm is use which extracts out an arbitrary kernel successfully. Because of the fastfast algorithm for generating an arbitrary kernel, decomp -q is very fast compared with decomp -g. In most cases, the results ure very close. This command is recommended at the early phase of the optimization.

-g the goodgood decomp algorithm is used which successively extracts out the best kernel until the function is factor free, and apply the same algorithm to all the kernels just extracted. This operation will give the bestbest algebraic decomposition for the nodes. But, since it generates all the kernels at each step, it takes more CPU time. In general, decomp -q should be used in the early stage of the optimization. Only at the end of the optimization, should decomp -g be used.

-d disjointdisjoint decomposition is performed. It partitions the cubes into sets of cubes having disjoint variable support, creates one node for each partition, and a root node, the OR of the partitions.

Page 62: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

62

Re-substitution (resub)Re-substitution (resub)

Idea:Idea: An An existingexisting node in a network may be a useful divisor in another node in a network may be a useful divisor in another node. If so, no loss in using it (node. If so, no loss in using it (unless delay is a factorunless delay is a factor).).

Algebraic substitutionAlgebraic substitution consists of the process of algebraically dividing the consists of the process of algebraically dividing the function ffunction fii at node i in the network by the function f at node i in the network by the function fjj (or by f’(or by f’jj)) at node at node j. During substitution, if fj. During substitution, if fjj is an algebraic divisor of f is an algebraic divisor of fii, then f, then fii is is transformed intotransformed into

ffii = qy = qyjj + r + r (or f(or fii = q = q11yyjj + q + q00y’y’jj + r ) + r )In practiceIn practice, this is tried for , this is tried for eacheach node pair of the network. n nodes in the network node pair of the network. n nodes in the network

O(nO(n22) divisions.) divisions.

ffii

ffjj

yyjj

Page 63: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

63

Boolean Re-substitution Boolean Re-substitution ExampleExample

Substituting x into F.Substituting x into F.xx = ab + cd + e= ab + cd + eFF = abf + a’cd + cdf + a’de + ef= abf + a’cd + cdf + a’de + ef

Incompletely specified function Incompletely specified function F F = (F= (F11,D,R,D,R11))DD = x’(cad + cd + e) + x(ab + cd + e)= x’(cad + cd + e) + x(ab + cd + e)FF11 = xef + xa’cd + xa’de + xabf + xcdf= xef + xa’cd + xa’de + xabf + xcdfRR11 = abf’x + aef’x + d’ef’x + a’c’e’x’ += abf’x + aef’x + d’ef’x + a’c’e’x’ +

b’c’e’x’ + a’d’e’x’ + b’d’e’x’ + acdf’ b’c’e’x’ + a’d’e’x’ + b’d’e’x’ + acdf’

SufficientSufficient variables a, d, f, x variables a, d, f, x (minvar).(minvar).FF33 = xf + xa’d + xa’d + xaf + xdf = xf + xa’d + xa’d + xaf + xdf = xf + xa’d = xf + xa’d

= x(f + a’d) = x(f + a’d)

F = (F = (ab + cd + eab + cd + e) (f + a’d) ) (f + a’d)

Page 64: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

64

resubresub

resub [-ab] [node-list]

Resubstitute each node in the node-list into all the nodes in the network. Theresubstitution will try to use both the positive and negative phase of the node.If node-list is not specified, the resubstitution will be done for every node inthe network and this operation will keep looping until no more changes of the network can be made. Note the difference between resub * and resub. Theformer will apply the resubstitution to each node only once.

- a (defaultdefault) option uses algebraicalgebraic division when substituting one node into another. The division is performed on both the divisor and it’s complement. -b uses BooleanBoolean division when substituting one node into another.

Page 65: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

65

Extraction-IExtraction-IRecall:Recall: Extraction operation identifies Extraction operation identifies commoncommon sub- sub-

expressions and manipulates the Boolean network.expressions and manipulates the Boolean network.

We can combine We can combine decompositiondecomposition and and substitutionsubstitution to to provide an effective extraction algorithm.provide an effective extraction algorithm.

EXTRACT(EXTRACT())For each node n {For each node n {

= DECOMP(n, = DECOMP(n, ))}}For each node n {For each node n {

RESUB(n, RESUB(n, ))}}Eliminate nodes with small valueEliminate nodes with small value

Page 66: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

66

Extraction-IIExtraction-II

Kernel Extraction:Kernel Extraction:1. Find 1. Find allall kernels of all functions kernels of all functions2. 2. ChooseChoose kernel intersection with best “value” kernel intersection with best “value”3. 3. CreateCreate new node with this as function new node with this as function4. Algebraically 4. Algebraically substitutesubstitute new node everywhere new node everywhere5. Repeat 1,2,3,4 until best value 5. Repeat 1,2,3,4 until best value threshold threshold

New NodeNew Node

Page 67: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

67

Example-ExtractionExample-Extractionff11 = ab(c(d + e) + f + g) + h = ab(c(d + e) + f + g) + h

ff22 = ai(c(d + e) + f + j) + k = ai(c(d + e) + f + j) + konly level-0 kernels used in this exampleonly level-0 kernels used in this example

Extraction:Extraction: KK00(f(f11) = K) = K00(f(f22) = {d + e}) = {d + e}l l = d + e f= d + e f11 = ab(c = ab(cll + f + g) + h + f + g) + h

ff22 = ai(c = ai(cl l + f + j) + k+ f + j) + k

Extraction:Extraction:

KK00(f(f11) = {cl + f + g} K) = {cl + f + g} K00(f(f22) = {cl + f + j}) = {cl + f + j}

KK00(f(f11) ) K K00(f(f22) = cl + f) = cl + f

mm = cl + f = cl + f

ff11 = ab( = ab(m m + g) + h+ g) + h

ff22 = ai( = ai(mm + j) + k + j) + k

Note:Note: no kernel intersections no kernel intersections at this point. at this point.

cube extraction:cube extraction:nn = am = amff11 = b( = b(nn + ag) + h + ag) + hff22 = i( = i(nn + aj) + k + aj) + k

Page 68: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

68

gkxgkxgkx [-1abcdfo] [-t threshold]Extract multiple-cube common divisors from the network.Extract multiple-cube common divisors from the network.-a generates all kernels of all function in the network.-b chooses the best kernel intersection as the new factor at each step of the algorithm; this is done by enumerating and considering each possible kernel intersection, and choosing the best.-c uses the new factor and its complement when attempting to introduce the new factor into the network.-d enables debugging information which traces the execution of the kernel extract algorithm.-f uses the number of literals in the factored form for the network as the cost function when determining the value of a kernel intersection.-o allows for overlapping factors.-t sets a threshold such that divisors are extracted only while their value exceeds the threshold.-1 performs only a single pass over the network

Page 69: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

69

script.algebraicscript.algebraic

sweepeliminate 5simplify -m nocomp -dsimplify -m nocomp -dresub -a

gkx -abt 30resub -a; sweepgcx -bt 30resub -a; sweep

gkx -abt 10resub -a; sweepgcx -bt 10resub -a; sweep

gkx -abresub -a; sweepgcx -bresub -a; sweep

eliminate 0decomp -g *

Page 70: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

70

Faster “Kernel” ExtractionFaster “Kernel” Extraction

Non-robustnessNon-robustness of kernel extraction of kernel extraction– Recomputation of kernels after every substitution: Recomputation of kernels after every substitution:

expensiveexpensive– Some functions may have many kernels (e.g. Some functions may have many kernels (e.g.

symmetric functions).symmetric functions).

Two-cube “kernel”Two-cube “kernel” extraction [Rajski et al ‘90] extraction [Rajski et al ‘90]– Objects:Objects:

• 2-cube divisors2-cube divisors• 2-literal cube divisors2-literal cube divisors

– Example:Example: f = abd + a’b’d + a’cd f = abd + a’b’d + a’cd• ab + a’b’, b’ + c and ab + a’c are 2-cube divisors.ab + a’b’, b’ + c and ab + a’c are 2-cube divisors.• a’d is a 2-literal cube divisor.a’d is a 2-literal cube divisor.

Page 71: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

71

Fast Divisor ExtractionFast Divisor Extraction

FeaturesFeaturesO(nO(n22)) number of 2-cube divisors in an n-cube Boolean number of 2-cube divisors in an n-cube Boolean

expression.expression.

ConcurrentConcurrent extraction of 2-cube divisors extraction of 2-cube divisors andand 2-literal 2-literal cube divisors.cube divisors.

Some complementSome complement divisors recognized in each step divisors recognized in each step during the synthesis, thus no algebraic during the synthesis, thus no algebraic resubstitution needed.resubstitution needed.Example:Example: f = abd + a’b’d + a’cd. f = abd + a’b’d + a’cd.

k = ab + a’b’, k’ = ab’ + a’b k = ab + a’b’, k’ = ab’ + a’b (both 2-cube divisors)(both 2-cube divisors)

j = ab + a’c, j’ = a’b’ + ac’ j = ab + a’c, j’ = a’b’ + ac’ (both 2-cube divisors)(both 2-cube divisors)

c = ab c = ab (2-literal cube)(2-literal cube), c’ = a’ + b’ , c’ = a’ + b’ (2-cube divisor)(2-cube divisor)

Page 72: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

72

Generating all 2-cube Generating all 2-cube divisorsdivisors

F = {cF = {cii}}

D(F) = {d | d = make_cube_free(cD(F) = {d | d = make_cube_free(c ii + c + cjj)})}

This just takes all pairs of cubes in F and makes them cube-This just takes all pairs of cubes in F and makes them cube-free.free.

ccii, c, cjj are any pair of cubes of cubes in F are any pair of cubes of cubes in FDivisor generation is O(nDivisor generation is O(n22),),where n = number of cubes in Fwhere n = number of cubes in F

Example:Example: F = axe + ag + bcxe + bcg F = axe + ag + bcxe + bcgmake_cube_free(make_cube_free(ccii + c + cjj) = ) =

{xe + g, a + bc, axe + bcg, ag + bcxe}{xe + g, a + bc, axe + bcg, ag + bcxe}

Notes:Notes: (1) the function F is made an algebraic expression (1) the function F is made an algebraic expression before generating double-cube divisors. before generating double-cube divisors.

(2) not all 2-cube divisors are kernels.(2) not all 2-cube divisors are kernels.

Page 73: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

73

Key result for 2-cube Key result for 2-cube divisorsdivisors

THEOREM 23:THEOREM 23: Expressions F and G have a common Expressions F and G have a common multiple-cube divisors multiple-cube divisors if and onlyif and only ifif D(F) D(F) D(G) D(G) 0. 0.

Proof.Proof.

If part:If part: If D(F) If D(F) D(G) D(G) 0 then 0 then d d D(F) D(F) D(G) which is a D(G) which is a double-cube divisor of F and G. d is a multiple-cube double-cube divisor of F and G. d is a multiple-cube divisor of F and of G.divisor of F and of G.

Only if part:Only if part: Suppose C = {c Suppose C = {c11, c, c22, ..., c, ..., cmm} is a multiple-cube } is a multiple-cube divisor of F and of G. Take any e = cdivisor of F and of G. Take any e = c ii = c = cjj C. If e is C. If e is cube-free, then e cube-free, then e D(F) D(F) D(G). If e is not cube-free, D(G). If e is not cube-free, then let d = make_cube_free(cthen let d = make_cube_free(c ii + c + cjj). d has 2 cubes ). d has 2 cubes since F and G are algebraic expressions. Hence d since F and G are algebraic expressions. Hence d D(F) D(F) D(G). D(G).

Page 74: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

74

Key result for 2-cube Key result for 2-cube divisorsdivisors

Example:Example: Suppose that Suppose that C = ab + ac + fC = ab + ac + f is is a multiple divisor of F and G.a multiple divisor of F and G.If e = ac + f, e is cube-free and e If e = ac + f, e is cube-free and e D(F) D(F) D(G). D(G).If e = ab + ac, d = {b + c} If e = ab + ac, d = {b + c} D(F) D(F) D(G) D(G)

As a result of the Theorem, all multiple-As a result of the Theorem, all multiple-cube divisors can be “discovered” by cube divisors can be “discovered” by using just double-cube divisors.using just double-cube divisors.

Page 75: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

75

Fast Kernel ExtractionFast Kernel ExtractionAlgorithm:Algorithm:

GenerateGenerate and store all 2-cube kernels (2-literal cubes) and recognize and store all 2-cube kernels (2-literal cubes) and recognize complement divisors.complement divisors.

Find the Find the bestbest 2-cube kernel or 2-literal cube divisor at each stage and 2-cube kernel or 2-literal cube divisor at each stage and extract it.extract it.

UpdateUpdate 2-cube divisor set after extraction 2-cube divisor set after extraction

IteratateIteratate extraction of divisors until no more improvement extraction of divisors until no more improvement

Results:Results:Much Much fasterfaster..

QualityQuality as good as that of kernel extraction. as good as that of kernel extraction.

On a set of examples: On a set of examples: – fast extract gives 9563 literals, general kernel extraction 9732, fast extract gives 9563 literals, general kernel extraction 9732, – fast extract was 20 times faster.fast extract was 20 times faster.

Page 76: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

76

fast_extractfast_extractfx [-o] [-b limit] [-l] [-z]

Greedy concurrent algorithm for finding the best double cube divisorsGreedy concurrent algorithm for finding the best double cube divisorsand single cube divisors. Finds all the double cube and single cube divisorsand single cube divisors. Finds all the double cube and single cube divisorsof the nodes in the network. It associates a value to each node,of the nodes in the network. It associates a value to each node,and extracts the node with the best value greedily.and extracts the node with the best value greedily.

-o only looks for 0-level0-level two-cube divisors.

-b reads an upper boundbound for the number of divisors generated.

-l changes the levellevel of each node in the network as allowed by the slack between the required time and arrival time at that node.

-z uses zerozero-value divisors (in addition to divisors with a larger weight). This means that divisors that contribute zero gain to the overall decomposition are extracted. This may result in an overall better decomposition but takes an exorbitant amount of time.

Page 77: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

77

script.ruggedscript.ruggedsweep; eliminate -1simplify -m nocompeliminate -1

sweep; eliminate 5simplify -m nocompresub -a

fxresub -a; sweep

eliminate -1; sweepfull_simplify -m nocomp

Page 78: 1 Outline Division is central in many operations. –What is it (in the context of Boolean functions)? –What to divide (divisor) with? –How to divide (quotient.

78

End End