the coq proof assistant
play

The Coq proof assistant : inductive predicate principles and - PowerPoint PPT Presentation

Coq J.-F. Monin Structural induction Induction on a The Coq proof assistant : inductive predicate principles and practice Well-founded induction J.-F. Monin Universit Grenoble Alpes 2016 Lecture 8 Outline Coq J.-F. Monin


  1. Coq J.-F. Monin Structural induction Induction on a The Coq proof assistant : inductive predicate principles and practice Well-founded induction J.-F. Monin Université Grenoble Alpes 2016 Lecture 8

  2. Outline Coq J.-F. Monin Structural induction Induction on a inductive predicate Well-founded induction Structural induction Induction on a inductive predicate Well-founded induction

  3. Outline Coq J.-F. Monin Structural induction Induction on a inductive predicate Well-founded induction Structural induction Induction on a inductive predicate Well-founded induction

  4. Structural induction Coq J.-F. Monin A very natural generalisation of induction Structural induction Induction on a inductive predicate On lists Well-founded induction ∀ n ∀ l , P l ⇒ P ( n :: l ) P nil ∀ l , P l Examples: stuttering list, associativity of append, reverse On binary trees P leaf ∀ n ∀ t l t r , P t l ⇒ P t r ⇒ P ( Node t l n t r ) ∀ t , P t Examples: number of keys and of leaves, algorithms on binary search trees

  5. Outline Coq J.-F. Monin Structural induction Induction on a inductive predicate Well-founded induction Structural induction Induction on a inductive predicate Well-founded induction

  6. Induction on a inductive predicate Coq J.-F. Monin Structural induction Induction on a inductive predicate Well-founded Inductive even : nat -> Prop := induction | E0 : even 0 | E2: forall n:nat, even n -> even (S (S n)). We expect the following induction principle: P 0 ∀ n , even n ⇒ P n ⇒ P ( S ( S n )) ∀ n , even n ⇒ P n

  7. Lists of consecutive even numbers Coq J.-F. Monin Structural Inductive natlist: Set := induction Induction on a | E : natlist inductive predicate | C : nat -> natlist -> natlist. Well-founded induction P E ∀ n ∀ l , P l ⇒ P ( C n l ) ∀ l , P l Inductive evl : nat -> Set := | E0 : evl 0 | E2: forall n:nat, evl n -> evl (S (S n)). P E 0 ∀ n ∀ l , P l ⇒ P ( E 2 n l ) ∀ l , P l P 0 E 0 ∀ n ∀ l , P n l ⇒ P ( S ( S n )) ( E 2 n l ) ∀ nl , P n l

  8. Lists of consecutive even numbers (cont’d) Coq J.-F. Monin Structural induction Inductive evl : nat -> Set := Induction on a | E0 : evl 0 inductive predicate | E2: forall n:nat, evl n -> evl (S (S n)). Well-founded induction P 0 E 0 ∀ n ∀ l , P n l ⇒ P ( S ( S n )) ( E 2 n l ) ∀ nl , P n l Take for P a predicate which does not depend on its second def argument: P n l = Q n = Q 0 ∀ n ∀ ( l : evl n ) , Q n ⇒ Q ( S ( S n )) ∀ n ( l : evl n ) , Q n Q 0 ∀ n , evl n ⇒ Q n ⇒ Q ( S ( S n )) ∀ n , evl n ⇒ Q n Now, evl reads just even

  9. Functional interpretation Coq J.-F. Monin Inductive list : Set := Structural induction | E : list Induction on a | C : nat -> list -> list. inductive predicate P E ∀ n ∀ l , P l ⇒ P ( C n l ) Well-founded induction ∀ l , P l Lists of consecutive even numbers typed according to the value of the expected next head Inductive evl : nat -> Set := | E0 : evl 0 | E2: forall n:nat, evl n -> evl (S (S n)). P E 0 ∀ n ∀ l , P l ⇒ P ( E 2 n l ) ∀ l , P l P 0 E 0 ∀ n ∀ l , P n l ⇒ P ( S ( S n )) ( E 2 n l ) ∀ nl , P n l

  10. Booleans and inductively defined predicates Coq J.-F. Monin Structural Fixpoint evenb (n:nat) : bool := induction match n with Induction on a inductive predicate | O => true Well-founded | S O => false induction | S (S n’) => evenb n’ end. Inductive even : nat -> Prop := | E0 : even O | E2 : ∀ n, even n -> even (S (S n)). Theorem even_evenb : ∀ n, even n -> evenb n = true. By induction on the structure of the proof of even n Theorem evenb_even : ∀ n, evenb n = true -> even n. By induction on n

  11. Booleans and inductively defined predicates Coq J.-F. Monin Structural induction Theorem even_evenb : Induction on a inductive predicate ∀ n, even n -> evenb n = true. Well-founded induction By induction on the structure of the proof of even n Don’t have to bother about odd numbers Theorem evenb_even : ∀ n, evenb n = true -> even n. By induction on n : need for strengthening and discrimination. Inversion Issue: getting the possible ways of constructing a hypothesis Easier for evenb than for even , see even inversion.v This issue cannot be avoided for non-deterministic relations

  12. Outline Coq J.-F. Monin Structural induction Induction on a inductive predicate Well-founded induction Structural induction Induction on a inductive predicate Well-founded induction

  13. Stronger induction principles Coq J.-F. Monin Structural induction Induction on a P 0 P 1 ∀ n , P n ∧ P ( S n ) ⇒ P ( S ( S n )) inductive predicate ∀ n , P n Well-founded induction P 0 ∀ n , ( ∀ m , m ≤ n ⇒ P m ) ⇒ P ( S n ) ∀ n , P n By (basic) induction on Q n def = ∀ m , m ≤ n ⇒ P m = Rephrasing ∀ n , ( ∀ m , m < n ⇒ P m ) ⇒ P n ∀ n , P n Well-founded induction on ( nat , < )

  14. Well-founded induction Coq J.-F. Monin Structural Material: induction Induction on a ◮ S : a set, called the domain of the induction inductive predicate ◮ R : a relation on S Well-founded induction ◮ R is well-founded (see below) Then we have the following induction principle: ∀ x , ( ∀ y , R y x ⇒ P y ) ⇒ P x ∀ x , P x Two definitions on well-founded (equivalent in classical logic) ◮ any decreasing chain eventually stops ◮ all elements of S are accessible An element is accessible def = all its predecessors are accessible =

  15. Well-founded relation Coq J.-F. Monin Structural induction Induction on a inductive predicate Well-founded ◮ R is well-founded if induction all elements of S are accessible for R Variable A : Type. Variable R : A -> A -> Prop. Inductive Acc (x: A) : Prop := Acc_intro : ( ∀ y:A, R y x -> Acc y) -> Acc x.

  16. Important application Coq J.-F. Monin Structural Theorem of chocolate tablets induction Induction on a inductive predicate Well-founded Statement induction Let us take a tablet containing n tiles and cut it into pieces along grooves How many shots are needed for reducing the tablet into tiles? Answer n − 1 It does not depend on successive choices of grooves! Proof By well-founded induction on ( nat , < )

  17. Construction of well-founded relations Coq J.-F. Monin Structural induction Induction on a inductive predicate Well-founded induction E.g. the lexicographic ordering of two well-founded relations is well-founded.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend