boolean algebra cont’ the digital abstraction graphs and topological sort מבנה המחשב +...

49
Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort םםםם םםםםםםם םםםםםםם+ םםםם םםםםם םםםםם2#

Post on 19-Dec-2015

228 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Boolean Algebra cont’

The digital abstraction

Graphs and Topological Sort

מבנה המחשב + מבוא למחשבים ספרתיים

2#תרגול

Page 2: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Theorem 11: DeMorgan’s Law

For every pair of elements a , b B,

1. ( a + b )’ = a’ · b’

2. ( a · b )’ = a’ + b’

Proof:

(1) We first prove that (a+b) is the complement of a’·b’.

Thus, (a+b)’ = a’·b’

By the definition of the complement and its uniqueness, it suffices to show: (i) (a+b)+(a’b’) = 1 and

(ii) (a+b)(a’b’) = 0.

(2) Duality (a·b)’ = a’+b’

Page 3: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

bbaabababa

bbaaab

bbaaab

11 ab

11

1

Distributivity

Commutativity

Associativity

a’ and b’ are the complements of a and b respectively

Theorem: For any a B, a + 1 = 1

Idempotent Law

Page 4: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

babababa

bbaaba

bbaaab

bbaaab

bbaaab

00 ab

00

0

Commutativity

Distributivity

Commutativity

Associativity

Commutativity

a’ and b’ are the complements of a and b respectively

Theorem: For any a B, a · 0 = 0

Idempotent Law

Page 5: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Transfer function for an inverter

• Given an electronic device whose transfer function is: f(x) = 1-x

•Is it a valid device for an inverter?

•In the two threshold model:

•Yes, chose for example Vlow = 0.25, Vhigh = 0.75

•In the (more realistic) four threshold model?

Page 6: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Transfer function for an inverter (cont.)

• Assume it is a valid device

There exists four numbers vil, vih, vol, voh such that:

•f(vil) voh ,namely if in signal is vil the out signal is voh. (the device is an inverter).

•f(vih) vol (same as above)

•vol < vil < vih < voh (4-thresholds model).

•However, according to the transfer function:

• f(vih) = 1- vih

• f(vil) = 1- vil

Page 7: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Transfer function for an inverter (con. 2)

• 1- vil voh and 1- vih vol

voh + vil 1 and vol + vih 1

A contradiction, since voh > vol and vil > vih

•Conclusion: not any monotonically decreasing function is adequate to be a transfer function in the 4-thresholds model.

Page 8: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Graph Representationby List of Neighbors

6

7

8

3

4

5

2

1 3 5 86

7 5 6

2 8

Page 9: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Graph Representationby Matrix

v

v

v

12345

1

2

3

4

5

Page 10: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort

• Works only on Directed Acyclic Graphs (DAG).• Notations:

– In degree: The number of edges entering a vertex.– Sources: vertices with in-degree 0.

• The Algorithm:– Initialize: V The set of all vertices.– While V is not empty

• Extract a source s (if non-exists, then not a dag).• Decrease the incoming degree of all its neighbors.• Set s to be the next vertex in the topological order.

Page 11: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort Example

OR

AND

NOT XOR OUT

IN

IN

= Independent Vertex

Page 12: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort Example

OR

AND

NOT XOR OUT

IN

IN

The Topological Sort:

IN

Page 13: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort Example

OR

AND

NOT XOR OUT

IN

IN

The Topological Sort:

IN IN

Page 14: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort Example

OR

AND

NOT XOR OUT

IN

IN

The Topological Sort:

IN IN OR

Page 15: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort Example

OR

AND

NOT XOR OUT

IN

IN

The Topological Sort:

IN IN OR AND

Page 16: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort Example

OR

AND

NOT XOR OUT

IN

IN

The Topological Sort:

IN IN OR AND NOT

Page 17: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort Example

OR

AND

NOT XOR OUT

IN

IN

The Topological Sort:

IN IN OR AND NOT XOR

Page 18: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Topological Sort Example

OR

AND

NOT XOR OUT

IN

IN

The Topological Sort:

IN IN OR AND NOT XOR OUT

Page 19: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

The next slides are for the interested students (home

reading)

Page 20: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Theorem: Associative Law

In a Boolean algebra, each of the binary operations ( + ) and ( · ) is associative. That is, for every a , b , c B,

1. a + ( b + c ) = ( a + b ) + c

2. a · ( b · c ) = ( a · b ) · c

Page 21: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

cbacbaA

cbcbaacbaA Distributivity

cbaaacba

acabaa

aca

a

acbaa

Commutativity

Distributivity

Distributivity

Absorption Law

Absorption Law

acaba Idempotent Law

Proof:

(1) Let

Page 22: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

cbcbaacbaA

ccbabcbacbcba

cbabbcba

bcbab

bcbbba

bba

bab

b

bcbba

Commutativity

Distributivity

Distributivity

Idempotent Law

Absorption Law

Commutativity

Absorption Law

Page 23: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

ccbabcbacbcba

c

Putting it all together:

cbcbaacbaA

ccbabcbaacba

cba

cba

Same transitions

· before +

Page 24: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

cbaccbabaA

cbaccbabcbaa

cba

cbacbaA

(2) Duality

Also,

Page 25: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Dual transformation - Recursive definition:Dual: expressions → expressions base: 0 → 1

1 → 0a → a , a B\{0,1}

recursion step: Let E1 and E2 be Boolean expressions. Then,

E1’ → [dual(E1)]’ ( E1 + E2 ) → [ dual(E1) · dual(E2) ]

( E1 · E2 ) → [ dual(E1) + dual(E2) ]

Boolean expression - Recursive definition: base: 0 , 1 , a B – expressions. recursion step: Let E1 and E2 be Boolean expressions. Then,

E1’ ( E1 + E2 )

( E1 · E2 )

Page 26: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Proof:

Let f ( x1 , x2 , … , xn ) be a Boolean expression.

We show that applying the complement on the whole expression together with replacing each variable by it’s complement, yields the dual transformation definition.

Let fd be the dual of a function f ( x1 , x2 , … , xn )

Lemma: In switching algebra, fd = f’ ( x1’ , x2’ , … , xn’ )

Induction basis: 0 , 1 – expressions.

0xf nxxxf ,,, 21

nxxxf ,,, 21 1xf

dfxf 10

dfxf 01

Page 27: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Induction hypothesis: Lemma holds for Boolean expressions: E1 and E2 .

That is:

nnn xxxExxxExxxE ,,,,,,,,, 21221121

Induction step: show that it is true for E1’ ( E1 + E2 )

( E1 · E2 )

dn

dn

ExxxE

ExxxE

,2212

,1211

,,,

,,,

hypothesis induction ndnd xxxExxxE ,,,,,, 21,221,1

LawMorganDe ' nn xxxExxxE ,,,,,, 212211

nnn xxxExxxExxxE ,,,,,,,,, 21221121 If

then,

nd xxxE ,,, 21

Page 28: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

xExExE

21

xExExE

21

hypothesis induction xExE dd

,2,1

LawMorganDe ' xExE 21

If

then,

xEd

xExE

1If

xExE 1

then,

xE

1

xE d

,1

xEd

hypothesis induction

Page 29: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Definition: A function f is called self-dual if f = fd

Lemma: For any function f and any two-valued variable A, the function g = Af + A’fd is a self-dual.

Proof: (holds for any Boolean algebra)

dfAAfdualgdual

dfAdualAfdual

dfdualAdualfdualAdual

fAfA d

ffAAfA dd

dd fAffAA

Dual definition

Distributivity

Commutativity

Page 30: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

dd fAffAA

dd fffAfAAA

dd fffAfA 0

dd fffAfA

dd fffAAf

Notice that the above expression has the form:

ab + a’c +bc

where “a” =A, “b”=f, “c” = fd.

Distributivity

dd fffAfAAA Commutativity

A’ is the complement of A

Identity

Commutativity

Page 31: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

We now prove a stronger claim:

caabbccaabBcba .,,

111 bccaabbccaab

aabccaab 11

abcbcacaab 11

cbaabccaab 11

11 cacbaababc

11 bcacab

11 caab

caab

Identity

a’ is the complement of a

Distributivity

Commutativity

Commutativity

Distributivity

Theorem: For any a B, a + 1 = 1

Identity

Page 32: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

dd fffAAf

dfAAfdualgdual

dfAAf

caabbccaab

For example:

cvbf

vcbfd

vcbacvbag

self-dual

Page 33: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Easier proof (1) for switching algebra only: (using dual properties)

dd fffAAf

dfAAfdualgdual

Switching algebra

1 and 0 dff

0 and 1 dffOR 0dff

0 dfAAf

dfAAf Identity

Page 34: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

A = 0dd ffffgdual 00)(

dd ffff 10

dd ffff 0

ffff dd 0

df0

df

dd fffg 00

0’ = 1

Identity

Commutativity

Absorption Law

Theorem: For any a B, a · 0 = 0

Identity

Easier proof (2) for switching algebra only: (case analysis)

dd fffAAf

dfAAfdualgdual

Page 35: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

A = 1

dd ffffgdual 11)(

f

fffg d 11

Page 36: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Algebra of SetsConsider a set S.

B = all the subsets of S (denoted by P(S)).

,,SPM

“plus” set-union ∪

“times” set-intersection ∩

Additive identity element – empty set Ø

Multiplicative identity element – the set S.

Complement of X B: XSX \

Page 37: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Theorem: The algebra of sets is a Boolean algebra.

Proof:

By satisfying the axioms of Boolean algebra:

• B is a set of at least two elements

For every non empty set S:

→ |B| ≥ 2.

SPS ,

• Closure of (∪) and (∩) over B (functions ) . BBB

., SYX definitionby )(SPX

definitionby )(SPY

definitionby )( and SPYXSYX

definitionby )( and SPYXSYX

Page 38: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

A1. Cummutativity of ( ∪ ) and ( ∩ ).

YxXxxYX or :

XxYxxXY or :

An element lies in the union precisely when it lies in one of the two sets X and Y. Equally an element lies in the union precisely when it lies in one of the two sets X and Y. Hence,

YX XY

XYYX

YxXxxYX and :

XxYxxXY and :

XYYX

Page 39: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

A2. Distributivity of ( ∪ ) and ( ∩ ).

.ZYXx

Xx ZYx

ZxYx

YXx ZXx ZXYXx

ZXYXZYX

Let

and

or

If ,Yx Xx Yx YXx We have and . Hence,

If ,Zx Xx Zx ZXx We have and . Hence,

or

ZXYXZYX

Page 40: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

ZYXZXYX Taking (*) and (**) we get,

ZXYXZYX

Distributivity of union over intersection can be conducted in the same manner.

ZXYXZYX

Page 41: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

This can be conducted in the same manner as ⊆.

We present an alternative way:

Definition of intersection XYX XZX and

XZXYX

Also, definition of intersection YYX

definition of union ZYY ZYYX

Similarly, ZYZX

ZYZXYX

*

**

Page 42: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

A3. Existence of additive and multiplicative identity element.

XXXSX .

XXSSXSX .

identity additive -

identity tivemultiplica - S

A4. Existence of the complement.

XSXBX \.

SXXSXSXBX \\.

XXSXSXBX \\.

Algebra of sets is Boolean algebra.All axioms are satisfied

Page 43: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

1,01,0: f

decreasing monotone xf

Example 2 of a transfer function for an inverter

xf

xf

,0in decreasingstrictly xf

0.,0 xfx

0, interval in the concave xf

1,in increasingstrictly xf

0.1, xfx

,1 interval in theconvex is xf

Page 44: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

-1f

-10 f

-11 f

continuous xf

1.! 11 xfx

1.! 22 xfx

1

1

slope = -1

slope = -1

x

xf

1x 2x

Page 45: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

1

1

outhighV ,

inhighV ,

outlowV ,

inlowV ,

slope = -1

slope = -1

x

xf

outlowinlowinhighouthigh VVVV ,,,,

true only if:

Page 46: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

BUT, this is not always the case.

For example:

1

1 x

xf

outhighV ,

inhighV ,

outlowV ,

inlowV ,

slope = -1

slope = -1

outhighinhigh VV ,,

Moreover, in this example it can be proved that no threshold values exist, which are consistent with definition 3 from lecture notes.

Page 47: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

Using the assumption:

00

2010

such that

:point a exists there

xxf

xxxx

slope < -1

f (x) = x

1

1 x

xf

1x 0x 2x

0,,,,

:start with

xVVVV outlowinlowinhighouthigh

0x 0x

0xf

0xf

y

x

xy

Page 48: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

:set 0,, xVV inhighinhigh

0,, xVV inlowinlow

0,, xfVfV inlowouthigh

0,, xfVfV inhighoutlow

0xf

0x

0xf

0x

f (x) = x

1

1

slope < -1

x

xf

1x 0x 2x

0x 0x

0xf

0xf

y

x

xy

Page 49: Boolean Algebra cont’ The digital abstraction Graphs and Topological Sort מבנה המחשב + מבוא למחשבים ספרתיים תרגול 2#

0, xV inhigh

0, xV inlow

0, xV outhigh

0, xV outlow

10,02min xxxx

true if:

10,02minset xxxx

f (x) = x

1

1

slope < -1

x

xf

1x 0x 2x

outhighV ,

inhighV ,

outlowV ,

inlowV ,

slope = -1

slope = -1outlowinlowinhighouthigh VVVV ,,,,