Proving with Computer Assistance Lecture 2. Herman Geuvers

Σχετικά έγγραφα
Introduction to Type Theory February 2008 Alpha Lernet Summer School Piriapolis, Uruguay. Herman Geuvers Nijmegen & Eindhoven, NL

Type Theory and Coq. Herman Geuvers. Principal Types and Type Checking

About these lecture notes. Simply Typed λ-calculus. Types

The Simply Typed Lambda Calculus

C.S. 430 Assignment 6, Sample Solutions

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

2 Composition. Invertible Mappings

Lecture 2. Soundness and completeness of propositional logic

Introduction to Type Theory February 2008 Alpha Lernet Summer School Piriapolis, Uruguay. Herman Geuvers Nijmegen & Eindhoven, NL

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Finite Field Problems: Solutions

λρ-calculus 1. each λ-variable is a λρ-term, called an atom or atomic term; 2. if M and N are λρ-term then (MN) is a λρ-term called an application;

CRASH COURSE IN PRECALCULUS

Fourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics

EE512: Error Control Coding

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

The challenges of non-stable predicates

Fractional Colorings and Zykov Products of graphs

derivation of the Laplacian from rectangular to spherical coordinates

Every set of first-order formulas is equivalent to an independent set

Areas and Lengths in Polar Coordinates

Example Sheet 3 Solutions

4.6 Autoregressive Moving Average Model ARMA(1,1)

Formal Semantics. 1 Type Logic

Areas and Lengths in Polar Coordinates

PARTIAL NOTES for 6.1 Trigonometric Identities

Sequent Calculi for the Modal µ-calculus over S5. Luca Alberucci, University of Berne. Logic Colloquium Berne, July 4th 2008

The λ-calculus. Lecturer: John Wickerson. Phil Wadler

Galatia SIL Keyboard Information

Other Test Constructions: Likelihood Ratio & Bayes Tests

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Section 8.3 Trigonometric Equations

From the finite to the transfinite: Λµ-terms and streams

Srednicki Chapter 55

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Solutions to Exercise Sheet 5

A Lambda Model Characterizing Computational Behaviours of Terms

Approximation of distance between locations on earth given by latitude and longitude

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Section 7.6 Double and Half Angle Formulas

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

Tridiagonal matrices. Gérard MEURANT. October, 2008

Chapter 3: Ordinal Numbers

Second Order Partial Differential Equations

Section 9.2 Polar Equations and Graphs

Reminders: linear functions

6.3 Forecasting ARMA processes

If we restrict the domain of y = sin x to [ π, π ], the restrict function. y = sin x, π 2 x π 2

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

If we restrict the domain of y = sin x to [ π 2, π 2

Εγχειρίδια Μαθηµατικών και Χταποδάκι στα Κάρβουνα

ST5224: Advanced Statistical Theory II

Finitary proof systems for Kozen s µ

CHAPTER 48 APPLICATIONS OF MATRICES AND DETERMINANTS

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

Affine Weyl Groups. Gabriele Nebe. Summerschool GRK 1632, September Lehrstuhl D für Mathematik

ΕΠΙΧΕΙΡΗΣΙΑΚΗ ΑΛΛΗΛΟΓΡΑΦΙΑ ΚΑΙ ΕΠΙΚΟΙΝΩΝΙΑ ΣΤΗΝ ΑΓΓΛΙΚΗ ΓΛΩΣΣΑ

Parametrized Surfaces

Jesse Maassen and Mark Lundstrom Purdue University November 25, 2013

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

A Note on Intuitionistic Fuzzy. Equivalence Relation

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

Homework 3 Solutions

Arithmetical applications of lagrangian interpolation. Tanguy Rivoal. Institut Fourier CNRS and Université de Grenoble 1

Advanced Subsidiary Unit 1: Understanding and Written Response

TMA4115 Matematikk 3

Main source: "Discrete-time systems and computer control" by Α. ΣΚΟΔΡΑΣ ΨΗΦΙΑΚΟΣ ΕΛΕΓΧΟΣ ΔΙΑΛΕΞΗ 4 ΔΙΑΦΑΝΕΙΑ 1

Statistical Inference I Locally most powerful tests

14 Lesson 2: The Omega Verb - Present Tense

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Math221: HW# 1 solutions

ΑΚΑ ΗΜΙΑ ΕΜΠΟΡΙΚΟΥ ΝΑΥΤΙΚΟΥ ΜΑΚΕ ΟΝΙΑΣ ΣΧΟΛΗ ΜΗΧΑΝΙΚΩΝ ΠΤΥΧΙΑΚΗ ΕΡΓΑΣΙΑ

DiracDelta. Notations. Primary definition. Specific values. General characteristics. Traditional name. Traditional notation

Homework 8 Model Solution Section

Abstract Storage Devices

SOLUTIONS TO MATH38181 EXTREME VALUES AND FINANCIAL RISK EXAM

Solutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz

Lambda calculus. Part II Lambda Calculi with Types

forms This gives Remark 1. How to remember the above formulas: Substituting these into the equation we obtain with

Homomorphism in Intuitionistic Fuzzy Automata

Congruence Classes of Invertible Matrices of Order 3 over F 2

Αλγόριθμοι και πολυπλοκότητα NP-Completeness (2)

Space-Time Symmetries

D Alembert s Solution to the Wave Equation

Commutative Monoids in Intuitionistic Fuzzy Sets

Dr. D. Dinev, Department of Structural Mechanics, UACEG

ADVANCED STRUCTURAL MECHANICS

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

Lecture 15 - Root System Axiomatics

Mean bond enthalpy Standard enthalpy of formation Bond N H N N N N H O O O

Transcript:

Proving with Computer Assistance Lecture 2 Herman Geuvers 1

Typed λ calculus as the basis for a Proof Assistant (e.g. Coq) λ-term program proof type specification formula Integrated system for proving and programming 2

Simplest system: λ or simple type theory, STT. Just arrow types Typ := TVar (Typ Typ) Examples: (α β) α, (α β) ((β γ) (α γ)) Brackets associate to the right and outside brackets are omitted: (α β) (β γ) α γ Types are denoted by σ, τ,.... Terms: typed variables x σ 1, x σ 2,..., countably many for every σ. application: if M : σ τ and N : σ, then (MN) : τ abstraction: if P : τ, then (λx σ.p) : σ τ 3

Examples: λx σ.λy τ.x : σ τ σ λx α β.λy β γ.λz α.y(xz) : (α β) (β γ) α γ λx α.λy (β α) α.y(λz β.x) : α ((β α) α) α For every type there is a term of that type: x σ : σ Not for every type there is a closed term of that type: (α α) α is not inhabited [That is: there is no closed term of type (α α) α.] 4

Typed Terms versus Type Assignment: With typed terms also called typing à la Church, we have terms with type information in the λ-abstraction Terms have unique types, λx α.x : α α The type is directly computed from the type info in the variables. With typed assignment also called typing à la Curry, we assign types to untyped λ-terms λx.x : α α Terms do not have unique types, A principal type can be computed using unification. Will be discussed in detail in a forthcoming lecture 5

Examples: Typed Terms: λx α.λy (β α) α.y(λz β.x) has only the type α ((β α) α) α Type Assignment: λx.λy.y(λz.x) can be assigned the types α ((β α) α) α α ((β α) γ) γ (α α) ((β α α) γ) γ... 6

The Curry formulation is especially interesting for programming: you want to write as little type information as possible; let the compiler infer the types for you. The Church formulation is especially interesting for proof checking: terms are created interactively; type structure is so intricate that type inference is undecidable (if you start from an untyped term). In this course we will mainly focus on the Church formulation of type theory: terms with type information. 7

Church formulation of simple type theory: terms with type information. Inductive definition of the terms: typed variables x σ 1, x σ 2,..., countably many for every σ. application: if M : σ τ and N : σ, then (MN) : τ abstraction: if P : τ, then (λx σ.p) : σ τ Alternative: Inductive definition of the terms in rule form: x σ : σ M : σ τ N : σ MN : τ P : τ λx σ.p : σ τ Advantage: We also have a derivation tree, a proof of the fact that the term has that type. We can reason over derivations. 8

Simple type theory a la Church. Formulation with contexts to declare the free variables: x 1 : σ 1, x 2 : σ 2,...,x n : σ n is a context, usually denoted by Γ. Derivation rules of λ (à la Church): x:σ Γ Γ x : σ Γ M : σ τ Γ N : σ Γ MN : τ Γ, x:σ P : τ Γ λx:σ.p : σ τ Γ λ M : σ if there is a derivation using these rules with conclusion Γ M : σ 9

Formulas-as-Types (Curry, Howard): There are two readings of a judgement M : σ 1. term as algorithm/program, type as specification: M is a function of type σ 2. type as a proposition, term as its proof: M is a proof of the proposition σ There is a one-to-one correspondence: typable terms in λ derivations in minimal proposition logic x 1 : τ 1, x 2 : τ 2,...,x n : τ n M : σ can be read as M is a proof of σ from the assumptions τ 1, τ 2,...,τ n. 10

Example [α β γ] 3 [α] 1 β γ γ 1 α γ (α β) α γ [α β] 2 [α] 1 β (α β γ) (α β) α γ 2 3 λx:α β γ.λy:α β.λz:α.xz(yz) : (α β γ) (α β) α γ 11

Example [x : α β γ] 3 [z : α] 1 xz : β γ xz(yz) : γ λz:α.xz(yz) : α γ [y : α β] 2 [z : α] 1 yz : β λy:α β.λz:α.xz(yz) : (α β) α γ λx:α β γ.λy:α β.λz:α.xz(yz) : (α β γ) (α β) α γ 1 2 3 Exercise: Give the derivation that corresponds to λx:γ ε.λy:(γ ε) ε.y(λz.y x) : (γ ε) ((γ ε) ε) ε 12

Computation: β-reduction: (λx:σ.m)p β M[P/x] 13

Cut-elimination in minimal logic = β-reduction in λ. [σ] 1 D 1 τ 1 σ τ τ [x : σ] 1 D 1 D 2 σ M : τ D 2 1 λx:σ.m : σ τ P : σ (λx:σ.m)p : τ β D 2 σ D 1 τ D 2 P : σ D 1 M[P/x] : τ 14

Example: Proof of A A B, (A B) A B [A] 1 A A B [A] 1 A B B A B (A B) A [A] 1 A A B [A] 1 A B A B A B It contains a cut: a -i directly followed by an -e. B 15

Example: Proof of A A B, (A B) A B after reduction [A] 1 A A B [A] 1 A B [A] 1 A A B [A] 1 A B B B (A B) A A B (A B) A A B A A A B A A B B 16

Example: Proof of A A B, (A B) A B with term information. [y : A] 1 p : A A B [y : A] 1 p y : A B p y y : B λy:a.p y y : A B q : (A B) A (λy:a.p y y)(q(λx:a.p xx)) : B Term contains a β-redex: (λx:a.p x x) (q(λx:a.p x x)) [x : A] 1 p : A A B [x : A] 1 p x : A B p xx : B λx:a.p xx : A B q(λx:a.p xx) : A 17

Example: Reduced proof of A A B, (A B) A B with term info. [x : A] 1 p : A A B [x : A] 1 p : A A B [x : A] 1 p x : A B [x : A] 1 p x : A B p x x : B p x x : B q : (A B) A λx:a.p x x : A B q : (A B) A λx:a.p x x : A B q(λx:a.p x x) : A p : A A B q(λx:a.p x x) : A p(q(λx:a.p x x)) : A B p(q(λx:a.p x x))(q(λx:a.p x x)) : B 18

The Fitch style (also: flag style) presentation of λ. 1 x : σ 2... 3... 4 M : τ 5 λx:σ.m : σ τ abs, 1, 4 abs-rule 1... 2... 3 M : σ τ 4... 5... 6 N : σ 7... 8 M N : τ app, 3, 6 app-rule 19

Example 1 x : α β γ 2 y : α β 3 z : α 4?? 5?? 6? : γ 7 λz:α.? : α γ 8 λy:α β.λz:α.? : (α β) α γ 9 λx:α β γ.λy:α β.λz:α.? : (α β γ) (α β) α γ 20

Example (ctd.) 1 x : α β γ 2 y : α β 3 z : α 4 xz : β γ 5 y z : β 6 xz(y z) : γ 7 λz:α.xz(y z) : α γ 8 λy:α β.λz:α.x z(y z) : (α β) α γ 9 λx:α β γ.λy:α β.λz:α.x z(y z) : (α β γ) (α β) α γ 21

Extension with other connectives: STT with product types (proposition logic with conjunction ) Γ M : σ τ Γ π 1 M : σ With reduction rules Γ M : σ τ Γ π 2 M : τ π 1 P, Q P π 2 P, Q Q Γ P : σ Γ Q : τ Γ P, Q : σ τ 22

Extension to predicate logic: First order language: domain D, with variables x, y, z : D and possibly functions over D, e.g. f : D D, g : D D D. Rules for x:d.ϕ and x:d.ϕ. (NB In ProofWeb, the domain D is always suppressed: x.ϕ and x.ϕ.) NB There are two kinds of variables: the first order variables (ranging over the domain D) and the proof variables (used as [local] assumptions of formulas). NB In Coq, you can use any name for these variables, but often H : ϕ x : D for assumptions: Suppose H is a proof of ϕ for variable declarations: Let x be an element of D 23

Extension to -quantifier in predicate logic. Γ M : x:d.σ Γ M t : σ[x := t] if t : D Γ M : σ Γ λx:d.m : x:d.σ x not free in Γ With the usual β-reduction rule 24

Example: Deriving irreflexivity from anti-symmetry AntiSym R Irrefl R := x, y:d.(rxy) (Ryx) := x:d.(rxx) Derivation in predicate logic: x, y:d.r xy R y x y:d.r xy R y x R xx R xx [R xx] R xx R xx x:d.r xx [R xx] 25

Derivation in type theory, with terms: H : x, y:d.r xy R y x H x : y:d.r xy R y x H xx : R xx R xx [H : R xx] H xxh : R xx [H : R xx] H xxh H : λh :(R xx).h xxh H : R xx λx:a.λh :(R xx).h xxh H : x:d.r xx 26