Sets, POSets, and Lattice
Y:\public_html\figs\pan\pan3.jpg
http://pan.cin.ufpe.br
© Marcelo d’Amorim 2010
SETS
© Marcelo d’Amorim 2010
Set
Collection of objects (elements) that carry noparticular 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}
© Marcelo d’Amorim 2010
Set A includes integer elementswith a 0 remainder for division by 2
Set A includes integer elementswith a 0 remainder for division by 2
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), 2A
Example
A={1,2,3}, 2A={Ø,{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:  thefirst (resp., second) component comes fromthe first (resp., second) set.
More formally:
   A x B = { (a,b) | a  A and b  B}
Notes
| A x B | = | A | x | B |
A2 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,<=)  Int x Int = {(a,b)| a,b: Int, a <= b}
Notation
  aRb = (a,b)  R
© Marcelo d’Amorim 2010
Relation properties
Reflexive
Symmetric
Anti-symmetry
Transitive
© Marcelo d’Amorim 2010
Relation properties
Reflexive:  a. aRa
Symmetric:  a,b . aRb implies bRa
Anti-symmetry:  a,b . aRb and bRa implies a=b
Transitive:  a, b, c. aRb and bRc implies aRc
© Marcelo d’Amorim 2010
Function
Def.: Relation R s.t. aRb and aRc 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 isreflexive, transitive, and anti-symmetric
Examples?
© Marcelo d’Amorim 2010
Partial Ordering
Def.: Relation ≤ : L x L => {true,false} that isreflexive, transitive, and anti-symmetric
Examples?
ancestor of
phenomena causality
© Marcelo d’Amorim 2010
Note: Important to characterizesemantics of concurrent systems!
Note: Important to characterizesemantics of concurrent systems!
Total order
Def.: Relation that is transitive, anti-symmetricand…total
Total:  a, b. aRb or bRa
© Marcelo d’Amorim 2010
reflexivity implied
reflexivity implied
POSETS
© Marcelo d’Amorim 2010
POSET
Set L with a partial ordering 
Notation
(L, ≤) to describe POSET
l1 ≤ l2 to describe a particular pair
© Marcelo d’Amorim 2010
≤ is not necessarily the subset relation
≤ is not necessarily the subset relation
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 upperbound ulub ≤ u
© Marcelo d’Amorim 2010
lub, whenexist, is unique
lub, whenexist, is unique
Greatest lower bound (glb)
Dual of lub
© Marcelo d’Amorim 2010
Meet and Join
© Marcelo d’Amorim 2010
a
b
d
f
g
h
c
d is the meet of {a,b,c}
f is the join of {g,h}
COMPLETE LATTICE
© Marcelo d’Amorim 2010
Complete lattice
Poset (L,≤) s.t. all subsets of L have lubs andglbs.  Also, Top = lub L and Bottom = glb L
© Marcelo d’Amorim 2010
Exercises
Considering the following cases, answer thequestions:
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
© Marcelo d’Amorim 2010
Dataflow analysis encodes programinformation as an element in the lattice.Ordering denotes precision:
l0 ≤ l1 indicates that l1 carries moreinformation than l0.
Dataflow analysis encodes programinformation as an element in the lattice.Ordering denotes precision:
l0 ≤ l1 indicates that l1 carries moreinformation than l0.
Dataflow analysis encodes programinformation as an element in the lattice.Ordering denotes precision:
l0 ≤ l1 indicates that l1 carries moreinformation than l0.
Dataflow analysis encodes programinformation as an element in the lattice.Ordering denotes precision:
l0 ≤ l1 indicates that l1 carries moreinformation than l0.
© Marcelo d’Amorim 2010
Accumulation of information (i.e., progressin the analysis) conceptually corresponds toordered movements in the lattice.  Butwhen to stop such iteractive process?
Accumulation of information (i.e., progressin the analysis) conceptually corresponds toordered movements in the lattice.  Butwhen to stop such iteractive process?
Chain
A subset Y of L is a chain if the elements aretotally ordered
© Marcelo d’Amorim 2010
Ascending (Descending) Chain
A sequence [y0,y1,y2,…] denotes an ascendingchain if y0 ≤ y1 ≤ y2 ≤ …
Similar for descending chains
© Marcelo d’Amorim 2010
Ascending chain condition
A poset satisfies ascending chain conditions iffall ascending chains stabilize
© Marcelo d’Amorim 2010
0
1
2
3
satisfies ascendingchain condition, butnot descending
satisfies ascendingchain condition, butnot descending
Fix Points
Consider a monotone function f : L => L
© Marcelo d’Amorim 2010
if L satisfies ascending chain conditionand f is monotonic increasing then existsn such that fn(Bottom)=fn+1(Bottom)
if L satisfies ascending chain conditionand f is monotonic increasing then existsn such that fn(Bottom)=fn+1(Bottom)
© Marcelo d’Amorim 2010
Lattices considered in program analysistypically have finite height.  For example,due to finite number of program locationsand variable names.
Lattices considered in program analysistypically have finite height.  For example,due to finite number of program locationsand variable names.
© Marcelo d’Amorim 2010
Y:\public_html\figs\pan\pan3.jpg
http://pan.cin.ufpe.br
Recommended Bibliography
Appendix A from “Principles of Program Analysis”,Nielson, Nielson and Hanking, Springer 2005
First chapters from “Introduction to Lattices andOrder”, Davey and Priestley, Cambridge Press, 1990