sets, posets, and lattice © marcelo d’amorim 2010

37
Sets, POSets, and Lattice http://pan.cin.ufpe.br © Marcelo d’Amorim 2010

Upload: shana-cunningham

Post on 24-Dec-2015

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Sets, POSets, and Lattice

http://pan.cin.ufpe.br

Page 2: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

SETS

Page 3: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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

Page 4: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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

Page 5: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Cardinality

• |A| denotes the number of elements in A

Page 6: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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⊃ ∈ ∈

Page 7: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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)}∈ ∈

Page 8: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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}}

Page 9: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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– | A x B | = | A | x | B |– A2 is shorthand for A x A

Page 10: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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∈

Page 11: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Relation properties

• Reflexive• Symmetric• Anti-symmetry• Transitive

Page 12: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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∀

Page 13: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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∀ ∃

Page 14: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

PARTIAL ORDERING

Page 15: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Partial Ordering

• Def.: Relation ≤ : L x L => {true,false} that is reflexive, transitive, and anti-symmetric

• Examples?

Page 16: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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!

Page 17: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Total order

• Def.: Relation that is transitive, anti-symmetric and…total

• Total: a, b. aRb or bRa∀

reflexivity implied

Page 18: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

POSETS

Page 19: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

POSET

• Set L with a partial ordering ≤ • Notation – (L, ≤) to describe POSET– l1 ≤ l2 to describe a particular pair

≤ is not necessarily the subset relation

Page 20: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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

Page 21: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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

Page 22: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Greatest lower bound (glb)

• Dual of lub…

Page 23: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Meet and Join

a b

d

f

g h

c

• d is the meet of {a,b,c}• f is the join of {g,h}

Page 24: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

COMPLETE LATTICE

Page 25: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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

Page 26: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Exercises

• Considering the following cases, answer the questions:– What is L?– What is ≤?– Is the (Hasse) diagram a lattice?

Page 27: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Example 1

Page 28: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Example 2

Page 29: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Example 3

Page 30: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Dataflow analysis encodes program information as an element in the lattice. Ordering denotes precision:l0 ≤ l1 indicates that l1 carries more information than l0.

Page 31: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Dataflow analysis encodes program information as an element in the lattice. Ordering denotes precision:l0 ≤ l1 indicates that l1 carries more information than l0.

Accumulation of information (i.e., progress in the analysis) conceptually corresponds to ordered movements in the lattice. But when to stop such iteractive process?

Page 32: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Chain

• A subset Y of L is a chain if the elements are totally ordered

Page 33: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

Ascending (Descending) Chain

• A sequence [y0,y1,y2,…] denotes an ascending chain if y0 ≤ y1 ≤ y2 ≤ …

• Similar for descending chains

Page 34: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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

Page 35: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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)

Page 36: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© 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.

Page 37: Sets, POSets, and Lattice  © Marcelo d’Amorim 2010

© Marcelo d’Amorim 2010

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 and

Order”, Davey and Priestley, Cambridge Press, 1990