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

Post on 24-Dec-2015

219 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

© Marcelo d’Amorim 2010

Sets, POSets, and Lattice

http://pan.cin.ufpe.br

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

© 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 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. aRb or bRa∀

reflexivity implied

© Marcelo d’Amorim 2010

POSETS

© 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

© 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

d

f

g h

c

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

© Marcelo d’Amorim 2010

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:l0 ≤ l1 indicates that l1 carries more information than l0.

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

© 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 [y0,y1,y2,…] denotes an ascending chain if y0 ≤ y1 ≤ y2 ≤ …

• 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, Nielson and Hanking, Springer 2005– First chapters from “Introduction to Lattices and

Order”, Davey and Priestley, Cambridge Press, 1990

top related