The Strange Case of Dr. Admissibility and Mr. Derive

Similar documents
A Pronominal Account of Binding and Computation

Fall Recursion and induction. Stephen Brookes. Lecture 4

Lecture 2: SML Basics

Meta-programming with Names and Necessity p.1

Lecture 3: Recursion; Structural Induction

Fall Lecture 3 September 4. Stephen Brookes

Mechanizing Metatheory with LF and Twelf

Lecture Notes on Data Representation

Refinement Types as Proof Irrelevance. William Lovas with Frank Pfenning

if s has property P and c char, then c s has property P.

Dependently Typed Programming with Domain-Specific Logics

Lambda Calculus and Type Inference

Z Notation. June 21, 2018

UNIT 14C The Limits of Computing: Non computable Functions. Problem Classifications

Rule Formats for Nominal Modal Transition Systems

function at the given point. Thus, for our previous example we would find that lim f(x) = 0

CS 3512, Spring Instructor: Doug Dunham. Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010

Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description)

Lesson 4 Typed Arithmetic Typed Lambda Calculus

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

c constructor P, Q terms used as propositions G, H hypotheses scope identifier for a notation scope M, module identifiers t, u arbitrary terms

Coq quick reference. Category Example Description. Inductive type with instances defined by constructors, including y of type Y. Inductive X : Univ :=

Topic 1: What is HoTT and why?

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

Presented By : Abhinav Aggarwal CSI-IDD, V th yr Indian Institute of Technology Roorkee. Joint work with: Prof. Padam Kumar

Shared Variables and Interference

Exercise 1 ( = 22 points)

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes

CIS 194: Homework 8. Due Wednesday, 8 April. Propositional Logic. Implication

Type Inference Systems. Type Judgments. Deriving a Type Judgment. Deriving a Judgment. Hypothetical Type Judgments CS412/CS413

1. Abstract syntax: deep structure and binding. 2. Static semantics: typing rules. 3. Dynamic semantics: execution rules.

15 150: Principles of Functional Programming. More about Higher-Order Functions

Induction in Coq. Nate Foster Spring 2018

An experiment with variable binding, denotational semantics, and logical relations in Coq. Adam Chlipala University of California, Berkeley

Shared Variables and Interference

Outline Mousavi: ADT

CSCI 270: Introduction to Algorithms and Theory of Computing Fall 2017 Prof: Leonard Adleman Scribe: Joseph Bebel

14.1 Encoding for different models of computation

Introduction to Homotopy Type Theory

CS 151 Complexity Theory Spring Final Solutions. L i NL i NC 2i P.

Encoding functions in FOL. Where we re at. Ideally, would like an IF stmt. Another example. Solution 1: write your own IF. No built-in IF in Simplify

CSE200: Computability and complexity Interactive proofs

Lecture 6: Sequential Sorting

SAT-CNF Is N P-complete

CMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008

On Agda JAIST/AIST WS CVS/AIST Yoshiki Kinoshita, Yoriyuki Yamagata. Agenda

Programming Languages Fall 2014

Lecture 9: Zero-Knowledge Proofs

Introduction to the Lambda Calculus

CSE 120. Computer Science Principles

Natural Numbers. We will use natural numbers to illustrate several ideas that will apply to Haskell data types in general.

Processadors de Llenguatge II. Functional Paradigm. Pratt A.7 Robert Harper s SML tutorial (Sec II)

15 212: Principles of Programming. Some Notes on Induction

Lambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,

Automated Reasoning. Natural Deduction in First-Order Logic

CLF: A logical framework for concurrent systems

Lambda Calculus and Type Inference

Outline Purpose How to analyze algorithms Examples. Algorithm Analysis. Seth Long. January 15, 2010

Nominal Techniques in Coq

Introduction to dependent types in Coq

Focusing on Binding and Computation

Lee Pike. June 3, 2005

dynamically typed dynamically scoped

Topology Homework 3. Section Section 3.3. Samuel Otten

Jessica Su (some parts copied from CLRS / last quarter s notes)

1 Elementary number theory

2/18/14. Uses for Discrete Math in Computer Science. What is discrete? Why Study Discrete Math? Sets and Functions (Rosen, Sections 2.1,2.2, 2.

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

Math 302 Introduction to Proofs via Number Theory. Robert Jewett (with small modifications by B. Ćurgus)

Homework 3 COSE212, Fall 2018

COMP80 Lambda Calculus Programming Languages Slides Courtesy of Prof. Sam Guyer Tufts University Computer Science History Big ideas Examples:

Assistant for Language Theory. SASyLF: An Educational Proof. Corporation. Microsoft. Key Shin. Workshop on Mechanizing Metatheory

Lecture 3: Constructing the Natural Numbers

Graphs and Algorithms 2015

A Canonical 1 Locally Named Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh

Programming Languages Third Edition

CSC Discrete Math I, Spring Sets

Typed Lambda Calculus

Operational semantics questions and answers

Reasoning About Imperative Programs. COS 441 Slides 10

INTRODUCTION TO GRAPH THEORY. 1. Definitions

Introduction to Functional Programming in Haskell 1 / 56

CS 456 (Fall 2018) Scribe Notes: 2

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods

Chapter 2 The Language PCF

GADTs. GADTs in Haskell

Negations in Refinement Type Systems

Course notes for Data Compression - 2 Kolmogorov complexity Fall 2005

Propositional Logic. Part I

Math 55 - Spring 04 - Lecture notes # 1 - Jan 20 (Tuesday)

On the Minimum Number of Convex Quadrilaterals in Point Sets of Given Numbers of Points

Graphical Untyped Lambda Calculus Interactive Interpreter

Functional programming languages

A Universe of Binding and Computation

Reducibilities relations with applications to symbolic dynamics

QUIZ. What is wrong with this code that uses default arguments?

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Umans Complexity Theory Lectures

CPSC 467b: Cryptography and Computer Security

Transcription:

The Strange Case of Dr. Admissibility and Mr. Derive Dan Licata Joint work with Noam Zeilberger and Robert Harper 1

2 Goal A programming language that helps people: Define programming languages and logics Study their properties Use logics to reason about programs

3 Need A programming language that makes it easy to: Represent syntax as data: Programs of a programming language Propositions of a logic Compute with these representations: Write a compiler Write a theorem prover

Derivability 4

5 In math Polynomials over the reals: f(x) = x 2 + 2x + 1

5 In math Polynomials over the reals: f(x) = x 2 + 2x + 1

5 In math Polynomials over the reals: f(x) = x 2 + 2x + 1 Substitution: plug in for the variable f(3) = 3 2 + 2*3 + 1 f(y+5) = (y+5) 2 + 2(y+5) + 1

6 In programming Functional abstraction: fact(x) = if (x = 0) then 1 else x * (fact (x-1))

6 In programming Functional abstraction: fact(x) = if (x = 0) then 1 else x * (fact (x-1)) Compute by substitution: fact(5) = if (5 = 0) then 1 else 5 * (fact (5-1))

7 In logic A Assumption B Conclusion (A implies B)

8 In logic If (A implies B) and A then B A B (A implies B)

8 In logic If (A implies B) and A then B A + B A (A implies B)

8 In logic If (A implies B) and A then B A + = A B (A implies B) A B

9 Derivability Captures notion of terms-with-holes, which can be filled by substitution Represent syntax with variable binding Represent hypothetical judgements (typing for a programming language)

Admissibility 10

11 In math Function from reals to reals specified by: set of ordered pairs every number appears exactly once on the LHS { (0, 1), (1, 4), ( 2, 3 + 2 2), }

12 In programming Specify a function by its behavior (e.g., memo table): Factorial = { (0, 1), (1, 1), (2, 2), (3, 6), (4, 24), }

13 In logic To prove x:nat.a(x), prove A(n) for each numeral n. A(0) and A(1) and A(2) and A(3) and A(4)...

14 In logic To prove x:nat.(even(x) odd(x)), prove (even(n) odd(n)) for each numeral n. even(0) odd(0) and even(1) odd(1) and even(2) odd(2) and even(3) odd(3)...

15 Admissibility Captures notion of an arbitrary transformation: only i/o-behavior matters Represent proofs with infinitely many cases Compute with logical systems (compiler transformation, translation between logics) Prove theorems about logics

Derivability f(x) = x 2 + 2x + 1 Admissibility { (0, 1), (1, 4), ( 2, 3 + 2 2), }

17 Proof assistants Coq How well do existing proof assistants support derivability and admissibility?

18 Contributions Definitions using Derivability: easy in Twelf, hard in Coq Admissibility: easy in Coq, hard in Twelf

18 Contributions Definitions using Derivability: easy in Twelf, hard in Coq Admissibility: easy in Coq, hard in Twelf This work: Supports definitions using both derivability and admissibility

19 Outline Representations using derivability Representations using admissibility Mixed representations

20 Outline Representations using derivability Representations using admissibility Mixed representations

21 Derivability How do we represent variable binding?

21 Derivability How do we represent variable binding? What is variable binding?

22 Syntax with binding f(x) = x 2 + 2x + 1 x:nat.even(x) odd(x)

23 Structural properties Properties of variables: Substitution Renaming Weakening

24 Structural properties Properties of variables: Substitution (can plug in) Renaming Weakening

25 Structural properties Properties of variables: Substitution (can plug in) Renaming Weakening

Dan s Homework 1. Factor the following: f(x) = x 2 + 2x + 1 Answer : f(y) = (y + 1) 2 26

Dan s Homework 1. Factor the following: f(x) = x 2 + 2x + 1 Answer : f(y) = (y + 1) 2 The answer is f(x) = (x + 1) 2 26

Dan s Homework 1. Factor the following: f(x) = x 2 + 2x + 1 Answer : f(y) = (y + 1) 2 The answer is f(x) = (x + 1) 2 (Dan finds a new math teacher ) 26

27 Renaming Variables are pronouns: pointer structure matters, names don t f(x) = x 2 + 2x + 1 f(y) = y 2 + 2y + 1

28 Renaming Variables are pronouns: pointer structure matters, names don t f(x,y) = x 2 + 2y + 1 f(y,x) = y 2 + 2x + 1

29 Renaming Variables are pronouns: pointer structure matters, names don t f(x,y) = x 2 + 2y + 1 f(x,y) = y 2 + 2x + 1

30 Structural properties Properties of variables: Substitution (can plug in) Renaming (names don t matter) Weakening

31 Weakening A polynomial in one variable is called a univariate polynomial, a polynomial in more than one variable is called a multivariate polynomial when working with univariate polynomials one does not exclude constant polynomials...although strictly speaking constant polynomials do not contain any variables at all. -- Polynomial in Wikipedia

32 Weakening OK not to use a variable: f(x) = 4 f(x,y) = x 2 + 2x + 1

33 Structural properties Properties of variables: Substitution (can plug in) Renaming (names don t matter) Weakening (unused variables ok)

34 Representing derivability Q: How to implement data with binding? Answer 1: variables = strings Polynomial: f(x) = x 2 + 2 * x + 1 Representation: ( x, x 2 + 2 * x + 1) name of bound variable reference to binding

35 Representing derivability Q: How to implement data with binding? Answer 1: variables = strings ( x, x 2 + 2 * x + 1) Problems: Non-unique representations Do functions respect renaming? Have to implement substitution for each language

36 Representing derivability Q: How to implement data with binding? Other implement: de Bruijn indices/levels nominal logic [Pitts and Gabbay] cofinite quantification [Ayedemir et al.]

36 Representing derivability Q: How to implement data with binding? Other implement: de Bruijn indices/levels nominal logic [Pitts and Gabbay] cofinite quantification [Ayedemir et al.] These are implementation; we want the interface!

37 Representing derivability Key idea: represent binding with functions [HHP 93] Language provides a type of substitution functions with substitution, weakening,... Implementation hidden from programmer

38 Representing derivability f(x) = x + 3 represented by λx.plus x 3 Substitution functions written λu.v, where V is a value (e.g. constructors and variables)

39 Representing derivability Constructors generate syntax: const : rational exp Example: 3 represented by (const 3) plus : exp exp exp Example: 3 + 3 represented by plus (const 3) (const 3)

40 Representing derivability Polynomials represented by substitution functions of type (exp exp): f(x) = x + 3 represented by λx.plus x (const 3) variables represented by variables!

41 Representing derivability Polynomials represented by substitution functions of type (exp exp): substitution = application f(x) = x + 3 represented by λx.plus x (const 3) f(5) represented by (λx.plus x (const 3)) applied to (const 5)

42 Representing derivability Polynomials represented by substitution functions of type (exp exp): substitution = application f(x) = x + 3 represented by λx.plus x (const 3) f(5) represented by (λx.plus x (const 3)) applied to (const 5) = plus (const 5) (const 3)

43 Adequacy Important that λu.v allows only substitution functions Cannot use admissibility to represent syntax: there are many more set-theoretic functions from expressions to expressions than polynomials {(const n, 2 * 2 * 2 * * 2), } n times in total

44 Derivability A theory of syntax with variable binding 1. Represent data with binding a) Define constructors (plus) b) Use derivability to represent binding ( ) 2. Next: write recursive proofs/programs (admissibility)

45 Outline Representations using derivability Representations using admissibility Mixed representations

46 Admissibility Admissibility ( ) provided by pattern-matching functional programs zero : nat succ : nat nat double : nat nat double zero = zero double (succ n) = succ (succ (double n))

47 Admissibility Can pattern-match on substitution functions as well: eval : (exp exp) rational rational eval (λx.v) r = evalexp ( (λx.v) applied to (const r) ) evalexp : exp rational evalexp (const n) = n evalexp (plus n1 n2) = add (evalexp n1) (evalexp n2) apply a substitution function to perform substitution

48 Admissibility Twelf: Can use admissibility to reason about logical systems, but not to define logical systems Coq and our framework: Can use admissibility in definitions

49 Admissibility 3 a b 5 3 c shortestpath(a1,a2,n) iff path(a1,a2,n) and ( m.path(a1,a2,m) m n)

50 Admissibility shortestpath(a1,a2,n) iff path(a1,a2,n) and ( m.path(a1,a2,m) m n) can be written as path(a1,a2,n) ( m.path(a1,a2,m) m n) shortestpath(a1,a2,n)

51 Admissibility 3 a b 5 3 c path(a,c,5) ( m.path(a,c,m) m 5) shortestpath(a,c,5)

52 Admissibility in rules 3 a b 5 3 c case [ac]: 5 5 path(a,c,5) case [abc]: 6 5 shortestpath(a,c,5)

53 Admissibility in rules 3 a b 5 (undirected, repeats ok) 3 c case [ac]: 5 5 case [abc]: 6 5 case [acbc]: 11 5 path(a,c,5) infinitely many more... shortestpath(a,c,5)

Contrast with derivability Admissibility ( m.path(a,c,m) m 5) allows proof by cases on the paths in this particular graph Derivability ( m.path(a,c,m) m 5) requires proof for a new path of new length m: not true!

55 Outline Representations using derivability Representations using admissibility Mixed representations

56 Arithmetic expressions Arithmetic expressions with let-binding: e ::= const n let x be e1 in e2 plus e1 e2 times e1 e2 sub e1 e2 mod e1 e2 div e1 e2 let x be (const 4) in (plus x x)

56 Arithmetic expressions Arithmetic expressions with let-binding: let x be (const 4) in (plus x x) e ::= const n let x be e1 in e2 plus e1 e2 times e1 e2 sub e1 e2 mod e1 e2 div e1 e2 Suppose we want to treat binops uniformly

57 Arithmetic expressions Arithmetic expressions with let-binding e ::= const n let x be e1 in e2 binop e1 φ e2 where φ : (nat nat nat) is the code for the binop.

58 Arithmetic expressions const : nat exp let : exp (exp exp) exp binop : exp (nat nat nat) exp exp let x be (const 4) in (x + x) represented by let (const 4) (λx.binop x add x) where add:(nat nat nat) is the code for addition

59 Arithmetic expressions const : nat exp let : exp (exp exp) exp binop : exp (nat nat nat) exp exp let x be (const 4) in (x + x) let (const 4) (λx.binop x add x) where add:(nat nat nat) is the code for addition

59 Arithmetic expressions const : nat exp let : exp (exp exp) exp binop : exp (nat nat nat) exp exp let x be (const 4) in (x + x) let (const 4) (λx.binop x add x) where add:(nat nat nat) is the code for addition

60 Arithmetic expressions const : nat exp let : exp (exp exp) exp binop : exp (nat nat nat) exp exp let x be (const 4) in (x + x) let (const 4) (λx.binop x add x) where add:(nat nat nat) is the code for addition

61 Arithmetic expressions const : nat exp let : exp (exp exp) exp binop : exp (nat nat nat) exp exp let x be (const 4) in (x + x) let (const 4) (λx.binop x add x) where add:(nat nat nat) is the code for addition

Structural properties 62

62 Structural properties Weakening for mixed representations:

62 Structural properties Weakening for mixed representations: 1. Go from (nat nat) to (nat nat nat)

62 Structural properties Weakening for mixed representations: 1. Go from (nat nat) to (nat nat nat) λx.(λy.v) [x doesn t occur in V]

62 Structural properties Weakening for mixed representations: 1. Go from (nat nat) to (nat nat nat) λx.(λy.v) [x doesn t occur in V] 2.Go from (nat nat) to (nat nat nat)

62 Structural properties Weakening for mixed representations: 1. Go from (nat nat) to (nat nat nat) λx.(λy.v) [x doesn t occur in V] 2.Go from (nat nat) to (nat nat nat) drop x y = f y [x doesn t occur in f]

Structural properties 63

63 Structural properties Weakening for mixed representations:

63 Structural properties Weakening for mixed representations: 3. Go from (nat nat) to (nat nat nat)

63 Structural properties Weakening for mixed representations: 3. Go from (nat nat) to (nat nat nat) h x = λy.v [x doesn t occur in V]

63 Structural properties Weakening for mixed representations: 3. Go from (nat nat) to (nat nat nat) h x = λy.v [x doesn t occur in V] 4.Go from (nat nat) to (nat (nat nat))

64 Structural properties A function of type (nat nat): double zero = zero double (succ n) = succ (succ (double n))

65 Structural properties A (nat (nat nat)): λx.double zero = zero double (succ n) = succ (succ (double n)) double x =??? Problem: double doesn t have a case for x, so mixed representations not necessarily structural!

66 Structural properties Our solution: λx.v used by pattern-matching; application (=substitution) is not built-in Nothing forces to be structural Weakening/substitution implemented generically for a wide class of rule systems, using some technical conditions

67 Structural properties const : nat exp let : exp (exp exp) exp binop : exp (nat nat nat) exp exp Can t weaken exp with nat: could need new case for in a binop Can weaken exp with exp: doesn t appear to left of

Conclusion 68

69 Summary Derivability (variable binding) provided by substitution functions ( ) Admissibility (arbitrary reasoning) provided by pattern-matching functional programs ( ) Our framework makes it easy to use both

70 Future work This talk: syntax of logical systems Need dependent types to represent judgements More examples mixing / Thesis work: a language in which you can define logics and use them to reason about programs

71

Strange Case of Dr. Admissibility and Mr. Derive 71