Models of Computation by Costas Busch, LSU 1
Computation CPU memory 2
temporary memory input memory CPU output memory Program memory 3
Example: f ( x) x 3 temporary memory input memory Program memory compute compute CPU x x 2 x x output memory 4
f ( x) x 3 temporary memory input memory x 2 Program memory compute compute CPU x x 2 x x output memory 5
temporary memory f ( x) x 3 z 2*2 4 f ( x) z *2 8 CPU Program memory compute x x input memory x 2 output memory compute 2 x x 6
temporary memory f ( x) x 3 z 2*2 4 f ( x) z *2 8 CPU Program memory compute x x input memory f x 2 ( x) 8 output memory compute 2 x x 7
Automaton temporary memory Automaton input memory CPU output memory Program memory 8
Different Kinds of Automata Automata are distinguished by the temporary memory Finite Automata: no temporary memory Pushdown Automata: stack Turing Machines: random access memory 9
Finite Automaton temporary memory Finite Automaton input memory output memory Example: Vending Machines (small computing power) 10
Pushdown Automaton Stack Push, Pop Pushdown Automaton input memory output memory Example: Compilers for Programming Languages (medium computing power) 11
Turing Machine Random Access Memory Turing Machine input memory output memory Examples: Any Algorithm (highest computing power) 12
Power of Automata Finite Automata Pushdown Automata Turing Machine Less power Solve more More power computational problems 13
Mathematical Preliminaries 14
Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques 15
SETS A set is a collection of elements A {1,2,3} B { train, bus, bicycle, airplane} We write 1 A ship B 16
Set Representations C = { a, b, c, d, e, f, g, h, i, j, k } C = { a, b,, k } finite set S = { 2, 4, 6, } infinite set S = { j : j > 0, and j = 2k for some k>0 } S = { j : j is nonnegative and even } 17
A = { 1, 2, 3, 4, 5 } U 6 A 7 10 1 2 3 4 5 9 8 Universal Set: all possible elements U = { 1,, 10 } 18
Set Operations A = { 1, 2, 3 } B = { 2, 3, 4, 5} Union A U B = { 1, 2, 3, 4, 5 } Intersection A B = { 2, 3 } U Difference A - B = { 1 } B - A = { 4, 5 } A A-B B 19
Complement Universal set = {1,, 7} A = { 1, 2, 3 } A = { 4, 5, 6, 7} 4 5 A 1 A 2 3 7 6 A = A 20
{ even integers } = { odd integers } Integers 1 odd 3 2 even 0 4 6 7 5 21
DeMorgan s Laws A U B = A U B A U B = A U B 22
Empty, Null Set: = { } S U = S S = U = Universal Set S - = S - S = 23
Subset A = { 1, 2, 3} B = { 1, 2, 3, 4, 5 } A U B Proper Subset: A B U B A 24
Disjoint Sets A = { 1, 2, 3 } B = { 5, 6} A B = U A B 25
Set Cardinality For finite sets A = { 2, 5, 7 } A = 3 26
Powersets A powerset is a set of sets S = { a, b, c } Powerset of S = the set of all the subsets of S 2 S = {, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} } Observation: 2 S = 2 S ( 8 = 2 3 ) 27
Cartesian Product A = { 2, 4 } B = { 2, 3, 5 } A X B = { (2, 2), (2, 3), (2, 5), ( 4, 2), (4, 3), (4, 5) } A X B = A B Generalizes to more than two sets A X B X X Z 28
FUNCTIONS domain 1 2 A 3 f(1) = a range B a b c If A = domain f : A -> B then f is a total function otherwise f is a partial function 29
RELATIONS R = {(x 1, y 1 ), (x 2, y 2 ), (x 3, y 3 ), } x i R y i e. g. if R = > : 2 > 1, 3 > 2, 3 > 1 In relations x i can be repeated 30
Equivalence Relations Reflexive: x R x Symmetric: x R y y R x Transitive: x R y and y R z x R z Example: R = = x = x x = y x = y and y = z y = x x = z 31
For equivalence relation R Equivalence Classes equivalence class of x = {y : x R y} Example: R = { (1, 1), (2, 2), (1, 2), (2, 1), (3, 3), (4, 4), (3, 4), (4, 3) } Equivalence class of 1 = {1, 2} Equivalence class of 3 = {3, 4} 32
A directed graph node a GRAPHS b e d c Nodes (Vertices) V = { a, b, c, d, e } Edges E = { (a,b), (b,c), (b,e),(c,a), (c,e), (d,c), (e,b), (e,d) } 33
Labeled Graph 2 a 1 5 b 6 c 3 6 e 2 d 34
Walk a b e d c Walk is a sequence of adjacent edges (e, d), (d, c), (c, a) 35
Path a b e d c Path is a walk where no edge is repeated Simple path: no node is repeated 36
Cycle a 3 base 2 b 1 c e d Cycle: a walk from a node (base) to itself Simple cycle: only the base node is repeated 37
Euler Tour a 4 3 b 5 8 7 6 c base e 1 2 d A cycle that contains each edge once 38
Hamiltonian Cycle a 4 3 b 5 c base e 1 2 d A simple cycle that contains all nodes 39
Finding All Simple Paths a b e d c origin 40
Step 1 a b e d (c, a) (c, e) c origin 41
Step 2 a b e d (c, a) (c, a), (a, b) (c, e) (c, e), (e, b) (c, e), (e, d) c origin 42
Step 3 a b e d (c, a) (c, a), (a, b) (c, a), (a, b), (b, e) (c, e) (c, e), (e, b) (c, e), (e, d) c origin 43
Step 4 (c, a) (c, a), (a, b) a (c, a), (a, b), (b, e) (c, a), (a, b), (b, e), (e,d) (c, e) (c, e), (e, b) (c, e), (e, d) b c e origin d 44
root Trees parent leaf child Trees have no cycles 45
root Level 0 leaf Level 1 Level 2 Height 3 Level 3 46
Binary Trees 47
PROOF TECHNIQUES Proof by induction Proof by contradiction 48
Induction We have statements P 1, P 2, P 3, If we know for some b that P 1, P 2,, P b are true for any k >= b that P 1, P 2,, P k imply P k+1 Then Every P i is true 49
Inductive basis Proof by Induction Find P 1, P 2,, P b which are true Inductive hypothesis Let s assume P 1, P 2,, P k are true, for any k >= b Inductive step Show that P k+1 is true 50
Example Theorem: A binary tree of height n has at most 2 n leaves. Proof by induction: let L(i) be the number of leaves at level i L(0) = 1 L(1) = 2 L(2) = 4 L(3) = 8 51
We want to show: L(i) <= 2 i Inductive basis L(0) = 1 (the root node) Inductive hypothesis Let s assume L(i) <= 2 i for all i = 0, 1,, k Induction step we need to show that L(k + 1) <= 2 k+1 52
Induction Step Level k+1 k From Inductive hypothesis: L(k) <= 2 k 53
Induction Step Level k L(k) <= 2 k k+1 L(k+1) <= 2 * L(k) <= 2 * 2 k = 2 k+1 54
Remark Recursion is another thing Example of recursive function: f(n) = f(n-1) + f(n-2) f(0) = 1, f(1) = 1 55
Proof by Contradiction We want to prove that a statement P is true we assume that P is false then we arrive at an incorrect conclusion therefore, statement P must be true 56
Theorem: 2 Example is not rational Proof: Assume by contradiction that it is rational 2 = n/m n and m have no common factors We will show that this is impossible 57
2 = n/m 2 m 2 = n 2 Therefore, n 2 is even n is even n = 2 k 2 m 2 = 4k 2 m 2 = 2k 2 m is even m = 2 p Thus, m and n have common factor 2 Contradiction! 58