Semilattices presented by Niko Simonson, CSS 548, Autumn 2012 Semilattice City, © 2009 Nora Shader.

Slides:



Advertisements
Similar presentations
Continuing Abstract Interpretation We have seen: 1.How to compile abstract syntax trees into control-flow graphs 2.Lattices, as structures that describe.
Advertisements

Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
Foundations of Data-Flow Analysis. Basic Questions Under what circumstances is the iterative algorithm used in the data-flow analysis correct? How precise.
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
CSE 231 : Advanced Compilers Building Program Analyzers.
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Worklist algorithm Initialize all d i to the empty set Store all nodes onto a worklist while worklist is not empty: –remove node n from worklist –apply.
CS 536 Spring Global Optimizations Lecture 23.
Discrete Mathematics Lecture 4 Harper Langston New York University.
From last time: live variables Set D = 2 Vars Lattice: (D, v, ?, >, t, u ) = (2 Vars, µ, ;,Vars, [, Å ) x := y op z in out F x := y op z (out) = out –
From last time: Lattices A lattice is a tuple (S, v, ?, >, t, u ) such that: –(S, v ) is a poset – 8 a 2 S. ? v a – 8 a 2 S. a v > –Every two elements.
Data Flow Analysis Compiler Design Nov. 3, 2005.
From last time: reaching definitions For each use of a variable, determine what assignments could have set the value being read from the variable Information.
FSM Decomposition using Partitions on States 290N: The Unknown Component Problem Lecture 24.
Back to lattice (D, v, ?, >, t, u ) = (2 A, ¶, A, ;, Å, [ ) where A = { x ! N | x 2 Vars Æ N 2 Z } What’s the problem with this lattice? Lattice is infinitely.
Data Flow Analysis Compiler Design October 5, 2004 These slides live on the Web. I obtained them from Jeff Foster and he said that he obtained.
Administrative stuff Office hours: After class on Tuesday.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs, Data-flow Analysis Data-flow Frameworks --- today’s.
Recap: Reaching defns algorithm From last time: reaching defns worklist algo We want to avoid using structure of the domain outside of the flow functions.
Prof. Fateman CS 164 Lecture 221 Global Optimization Lecture 22.
From last lecture x := y op z in out F x := y op z (in) = in [ x ! in(y) op in(z) ] where a op b =
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Orderings and Bounds Parallel FSM Decomposition Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 10 Update and modified by Marek.
1 Data-Flow Frameworks Lattice-Theoretic Formulation Meet-Over-Paths Solution Monotonicity/Distributivity.
Project web page
Algebraic Laws Commutative and Associative Laws Commutativity for Sets and Bags (Ch5): R x S = S x R (Proof) R  S = S  R (ch5 e) R U S = S U.
From last lecture We want to find a fixed point of F, that is to say a map m such that m = F(m) Define ?, which is ? lifted to be a map: ? = e. ? Compute.
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
Partially Ordered Sets (POSets)
Lecture 9 Illustrations Lattices. Fixpoints Abstract Interpretation.
Sets, POSets, and Lattice © Marcelo d’Amorim 2010.
Λλ Fernando Magno Quintão Pereira P ROGRAMMING L ANGUAGES L ABORATORY Universidade Federal de Minas Gerais - Department of Computer Science P ROGRAM A.
Constant Propagation. The constant propagation framework is different from all the data-flow problems discussed so far, in that It has an unbounded set.
Precision Going back to constant prop, in what cases would we lose precision?
Abstract Interpretation (Cousot, Cousot 1977) also known as Data-Flow Analysis.
Solving fixpoint equations
Machine-Independent Optimizations Ⅱ CS308 Compiler Theory1.
Sets --- A set is a collection of objects. Sets are denoted by A, B, C, … --- The objects in the set are called the elements of the set. The elements are.
CS 267: Automated Verification Lecture 3: Fixpoints and Temporal Properties Instructor: Tevfik Bultan.
Sets, Relations, and Lattices
Module Code MA1032N: Logic Lecture for Week Autumn.
Sets and Subsets Set A set is a collection of well-defined objects (elements/members). The elements of the set are said to belong to (or be contained in)
UNIT VOCABULARY Functions. Closed Form of a Sequence (This is also known as the explicit form of a sequence.) For an arithmetic sequence, use a n = a.
Plan 1.Introduction a)What is a Program Fault? b)Deterministic/Non-Deterministic Programs 2.A Refinement Calculus 3.Relative Correctness for Non Deterministic.
Compiler Principles Fall Compiler Principles Lecture 11: Loop Optimizations Roman Manevich Ben-Gurion University.
Set Theory Concepts Set – A collection of “elements” (objects, members) denoted by upper case letters A, B, etc. elements are lower case brackets are used.
Data Flow Analysis II AModel Checking and Abstract Interpretation Feb. 2, 2011.
Iterative Dataflow Problems Taken largely from notes of Alex Aiken (UC Berkeley) and Martin Rinard (MIT) Dataflow information used in optimization Several.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Yet More Data flow analysis John Cavazos.
Lub and glb Given a poset (S, · ), and two elements a 2 S and b 2 S, then the: –least upper bound (lub) is an element c such that a · c, b · c, and 8 d.
DFA foundations Simone Campanoni
Fixpoints and Reachability
Chapter 15. Information Flow
Simone Campanoni DFA foundations Simone Campanoni
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Global optimizations.
Another example: constant prop
Introductory Material
Concurrent Models of Computation
Selection Statements.
Sequences Overview.
Data Flow Analysis Compiler Design
Lecture 20: Dataflow Analysis Frameworks 11 Mar 02
Background material.
Background material.
Introductory Material
Presentation transcript:

Semilattices presented by Niko Simonson, CSS 548, Autumn 2012 Semilattice City, © 2009 Nora Shader

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.

What do they look like?

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

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

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.

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!

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)

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.

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.

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.

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