# 1

Consensus
Definition Let w, x, y, z be cubes, and a
be a variable such that
w = ax and y = a’z
Then the cube xz is called the consensus
cube of w and y
In particular, w + y = w + y + xz

Example: ab + a’c = ab + a’c + bc
a
c
b
=
2
Quine-McCluskey Summary
Q-M:
1. Generate cover of all primes
2. Make G irredundant (in optimum way)
Note: Q-M is exact i.e. it gives an exact minimum
Heuristic Methods:
1. Generate (somehow) a cover of · using some of
the primes
2. Make G irredundant (maybe not optimally)
3. Keep best result - try again (i.e. go to 1)
n
n
p p p G
/ 3
2 1
+ + + = 
k
i i i
p p p G + + + = 
2 1
3
ESPRESSO - Heuristic Two-Level
Minimization
ESPRESSO( )
{
(F,D,R) DECODE( )
F EXPAND(F,R)
F IRREDUNDANT(F,D)
E ESSENTIAL_PRIMES(F,D)
F F-E; D D E
do{
do{
F REDUCE(F,D)
F EXPAND(F,R)

F IR
÷
·
÷ ·
÷
÷
÷
+
÷
÷
÷ ÷
}while few
REDUND
er ter
ANT
ms
(F,D)
in F
//LASTGASP
G REDUCE_GASP(F,D)
G EXPAND(G,R)
F IRREDUNDANT(F G,D)

}while G
F F E; D D-E
LOWER_OUTPUT(F,D)
RAISE_I
//LASTGAS
NPUTS(F,R)

P
erro
= C
+
÷
÷
÷
÷
÷ +
on old
r (F F) or (F F D)
return (F,error)
}
÷ . . +
4
ESPRESSO Illustrated
minimum Local
REDUCE
EXPAND
minimum Local
T IRREDUNDAN
5
IRREDUNDANT
Problem:
Given a cover of cubes {c
i
}, find a minimal subset {ci
k
}
that is also a cover, i.e.
d f c f
k
i
+ _ _
¿
Idea:
We are going to create a function g(y) and a new set of
variables y
i
, one for each cube c
i
. A minterm in the y-
space will indicate a subset of the cubes {c
i
}.
Example 1:
y=011010 = {c
2
,c
3
,c
5
}
6
IRREDUNDANT
Idea 2:
Create g(y) so that it is the function such that:

g(y) = 1 · is a cover

i.e. if g(y
k
) = 1 if and only if {c
i
| y
k
i
=1} is a cover.

Note: g(y) is positive unate (monotone increasing) in all
its variables.
1
k
i
k
i
y
c
=
¿
7
Example
c b b a c a bc f + + + =
Example 2:

) ( ) , , , (
3 2 4 1 4 3 2 1
y y y y y y y y g + =
Note:
We are after a minimum subset of cubes. Thus we want:
the largest prime of g (least literals).
Consider g : it is monotone decreasing in y, e.g.
3 2 4 1 4 3 2 1
) , , , ( y y y y y y y y g + + =
1
2
3
4
8
Example
Example 3: {1,2,4} ¬ y
1
y
2
y
4
(i.e. cubes 1,2,4)
Create a Boolean matrix for g:
{ } c b c, a bc, ¬
• Recall a minimal column cover of B is a prime of

• We want a minimal column cover of B
( ) g g =
c b b a c a bc f + + + =
3 2 4 1 4 3 2 1
) , , , ( y y y y y y y y g + + =
9
Deriving g(y)
Modify tautology algorithm:
F = cover of ·=(f,d,r)
D = cover of d

Pick a cube c
i
e F.
(Note: c
i
_ F · F
c
i
÷ 1)

Do the following for each
cube c
i
_ F :
i
i
C
C
F
A
D
B
(
(
÷
(
(
¸ ¸
¸ ¸
10
Deriving g(y)
1. All leaves will be tautologies
2. g means how can we make it not
the tautology. We must exactly
delete all rows of all 2‟s that
are not part of D
3. Each row of all 2‟s came from
some row of A/B
4. Each row of A is associated with some cube of F.
5. Each cube of B associated with some cube of D ( we
don‟t need to know which, and we can‟t delete its rows).
6. Rows that must be deleted are written as a cube, e.g.
y
1
y
2
y
7
¬ delete rows 1,3,7 of F.
11
Example 4: Suppose unate leaf is in
subspace x
1
x‟
2
x
3
:
Thus we write down: y
10
y
18
(actually, y
i

must be one of y
10 ,
y
18
). Thus, F is not a
cover if we leave out cubes c
10
,

c
18
.
Row of all 2‟s
in don‟t cares
Note: If row of all 2‟s in
don‟t cares,
then there is no way
not to have tautology at
that leaf. So in the
example to the right,
we do not write y
10
y
18

Unate leaf
Deriving g(y)
12
(
¸
(

¸

D
F
c
i
c
j

) ( y g
i ) ( y g
j
 + + = ) ( ) ( ) ( y g y g y g
j i
x
1

x
2
x
3

10 18
( )
i
g y y y = +
Deriving g(y)
13
Summary
Convert g(y) into a Boolean matrix B (note that g(y) is
unate). Then find a minimum cover of B. For example,
if y
1
y
3
y
18
is a minimum cover, then the set of cubes:
{c
1
, c
3
, c
18
}
is a minimum sub cover of { c
i
| i=1,…,k}. (Recall that a
minimal cover of B is a prime of g(y), and g(y) gives all
possible sub-covers of F).
Note: We are just checking for tautology, so unate
reduction can be used as well…
14
Back to Q-M
We want a maximum prime of g(y).
Note: A row of B says if we leave out primes
{p
1
, p
3
, p
4
, p
6
}
we cease to have a cover.
(
(
(
(
(
¸
(

¸

1011010
All primes
B = Minterms
of f
 + = ~
6 4 3 1
) ( y y y y y g B
So basically, the only difference between Q-M and IRREDUNDANT
is that for the latter, we just constructed a g(y) where we did
not consider all primes, but only those in some cover:
F = {c
1
, c
3
,…, c
k
}
15
EXPAND
Problem: Take a cube c and make it prime by removing
literals.

a). Greedy way which we saw earlier: (uses D and not R)
R) EXPAND(F, F÷
- ÷
- _ + + ÷
-
remove literal from c (results in )
test if (same as 1)
repeat, removing valid literals in order found.
c
c c
c f d (f d)
i
l
16
EXPAND
R) EXPAND(F, F÷
b). Better way: (uses R and not D)
Want to see all possible ways to remove maximal
subset of literals.
Idea: Create a function g(y) such that g(y)=1 iff
literals:

can be removed without hitting R.
} 0 | { =
i i
y l
C = · + _
=
r c d f c
y l
i i
~
,
~
} 1 | {
i.e.
make still will c, in kept if that such
literals of subset a is or
17
Main Idea of EXPAND
Outline:
1. Expand one cube, c
i
, at a time
2. Build “blocking” matrix B = B
c
i

3. See which other cubes c
j
can be feasibly
covered using B.
4. Choose expansion (literals to be removed) to
cover most other c
j
.

Note:
-
- ~
-
( ) is monotone increasing
( ) is easily built if we have , a cover of .
We do not need all of (reduced offset) .
g y
B g y R r
R
18
Blocking Matrix B (for cube C)
Given R = {r
i
}, a cover of r. [ · = (f,d,r) ]
¦
¹
¦
´
¦
e e
e e
· =
i j j
i j j
ij
r l C l
r l C l
B
and
and
1
What does row i of B say?
{ }
=
· = C =
ij
i ij
i
j | B c
c r B c
r
It says that if literals 1 are removed from ,
then , i.e. 1 is one reason why is
orthogonal to offset cube .
( ) C = ·
+ .
+ = ÷
r c
d f c
y y y y g B
~
~
) (
10 3 1
get to removed be can c of literals
that ways all gives Thus 
19
EXPAND example
d y
b y
a y
keep 1
keep 1
keep 1
3
2
1
· =
· =
· =
( ) (y) g y y B
i
= + = = 
3 1 1
101
B
1
means if do not keep literals 1 and 3 of c, then the
subsequent is not an implicant). If literals 1, 3 are
removed we get . But :

so obviously b is not an implicant since it has an non-null
intersection with R.
c
~
b c c = ÷
~
C = ·
i
r c
~
C = = × e bd a e bd a b
Suppose c = abd, and r
1
= abde, r
2
= abe. Then we
first construct y
1
, y
2
, y
3
corresponding to a, b, d
respectively. Their meaning is:

So B is:
(
¸
(

¸

=
010
101
B
20
EXPAND continued
Thus all minimal column covers ( ~ g(y) ) of B are the
minimal subsets of literals of c that must be kept to
ensure that

Thus each minimal column cover is a prime p that covers
c, i.e. p _ c.
_ + · = C
i
c f d c r ( i.e. )
1
p
2
p
3
p
c
c p
i
_
21
Expanding c
i

F = { c
i
}, · = (f,d,r) f _ F _ f+d
Q: Why do we want to expand c
i
?
A: To cover some other c
j
„s.

Q: Can we cover c
j
?
A: If and only if (SCC = “smallest cube containing” also called
“supercube” )

equivalent to:

equivalent to:
literals ”conflicting” between c
i
, c
j
can be removed and still have
an implicant
( ) d f c c SCC
j i
+ _
i
c
j
c
p
( ) C = ·
i j i
r c c SCC
22
Expanding c
i

Can check SCC(c
i
, c
j
) with blocking matrix:
c
i
= 12012
c
j
= 12120

implies that literals 3 and 4 must be removed for
to cover c
j
.
So check if column 3, 4 of B can be removed
without causing a row of all 0‟s. If so, c
i
can be
expanded to cover c
j
i
c
~
i
c
j
c
p
23
Covering function
The objective of EXPAND is to expand c
i
to cover as
many cubes c
j
as possible. The blocking function
g(y)=1 whenever the subset of literals
yields a cube . (Note that ).

We now build the covering function,h , such that:
h(y) = 1
whenever the cube covers another cube c
j
_ F.
Note: h(y) is easy to build.
Thus a minterm m e g(y) h(y) is such that it gives
( g(m) =1 ) and covers at least one cube
(h(m) =1). In fact every cube is covered. We
seek m which results in the most cubes covered.
i
c c _
~
} 1 | { =
i i
y l
d f c + .
~
[
=
=
) 1 (
~
j
y
j
l c
d f c + _
~
l m
c c _
~
24
Covering function
Thus define h(y) by a set of cubes where d
k
= k
th
cube is:

(Thus each d
k
gives minimal expansion to cover c
k
)
Thus d
k
= C if cube c
k
can be feasibly covered by expanding cube c
i
.
d
k
says which literals we have leave out to minimally cover c
k
.
Thus h(y) is defined by h(y) = d
1
+ d
2
+… + d
|F|-1
(one for each cube
of F, except c
i
itself. It is monotone decreasing).
if [ ] else
2 1
if i.e. 0 1
1 0
2 otherwise
k i k
j j
j k i
j
k
d SCC c c f d
y c c
d
= C . +
¦ .
¦
¦ ¦
. .
¦ ´
=
´
¦
.
¹
¦
¦
¹
25
Covering function
We want m e g(y)h(y) contained in a maximum number of
d
k
„s.
In Espresso, we build a Boolean covering matrix C (note
that h(y) is unate negative) representing h(y) and solve
this problem with greedy heuristics.

Note:
¦
¦
¦
)
¦
¦
¦
`
¹
¦
¦
¦
¹
¦
¦
¦
´
¦
=
¦
¦
¦
)
¦
¦
¦
`
¹
¦
¦
¦
¹
¦
¦
¦
´
¦
=

101001
101010
110110
100101
101011
010110
B C ) ( ) (
~
) (
y h y h C
y g B
_ ~
~
but

26
Covering function
Want set of columns such that if eliminated from B and C
results in no empty rows of B (i.e. a valid expansion)
and a maximum of empty rows in C (i.e. an expansion
that covers as many other cubes as possible)
Note:
a 1 in C can be interpreted as a reason why does not
cover c
j
.
¦
¦
¦
)
¦
¦
¦
`
¹
¦
¦
¦
¹
¦
¦
¦
´
¦
=
¦
¦
¦
)
¦
¦
¦
`
¹
¦
¦
¦
¹
¦
¦
¦
´
¦
=

101001
101010
110110
100101
101011
010110
B C
c
~
27
Endgame
What do we do if h(y) ÷ 0 ?
Some things to try:
• generate largest prime covering c
i
• cover most care points of another cube c
k

• coordinate two or more cube expansions, i.e. try to cover
another cube by a combination of several other cube expansions

So far we have not come up with a really satisfactory
endgame. This could be important in many hard
problems, since it is often the case that h(y) ÷ 0 .
28
REDUCE
Problem: Given a cover F and c e F, find the smallest
cube c _ c such that
F\{ c } + { c }
is still a cover. c is called the maximally reduced cube
of c.
off
on
Don’t care
GOOD
REDUCE is
order dependent
29
REDUCE Example
Example 5:

Two orders:

REDUCE is order dependent !
c a c b bc ac F + + + =
{ }
( )
{ }
( )
= = + + +
= = + + +
F ac bc bc ac abc bc abc ac
F bc bc ac ac abc ac abc ac
1. REDUCE , , ,
2. REDUCE , , ,
GOOD
30
REDUCE Algorithm
( )
÷
s s
÷
÷
j
j j
F D
F
c
c c
REDUCE , {
F ORDER( F)
for (1 j ) do {
MAX_REDUCE( c, F, D)
F (F { }) \ { }
}
return F
}
31
REDUCE
Main Idea: Make a prime not a prime but still maintain
cover:
{c
1
,…, c
i
,…, c
k
} ÷ {c
1
,…,c
i
,c
i+1
,…,c
k
}
But ÷
= = +
_ + + _ +
¿ ¿
i k
i j j
j j i
f c c c f d
1
0 1
• Get out of a local minimum (prime and
irredundant is local minimum)
• Then have nonprimes, so can expand
again in different directions. (Since
EXPAND is “smart”, it may know best
direction)
32
REDUCE
F = {c
1
,c
2
,

…,c
k
}
F (i) = (F + D) \ {

c
i
}
Reduced cube:
c
i
= smallest cube containing (c
i
·F(i) )

• Note that c
i
·F(i) is the set of points uniquely covered
by c
i
(and not by any other c
j
or D).
• Thus, c
i
is the smallest cube containing the minterms of
c
i
which are not in F(i).
33
( )
( )
( )
( )
=
=
=
=
i
i
i
i i
i c
i c
i c
c SCC c F i
SCC c F i
c SCC F i
c SCCC F i
( )
( )
( )
( )
REDUCE

• SCC == “supercube”
• SCCC = “smallest cube containing complement”
2
C
1
C
2
C
1
C
off
on
Don’t care
34
Efficient Algorithm for SCCC
• select most binate variable
• cofactor
• until unate leaf

What is SCCC (unate cover) ?
• Note that for a cube c with at least 2 literals,
SCCC(c) is the universe:
1
x
1
x
2
x
2
x
3
x
3
x
01222 cube =
20222
12222
cube =
unate
So SCCC(cube) = 22222
35
SCCC
SCCC (U) = ¸
Claim: if unate cover has row of
– all 2‟s except one 0, then complement is in x
i
, i.e. ¸
i
= 1
– all 2‟s except one 1, complement is in x
i
, i.e. ¸
i
= 0
otherwise in both subspaces, i.e. ¸
i
= 2

Finally

Implies that only need to look at 1-literal cubes.
( ) ( )
( ) ( )
1 2 1 2
1
k k
k
SCCC c c c SCC c c c
SCC c SCC c
+ + + =
=
36
SCCC Example
Example1:

Note: 0101 and 0001 are both inf . So SCCC could not have literal
b or b in it.

Example2:

Note that columns 1 and 5 are essential: they must be in every
minimal cover. So U = x
1
x
5
(...). Hence SCCC(U) = x
1
x
5
d a d c b a f d bc a f _ + = ¬ + + = ) (
=
| |
U unate
2 2 2 2
2 2 2 2
( ) 2 1 1 2 2
2 1 2 1 0
0
0
37
SCCC Example
Proof. (sketch):

The marked columns contain both 0‟s and 1‟s. But every prime ofU
contains literals x
1
,

x
5
1 5 2 3 4
1 5 2 3 4
( )
( )
1 0 2 2 1
( ) 1 2 0 0 1 12221
U x x x x x
U x x x x x
U unate
| | |
= + + +
= +
= _
1 0 1 1 1
1 0 0 1 1
1 0 1 0 1
minterms of
1 0 0 0 1
1 0 0 0 1
1 1 0 0 1
= U
38
SCCC
Thus

Thus unate leaf is easy !

SCCC(unate) if row of all 2's
if column has a row singleton with a 0 in it
if column has a row singleton with a 1 in it
2 otherwise
j
j
j
γ
x j
γ x j
= = C
=

¦
¦
´
¦
¹
39
Merging
We need to produce

( ) ( )
¸ = + =
i i
SCCC f SCC x c x c
1 2
¸
¸
¸
¸
=
=
e · = C
e · = C
e · e . e
k
i
i
j i j j
l l l
x c
x c
l l c l c
1 2
2
1
1 2
( ) ( )
If c
1
. c
2
= C, then points in both x
i
andx
j
, so
( SCC(x
i
c
1
+x
i
c
2
) )
i
= 2
If l
j
ec
1
, or l
j
ec
2
, then both x
j
andx
j
points exit, hence ¸
j
=2.
Also if l
j
ec
1
and l
j
ec
2
, then ¸
j
=2.
40
ESPRESSO - Heuristic
Two-Level Minimization
F in terms fewer }while
D) T(F, IRREDUNDAN F
R) EXPAND(F, F
D) REDUCE(F, F
do{
do{
E D D E; - F F
D) PRIMES(F, ESSENTIAL_ E
D) T(F, IRREDUNDAN F
R) EXPAND(F, F
) DECODE( R) D, (F,
{
) ESPRESSO(
÷
÷
÷
+ ÷ ÷
÷
÷
÷
· ÷
·
÷
÷
÷ +
= C
÷ + ÷
//LASTGASP
G REDUCE_GASP(F,D)
G EXPAND(G,R)
F IRREDUNDANT(F G,D)

}while G
F F E; D D-E
LOWER_OUTPUT(F,D)
RAISE_INPUTS(F,R
/
)
/LASTG

ASP
erro ÷ . . +
on old
r (F F) or (F F D)
return(F,error)
}
41
LASTGASP
Reduce is order dependent:
Expand can‟t do anything with the
reduction produced by
REDUCE 2.

Maximal Reduce:
1
REDUCE
2
REDUCE
i.e. we reduce all cubes as if each were the first one.
Note:
{c
1
M

,c
2
M
,...} is not a cover.
GOOD
i
i
c
i F SCCC
i
c i F
i
c SCC
M
i
c ¬ = = ) ) ( ( ) ) ( (  
42
LASTGASP
Now expand use EXPAND, but try to cover only c
j
M
„s. (Note here
we call EXPAND(G,R), where G = {c
1
M

,c
2
M
,…, c
k
M
} ) If a covering
is possible, take the resulting prime:

Since F is a cover, so is . Now make irredundant (using
IRREDUNDANT).
M
j
M
i i
c c p d f  _ _ +
} {
~
i
p F F  =
Main Idea: Generally, think of ways
to throw in a few more primes
and then use IRREDUNDANT. If
generate all primes, then just
Quine-McCluskey
F F

Quine-McCluskey Summary
Q-M:
1. Generate cover of all primes G  p1  p2    p3n / n 2. Make G irredundant (in optimum way) Note: Q-M is exact i.e. it gives an exact minimum

Heuristic Methods:
1. 2. 3. Generate (somehow) a cover of  using some of the primes G  pi  pi    pi 1 2 k Make G irredundant (maybe not optimally) Keep best result - try again (i.e. go to 1)
2

ESPRESSO() {

ESPRESSO - Heuristic Two-Level Minimization
//LASTGASP G  REDUCE_GASP(F,D) G  EXPAND(G,R) F  IRREDUNDANT(F  G,D) //LASTGASP }while G   F  F  E; D  D-E LOWER_OUTPUT(F,D) RAISE_INPUTS(F,R) error  (Fon  F) or (F  Fold  D) return (F,error)
3

(F,D,R)  DECODE() F  EXPAND(F,R) F  IRREDUNDANT(F,D) E  ESSENTIAL_PRIMES(F,D) F  F-E; D  D  E do{ do{ F  REDUCE(F,D) F  EXPAND(F,R) F  IRREDUNDANT(F,D) } }while fewer terms in F

ESPRESSO Illustrated

REDUCE

Local minimum

EXPAND

IRREDUNDAN T Local minimum
4

i.c3. Example 1: y=011010 = {c2. one for each cube ci. A minterm in the yspace will indicate a subset of the cubes {ci}.c5} 5 . f   cik  f  d Idea: We are going to create a function g(y) and a new set of variables yi.IRREDUNDANT Problem: Given a cover of cubes {ci}. find a minimal subset {cik} that is also a cover.e.

IRREDUNDANT Idea 2: Create g(y) so that it is the function such that: g(y) = 1  yik 1 c ik is a cover i. if g(yk) = 1 if and only if {ci | yki =1} is a cover.e. 6 . Note: g(y) is positive unate (monotone increasing) in all its variables.

e. y3 .Example Example 2: 2 3 1 f  bc  a c  a b  b c g ( y1 . Thus we want: the largest prime of g (least literals). y3 . y4 )  y1  y4  y2 y3 7 . y4 )  y1 y4 ( y2  y3 ) Note: 4 We are after a minimum subset of cubes.g. y2 . Consider g : it is monotone decreasing in y. g ( y1 . y2 .

2.b c  8 . y2 .e. y3 .4}  y1 y2 y4 (i.Example Create a Boolean matrix for g: f  bc  a c  a b  b c g ( y1 .a c.4)   bc. y4 )  y1  y4  y2 y3 • Recall a minimal column cover of B is a prime of • We want a minimal column cover of B g  (g) Example 3: {1.2. cubes 1.

(Note: ci  F  Fci  1) Do the following for each cube ci  F :  A  FCi  B  D     Ci  9 .r) D = cover of d Pick a cube ci  F.d.Deriving g(y) Modify tautology algorithm: F = cover of =(f.

7 of F. y1y2y7  delete rows 1. Each cube of B associated with some cube of D ( we don‟t need to know which. e.g. We must exactly delete all rows of all 2‟s that are not part of D 3. Each row of all 2‟s came from some row of A/B 4. Each row of A is associated with some cube of F. All leaves will be tautologies 2. and we can‟t delete its rows). 5. 6.Deriving g(y) 1. g means how can we make it not the tautology. 10 . Rows that must be deleted are written as a cube.3.

we do not write y10 y18 Unate leaf Row of all 2‟s in don‟t cares 11 . then there is no way not to have tautology at that leaf. F is not a cover if we leave out cubes c10 . Thus. So in the example to the right. yi must be one of y10 . y18). c18.Deriving g(y) Example 4: Suppose unate leaf is in subspace x1x‟2x3 : Thus we write down: y10 y18 (actually. Note: If row of all 2‟s in don‟t cares.

Deriving g(y) g ( y)  gi ( y)  g j ( y)   gi ( y)  y10 y18  gi ( y) ci F  D    cj g j ( y) x1 x2 x3 12 .

…. if y1y3y18 is a minimum cover. c18 } is a minimum sub cover of { ci | i=1. c3 .Summary Convert g(y) into a Boolean matrix B (note that g(y) is unate). and g(y) gives all possible sub-covers of F). For example. Note: We are just checking for tautology. (Recall that a minimal cover of B is a prime of g(y). then the set of cubes: {c1 . Then find a minimum cover of B. so unate reduction can be used as well… 13 .k}.

Note: A row of B says if we leave out primes {p1 . p4 . c3 . p3 .Back to Q-M All primes B= Minterms of f We want a maximum prime of g(y). but only those in some cover: F = {c1 .…. the only difference between Q-M and IRREDUNDANT is that for the latter. we just constructed a g(y) where we did not consider all primes. ck } 14 1011010                  B  g ( y)  y1 y3 y4 y6   . p6 } we cease to have a cover. So basically.

EXPAND F  EXPAND(F. removing valid literals in order found. 15 . a).R) Problem: Take a cube c and make it prime by removing literals. Greedy way which we saw earlier: (uses D and not R)  remove literal l i from c (results in c  c )  test if c  f  d (same as (f  d)c  1)  repeat.

c  r   16 . Better way: (uses R and not D) Want to see all possible ways to remove maximal subset of literals. Idea: Create a function g(y) such that g(y)=1 iff literals: {li | yi  0} can be removed without hitting R.e. will still make ~ ~ c  f  d .R) b). or {li | yi  1} is a subset of literals such that if kept in c. i.EXPAND F  EXPAND(F.

4. ci . (reduced offset) . See which other cubes cj can be feasibly covered using B. a cover of r . Note:  g (y ) is monotone increasing  B  g (y ) is easily built if we have R . Choose expansion (literals to be removed) to cover most other cj . 17  We do not need all of R . Expand one cube.Main Idea of EXPAND Outline: 1. at a time 2. Build “blocking” matrix B = B ci 3.

Blocking Matrix B (for cube C) Given R = {ri }.d. i. Bij  1 is one reason why c is orthogonal to offset cube ri . [  = (f. a cover of r. then c  ri  .e. Thus B  g ( y )  y1 y3 y10   gives all ways that ~ literals of c can be removed to get c  f  d ~ c  r   18 .r) ] l j  C and l j  ri  Bij  1   l j  C and l j  ri  What does row i of B say? It says that if literals j | Bij  1 are removed from c.

y2. Then we first construct y1. But c  ri   : so obviously b is not an implicant since it has an non-null intersection with R. r2 = abe. d respectively.Suppose c = abd. y3 corresponding to a. 3 are ~ ~ removed we get c  c  b . b. and r1 = abde. then the ~ subsequent c is not an implicant). If literals 1. b  a bde  a bde   19 . Their meaning is: y1  1  keep a EXPAND example y2  1  keep b So B is: y3  1  keep d 101  B 010   B1   101  y1 y3    gi(y) B1 means if do not keep literals 1 and 3 of c.

EXPAND continued Thus all minimal column covers (  g(y) ) of B are the minimal subsets of literals of c that must be kept to ensure that c  f  d ( i. p  c. p1 p2 c p3 pi  c 20 .e.e. i. c  ri   ) Thus each minimal column cover is a prime p that covers c.

Expanding ci F = { ci }.r) f  F  f+d Q: Why do we want to expand ci ? A: To cover some other cj „s. cj can be removed and still have an implicant 21 . ci p cj Q: Can we cover cj ? A: If and only if (SCC = “smallest cube containing” also called “supercube” ) equivalent to: equivalent to: SCC ci  c j   f  d SCC ci  c j   ri   literals ”conflicting” between ci.  = (f.d.

If so. So check if column 3. cj) with blocking matrix: ci = 12012 cj = 12120 implies that literals 3 and 4 must be removed for to cover cj . 4 of B can be removed without causing a row of all 0‟s. ci can be expanded to cover cj ~ ci ci p cj 22 .Expanding ci Can check SCC(ci.

such that: h(y) = 1 ~ whenever the cube c  ci covers another cube cj  F. We seek m which results in the most cubes covered. In fact every cube cm  cl is covered. Note: h(y) is easy to build. Thus a minterm m  g(y) h(y) is such that it gives ~ c  f  d ( g(m) =1 ) and covers at least one cube ~ (h(m) =1). 23 . The blocking function g(y)=1 whenever the subset of literals {li | yi  1} ~ ~ yields a cube c  f  d. (Note that c   l j).h . ( y j 1) We now build the covering function.Covering function The objective of EXPAND is to expand ci to cover as many cubes cj as possible.

Thus h(y) is defined by h(y) = d1 + d2 +… + d|F|-1 (one for each cube of F. 24 . except ci itself. It is monotone decreasing).Covering function Thus define h(y) by a set of cubes where dk = kth cube is: d k   if SCC[ci  ck ]  f  d else    j dk      2  1  y j if ckj  cij i. dk says which literals we have leave out to minimally cover ck .e. 0  1 1  0  2 otherwise (Thus each dk gives minimal expansion to cover ck ) Thus dk   if cube ck can be feasibly covered by expanding cube ci.

   010110 B  g ( y)   ~   but C  h ( y)  h( y) C  101011 100101           110110     B  101010 101001        25 . Note: dk „s.Covering function We want m  g(y)h(y) contained in a maximum number of In Espresso. we build a Boolean covering matrix C (note that h(y) is unate negative) representing h(y) and solve this problem with greedy heuristics.

an expansion that covers as many other cubes as possible) Note: ~ a 1 in C can be interpreted as a reason why c does not cover cj .e. 26 . a valid expansion) and a maximum of empty rows in C (i.Covering function    010110     C  101011 100101           110110     B  101010 101001        Want set of columns such that if eliminated from B and C results in no empty rows of B (i.e.

This could be important in many hard problems. try to cover another cube by a combination of several other cube expansions So far we have not come up with a really satisfactory endgame. 27 .Endgame What do we do if h(y)  0 ? Some things to try: • generate largest prime covering ci • cover most care points of another cube ck • coordinate two or more cube expansions. i. since it is often the case that h(y)  0 .e.

REDUCE Problem: Given a cover F and c  F. c is called the maximally reduced cube of c. find the smallest cube c  c such that F\{ c } + { c } is still a cover. REDUCE is order dependent on off Don’t care BAD GOOD 28 .

bc .REDUCE Example Example 5: F  ac  bc  b c  a c Two orders: 1. bc . ac    abc  ac  abc  ac REDUCE is order dependent ! 29 BAD GOOD . ac    abc  bc  abc  ac   2. bc. REDUCE F  ac. REDUCE  F  bc. ac.

REDUCE Algorithm REDUCE  F . D  { F  ORDER( F) for (1  j  F ) do { c j  MAX_REDUCE( c. F. D) F  (F  {c j }) \ {c j } } return F } 30 .

…. so can expand again in different directions.….….ck } i 1 k But f  c j  ci   c j  f  d j 0 j  i 1 • Get out of a local minimum (prime and irredundant is local minimum) • Then have nonprimes.ci+1 .REDUCE Main Idea: Make a prime not a prime but still maintain cover: {c1 .…. ck}  {c1 . it may know best direction) 31 . ci. (Since EXPAND is “smart”.ci.

• Thus. ….REDUCE F = {c1 .ck} F (i) = (F + D) \ { ci } Reduced cube: c i = smallest cube containing (ci F(i) ) • Note that ci F(i) is the set of points uniquely covered by ci (and not by any other cj or D).c2. 32 . ci is the smallest cube containing the minterms of ci which are not in F(i).

REDUCE C1 C2 C1 C2 on off Don’t care c i  SCC ci i  F (i )   SCC  c F (i )  c SCC  F (i )  ci i ci  ci SCCC  Fci (i ) • SCC == “supercube” • SCCC = “smallest cube containing complement” 33 .

SCCC(c) is the universe: cube  01222 So SCCC(cube) = 22222 12222 cube  20222 34 .Efficient Algorithm for SCCC Unate Recursive Paradigm: • select most binate variable • cofactor • until unate leaf x1 x2 x1 x2 x3 x3 unate What is SCCC (unate cover) ? • Note that for a cube c with at least 2 literals.

35 .SCCC SCCC (U) =  Claim: if unate cover has row of otherwise in both subspaces. complement is in x i. i. i = 1 – all 2‟s except one 1. i = 0 SCCC  c1  c2   ck   SCC  c1c2  SCC  c1  ck  SCC  ck  Implies that only need to look at 1-literal cubes. i = 2 Finally – all 2‟s except one 0.e. i. then complement is in x i . i.e.e.

.SCCC Example Example1: f  a  bc  d  f  a (b  c )d  a d Note: 0101 and 0001 are both inf .). So U = x1x5(.. Example2: 2 2 2 2 0 0 2 2 2 2 U (unate )  2 1 1 2 2 2 1 2 1 0   Note that columns 1 and 5 are essential: they must be in every minimal cover. Hence SCCC(U) = x1x5 36 . So SCCC could not have literal b or b in it.

(sketch): U  x1  x5  x2 ( x3  x4 ) U  x1 x5 ( x2  x3 x4 ) 2 0 2 1 0 1  12221 1 0 U (unate)  1 2    The marked columns contain both 0‟s and 1‟s. But every prime ofU contains literals x1 . x5 1 1 1 minterms of U  1 1 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 37 .SCCC Example Proof.

SCCC Thus γ  SCCC(unate)   if row of all 2's  x j if column j has a row singleton with a 0 in it  γ j   x j if column j has a row singleton with a 1 in it  2 otherwise  Thus unate leaf is easy ! 38 .

hence j =2. or ljc2 . then points in both xi andxj. so ( SCC(xic1 +xic2) )i = 2 If ljc1 . then j =2.Merging We need to produce SCCC  f   SCC  xi c1  xi c2     xi   xi   l j i    l1l 2 lk  c2    c1    (l j  c1 )  (l j  c2 ) If c1  c2  . then both xj andxj points exit. Also if ljc1 and ljc2 . 39 .

D.E.Heuristic Two-Level Minimization ESPRESSO() { (F.R) F  IRREDUNDAN T(F. D) F  F . D) E  ESSENTIAL_ PRIMES(F.D) G  EXPAND(G.R) F  IRREDUNDAN T(F.ESPRESSO .D) F  EXPAND(F.error) } .R)  DECODE() F  EXPAND(F. D) }while fewer terms in F //LASTGASP G  REDUCE_GASP(F.D) //LASTGASP }while G   F  F  E.R) F  IRREDUNDANT(F  G.R) error  (Fon  F) or (F  Fold  D) 40 return(F. D  D  E do{ do{ F  REDUCE(F.D) RAISE_INPUTS(F. D  D-E LOWER_OUTPUT(F.

we reduce all cubes as if each were the first one..c2M .} is not a cover. i 41 .. REDUCE 2 REDUCE 1 Maximal Reduce: BAD GOOD c M  SCC (c  F (i ))  c  SCCC ( F (i ) ) i i i c i i.. Note: {c1M .LASTGASP Reduce is order dependent: Expand can‟t do anything with the reduction produced by REDUCE 2.e.

but try to cover only cjM„s.R). If generate all primes.LASTGASP Now expand use EXPAND. What about “supergasp” ? Main Idea: Generally.…. (Note here we call EXPAND(G. ckM} ) If a covering is possible.c2M . so is F . think of ways to throw in a few more primes and then use IRREDUNDANT. then just Quine-McCluskey 42 . where G = {c1M . take the resulting prime: f  d  pi  c i  c j and add to F: ~ F  F  { pi } Since F is a cover. Now make F irredundant (using M M IRREDUNDANT).