Download presentation
Presentation is loading. Please wait.
Published byDouglas Parsons Modified over 8 years ago
1
Semilattices presented by Niko Simonson, CSS 548, Autumn 2012 Semilattice City, © 2009 Nora Shader
2
What is a Semilattice? Some domain of values... Example: {a, b, c}... a meet operator: Λ...... and a top element: T The top element is defined as T Λ a = a, for all elements a in the domain. Optionally, there may be a bottom element: ⊥, where ⊥ Λ a = ⊥, for all elements a in the domain.
3
What do they look like?
4
Partial Ordering The meet operator causes all semilattices to be partially ordered. If an ordered set is one where the operation a < b applies to any two elements, a partially ordered one is where the operation a ≤ b applies. ≤ does not necessarily mean less than or equal to! It can be any ordering. a ≤ b can mean: a is smaller than or equal to b a is a refinement of or the same as b a has the same or more (!) elements than b... as long as the relationship is always the same for all elements
5
Meet the Meet Operator The meet operator can be any binary operator that has the following attributes for all elements in the domain: a Λ a = a a Λ b = b Λ a a Λ (b Λ c) = (a Λ b) Λ c Good candidates for the meet operator are union U and intersection ∩ Remember T Λ a = a If T is empty, Λ is union If T is all the elements in the domain, Λ is intersection
6
So, what is a Lattice? Lattices have all the qualities of semilattices. They have two binary operators: a join operator in addition to the meet operator. The join operator is usually denoted as: V The join operator is complementary to meet: if meet means union, join means intersection, and vice versa.
7
Greatest Lower Bounds Partial ordering through the meet operator means the Greatest Lower Bound (GLB) can be identified. If a and b are elements in the set, there is an element g: G ≤ a G ≤ b Any element c where c ≤ a and c ≤ b means: c ≤ g... and the kicker: a Λ b = g, always!
8
We can make it all backwards! The semilattice described thus far is a meet semilattice. There are also join semilattices. The only difference is they use the join operator instead of the meet operator. Join operators produce Least Upper Bounds (LUBs)
9
A few more details If Λ is union, then a Λ b = a means a includes b. If Λ is intersection, then a Λ b = a means a is contained in b. If U is all the elements in the domain of a semilattice, then the set of all subsets in the domain has the size 2 U Semilattices of finite domains have finite heights. Semilattices of infinite domains (e.g. all constant integer values) may still have finite heights.
10
Go with the flow. Semilattices have applications to data flow analysis. Data flow consists of a family of schema that tracks various kinds of inputs and outputs over basic blocks (of sequential statements) of code. Important for determining whether variables are defined, constant expressions are available, etc. Even in simple programs, there is a vast amount of possible inputs.
11
Ideal, Incorrect, Safe, Precise Expressing data flow through semilattices, the greatest lower bounds can increase the precision of the number of possible execution paths. The number of execution paths found equal to the GLB is the ideal answer. The number of execution paths found that is more than the GLB is always incorrect. The fewer the execution paths found below the GLB, the safer (more conservative) the result. The closer the number of execution paths to the GLB, while still under, the more precise the result.
12
Data Flow Analysis For data flow analysis, three items are required: The direction of data flow Forward: statement blocks define data Backward: data is defined by upcoming statement blocks A family of transfer functions: how data changes before and after blocks A semilattice of the possible values of the data! Compilers, 2 nd ed., Aho, Lam et. al
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.