CSE 311 Foundations of Computing I Lecture 20 Relations, Graphs, Finite State Machines Autumn 2011 CSE 3111 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A A AA
Announcements Reading assignments – 7 th Edition, Sections 9.3 and 13.3 – 6 th Edition, Section 8.3 and 12.3 – 5 th Edition, Section 7.3 and 11.3 Autumn 2011CSE 3112
Lecture highlights Autumn 2011CSE 3113 Let A and B be sets, A binary relation from A to B is a subset of A B S R = {(a, c) | b such that (a,b) R and (b,c) S} R 1 = R; R n+1 = R n R
n-ary relations Let A 1, A 2, …, A n be sets. An n-ary relation on these sets is a subset of A 1 A 2 ... A n.
Relational databases Student_NameID_NumberMajorGPA Knuth CS4.00 Von Neuman CS3.78 Von Neuman Mathematics3.78 Russell Philosophy3.85 Einstein Physics2.11 Newton Mathematics3.61 Karp CS3.98 Newton Physics3.61 Bernoulli Mathematics3.21 Bernoulli Mathematics3.54
Alternate Approach Student_IDNameGPA Knuth Von Neuman Russell Einstein Newton Karp Bernoulli Bernoulli3.54 Student_IDMajor CS CS Mathematics Philosophy Physics Mathematics CS Physics Mathematics Mathematics
Database Operations Projection Join Select
Matrix representation Relation R on A={a 1, … a p } {(1, 1), (1, 2), (1, 4), (2,1), (2,3), (3,2), (3, 3) (4,2) (4,3)}
Directed graphs Autumn 2011CSE 3119 Path: v 1, v 2, …, v k, with (v i, v i+1 ) in E Simple Path Cycle Simple Cycle G = (V, E) V – vertices E – edges, order pairs of vertices
Representation of relations Directed Graph Representation (Digraph) {(a, b), (a, a), (b, a), (c, a), (c, d), (c, e) (d, e) } ad e bc
Paths in relations Autumn 2011CSE Let R be a relation on a set A. There is a path of length n from a to b if and only if (a,b) R n
Connectivity relation Autumn 2011CSE Let R be a relation on a set A. The connectivity relation R* consists of the pairs (a,b) such that there is a path from a to b in R.
Properties of Relations Let R be a relation on A R is reflexive iff (a,a) R for every a A R is symmetric iff (a,b) R implies (b, a) R R is transitive iff (a,b) R and (b, c) R implies (a, c) R /
Transitive-Reflexive Closure Autumn 2011CSE Add the minimum possible number of edges to make the relation transitive and reflexive The transitive-reflexive closure of a relation R is the connectivity relation R*
Finite state machines States Transitions on inputs Start state and finals states The language recognized by a machine is the set of strings that reach a final state Autumn 2011 CSE s0s0 s2s2 s3s3 s1s , State01 s0s0 s0s0 s1s1 s1s1 s0s0 s2s2 s2s2 s0s0 s3s3 s3s3 s3s3 s3s3
What language does this machine recognize? Autumn 2011CSE s0s0 s2s2 s3s3 s1s