ENSIIE – C´ edric CoqInE S´ eminaire Dedukti/CPR Guillaume Burel Friday April 1st, 2011 Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 1/28
Introduction Universal proof checker Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 2/28
Introduction Dedukti Proof checker for λ Π -modulo [Boespflug] nat : Type. 0 : nat. S : nat -> nat. plus : nat -> nat -> nat. [x : nat] plus x 0 --> x. [x : nat] plus 0 y --> y. [x : nat, y : nat] plus x (S y) --> S (plus x y). [x : nat, y : nat] plus (S x) y --> S (plus x y). array : nat -> Type. concat : x : nat -> y : nat -> array x -> array y -> array (plus x y). Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 3/28
Introduction λ Π -modulo Dependent types but restricted to types of type Type ◮ no higher order ◮ no polymorphism ◮ no inductives Possibility to have rewrite rules Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 4/28
Encoding of CoC Outline Introduction � Encoding of CoC � Encoding of Coq � Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 5/28
Encoding of CoC Is there hope? [Cousineau Dowek 07] encoding of every functional pure type systems in λ Π modulo in particular CoC Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 6/28
Encoding of CoC Encoding U ∗ : Type. U � : Type. ε ∗ : U ∗ -> Type. ε � : U � -> Type. ˙ ∗ : U � . ˙ Π ∗ ∗ ∗ : x : U ∗ -> ( ε ∗ x -> U ∗ ) -> U ∗ . ˙ Π ∗ �� : x : U ∗ -> ( ε ∗ x -> U � ) -> U � . ˙ Π � ∗ ∗ : x : U � -> ( ε � x -> U ∗ ) -> U ∗ . ˙ Π ��� : x : U � -> ( ε � x -> U � ) -> U � . [] ε � ˙ ∗ --> U ∗ . [a : U ∗ , b : ε ∗ a -> U � ] ε � ( ˙ Π ∗ �� a b) --> x : ε ∗ a -> ε � (b x). Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 7/28
Encoding of CoC Encoding (cont.) | x | = x |∗| = ˙ ∗ | A B | = | A | | B | | λx : A. t | = x : || A || => | t | | Π x : A. B | = ˙ Π s 1 s 2 s 2 | A | ( x : || A || => | B | ) || � || = U � || A || = ε s 1 | A | with A : s 1 , B : s 2 (sort inference) Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 8/28
Encoding of Coq Outline Introduction � Encoding of CoC � Encoding of Coq � • Declarations • Modules Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 9/28
Encoding of Coq Coq’s proof terms type term = | Cast of _ Meta of _ | LetIn of _ | Evar of _ | Const of _ | Rel of int | Var of string | Ind of _ | Sort of _ | Construct of _ | App of term * term array | Case of _ | Lambda of _ | Fix of _ | Prod of _ Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28
Encoding of Coq Coq’s proof terms type term = | Cast of _ Meta of _ (*1*) | LetIn of _ | Evar of _ | Const of _ | Rel of int | Var of string | Ind of _ | Sort of _ | Construct of _ | App of term * term array | Case of _ | Lambda of _ | Fix of _ | Prod of _ 1: Do not appear in final proof terms Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28
Encoding of Coq Coq’s proof terms type term = | Cast of _ Meta of _ (*1*) | LetIn of _ | Evar of _ | Const of _ | Rel of int (*2*) | Var of string | Ind of _ | Sort of _ | Construct of _ | App of term * term array | Case of _ | Lambda of _ | Fix of _ | Prod of _ 2: [Cousineau Dowek] Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28
Encoding of Coq Coq’s proof terms type term = | Cast of _ (*3*) Meta of _ (*1*) | LetIn of _ | Evar of _ | Const of _ | Rel of int (*2*) | Var of string | Ind of _ | Sort of _ | Construct of _ | App of term * term array | Case of _ | Lambda of _ | Fix of _ | Prod of _ 3: Inlining and cast removing Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28
Encoding of Coq Coq’s proof terms type term = | Cast of _ (*3*) Meta of _ (*1*) | LetIn of _ | Evar of _ | Const of _ (*4*) | Rel of int (*2*) | Var of string | Ind of _ | Sort of _ | Construct of _ | App of term * term array | Case of _ | Lambda of _ | Fix of _ | Prod of _ 4: Using an environment Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28
Encoding of Coq Coq’s proof terms type term = | Cast of _ (*3*) Meta of _ (*1*) | LetIn of _ | Evar of _ | Const of _ (*4*) | Rel of int (*2*) | Var of string | Ind of _ (*5*) | Sort of _ | Construct of _ | App of term * term array | Case of _ | Lambda of _ | Fix of _ | Prod of _ 5: Inductives Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28
Encoding of Coq Content of Coq’s modules Struct : list of declarations: ◮ Constants: name, term, type ◮ Inductives: name, arity, constructors, . . . ◮ Modules: struct, ident, functor, application ◮ Module types: not translated Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 11/28
Encoding of Coq Declarations Constants .v: Definition n : A = t. or Theorem n : A. exact(t). Qed. .vo: n : A = t .dk: n : || A || . [] n --> | t | . Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 12/28
Encoding of Coq Declarations Inductives Inductive eq (A:Type) (x:A) : A -> Prop := refl : eq A x x. eq : A : U Type -> ε Type A -> ε Type A -> U Prop . refl : A : U Type -> x : ε Type A -> ε Prop (eq A x x). eq__case : A : U Type -> x : ε Type A -> P : (y : ε Type A -> ε Prop (eq A x y) -> U Type ) -> f : ε Type (P A (refl A x)) -> y : ε Type A -> m : ε Prop (eq A x y) -> ε Type (P y m). [A : U Type , x : ε Type A, P : y : ε Type A -> ε Prop (eq A x y) -> U Type , f : ε Type (P A (refl A x))] eq__case A x P f x (refl A x) --> f. Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 13/28
Encoding of Coq Declarations Translation of inductives | Ind(i) | = i | Construct(c) | = c | Case(Ind(i),P,m,[|b1,...,bn|]) | = i case P b1 ... bn m Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 14/28
Encoding of Coq Declarations Fixpoints Fixpoint f (x1:A1) ... (xn:An) { struct xn } : A := t. f : x1 : || A1 || -> ... -> xn : || An || -> || A || . [x1 : || A1 || , ..., xn : || An || ] f x1 ... xn --> t. Problem: loops Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 15/28
Encoding of Coq Declarations Fixing fixpoints I Restrict the unfolding to the cases when xn is a constructor (semantics of Coq). Fixpoint f (x1:A1) ... (xn:nat) { struct xn } : A := t. f : x1 : || A1 || -> ... -> xn : ε Set nat -> || A || . [x1 : || A1 || , ...] f x1 ... O --> t. [x1 : || A1 || , ..., x : ε Set nat] f x1 ... (S x) --> t. Problem: dependant inductive types Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 16/28
Encoding of Coq Declarations Fixing fixpoints II Fixpoint f (A:Type) (x y:A) (m:eq A x y) { struct m } : B := t. f : A : U Type -> x : ε Type A -> y : ε Type A -> m : ε Prop (eq A x y) -> B. [A : U Type ,x : ε Type A] f A x x (refl A x) --> t. Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 17/28
Encoding of Coq Declarations Fixing fixpoints III Solution: Cut constructors in two ◮ “I take the following arguments” ◮ “I am a constructor of inductive type i ” | Construct(c) x1 ... xn | = i constr (c x1 ... xn) Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 18/28
Encoding of Coq Declarations Example Inductive eq (A:Type) (x:A) : A -> Prop := refl : eq A x x. refl : A : U Type -> x : ε Type A -> ε Prop (pre_eq A x x). eq__constr : A : U Type -> x : ε Type A -> y : ε Type A -> ε Prop (pre_eq A x y) -> ε Prop (eq A x y). [A : U Type , x : ε Type A, P : y : ε Type A -> ε Prop (eq A x y) -> U Type , f : ε Type (P A (refl A x))] eq__case A x P f x (eq__constr A x x (refl A x)) --> f. Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 19/28
Encoding of Coq Declarations Fixing fixpoints IV Fixpoint f (A:Type) (x y:A) (m:eq A x y) { struct m } : B := t. f : A : U Type -> x : ε Type A -> y : ε Type A -> m : ε Prop (eq A x y) -> B. [A : U Type ,x : ε Type A,y : ε Type A,p : ε Prop (pre_eq A x y)] f A x y (eq__constr A x y p) --> t. Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 20/28
Encoding of Coq Modules References to other modules | M.t | = M. | t | Dedukti’s modules are flat ◮ Use the filename to simulate that | Coq.Init.Datatypes.unit | = Coq_Init_Datatypes.unit Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 21/28
Encoding of Coq Modules Modules In File.vo Module M := ... Create a new file File_M.dk and ◮ Structures: list of declarations, use the same translation as before ◮ Ident: copy the content of the identified module ◮ Functors, Apply : see next slides ◮ With : ? Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 22/28
Encoding of Coq Modules Ident Module M := C. In C.dk a : A. [x, y, z] a x (c y z) --> t. In File_M.dk a : A. [] a --> C.a. Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 23/28
Recommend
More recommend