View
214
Download
1
Category
Preview:
Citation preview
EECS 20
Lecture 4 (January 24, 2001)
Tom Henzinger
Block Diagrams
1 Systems are functions
2 Signals are functions
Systems as Functions
Input Output
Domain: set of possible inputs
Range: set of possible outputs
Graph: set of pairs ( input, output )
Factorial System
!Nats Nats
Factorial System
!Nats Nats
3 6
Factorial System
!Nats Nats
4 24
Factorial System
!Nats Nats
4 24
Domain: Nats
Range: Nats
Graph: { ( 1, 1 ), ( 2, 2 ), ( 3, 6), ( 4, 24 ), … }
Inverter System
Bools
Bools
Inverter System
Bools
Bools true false
Inverter System
Bools
Bools false true
Inverter System
Bools
Bools false true
Domain: Bools
Range: Bools
Graph: { ( true, false ), ( false, true ) }
Composition of Systems
Bools
Bools Bool
s true truefalse
Composition of Systems
Bools
Bools Bool
s false falsetrue
This is again a system !
Bools Bool
s
The Identity System
Bools
Bools id
Domain: Bools
Range: Bools
Graph: { ( x, y ) Bools2 | x = y }
System Composition is Function Composition
= id
because domain ( ) = domain (id)
range ( ) = range (id)
x Bools, ( x ) = id (x)
And System
Bools
And System
Bools2 Bools
And System
Bools (true, false) false
Bools2
And System
Bools
Bools
Bools
And System
Bools
Bools
Bools true
falsefalse
Exponentiation System
Nats exp
Nats
Nats 2
3?
-
graph (exp) = { ( (x,y), z ) Nats2 Nats | z = x
y }
Exponentiation System
Nats exp
Nats
Nats 2
38
2
1
graph (exp) = { ( (x,y), z ) Nats2 Nats | z = x
y }
Nats exp
Nats
Nats 2
39
1
2
Exponentiation System
graph (exp) = { ( (x,y), z ) Nats2 Nats | z = x
y }
Bools
Bools
Bools
Bools
Bools
Bools
Block Diagram
This cannot be written easily using .
Bools
Bools
Bools
Block Diagram
true
false
Bools
Bools
Bools
Block Diagram
true
false true
false
Bools
Bools
Bools
Block Diagram
true
false true
false
false
Bools
Bools
Bools
Block Diagram
true
false
true
true
false
false
Bools
Bools
Bools
Or System
domain () = Bools2
range () = Bools
graph () = { ( (x,y), z ) Bools2 Bools | z = x y }
Bools
Bools
Bools
Or System
domain () = Bools2
range () = Bools
graph () = { ( (x,y), z ) Bools2 Bools | z = x y }
-
Block Diagrams with Forks
Block Diagrams with Forks
true
false
Block Diagrams with Forks
true
false
f
Block Diagrams with Forks
true
false
f
f
t
Block Diagrams with Forks
true
false
f
f
t
true
Joins are illegal
Joins are illegal
true
false
Joins are illegal
true
false
f
t
?
Multiple Outputs
Nats
Nats Nats0
Nats0
f
f: Nats2 Nats02 such that
x,yNats, f (x,y) = { (q,r)Nats02 | x = q· y + r r <
y }
Division System
Nats
Nats
divide
divide: Nats2 Nats02 such that
x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r
< y }
1
2
1
2
quotient
remainderNats0
Nats0
Division System
Nats
Nats
divide
7
3
1
2
1
2
divide: Nats2 Nats02 such that
x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r
< y }
Nats0
Nats0
Division System
Nats
Nats
divide
7
3
1
2
1
2
2
1
divide: Nats2 Nats02 such that
x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r
< y }
Nats0
Nats0
Division System
Nats
Nats
divide
3
7
1
2
1
2
divide: Nats2 Nats02 such that
x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r
< y }
Nats0
Nats0
Division System
Nats
Nats
divide
3
7
1
2
1
2
0
3
divide: Nats2 Nats02 such that
x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r
< y }
Nats0
Nats0
Division System
Nats
Nats
divide
9
3
1
2
1
2
3
0
divide: Nats2 Nats02 such that
x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r
< y }
Nats0
Nats0
Many possible implementations
Nats
Nats
1
2
1
2
C program for Euclid’s algorithm
divide
divide: Nats2 Nats02 such that
x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r
< y }
Nats0
Nats0
Many possible implementations
Nats
Nats Nats0
Nats01
2
1
2
circuit
divide
divide: Nats2 Nats02 such that
x,yNats, divide (x,y) = { (q,r)Nats02 | x = q· y + r r
< y }
Block diagrams can hide outputs
divide22
1 1
zerocheck
zerocheck: Nats0 Bools such that
xNats, zerocheck (x) x = 0 .
Nats
Nats
Bools
Block Diagrams can hide outputs
divide22
1 1
zerocheck
zerocheck: Nats0 Bools such that
xNats, zerocheck (x) x = 0 .
Nats
Nats
Bools
Block Diagrams can hide outputs
2
1Nats
Nats
Boolsdivisible
divisible: Nats2 Bools such that
x,yNats, divisible (x,y) ( qNats, x = q· y ) .
Hidden inputs are illegal, for now
Hidden inputs are illegal, for now
true
?
Constant functions have no inputs
true
Constant function
true
true truetrue
Cycles are illegal, for now
divide
Block Diagrams
-are nested, directed, acyclic graphs
-allow compositional, hierarchical system description
Quiz
1. set x, x P(x)
2. function f, { x domain (f) | x = f(x) }
3. n Nats, n = 2 ( n, n+1 ) { 1, 2, 3 }
2
4. f [Nats Nats], f(x) = x 2
Recommended