introduction to the calculus of inductive constructions
play

Introduction to the Calculus of Inductive Constructions Workshop X - PowerPoint PPT Presentation

Introduction to the Calculus of Inductive Constructions Workshop X . X , Vienna Summer of Logic Christine Paulin-Mohring e Paris Sud & INRIA Saclay - Universit Ile-de-France July 18, 2014 C. Paulin (Paris-Sud) Calculus of


  1. Introduction to the Calculus of Inductive Constructions Workshop ∀ X . X π , Vienna Summer of Logic Christine Paulin-Mohring e Paris Sud & INRIA Saclay - ˆ Universit´ Ile-de-France July 18, 2014 C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 1 / 33

  2. Introduction Motivations ◮ Limitations of first-order logic ◮ need to work in axiomatic theories ◮ consistency issue ◮ infinite models of any cardinality ◮ equational reasoning but no computation on terms ◮ Calculus of Inductive Constructions ◮ a powerful functional basis ◮ types to automatically classify objects ◮ a general scheme to declare data-structures and relations ◮ rules for recursion / induction ◮ logical foundation of type theory (Agda, Coq) C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 2 / 33

  3. Introduction Examples of inductive data-types Emphasis is on constructors Inductive bool := true | false. O | S : nat → nat. Inductive nat := Inductive min := At : nat → min | Imp : min → min → min. Inductive tree A := leaf | node : A → tree A → tree A → tree A. Inductive BDT := T | F | var : nat → (bool → BDT) → BDT. Inductive W A B := node : ∀ (a:A),(B a → W A B) → W A B. C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 3 / 33

  4. Introduction Examples of inductive data-types Emphasis is on constructors Inductive bool := true | false. O | S : nat → nat. Inductive nat := Inductive min := At : nat → min | Imp : min → min → min. Inductive tree A := leaf | node : A → tree A → tree A → tree A. Inductive BDT := T | F | var : nat → (bool → BDT) → BDT. Inductive W A B := node : ∀ (a:A),(B a → W A B) → W A B. C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 3 / 33

  5. Introduction Examples of inductive data-types Emphasis is on constructors Inductive bool := true | false. O | S : nat → nat. Inductive nat := Inductive min := At : nat → min | Imp : min → min → min. Inductive tree A := leaf | node : A → tree A → tree A → tree A. Inductive BDT := T | F | var : nat → (bool → BDT) → BDT. Inductive W A B := node : ∀ (a:A),(B a → W A B) → W A B. C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 3 / 33

  6. Introduction Expected properties Inductive min := At : nat → min | Imp : min → min → min. Initiality – iterator (fold) Variable X : Type. Variable Xat : nat → X. Variable Ximp : X → X → X. Definition It (A : min) : X := ... Lemma Itat : ∀ n, It (At n) = Xat n. Lemma Itint : ∀ A B, It (Imp A B) = Ximp (It A) (It B). Non confusion Lemma diff : ∀ n A B, (At n) � = (Imp A B). Induction Variable P (A : min) : Prop. Variable Pat : ∀ (n:nat),P (At n). Variable Pimp : ∀ A B : min,P A → P B → P (Imp A B) Definition min_ind : ∀ A : min,P A := ... C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 4 / 33

  7. Introduction Examples of Inductive Relations Relations defined by inference rules, clauses A , l ⊢ B , r l ⊢ A , r B , l ⊢ r A , l ⊢ A , r l ⊢ A ⇒ B , r A ⇒ B , l ⊢ r Inductive proof : set min → set min → Prop := ax : ∀ (A:min)(l r:set min), proof (A :: l) (A :: r) | right : ∀ (A B:min)(l r:set min) proof (A :: l) (B :: r) → proof l (Imp(A,B) :: r) | left : ∀ (A B:min)(l r:set min) proof l (A :: r) → proof (B :: l) r → proof (Imp(A,B) :: l) r C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 5 / 33

  8. Introduction Examples of Inductive Relations Relations defined by inference rules, clauses A , l ⊢ B , r l ⊢ A , r B , l ⊢ r A , l ⊢ A , r l ⊢ A ⇒ B , r A ⇒ B , l ⊢ r Inductive proof : set min → set min → Prop := ax : ∀ (A:min)(l r:set min), proof (A :: l) (A :: r) | right : ∀ (A B:min)(l r:set min) proof (A :: l) (B :: r) → proof l (Imp(A,B) :: r) | left : ∀ (A B:min)(l r:set min) proof l (A :: r) → proof (B :: l) r → proof (Imp(A,B) :: l) r C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 5 / 33

  9. Introduction Expected properties Minimality Variable P (l r : set min) : Prop. Variable Pax : ∀ (A:min)(l r:set min),P (A :: l) (A :: r). Variable Pright : ∀ (A B:min)(l r:set min) P (A :: l) (B :: r) → P l (Imp(A,B) :: r). Variable Pleft : ∀ (A B:min)(l r:set min) P l (A :: r) → P (B :: l) r → P (Imp(A,B) :: l) r. Lemma proof_ind : ∀ l r, proof l r → P l r. C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 6 / 33

  10. Introduction Mathematical justification Intersection of a non-empty family of sets � � G = X = { x ∈ X 0 |∀ X ∈ G , x ∈ X } X ∈ G Fixpoints of monotonic operators ∃ A l ′ r ′ , l = A :: l ′ ∧ r = A :: r ′ F ( P )( l , r ) def = ∨∃ A B r ′ , r = Imp ( A , B ) :: r ′ ∧ P ( A :: l , B :: r ′ ) ∨∃ A B l ′ , l = Imp ( A , B ) :: l ′ ∧ P ( l ′ , A :: r ) ∧ P ( B :: l ′ , r ) proof def = � { P ∈ ℘ ( M × M ) |∀ l r , F ( P )( l , r ) ⇒ P ( l , r ) } ⇔ F ( proof ) Minimality ( ∀ l r , F ( P )( l , r ) ⇒ P ( l , r )) ⇒ ∀ l r . proof ( l , r ) ⇒ P ( l , r ) C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 7 / 33

  11. Introduction Inductive data-types ◮ start with an infinite set (usually N ) ◮ find a physical representation ◮ support type : words, trees, . . . (large enough, infinite branching) ◮ map “nodes” to index of constructors ◮ inductive definition of the set of terms ◮ (abstract) type of well-formed terms C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 8 / 33

  12. Introduction Calculus of Inductive Constructions ◮ calculus and logic behind the C OQ proof assistant ◮ can be used as higher-order logic ◮ propositions as types, proofs as objects ◮ dependent types ◮ internal computation fib ( 7 ) ≡ 13 ◮ constructive, intensional logic ◮ λ x ⇒ ¬¬ x � = λ x ⇒ x ◮ bool � = Prop ◮ �⊢ ¬¬ A → A C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 9 / 33

  13. Language and Rules Outline Introduction Language and Rules Properties C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 10 / 33

  14. Language and Rules Logical Rules : functional part ◮ Same language for terms and types: t ::= S | V | ∀ x : t , t | λ x : t ⇒ t | t t ◮ Sorts: S = { Prop , ( Type i ) i ∈ N } t → u def ◮ Notation: = ∀ : t , u ◮ Judgements: Γ ⊢ t : t ′ ◮ every object is typed ◮ a type is a term of type a sort ◮ everything (signature, hypothesis) is declared and named in the context in a consistent way A : Type , R : A → A → Prop , x : A , y : A , p : R x y ⊢ C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 11 / 33

  15. Language and Rules (Informal) Rules ◮ Sorts: Prop , Type i : Type i + 1 Γ ⊢ A : s x �∈ Γ ( x : A ) ∈ Γ ◮ Variables: Γ , x : A ⊢ Γ ⊢ x : A Γ , x : A ⊢ B : s Γ ⊢ A : s ′ s = s ′ or s = Prop ◮ Product: Γ ⊢ ∀ x : A , B : s ◮ Abstraction/Application: Γ , x : A ⊢ t : B Γ ⊢ t : ∀ x : A , B Γ ⊢ u : A Γ ⊢ λ x : A ⇒ t : ∀ x : A , B Γ ⊢ t u : B [ x ← u ] Γ ⊢ t : A Γ ⊢ B : s A ≡ B ◮ Computation ( β ) Γ ⊢ t : B C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 12 / 33

  16. Language and Rules Examples Γ , x : A ⊢ t : B Γ ⊢ t : ∀ x : A , B Γ ⊢ u : A Γ ⊢ λ x : A ⇒ t : ∀ x : A , B Γ ⊢ t u : B [ x ← u ] ◮ functional application Γ , x : A ⊢ t : B Γ ⊢ t : A → B Γ ⊢ u : A Γ ⊢ λ x : A ⇒ t : A → B Γ ⊢ t u : B ◮ natural deduction for implication Γ , A ⊢ B Γ ⊢ A ⇒ B Γ ⊢ A Γ ⊢ A ⇒ B Γ ⊢ B ◮ natural deduction for universal quantification Γ ⊢ B x �∈ Γ Γ ⊢ ∀ x , B Γ ⊢ ∀ x , B Γ ⊢ B [ x ← u ] C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 13 / 33

  17. Language and Rules Dependent types type of maps parameterized by a domain map : ∀ (A B:Type)(A → Prop) → Type find : ∀ (A B:Type)(d:A → Prop)(m:map A B d)(x:A)d x → B C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 14 / 33

  18. Language and Rules Fundamental (non-)inductive definitions Inductive zero : Type := . Inductive unit : Type := tt : one. Inductive sum (A B:Type) : Type := inl : A → sum A B | inr : B → sum A B. Inductive sig (A:Type) (B:A → Type) : Type := pair : ∀ a:A, B a → sig A B. propositions as types � constructor = introduction rule zero ≡ ⊥ unit ≡ ⊤ sum A B ≡ A ∨ B sig A ( λ x ⇒ B ) ≡ ∃ x : A , B sig A ( λ ⇒ B ) ≡ A ∧ B C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 15 / 33

  19. Language and Rules Elimination by pattern-matching ◮ Any value in an inductive type I starts with a constructor c 1 | . . . | c p ◮ Initiality in the non-recursive case : X : Type f 1 , . . . , f p : . . . match I ( f 1 , . . . , f p ) : I → X ◮ Dependent pattern-matching (proof by case): P : I → Type f 1 , . . . , f p : . . . match I ( f 1 , . . . , f p ) : ∀ i : I , P i ◮ Exactly one branch f i for each constructor c i ◮ when c i : ∀ ( x 1 : A 1 ) . . . ( x n : A n ) I we require f i : ∀ ( x 1 : A 1 ) . . . ( x n : A n ) P ( c i x 1 . . . x n ) ◮ Computation : match I ( f 1 , . . . , f p )( c i t 1 . . . t n ) − → f i t 1 . . . t n C. Paulin (Paris-Sud) Calculus of Inductive Constructions Jul. 2014 16 / 33

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