http pan cin ufpe br Sets POSets and
http: //pan. cin. ufpe. br Sets, POSets, and Lattice © Marcelo d’Amorim 2010
SETS © Marcelo d’Amorim 2010
Set • Collection of objects (elements) that carry no particular order • Two ways of expression – Intentional • A is the set of all odd integers – Extensional • B = {2, 4, 5} – Obs. Ø is the empty set © Marcelo d’Amorim 2010
Set builder notation A = {a | a: int, a % 2 = 0} Set A includes integer elements with a 0 remainder for division by 2 © Marcelo d’Amorim 2010
Cardinality • |A| denotes the number of elements in A © Marcelo d’Amorim 2010
Set relations • Membership a ∈ A iff A includes a • Subset A ⊂ B iff a ∈ A implies a ∈ B • Superset A ⊃ B iff a ∈ B implies a ∈ A © Marcelo d’Amorim 2010
Set factories • Intersection A ∩ B = {x | x ∈ A and x ∈ B} • Union A U B = {x | x ∈ A or x ∈ B} • Difference A - B = {x | x ∈ A and not (x ∈ B)} © Marcelo d’Amorim 2010
Power Set • Def. : The set of all subsets of A • Notations: P(A), 2 A • Example – A={1, 2, 3}, 2 A={Ø, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} © Marcelo d’Amorim 2010
Cartesian Product • Def. : Set of ordered pairs from two sets: the first (resp. , second) component comes from the first (resp. , second) set. • More formally: A x B = { (a, b) | a ∈ A and b ∈ B} • Notes –|Ax. B|=|A|x|B| – A 2 is shorthand for A x A © Marcelo d’Amorim 2010
Relation • Def. : Particular subset of a cartesian product • Triple (A, B, G) defines relation R – A is the relation domain and B the codomain – G is the binary relationship • Example: R = (Int, <=) ⊂ Int x Int = {(a, b)| a, b: Int, a <= b} • Notation a. Rb = (a, b) ∈ R © Marcelo d’Amorim 2010
Relation properties • • Reflexive Symmetric Anti-symmetry Transitive © Marcelo d’Amorim 2010
Relation properties • • Reflexive: ∀ a. a. Ra Symmetric: ∀ a, b. a. Rb implies b. Ra Anti-symmetry: ∀ a, b. a. Rb and b. Ra implies a=b Transitive: ∀ a, b, c. a. Rb and b. Rc implies a. Rc © Marcelo d’Amorim 2010
Function • Def. : Relation R s. t. a. Rb and a. Rc implies b = c • Notation f : A => B • Mapping – Injective: f(a) = f(b) implies a = b – Surjective: ∀ y. ∃ _. f(_) = y © Marcelo d’Amorim 2010
PARTIAL ORDERING © Marcelo d’Amorim 2010
Partial Ordering • Def. : Relation ≤ : L x L => {true, false} that is reflexive, transitive, and anti-symmetric • Examples? © Marcelo d’Amorim 2010
Partial Ordering • Def. : Relation ≤ : L x L => {true, false} that is reflexive, transitive, and anti-symmetric • Examples? – ancestor of – phenomena causality Note: Important to characterize semantics of concurrent systems! © Marcelo d’Amorim 2010
Total order • Def. : Relation that is transitive, anti-symmetric and…total • Total: ∀ a, b. a. Rb or b. Ra reflexivity implied © Marcelo d’Amorim 2010
POSETS © Marcelo d’Amorim 2010
POSET • Set L with a partial ordering ≤ • Notation – (L, ≤) to describe POSET – l 1 ≤ l 2 to describe a particular pair ≤ is not necessarily the subset relation © Marcelo d’Amorim 2010
Upper and Lower bounds • For any subset Y of a poset L – u is an upper bound of Y if ∀ a. a ≤ u – l is a lower bound of Y if ∀ a. l ≤ a © Marcelo d’Amorim 2010
Least upper bound (lub) • lub is an upper bound s. t. for any other upper bound u, lub ≤ u lub, when exist, is unique © Marcelo d’Amorim 2010
Greatest lower bound (glb) • Dual of lub… © Marcelo d’Amorim 2010
Meet and Join a b c f d g • d is the meet of {a, b, c} • f is the join of {g, h} © Marcelo d’Amorim 2010 h
COMPLETE LATTICE © Marcelo d’Amorim 2010
Complete lattice • Poset (L, ≤) s. t. all subsets of L have lubs and glbs. Also, Top = lub L and Bottom = glb L © Marcelo d’Amorim 2010
Exercises • Considering the following cases, answer the questions: – What is L? – What is ≤? – Is the (Hasse) diagram a lattice? © Marcelo d’Amorim 2010
Example 1 © Marcelo d’Amorim 2010
Example 2 © Marcelo d’Amorim 2010
Example 3 © Marcelo d’Amorim 2010
Dataflow analysis encodes program information as an element in the lattice. Ordering denotes precision: l 0 ≤ l 1 indicates that l 1 carries more information than l 0. © Marcelo d’Amorim 2010
Dataflow analysis encodes program Accumulation of information (i. e. , progress information as an element in corresponds the lattice. to in the analysis) conceptually Ordering denotes precision: ordered movements in the lattice. But lwhen that iteractive l 1 carries more to stop such process? 0 ≤ l 1 indicates information than l 0. © Marcelo d’Amorim 2010
Chain • A subset Y of L is a chain if the elements are totally ordered © Marcelo d’Amorim 2010
Ascending (Descending) Chain • A sequence [y 0, y 1, y 2, …] denotes an ascending chain if y 0 ≤ y 1 ≤ y 2 ≤ … • Similar for descending chains © Marcelo d’Amorim 2010
Ascending chain condition • A poset satisfies ascending chain conditions iff all ascending chains stabilize 0 1 2 … 3 ∞ satisfies ascending chain condition, but not descending © Marcelo d’Amorim 2010
Fix Points • Consider a monotone function f : L => L if L satisfies ascending chain condition and f is monotonic increasing then exists n such that fn(Bottom)=fn+1(Bottom) © Marcelo d’Amorim 2010
Lattices considered in program analysis typically have finite height. For example, due to finite number of program locations and variable names. © Marcelo d’Amorim 2010
http: //pan. cin. ufpe. br • Recommended Bibliography – Appendix A from “Principles of Program Analysis”, Nielson and Hanking, Springer 2005 – First chapters from “Introduction to Lattices and Order”, Davey and Priestley, Cambridge Press, 1990 © Marcelo d’Amorim 2010
- Slides: 37