CNS 188a Overview

59
CNS 188a Overview Boolean algebra as an axiomatic system Boolean functions and their representations using Boolean formulas and spectral methods Implementing Boolean functions with relay circuits, circuits of AON (AND, OR, NOT) gates and LT (Linear Threshold) gates Analyzing the complexity (size and depth) of circuits • Relations (as opposed to functions) and their implementation in circuits • Feedback and convergence in LT circuits

Transcript of CNS 188a Overview

CNS 188a Overview

• Boolean algebra as an axiomatic system

• Boolean functions and their representations using Boolean formulas and spectral methods

• Implementing Boolean functions with relay circuits, circuits ofAON (AND, OR, NOT) gates and LT (Linear Threshold) gates

• Analyzing the complexity (size and depth) of circuits

• Relations (as opposed to functions) and their implementation in circuits

• Feedback and convergence in LT circuits

XOR Function: Size of LT vs. AON in Depth 2

5

4

2

AONLT-l

LT-nl

Symmetric functions

How is SYM related to LT2 ?

+-1

TH1

TH2

0

1

0

TH1+TH2-1

0

1

1

TH2

12

11

00

TH1|X|

Generalization to EQ

1

0

0

0

1

1

0

2

1

1

+-1

Generalization to EQ

Q:What is the generalization to arbitrary symmetric functions?

Generalization to SYM

Q:What is the generalization to arbitrary symmetric functions?

A:Consider the symmetric function table, it is a sum of non-overlapping 1-intervals

0

0

1

1 Sum of two TH functions

LT-l Circuit Design Algorithm for SYMMuroga 1959

0

1

2

3

4

5

1

1

0

1

1

0

f(X)

6

7

1

1

Subtract 1 for everyisolated 1-block

0

0

1

1

Definition: Let T(f) be the number of transitionsin the symmetric function table

Q: using the design algorithm, how many TH gates are used the first layer?

LT-l Circuit Design Algorithm for SYM

A: T(f) TH gates are usedT(f) =1 is the single gate case

Can we do better?

The Layered Construction for SYM Is OPTIMALSummary of the Proof

Theorem (SYM with LT):A layered LT circuit for a symmetric function f, with the first layer being TH gates, has at least T(f)+1 gates for T(f) greater than 1.

Proof: A circuit for a symmetric function (not in TH) has at least 3 gatesGiven a layered LT circuit with k gates for

a symmetric function f

There exists a symmetric function g, such that:- T(g) = T(f) -1 - The function g can be implemented by a layeredLT circuit with k-1 gates

k23456 6

5433

Q

The Layered Construction for SYM Is OPTIMAL

Proof: Idea: start with T(f) = 2

Need to prove: the LT circuit for f has at least 3 gates

f is not in TH, hence we need at least 2 LT gates

X

Layered construction

Single input: identity or complement,hence this gate is redundant

Need at least3 gates!

Q

The Layered Construction for SYM Is OPTIMAL

Given a layered LT circuit with k gates fora symmetric function f

There exists a symmetric function g, such that:- T(g) = T(f) -1 - The function g can be implemented by a layeredLT circuit with k-1 gates

Say if we prove *:

Then it follows thatk (circuit size)

23456 6

543

Why?

By *

3 contradiction

The Layered Construction for SYM Is OPTIMAL

Given a layered LT circuit with k gates fora symmetric function f

There exists a symmetric function g, such that:- T(g) = T(f) -1 - The function g can be implemented by a layeredLT circuit with k-1 gates

Need to prove:

0

0

1

1

Assume wlog that this isthe symmetric function table of f first transition

The Layered Construction for SYM Is OPTIMAL

0

0

1

1

Assume wlog that this isthe symmetric function table of f first transition

Claim: There must be an TH gate in the first layer that detects the change from |X| =i to |X|= i+1

i

i+1

Proof:Note that it is a layered circuit, namely, inputs are connected only to the first layer!!

The Layered Construction for SYM Is OPTIMAL

0

0

1

1

Claim: There must be an TH gate in the first layer that detects the change from |X| =i to |X|= i+1

i

i+1Proof:It is a layered circuit, namely, inputs are connected onlyto the first layer!!

If all TH gates in the first layer output the samefor |X| =i and |X|= i+1 then the circuit will notcompute f:

Call this “sensitive” gate S Q

SCan we eliminate S ??

The Layered Construction for SYM Is OPTIMAL

0

0

1

1

i

i+1

Easy:

The output of S will be a constant 1 (or 0)

Setting the variables to results in a new circuit and a new function

Q: are we done?

Can we eliminate S ??S

The Layered Construction for SYM Is OPTIMAL

g

Given a layered LT circuit with k gates fora symmetric function f

There exists a symmetric function g, such that:- T(g) = T(f) -1 - The function g can be implemented by a layeredLT circuit with k-1 gates

- g is a symmetric function

- T(g) = T(f) -1

-We removed the gate S (or more), hence,the circuit for g is layered and has at most k-1 gates

Setting the variables to results in a new circuit and a new function

The Layered Construction for SYM Is OPTIMALRemarks

Theorem (SYM with LT):A layered LT circuit for a symmetric function f, with the first layer being TH gates, has at least T(f)+1 gates for T(f) greater than 1.

R1: circuit’s depth

- Our proof works for arbitrary depth

- Depth does not help in reducing the size (layered, TH)

- Depth-2 has optimal size

R2: Open problems- A lower bound for arbitrary LT gates (beyond TH)- Or, a better layered construction using LT gates

XOR Function: Size of LT vs. AON in Depth 2

5

4

2

AONLT-l

LT-nl

Symmetric functions; T(f) TH gatesoptimal

XOR Function: Size of LT vs. AON in Depth 2

5

4

2

AONLT-l

LT-nl

Symmetric functionsoptimal

1

1

1

-2

-2

11

-1

LT-nl Construction

1

A

0

1

2

3

0

0

1

1

-10

-1

0

A -1-2A+|X|

0

1

0

sgn( )

1

LT-nl = LT non-layered, inputs go to any layer

T(f)+1 = 4

LT-nl Construction

0

1

2

3

4

5

0

1

0

1

1

0

f(X)

6

7

1

1

Given a symmetric function f withk 1s in the symmetric function table

At locations:

Construct an LT-nl circuit with k+1 gates

LT-nl ConstructionMinnick 1961

M

TH(q1+1)

TH(q2+1)

TH(qk+1)

The Gate M

-(q2-q1)

-(q3-q2)

-(qk-qk-1)-q1

-(n+1- qk)

From the firstlayer of k TH

gates

LT-nl Construction - Example

0

1

2

3

4

5

0

1

0

0

1

1

f(X)Given a symmetric function f withk 1s in the symmetric function table

At locations:

Construct an LT-nl circuit with k+1 gates

LT-nl Construction – First Layer

TH(q1+1)

TH(q2+1)

TH(qk+1)

TH2

TH5

TH6

The Gate M

-(q2-q1) = -3-(q3-q2) = -1

-q1= -1

0

-3

-1-1

The Gate M

The Circuit

-3

-1-1

TH2

TH5

The Circuit

-3

-1-1

TH2

TH5

01234

5

01001

1

f(X)

a2

a1

-3a1-a2-1 …+|X|a1

00111

1

a2

00000

1

-1-1-4-4-4

-5

-10-2-10

0

sgn(:) 01001

1

The Minnick ConstructionWhy Does it work?

-(q2-q1)

-(q3-q2)

-(qk-qk-1)-q1

-(n+1- qk)

TH(q1+1)

TH(q2+1)

TH(qk+1)

a1

a2

ak

-(q2-q1)

-(q3-q2)

-(qk-qk-1)-q1

-(n+1- qk)

TH(q1+1)

TH(q2+1)

TH(qk+1)

a1

a2

ak

-(q2-q1)

-(q3-q2)

-(qk-qk-1)-q1

-(n+1- qk)

TH(q1+1)

TH(q2+1)

TH(qk+1)

a1

a2

ak

0 0 0**0

1 0 0**0

1 1 0**0

Q: how do the ai‘s look?

0 0 0**0

1 0 0**0

1 1 0**0

1 1 10*0

1 1 1111

-(q2-q1)

-(q3-q2)

-(qk-qk-1)-q1

-(n+1- qk)

a1=0 a1=1 a2=1 a3=1 ak=1

0 0 0**0

1 0 0**0

1 1 0**0

1 1 10*0

1 1 1111

What was Minnick’s key idea????

The Key: Telescopic Sum

1 1 1100*0

a1=1

a4=1a3=1a2=1

a5=0 We are alwaysleft with the lastelement in the sum

The Key: Telescopic Sum

1 1 1100*0

a1=1

a4=1a3=1a2=1

a5=0

The Minnick Construction

Claim: The Minnick construction is correctProof:

Consider |X| in each possible range:

F(X) is 0 for all the upper bounds of the ranges and negative otherwise

QTelescopic sum

The Example Circuit

-3

-1-1

TH2

TH5

01234

5

01001

1

f(X)

a2

a1

a1 a2 -3a1-a2-1 …+|X| sgn(:) 00111

1

00000

1

-1-1-4-4-4

-5

-10-2-10

0

01001

1

-3

-1-1

TH2

TH5

01234

5

01001

1

f(X)

a2

a1

a1 a2 -3a1-a2-1 …+|X| sgn(:) 00111

1

00000

1

-1-1-4-4-4

-5

-10-2-10

0

01001

1

Note that thesecond TH gateis redundant

The Example Circuit

-4 1

The Minnick ConstructionRemarks

R1: The Minnick construction is more general than what we described, it works on intervals; we recommendthat you read his paper (it is on the class web site)

R2: The Minnick construction is optimal for LT-nl of depth 2We will not prove it in the lectures

XOR Function: Size of LT vs. AON in Depth 2

5

4

2

AONLT-l

LT-nl

Symmetric functionsoptimal

intervals

transitions

Questions on LT Constructions

Q3: For LT-l we proved that depth does not help in reducing the circuit size, does it help in the case of LT-nl?

Q2: Why do we care about symmetric functions?What about general Boolean functions?

Q1: we understand how to implement a single symmetric function, what if we need to implement a circuit that computes a number of symmetric functions? Can we save in circuit size?

Questions on LT Constructions

A1: YES - we can ‘reuse’ the first layer! By putting all required TH gates.

Q1: We understand how to implement a single symmetric function, what if we need to implement a circuit that computes a number of symmetricfunctions? Can we save in circuit size?

TH(q1+1)TH(q1+1)TH(q1+1)THiTHiTHiTHiTHi

+

+

+

f1

f2

f3

Questions on LT Constructions

Q3: For LT-l we proved that depth does not help in reducing the circuit size, does it help in the case of LT-nl?

Q2: Why do we care about symmetric functions?What about general Boolean functions?

Q1: we understand how to implement a single symmetric function, what if we need to implement a circuitthat computes a number of symmetric functions? Can we save in circuit size?

Questions on LT Constructions

A2: A general Boolean function can be treated as a symmetric function by introducing linear ordering

Q2: Why do we care about symmetric functions?What about general Boolean functions?

4 gates with LT-l

3 gates with LT-nl

5 gates with DNF

THi

Questions on LT Constructions

Q3: For LT-l we proved that depth does not help in reducing the circuit size, does it help in the case of LT-nl?

Q2: Why do we care about symmetric functions?What about general Boolean functions?

Q1: We understand how to implement a single symmetric function, what if we need to implement a circuitthat computes a number of symmetric functions? Can we save in circuit size?

Questions on LT Constructions

Q3: of for LT-l we proved that depth does not help in reducing the circuit size, does it help in the case of LT-nl?

A3: Yes!

Idea: compute the base-2 representation of |X|

XOR(X)

Idea: compute the base-2 representation of |X|

Algorithm for computing the binary representation:

Idea: compute the base-2 representation of |X|

Algorithm for computing the binary representation:

6 Need 3 bits2

6 4 a2 = 1

6-4

Idea: compute the base-2 representation of |X|

Algorithm for computing the binary representation:

2 Need 3 bits1

2 2a1 = 1

2-2

a2 = 1

Idea: compute the base-2 representation of |X|

Algorithm for computing the binary representation:

0 Need 3 bits0

0 1

a0 = 00-0

a1 = 1

a2 = 1

Idea: compute the base-2 representation of |X|

Algorithm for computing the binary representation:

a2 = 1 a0 = 0a1 = 1

Implement the algorithm for computing the binary representation using LT gates

The Kautz Construction1961

-4

-2-4

a2 = 1

a1 = 1 a0 = 0

6

6

6-1

-4

-2

LT Constructions for Symmetric Functions

circuit kind size

LT-l

LT-nl, d-2

LT-nl -XOR

optimal

LT-nl ConstructionMinnick 1961

First construction

Minnick’s construction

LT-nl ConstructionMinnick 1961

The Kautz Construction1961

The Kautz Construction1961

Kautz

William H. Kautz (Sc.D., M.I.T). was Staff Scientist at Stanford Research Institute,where for 35 years he conducted scientific and technical research in computer science and various other fields.

He then founded and directed the Center for Applied Intuition, which carried out research on intuition and its applications.

He lives in Prague, Czech Republic, and Tucson, Arizona.