Supercompilation and Normalisation by Evaluation Gavin Mendel-Gleason & Geoff Hamilton Dublin City University.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

Types and Programming Languages Lecture 7 Simon Gay Department of Computing Science University of Glasgow 2006/07.
NP-Hard Nattee Niparnan.
1 Turing Machines and Equivalent Models Section 13.2 The Church-Turing Thesis.
CSE 636 Data Integration Conjunctive Queries Containment Mappings / Canonical Databases Slides by Jeffrey D. Ullman.
2005conjunctive-ii1 Query languages II: equivalence & containment (Motivation: rewriting queries using views)  conjunctive queries – CQ’s  Extensions.
Knowledge & Reasoning Logical Reasoning: to have a computer automatically perform deduction or prove theorems Knowledge Representations: modern ways of.
Resolution.
Generalization and Specialization of Kernelization Daniel Lokshtanov.
Induction Lecture 5: Sep 21 (chapter of the book and chapter of the notes)
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
Induction Sections 41. and 4.2 of Rosen Fall 2008 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions:
1 Finite Model Theory Lecture 10 Second Order Logic.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
10 December 2002BU CAS CS520 1 Principles of Programming Languages (Final Review) Hongwei Xi Comp. Sci. Dept. Boston University.
Induction Sections 4.1 and 4.2 of Rosen Fall 2010
15 PARTIAL DERIVATIVES.
Review Test 5 You need to know: How to symbolize sentences that include quantifiers of overlapping scope Definitions: Quantificational truth, falsity and.
Sparkle A theorem prover for the functional language Clean Maarten de Mol University of Nijmegen February 2002.
1 Chapter 2 Limits and Continuity Rates of Change and Limits.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
4. The Postulates of Quantum Mechanics 4A. Revisiting Representations
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
Claus Brabrand, UFPE, Brazil Aug 09, 2010DATA-FLOW ANALYSIS Claus Brabrand ((( ))) Associate Professor, Ph.D. ((( Programming, Logic, and.
Problem of the DAY Create a regular context-free grammar that generates L= {w  {a,b}* : the number of a’s in w is not divisible by 3} Hint: start by designing.
Induction and recursion
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
Review I Rosen , 3.1 Know your definitions!
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
The Pumping Lemma for Context Free Grammars. Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar.
Marriage Problem Your the sovereign in a small kingdom. One of your jobs is to marry off the people in kingdom. There are three rules that apply.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 11, 2014.
CS344: Introduction to Artificial Intelligence Lecture: Herbrand’s Theorem Proving satisfiability of logic formulae using semantic trees (from Symbolic.
Advanced Formal Methods Lecture 5: Isabelle – Proofs and Rewriting Mads Dam KTH/CSC Course 2D1453, Some slides from Paulson.
Rewriting Logic Model of Compositional Abstraction of Aspect-Oriented Software FOAL '10Mar. 15, 2010 Yasuyuki Tahara, Akihiko Ohsuga The University of.
REVIEW A relation is a set of ordered pairs. {(2,3), (-1,5), (4,-2), (9,9), (0,-6)} This is a relation The domain is the set of all x values.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
CS Introduction to AI Tutorial 8 Resolution Tutorial 8 Resolution.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
Automated Reasoning Early AI explored how to automated several reasoning tasks – these were solved by what we might call weak problem solving methods as.
Naïve Set Theory. Basic Definitions Naïve set theory is the non-axiomatic treatment of set theory. In the axiomatic treatment, which we will only allude.
Section 3.3: Mathematical Induction Mathematical induction is a proof technique that can be used to prove theorems of the form:  n  Z +,P(n) We have.
Mathematical Preliminaries
2.1 Sets 2.2 Set Operations –Set Operations –Venn Diagrams –Set Identities –Union and Intersection of Indexed Collections 2.3 Functions 2.4 Sequences and.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from.
CS 203: Introduction to Formal Languages and Automata
CS 461 – Nov. 30 Section 7.5 How to show a problem is NP-complete –Show it’s in NP. –Show that it corresponds to another problem already known to be NP-complete.
Discrete Mathematics CS 2610 February 10, Agenda Previously Functions And now Finish functions Start Boolean algebras (Sec. 11.1)
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
Albert Gatt LIN3021 Formal Semantics Lecture 3. Aims This lecture is divided into two parts: 1. We make our first attempts at formalising the notion of.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Week 4 - Friday.  What did we talk about last time?  Floor and ceiling  Proof by contradiction.
CMSC 330: Organization of Programming Languages Operational Semantics.
Types and Programming Languages Lecture 3 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
Metalogic Soundness and Completeness. Two Notions of Logical Consequence Validity: If the premises are true, then the conclusion must be true. Provability:
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
English for Economic Informatics I Tomáš Foltýnek Theoretical Foundations of Informatics.
Lecture 11: Proof by Reflection
Advanced Algorithms Analysis and Design
Proving Properties of Recursive List Functions
3.5 Minimum Cuts in Undirected Graphs
Advanced Analysis of Algorithms
Presentation transcript:

Supercompilation and Normalisation by Evaluation Gavin Mendel-Gleason & Geoff Hamilton Dublin City University

Why Bother? Wanted to figure out when one thing was like another. Thought that Supercompilation's intuitive process trees might have a deeper meaning. Normalisation is a well used framework for finding canonical terms Normalisation is stuck in a terminating world

Normalisation In the Curry Howard setting, normalisation is cut elimation and proof simplification. We can tell if two proofs are the same if they are synatically identical after normalisation. Normalisation just requires the application of appropriate reduction rules.

Curry-Howard Correspondance We try to draw a correspondance between the world of proofs and the world of programs Proofs Programs Propositions Types

System F System F is a simple language with an interesting type system. It allows quantification over types: implicational monadic second order logic. Λ A. (λ x : A. x) : ∀ A. A→A It is strongly normalising, so we can find a “value” for any program by applying reduction rules.

What does it mean to reduce?

System F - Extended Types {A,B,C} := 1| X | A→B | ∀ X.A | A+B | A*B X.A Terms {r,s,t} := x | f | () | λx:A.t | Λ X.t | r s | r A | inl(t,B) | inr(t,A) | (t,s) | in(t,A) | out(t,A) | split r as x1,x2 in s | case r of inl(x1) => s ; inr(x2) =>t Ctx {G} :=. | G,X | G,x:A D = a map from function constants to terms.

What have we done? Everything there is representable except unfolding. We can do sums, products and even least and greatest fixed points without extension – using a church encoding – but it's slow We've gained general recursion, lost normalisation. Cut evaluation into two peices!

We can't compare anymore We can still compare programs for syntactic equality, but it doesn't tell us anything about the unfolding behaviour. We want a behavioural model of the program. Let's see how things unfold

When is one thing like another? Morris contextual equivalence says that we want to know that C[e] = C[e'] for any context C. It's hard to quantify over contexts. Gordon tells us about another path – we can treat functional programs as a transition system. Equivalence becomes a question of bisimulation.

Two players, internal and external “A point to watch is to make a distinction between internal and external behaviour” - Plotkin We don't know what free variables are going to do except for what their type says. This is how supercompilation has always built process trees – nothing new. Our graph is built from a term t, using [t]

Transition System T = (S,A,:SxAxS)‏ A a set of actions – here determined by the language S a set of states – which are terms

Creating the Graph

Example

A Difference without a distinction Well known that we can distribute case – but we see it plainly here. Just compare edge labels and leaves to match. Where do these transitions come from?  They came from one-hole evaluation contexts – or atomic experiments that define the reduction semantics.  Case [] of... | Split [] as... | [] b

For Infinity

Arbitrary Bisimulation To show that a~b  Whenever (a,,a') in G1, then (b,,b') in G2 and a'~b'  Whenever (b,,b') in G2, then (a,,a') in G1,and a'~b'

Use Park's Principle We do this by coming up with a monotone relation, that we can use to replace ~, then we can easily show that it is a subset of ~ hence we can show ~ In practice this just means we have to be careful to have done something, before reusing our hypothesis. That is: assume a~b but make sure we have a transition before using it.

Composition of Graphs

Composition is Bisimilar [t] [s] ~ [t s] [t] T ~ [t T] We can go back and forth between splitting out separate graphs and combining into one.

Pending Questions Equivalence of process trees should give a contextual equivalence – we shouldn't need to show improvement, but I've yet to prove this. Do we need the improvement theorem?  In the f 0 = 42 example [Bird], we have equational rewriting going wrong, but we don't have a replacement of one normal form for an equivalent normal form. What fragments will we get normal forms for?

{- Also called min on natural numbers -} join :: CoTrue -> CoTrue -> CoTrue join T b = T join a T = T join (D a) (D b) = D (join a b)‏ ex :: (Nat -> CoTrue) -> NatStream -> CoTrue ex p (SCons x s) = D (join (p x) (ex p s))‏ {- Also called min on natural numbers -} join :: CoTrue -> CoTrue -> CoTrue join T b = T join a T = T join (D a) (D b) = D (join a b)‏ ex :: (Nat -> CoTrue) -> NatStream -> CoTrue ex p (SCons x s) = D (join (p x) (ex p s))‏ {- Also called min on natural numbers -} join :: CoTrue -> CoTrue -> CoTrue join T b = T join a T = T join (D a) (D b) = D (join a b)‏ ex :: (Nat -> CoTrue) -> NatStream -> CoTrue ex p (SCons x s) = D (join (p x) (ex p s))‏ data CoTrue = T | D CoTrue true = T false = D false eq Z Z = true eq (S x) (S y) = eq x y eq x y = false