Lecture 10: Fixed Points ad Infinitum M.C. Escher, Moebius Ants

Slides:



Advertisements
Similar presentations
Types and Programming Languages Lecture 7 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Advertisements

Continuing Abstract Interpretation We have seen: 1.How to compile abstract syntax trees into control-flow graphs 2.Lattices, as structures that describe.
Tutorial on Widening (and Narrowing) Hongseok Yang Seoul National University.
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
Programming Language Semantics Denotational Semantics Chapter 5 Based on a lecture by Martin Abadi.
Programming Language Semantics Denotational Semantics Chapter 5 Part II.
Prof. Aiken CS 294 Lecture 21 Abstract Interpretation Part 2.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Claus Brabrand, ITU, Denmark DATA-FLOW ANALYSISMar 25, 2009 Static Analysis: Data-Flow Analysis II Claus Brabrand IT University of Copenhagen (
Claus Brabrand, UFPE, Brazil Aug 09, 2010DATA-FLOW ANALYSIS Claus Brabrand ((( ))) Associate Professor, Ph.D. ((( Programming, Logic, and.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Fixed Points and Biological Computing.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CSE 230 The -Calculus. Background Developed in 1930’s by Alonzo Church Studied in logic and computer science Test bed for procedural and functional PLs.
CS 267: Automated Verification Lecture 3: Fixpoints and Temporal Properties Instructor: Tevfik Bultan.
Sequence Control Syntax and Semantics Jian Xu March 3, 2004 CS706, CAS McMaster.
Data Flow Analysis II AModel Checking and Abstract Interpretation Feb. 2, 2011.
David Evans CS200: Computer Science University of Virginia Computer Science Class 32: The Meaning of Truth.
1 Iterative Program Analysis Part II Mathematical Background Mooly Sagiv Tel Aviv University
Chaotic Iterations Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
Chaotic Iterations Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
1 Interactive Computer Theorem Proving CS294-9 October 19, 2006 Adam Chlipala UC Berkeley Lecture 9: Beyond Primitive Recursion.
Lecture 9 : Universal Types
CS5205: Foundation in Programming Languages Type Reconstruction
Functional Programming
(Thunking about Thunks)
Lecture 4: Metacircles Eval Apply David Evans
Fixpoints and Reachability
Unit – 3 :LAMBDA CALCULUS AND FUNCTIONAL PROGRAMMING
Lecture 6: Lambda Calculus
Lecture 11: Fixing Fixed Points On to Language Design
Lecture 2: Schreme David Evans
Class 27: Universal Turing Machines CS150: Computer Science
This statement is false.
More on Lambda Calculus
Lecture 37: A Universal Computer
Reasoning About Code.
Lambda Calculus Revisited
Class 19: Think Globally, Mutate Locally CS150: Computer Science
(Slides copied liberally from Ruth Anderson, Hal Perkins and others)
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Class 36: The Meaning of Truth CS200: Computer Science
Concurrent Models of Computation
Programming Languages and Compilers (CS 421)
CS 188: Artificial Intelligence Fall 2007
Lecture 21: Crosscutting Aspect-Oriented Programming Background
Lecture 10: The Return of Paco Background just got here last week
Formal Methods in software development
MA/CSSE 474 More Math Review Theory of Computation
CS 611: Lecture 10 More Lambda Calculus September 20, 1999
Data Flow Analysis Compiler Design
Lecture 20: Dataflow Analysis Frameworks 11 Mar 02
Class 33: Making Recursion M.C. Escher, Ascending and Descending
Lecture 10: Using Object-Oriented Languages
Class 24: Computability Halting Problems Hockey Team Logo
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Lecture 19: Proof-Carrying Code Background just got here last week
David Evans Lecture 19: ||ism I don’t think we have found the right programming concepts for parallel computers yet.
Lecture 12: Minding your Ps & Qs:
Class 26: Modeling Computing CS150: Computer Science
Lecture 5: DES Use and Analysis Background just got here last week
Lecture 14: Mocking Mockingbirds
CS 611: Lecture 10 More Lambda Calculus September 20, 1999
Lecture 15: Crazy Eddie and the Fixed Points Background
Induction: One Step At A Time
Group 4: Song Li, Ying Lu, Hexin Wang, and Michael Walker May 1, 2000
Lecture 23: Computability CS200: Computer Science
Presentation transcript:

David Evans http://www.cs.virginia.edu/~evans Lecture 10: Fixed Points ad Infinitum M.C. Escher, Moebius Ants Background just got here last week finished degree at MIT week before Philosophy of advising students don’t come to grad school to implement someone else’s idea can get paid more to do that in industry learn to be a researcher important part of that is deciding what problems and ideas are worth spending time on grad students should have their own project looking for students who can come up with their own ideas for research will take good students interested in things I’m interested in – systems, programming languages & compilers, security rest of talk – give you a flavor of the kinds of things I am interested in meant to give you ideas (hopefully even inspiration!) but not meant to suggest what you should work on CS655: Programming Languages University of Virginia Computer Science David Evans http://www.cs.virginia.edu/~evans

Goal: Understand the Least Fixed Point Theorem If D is a pointed complete partial order, then a continuous function f: D  D has a least fixed point (fixD f) defined by D { (fn D ) | n  0 } 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Last Time A domain is a structured set of values A function domain is constructed from two primitive domains, D1  D2 by associating an element of D2 with each element of D1. A fixed point of a function f: D1  D2 is an element d D such that f d = d. 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Last Time, cont. Any recursive definition can be encoded with a (non-recursive) generating function by abstracting out the thing that is defined. A fixed point of a generating function is a solution of its associated recursive definition. 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Last Time, cont. (D, ) is a partial order if is: reflexive: transitive: anti-symmetric: (D, ) is a pointed partial order if it has a bottom element u  D such that u d for all elements d  D. a a a b and b c imply a c a b and b a imply a = b 20 Feb 2000 University of Virginia CS 655

Ordered Product Domains If <D, D > and <E, E > is are POs, <D x E , D x E > is a partial order, ordered by: <d1, e1> D x E <d2, e2> if d1 D d2 and e1 E e2 20 Feb 2000 University of Virginia CS 655

Ordered Product Example What is << Nat,  > x < Nat,  >>? <0, 0> <0, 1> <1, 0> <0, 2> <2, 0> <1, 73> <3, 3> (Hasse diagram) 20 Feb 2000 University of Virginia CS 655

Ordered Function Domains If <D, D > and <E, E > is are POs, <D  E , D  E > is a partial order, ordered by: f  D  E f1 D  E f2 if for all d  D,(f1 d) E (f2 d) 20 Feb 2000 University of Virginia CS 655

Ordered Function Example < Bool,  > = { false, true } false  true true  false What is << Bool,  >  < Bool,  >>? <{false, true}, {true, true}> <{false, false}, {true, true}> <{false, true}, {true, false}> <{false, false}, {true, false}> 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 T-Shirt Exercise What is the order of the domain: <<Bool,  > x < Bool,  >  < Bool,  >> (includes xor, and, or, implies, ...) 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 The Domain Nat 2 1 3 4 ... Nat 20 Feb 2000 University of Virginia CS 655

Ordered Function Bottom What is the bottom of <Nat, >  <Nat, > ? { <0, >, <1, >, <2, >, ... } = { <x, > } = { } If a function map has no entry for x, it maps x to . 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Least Upper Bounds The least upper bound of a subset X of a domain D is the weakest element of X that is at least as strong as every other element of X. l  X = D X if for every x  X, x l and for every m  X such that x m x  X, l m 20 Feb 2000 University of Virginia CS 655

Least Upper Bounds in Nat { 0, 2, 4, 6, ... } = any element of { 0, 2, 4, 6, ... } Nat {Nat, 3, 17} = 3 or 17 Nat 2 1 3 4 ... Nat 20 Feb 2000 University of Virginia CS 655

Complete Partial Orders A partial order D is complete if every chain in D has a least upper bound in D. Any upward chain through a Hasse diagram converges to a limit All finite partial orders are complete Most sensible partial orders (including Nat) are complete (see Gifford’s notes for some incomplete POs.) 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Monotonic Functions f  D  E is monotonic if d1 D d2 implies (f d1) E (f d2). Is not over << Bool,  >  < Bool,  >> monotonic? Is { <x, x * 2>} over << Nat,  >  < Nat,  >> monotonic? What functions are monotonic over Nat  Nat? 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Continuous Functions f  D  E is continuous if, for all chains C in D, f applied to the least element of the chain over D is the least element of (f c) for cC over E. Continuity is like monotonicity, but it works for limits of infinite chains also. If the CPO is finite, monotonicity implies continuity. Continuity always implies monotonicity 20 Feb 2000 University of Virginia CS 655

Monotonic/Continuous Functions in Domain Nat 2 1 3 4 ... Nat What is a monotonic function in Nat? What is a continuous function in Nat? 20 Feb 2000 University of Virginia CS 655

Least Fixed Point Theorem If D is a pointed complete partial order, then a continuous function f: D  D has a least fixed point (fixD f) defined by D { (fn D ) | n  0 } The least upper bound of applying f any number of times, starting with D. 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Sanity Check In g: (Nat  Nat)  (Nat  Nat) =  f. n. if (n = 0) then 1 else (n * ( f (n - 1))) What is (fixNat  Nat g)? 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Sanity Check g: (Nat  Nat)  (Nat  Nat) =  f. n. if (n = 0) then 1 else (n * ( f (n - 1))) What is (fixNat  Nat g)? 20 Feb 2000 University of Virginia CS 655

What is the bottom of Nat  Nat? { <x, > | x  Nat } 20 Feb 2000 University of Virginia CS 655

What is (g { <x, > | x  Nat })? g =  f. n. if (n = 0) then 1 else (n * ( f (n - 1))) g { <x, > | x  Nat } = {<0, 1>, <x, > | x > 0 and x  Nat } 20 Feb 2000 University of Virginia CS 655

What is (g (g { <x, > | x  Nat }))? g =  f. n. if (n = 0) then 1 else (n * ( f (n - 1))) g { <0, 1>, <x, > | x > 0 and x  Nat } = { <0, 1>, <1, 1>, <x, > | x > 1 and x  Nat } 20 Feb 2000 University of Virginia CS 655

What is LUB (gn { <x, > | x  Nat }))? g =  f. n. if (n = 0) then 1 else (n * ( f (n - 1))) g { <0, 1>, <x, > | x > 0 and x  Nat } = { <0, 1>, <1, 1>, <2, 2>, <3, 6>, ...} = {<x, x!> | x  Nat } 20 Feb 2000 University of Virginia CS 655

Getting to the  of things Think of bottom as the element with the least information, or the “worst” possible approximation. To find the least fixed point in a function domain, start with the bottom of the function domain and iterate... 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Fixed Point Theorem Do all -calculus terms have a fixed point? (Smullyan: Is there a Sage bird?) 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Finding the Sage Bird  F ,  X  such that FX = X Proof: Let W =  x.F(xx) and X = WW. X = WW = ( x.F(xx))W   F (WW) = FX 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Why of Y? Y is  f. WW: Y   f. (( x.f (xx)) ( x. f (xx))) Y calculates a fixed point (but not necessarily the least fixed point) of any lambda term! If you’re not convinced, try calculating ((Y fact) n). (PS1, 1e) 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Still Uncomfortable? 20 Feb 2000 University of Virginia CS 655

Remember the problem reducing Y Different reduction orders produce different results Reduction may never terminate Normal Form means no more ß-reductions can be done There are no subterms of the form (x. M)N Not all -terms can be written in normal form 20 Feb 2000 University of Virginia CS 655

Church-Rosser Theorem If a -term has a normal form, any reduction sequence that produces a normal form always the same normal form Computation is deterministic Some orders of evaluation might not terminate though Evaluating leftmost first finds the normal form if there is one. Proof by trust the theory people, but don’t become one. 20 Feb 2000 University of Virginia CS 655

University of Virginia CS 655 Charge PS2 is due Thursday Domains are like types in programming languages, we will see them again soon... Next time: Intro to Language Design 20 Feb 2000 University of Virginia CS 655