CoqInE S eminaire Dedukti/CPR Guillaume Burel Friday April 1st, - - PowerPoint PPT Presentation

coqine
SMART_READER_LITE
LIVE PREVIEW

CoqInE S eminaire Dedukti/CPR Guillaume Burel Friday April 1st, - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

Introduction

Universal proof checker

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 2/28

slide-3
SLIDE 3

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

slide-4
SLIDE 4

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

slide-5
SLIDE 5

Encoding of CoC

Outline

  • Introduction
  • Encoding of CoC
  • Encoding of Coq

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 5/28

slide-6
SLIDE 6

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

slide-7
SLIDE 7

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

slide-8
SLIDE 8

Encoding of CoC

Encoding (cont.)

|x| = x |∗| = ˙ ∗ |A B| = |A| |B| |λx:A. t| = x : ||A|| => |t| |Πx:A. B| = ˙ Πs1s2s2 |A| (x : ||A|| => |B|) |||| = U ||A|| = εs1 |A| with A : s1, B : s2 (sort inference)

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 8/28

slide-9
SLIDE 9

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

slide-10
SLIDE 10

Encoding of Coq

Coq’s proof terms

type term = Meta of _ | Evar of _ | Rel of int | Var of string | Sort of _ | App of term * term array | Lambda of _ | Prod of _ | Cast of _ | LetIn of _ | Const of _ | Ind of _ | Construct of _ | Case of _ | Fix of _

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28

slide-11
SLIDE 11

Encoding of Coq

Coq’s proof terms

type term = Meta of _ (*1*) | Evar of _ | Rel of int | Var of string | Sort of _ | App of term * term array | Lambda of _ | Prod of _ | Cast of _ | LetIn of _ | Const of _ | Ind of _ | Construct of _ | Case of _ | Fix of _ 1: Do not appear in final proof terms

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28

slide-12
SLIDE 12

Encoding of Coq

Coq’s proof terms

type term = Meta of _ (*1*) | Evar of _ | Rel of int (*2*) | Var of string | Sort of _ | App of term * term array | Lambda of _ | Prod of _ | Cast of _ | LetIn of _ | Const of _ | Ind of _ | Construct of _ | Case of _ | Fix of _ 2: [Cousineau Dowek]

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28

slide-13
SLIDE 13

Encoding of Coq

Coq’s proof terms

type term = Meta of _ (*1*) | Evar of _ | Rel of int (*2*) | Var of string | Sort of _ | App of term * term array | Lambda of _ | Prod of _ | Cast of _ (*3*) | LetIn of _ | Const of _ | Ind of _ | Construct of _ | Case of _ | Fix of _ 3: Inlining and cast removing

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28

slide-14
SLIDE 14

Encoding of Coq

Coq’s proof terms

type term = Meta of _ (*1*) | Evar of _ | Rel of int (*2*) | Var of string | Sort of _ | App of term * term array | Lambda of _ | Prod of _ | Cast of _ (*3*) | LetIn of _ | Const of _ (*4*) | Ind of _ | Construct of _ | Case of _ | Fix of _ 4: Using an environment

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28

slide-15
SLIDE 15

Encoding of Coq

Coq’s proof terms

type term = Meta of _ (*1*) | Evar of _ | Rel of int (*2*) | Var of string | Sort of _ | App of term * term array | Lambda of _ | Prod of _ | Cast of _ (*3*) | LetIn of _ | Const of _ (*4*) | Ind of _ (*5*) | Construct of _ | Case of _ | Fix of _ 5: Inductives

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 10/28

slide-16
SLIDE 16

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

slide-17
SLIDE 17

Encoding of Coq

Declarations

Constants

.v: Definition n : A = t.

  • r

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

slide-18
SLIDE 18

Encoding of Coq

Declarations

Inductives

Inductive eq (A:Type) (x:A) : A -> Prop := refl : eq A x x. eq : A : UType -> εType A -> εType A -> UProp. refl : A : UType -> x : εType A -> εProp (eq A x x). eq__case : A : UType -> x : εType A -> P : (y : εType A -> εProp (eq A x y) -> UType) -> f : εType (P A (refl A x)) -> y : εType A -> m : εProp (eq A x y) -> εType (P y m). [A : UType, x : εType A, P : y : εType A -> εProp (eq A x y) -> UType, 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

slide-19
SLIDE 19

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

slide-20
SLIDE 20

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

slide-21
SLIDE 21

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

slide-22
SLIDE 22

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 : UType -> x : εType A -> y : εType A

  • > m : εProp (eq A x y) -> B.

[A : UType,x : εType A] f A x x (refl A x) --> t.

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 17/28

slide-23
SLIDE 23

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

slide-24
SLIDE 24

Encoding of Coq

Declarations

Example

Inductive eq (A:Type) (x:A) : A -> Prop := refl : eq A x x. refl : A : UType -> x : εType A -> εProp (pre_eq A x x). eq__constr : A : UType -> x : εType A -> y : εType A

  • > εProp (pre_eq A x y) -> εProp (eq A x y).

[A : UType, x : εType A, P : y : εType A -> εProp (eq A x y) -> UType, 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

slide-25
SLIDE 25

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 : UType -> x : εType A -> y : εType A

  • > m : εProp (eq A x y) -> B.

[A : UType,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

slide-26
SLIDE 26

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

slide-27
SLIDE 27

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

slide-28
SLIDE 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

slide-29
SLIDE 29

Encoding of Coq

Modules

Functors

Module M (N : Modtype):= ... prepend all type declaration with the signature Modtype

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 24/28

slide-30
SLIDE 30

Encoding of Coq

Modules

Example

In File.v Module Type X. Parameter a : Prop. End X. Module F (M:X). Definition b : Type := M.a -> Prop. End F. In File_F.dk b : a : UProp -> UType. [a : UProp] b a --> ˙ ΠPropTypeType a (_ :εProp a => ˙ Prop).

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 25/28

slide-31
SLIDE 31

Encoding of Coq

Modules

Application

In Coq’s module applications M(N), N is assumed to be a module identifier (not forced by OCaml types in .vo files) To be correct, M has to be of functorial type. There does not seem to be possible to build anonymous functors. Hence, we copy the content of M but apply the arguments corresponding to the signature of the functor using N

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 26/28

slide-32
SLIDE 32

Encoding of Coq

Modules

Example

Module N. Inductive a : Prop := . End N. Module M := F(N). In File_M.dk b : UType. [] b --> File_F.b File_N.a.

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 27/28

slide-33
SLIDE 33

Conclusion

Work to be done

◮ Implement what was presented for modules ◮ Subtyping of sorts ◮ Find a way to handle universes

(For the moment, we have ˙ Type : UType)

Guillaume Burel: S´ eminaire Dedukti/CPR, 2011-04-01 CoqInE 28/28