subset coercions in c
play

Subset coercions in C M S under direction of C - PowerPoint PPT Presentation

Subset coercions in C M S under direction of C P -M Paris-Sud 11 University LRI - D Team & INRIA F - P


  1. Subset coercions in C  M  S  under direction of C  P  -M  Paris-Sud 11 University LRI - D´  Team & INRIA F  - P  Project TYPES’06 Workshop 18-21 April 2006

  2. The Big Picture

  3. The Big Picture

  4. The Big Picture

  5. The Big Picture

  6. The Big Picture

  7. Outline The idea 1 Theoretical development 2 R  Traduction in C  The implementation 3

  8. A simple idea Definition { x : T | P } is the set of objects of set T verifying property P . Useful for specifying, widely used in mathematics ; Separates object and property.

  9. A simple idea Definition { x : T | P } is the set of objects of set T verifying property P . Useful for specifying, widely used in mathematics ; Separates object and property. Adapting the idea t : T P [ t / x ] t : { x : T | P } t : { x : T | P } t : T

  10. From “ Predicate subtyping ”. . . PVS Specialized typing algorithm for subset types, generating Type-checking conditions . t : { x : T | P } used as t : T ok used as if P [ t / x ] t : T t : { x : T | P }

  11. From “ Predicate subtyping ”. . . PVS Specialized typing algorithm for subset types, generating Type-checking conditions . t : { x : T | P } used as t : T ok used as if P [ t / x ] t : T t : { x : T | P } + Practical success ;

  12. From “ Predicate subtyping ”. . . PVS Specialized typing algorithm for subset types, generating Type-checking conditions . t : { x : T | P } used as t : T ok used as if P [ t / x ] t : T t : { x : T | P } + Practical success ; – No strong safety guarantee in PVS.

  13. . . . to Subset coercions A property-irrelevant language (R  ) with decidable 1 typing ; Γ ⊢ t : { x : T | P } Γ ⊢ t : T Γ ⊢ t : T Γ , x : T ⊢ P : Prop t : { x : T | P }

  14. . . . to Subset coercions A property-irrelevant language (R  ) with decidable 1 typing ; A total traduction to C  terms with holes ; 2 Γ ⊢ t : { x : T | P } Γ ⊢ σ 1 t : T Γ ⊢ t : T Γ , x : T ⊢ P : Prop Γ ⊢ ? : P [ t / x ] ( t , ?) : { x : T | P }

  15. . . . to Subset coercions A property-irrelevant language (R  ) with decidable 1 typing ; A total traduction to C  terms with holes ; 2 A method to turn the holes into proof obligations. 3

  16. Outline The idea 1 Theoretical development 2 R  Traduction in C  The implementation 3

  17. R  ’s typing ⊢ and coercion � Calculus of Constructions - C  + Γ ⊢ t : U Γ ⊢ T : s U � T C  Γ ⊢ t : T

  18. R  ’s typing ⊢ and coercion � Calculus of Constructions - C  + Γ ⊢ t : U Γ ⊢ T : s U � T C  Γ ⊢ t : T T ≡ βπ U S � T T � U S  -T  S  -C  S � U T � U

  19. R  ’s typing ⊢ and coercion � Calculus of Constructions - C  + Γ ⊢ t : U Γ ⊢ T : s U � T C  Γ ⊢ t : T T ≡ βπ U S � T T � U S  -T  S  -C  S � U T � U U � V U � V S  -S  { x : U | P } � V S  -P  U � { x : V | P }

  20. R  ’s typing ⊢ and coercion � Calculus of Constructions - C  + Γ ⊢ t : U Γ ⊢ T : s U � T C  Γ ⊢ t : T T ≡ βπ U S � T T � U S  -T  S  -C  S � U T � U U � V U � V S  -S  { x : U | P } � V S  -P  U � { x : V | P } 0 : nat nat � { x : nat | x � 0 } 0 : { x : nat | x � 0 }

  21. R  ’s typing ⊢ and coercion � Calculus of Constructions - C  + Γ ⊢ t : U Γ ⊢ T : s U � T C  Γ ⊢ t : T T ≡ βπ U S � T T � U S  -T  S  -C  S � U T � U U � V U � V S  -S  { x : U | P } � V S  -P  U � { x : V | P } 0 : nat nat � { x : nat | x � 0 } 0 : { x : nat | x � 0 } ? : 0 � 0

  22. R  ’s typing ⊢ and coercion � Calculus of Constructions - C  + Γ ⊢ t : U Γ ⊢ T : s U � T C  Γ ⊢ t : T T ≡ βπ U S � T T � U S  -T  S  -C  S � U T � U U � V U � V S  -S  { x : U | P } � V S  -P  U � { x : V | P } U � T V � W S  -P  Π x : T . V � Π x : U . W

  23. Results Theorem (Decidability of type checking) Γ ⊢ t : T is decidable. Γ ⊢ f : T T � Π x : A . B Γ ⊢ e : E E � A A  Γ ⊢ ( f e ) : B [ e / x ]

  24. Results Theorem (Decidability of type checking) Γ ⊢ t : T is decidable. Lemma (Elimination of transitivity) If T � U ∧ U � V then T � V . Γ ⊢ f : T T � Π x : A . B Γ ⊢ e : E E � A A  Γ ⊢ ( f e ) : B [ e / x ]

  25. Outline The idea 1 Theoretical development 2 R  Traduction in C  The implementation 3

  26. The target system CIC with metavariables Γ ⊢ ? t : T Γ ⊢ ? p : P [ t / x ] Γ ⊢ ? elt T P t p : { x : T | P } Γ ⊢ ? t : { x : T | P } Γ ⊢ ? t : { x : T | P } Γ ⊢ ? σ 1 t : T Γ ⊢ ? σ 2 t : P [ σ 1 t / x ] Γ ⊢ ? P : Prop Γ ⊢ ? ? P : P

  27. From C  to R  The easy way ( σ 1 t ) ◦ t ◦ = ( elt T P t p ) ◦ t ◦ = ( σ 2 t ) ◦ = ⊥ (? P ) ◦ = ⊥ If Γ ⊢ ? t : T then Γ ◦ ⊢ t ◦ : T ◦ if () ◦ is defined on Γ , t and T .

  28. From C  to R  and back The easy way ( σ 1 t ) ◦ t ◦ = ( elt T P t p ) ◦ t ◦ = ( σ 2 t ) ◦ = ⊥ (? P ) ◦ = ⊥ If Γ ⊢ ? t : T then Γ ◦ ⊢ t ◦ : T ◦ if () ◦ is defined on Γ , t and T . The hard way If Γ ⊢ t : T then � Γ � ⊢ ? � t � Γ : � T � Γ .

  29. Traduction : deriving explicit coercions Traduction for coercions If T � U then Γ ⊢ ? c [ • ] : T � U which implies � Γ � ⊢ ? λ x : � T � Γ . c [ x ] : � T � Γ → � U � Γ .

  30. Traduction : deriving explicit coercions Traduction for coercions If T � U then Γ ⊢ ? c [ • ] : T � U which implies � Γ � ⊢ ? λ x : � T � Γ . c [ x ] : � T � Γ → � U � Γ . Definition T ≡ βπ U Γ ⊢ ? : T � U

  31. Traduction : deriving explicit coercions Traduction for coercions If T � U then Γ ⊢ ? c [ • ] : T � U which implies � Γ � ⊢ ? λ x : � T � Γ . c [ x ] : � T � Γ → � U � Γ . Definition T ≡ βπ U Γ ⊢ ? • : T � U

  32. Traduction : deriving explicit coercions Traduction for coercions If T � U then Γ ⊢ ? c [ • ] : T � U which implies � Γ � ⊢ ? λ x : � T � Γ . c [ x ] : � T � Γ → � U � Γ . Definition T ≡ βπ U Γ ⊢ ? • : T � U Γ ⊢ ? : { x : T | P } � T

  33. Traduction : deriving explicit coercions Traduction for coercions If T � U then Γ ⊢ ? c [ • ] : T � U which implies � Γ � ⊢ ? λ x : � T � Γ . c [ x ] : � T � Γ → � U � Γ . Definition T ≡ βπ U Γ ⊢ ? • : T � U Γ ⊢ ? σ 1 • : { x : T | P } � T

  34. Traduction : deriving explicit coercions Traduction for coercions If T � U then Γ ⊢ ? c [ • ] : T � U which implies � Γ � ⊢ ? λ x : � T � Γ . c [ x ] : � T � Γ → � U � Γ . Definition T ≡ βπ U Γ ⊢ ? • : T � U Γ ⊢ ? σ 1 • : { x : T | P } � T : T � { x : T | P } Γ ⊢ ?

  35. Traduction : deriving explicit coercions Traduction for coercions If T � U then Γ ⊢ ? c [ • ] : T � U which implies � Γ � ⊢ ? λ x : � T � Γ . c [ x ] : � T � Γ → � U � Γ . Definition T ≡ βπ U Γ ⊢ ? • : T � U Γ ⊢ ? σ 1 • : { x : T | P } � T Γ ⊢ ? elt • ? � P � Γ , x : T [ • / x ] : T � { x : T | P }

  36. Traduction : deriving explicit coercions Traduction for coercions If T � U then Γ ⊢ ? c [ • ] : T � U which implies � Γ � ⊢ ? λ x : � T � Γ . c [ x ] : � T � Γ → � U � Γ . Definition T ≡ βπ U Γ ⊢ ? • : T � U Γ ⊢ ? σ 1 • : { x : T | P } � T Γ ⊢ ? elt • ? � P � Γ , x : T [ • / x ] : T � { x : T | P } Example Γ ⊢ ? 0 : nat Γ ⊢ ? c : nat � { x : nat | x � 0 } Γ ⊢ ? ( elt • ? ( x � 0)[ • / x ] )[0] = elt 0 ? 0 � 0 : { x : nat | x � 0 }

  37. Traduction : interpretation of terms �� Γ Example (Application) Γ ⊢ f : T T � Π x : V . W : s Γ ⊢ u : U U � V Γ ⊢ ( f u ) : W [ u / x ] � f u � Γ let π = coerce Γ T ( Π x : V . W ) in = let c = coerce Γ U V in ( π [ � f � Γ ]) ( c [ � u � Γ ]) Theorem (Soundness) If Γ ⊢ t : T then � Γ � ⊢ ? � t � Γ : � T � Γ .

  38. Theoretical matters ⊢ ? ’s equational theory : ( β ) ( λ x : X . e ) v ≡ e [ v / x ] σ i ( elt E P e 1 e 2 ) ( σ i ) ≡ e i ( η ) ( λ x : X . e x ) ≡ e if x � FV ( e ) ( SP ) elt E P ( σ 1 e ) ( σ 2 e ) ≡ e

  39. Theoretical matters ⊢ ? ’s equational theory : ( β ) ( λ x : X . e ) v ≡ e [ v / x ] σ i ( elt E P e 1 e 2 ) ( σ i ) ≡ e i ( η ) ( λ x : X . e x ) ≡ e if x � FV ( e ) ( SP ) elt E P ( σ 1 e ) ( σ 2 e ) ≡ e elt E P t ′ p ′ if t ≡ t ′ ( σ ) elt E P t p ≡ ⇒ Proof Irrelevance

Recommend


More recommend