a logical framework with dependently typed records
play

A Logical Framework with Dependently Typed Records Thierry Coquand, - PDF document

A Logical Framework with Dependently Typed Records Thierry Coquand, Randy Pollack, Makoto Takeyama April 16, 2003 (809) A Logical Framework with Dependently Typed Records Thierry Coquand, Slide 1 Robert Pollack, Makoto Takeyama April 16,


  1. A Logical Framework with Dependently Typed Records Thierry Coquand, Randy Pollack, Makoto Takeyama April 16, 2003 (809) A Logical Framework with Dependently Typed Records Thierry Coquand, Slide 1 Robert Pollack, Makoto Takeyama April 16, 2003 1

  2. 2 Long Term Goal: Precise explanation of mathematical vernacular. � Experiment with dependently typed records as a notation for mathematical structure. { Manifest fields { Structural subtyping with ’ notation to add information to signatures { ‘ Slide 2 { Signature strengthening ringSig = h G : grpSig ; M : monSig with rr = G : rr ; : : : i : � Typed equality. { � and surjective pairing { respects subtyping � Direct and simple implementation. This talk Restrict to a simple core similar to Martin-L¨ of’s framework. � PER semantics { Categorical judgements of Type Theory s.t. (up to � -expansion) Slide 3 � Well-typed objects are normalising � Equality is decidable { Extend to hypothetical judgements of Type Theory � Implementable rules for a logical framework. � Extend core system to subtyping . This core framework can be extended with definitions, structures and signatures, manifest fields, . . . See our paper.

  3. 3 Syntactic Objects and Syntactic Types � x , y , range over identifiers , I . � objects , O , are untyped � -terms. M ; N ::= x j M M j �x:M { Equality on objects is � -conversion ( ' ). Slide 4 { An object is neutral iff it is normalisable and of the form � ::= x j � M : � The category of syntactic types A; B ::= El M j fun A x:B j ? { Objects in ? are “names” of types; { for : ? , M is the type named by M . M El Categorical Judgements: Outline � Simultaneously define 1. A PER of intensional equality on the set of syntactic types. Write = B . A Write A 2 T yp e for A = A . Slide 5 2. For A 2 T yp e , a PER, A , on objects. Write M = N : A . Write : A for = : A . M M M � Define eta-expansion � Key normalization theorem.

  4. 4 Categorical Judgements: the definition � = ? . ? = : ? iff M and N are neutral and � -convertible. M N � = N whenever = : ? . El M El M N = : M iff 1 and 2 are neutral and N N El N N 1 2 � -convertible. Slide 6 � = 2 whenever fun A x :B fun A x :B 1 1 1 2 2 { A = A 2 , 1 { = : = ) [ M ℄ = [ M ℄ . M M A B B 1 2 1 1 1 2 2 M = M : fun A x:B iff 1 2 N = N : A = ) M N = M N : B [ M ℄ . 1 2 1 1 2 2 1 If A = B then A and B are extensionally equal. The converse is not true. Eta-Expansion Define an operation of � -expansion at type A (written f A g ). � : f A g M is normalising. M A will imply � Slide 7 � f ? g = �x:x � f El M g = �x:x � f fun A x:B g = �u:�z :� f B [ z b ℄ g ( u z b ) where z b = � f A g z where u and z are distinct and not free in � f A g or B .

  5. 5 Key Theorem: Normalization Theorem Let A 2 T yp e . 1. � f A g � : A , where � is neutral. : f A g M is normalisable. 2. If M A then � 3. If : A then = f A g M : A . M M � Slide 8 4. If = : A then f A g M ' f A g M 2 . M M � � 1 2 1 The four parts are proved simultaneously by induction on the proof that 2 T yp e . A Corollary Let A 2 T yp e , M : A and M : A . 1 2 f A g M ' f A g M = : 1. If � � 2 then M M A . 1 1 2 2. The relation = : A is decidable. M M 1 2 Hypothetical Judgements: Outline � Introduce environments , � , contexts , C . � Define a judgement � = � : C . 1 2 � Simultaneously define hypothetical judgements { C valid , { A = A [ C ℄ , 1 2 Slide 9 { = : [ C ℄ . M M A 1 2 For C valid , � = � : C , A = A [ C ℄ and 1 2 1 2 M = M : A [ C ℄ are PERs. 1 2 � Show that hypothetical judgements satisfy the rules of Type Theory. � Give conditions for M = M : A [ C ℄ to be decidable. 1 2 � Define a relation ` = 2 of syntactic type equality that is C A A 1 decidable and sound for the sematintic relation A = A [ C ℄ . 1 2

  6. 6 Contexts and Environments Contexts C ::= j C; x : A ( O is the empty context.) O Write x 2 C if x : A in C for some A . In writing C; x : A we assume x 62 C . Environments Slide 10 � An environment, � , is a function I ! O . � � 0 is the identity environment. � Environments are applied as simultaneous substitutions: M � , A� . � Write ( �; x = M ) for the update of � , defined by ( �; x = M )( x ) = M ; ( �; x = M )( y ) = � ( y ) if y 6 = x: Equal Environments Inductively define a judgement of form = : C : � � 1 2 Slide 11 � = � : O 1 2 � = � : C A� 2 T yp e � x = � x : A� 1 2 1 1 2 1 � = � : C; x : A 1 2 Write � : C for � = � : C .

  7. 7 Hypothetical Judgements Defined Simultaneously define three judgement forms: validity x 62 C A = A [ C ℄ valid C; x : A valid O type equality (write A t yp e [ C ℄ for A = A [ C ℄ ) Slide 12 C valid 8 � ; � : � = � : C = ) A � = A � 1 2 1 2 1 1 2 2 A = A [ C ℄ 1 2 object equality in a type (write : [ C ℄ for = : [ C ℄ ) M A M M A A t yp e [ C ℄ 8 � ; � : � = � : C = ) M � = M � : A� 1 2 1 2 1 1 2 2 1 M = M : A [ C ℄ 1 2 Properties of Hypothetical Judgements type formation and type equality C valid M = N : ? [ C ℄ A = A [ C ℄ B = B [ C; x : A ℄ 1 2 1 2 1 ? t yp e [ C ℄ El M = El N [ C ℄ fun A x:B = fun A x:B [ C ℄ 1 1 2 2 objects C; x : A valid M : B [ C; x : A ℄ x : A [ C; x : A ℄ �x:M : fun A x:B [ C ℄ Slide 13 : [ C ℄ : [ C ℄ M fun A x:B N A M N : B [ N ℄ [ C ℄ type conversion M = N : A [ C ℄ A = B [ C ℄ M = N : B [ C ℄ weakening = [ C ℄ x : = : [ C ℄ x : B B C; A valid M N B C; A valid 1 2 = [ C; x : A ℄ = : [ C; x : A ℄ B B M N B 1 2

  8. 8 Deciding Hypothetical Equality � We saw that if M ; M : A then M = M : A is decidable. 1 2 1 2 � Lift this property to hypothetical judgements: { need the “most general environment”, { intuitively, the identity environment, 0 . � � By the Key Theorem, we need to � -expand 0 at C : � � f O g � = � Slide 14 � f C; x : A g � = ( � 0 ; x = � f A� 0 g ( �x )) where � 0 = � f C g � Lemma Write � C for � f C g � 0 . � If valid then : C . � Æ = f C g � . C � � � � C C � If : [ C ℄ and : [ C ℄ then M A M A 1 2 M = M : A [ C ℄ iff � f A� g M � ' � f A� g M � 1 2 C 1 C C 2 C which is decidable. Approximating Type Equality Define a syntactic relation of shape ` = 2 which is C A A 1 = [ C ℄ . decidable and sound for the semantic relation A A 1 2 M = M : ? [ C ℄ 1 2 C ` ? = ? C ` El M = El M 1 2 Slide 15 ` = x : ` = C A A C; A B B 1 2 1 1 2 ` = C fun A x:B fun A x:B 1 1 2 2 Lemma 1. If [ C ℄ and [ C ℄ then ` = 2 is A t yp e A t yp e C A A 1 2 1 decidable. 2. If valid and ` = 2 then = [ C ℄ . C C A A A A 1 1 2

  9. 9 A Logical Framework in Syntax: Outline We give a concrete implementation. � Syntax of expressions and expression contexts Slide 16 � Judgement forms � Typechecking rules { syntax directed { terminating { sound Expressions The syntax of expressions and expression contexts: e ::= z j e e j [ z : e ℄ e j * j El e j f z : e g e j e - > e � ::= j � , x : e ( H is the empty context) H Judgement Forms Slide 17 Two judgement forms are defined simultaneously, � C ` e ) A , (expression e is interpreted in C as type A ) � C ` e ) M : A , (expression e is interpreted in C as object M having type A ) while a third can be defined afterwards. � � ) C , ( � is interpreted as the valid context C )

  10. 10 Typechecking type formation C ` e ) M : ? C ` e ) A C ` e ) B 1 2 C ` * ) ? C ` El e ) El M C ` e - > e ) A ! B 1 2 C ` e ) A C; x : A ` e ) B 1 2 C ` f x : e g e ) fun A x:B 1 2 Slide 18 objects x : A in C C ` e ) A C; x : A ` e ) M : B 1 2 C ` x ) x : A C ` [ x : e ℄ e ) �x:M : fun A x:B 1 2 C ` e ) M : fun A x:B C ` e ) M : A C ` A = A 1 1 1 2 2 2 1 2 C ` e e ) M M : B [ M ℄ 1 2 1 2 2 validity � ) C C ` e ) A ) � ; x : e ) C; x : A H O Correctness and Termination of Typechecking � If ` ) A and valid then [ C ℄ . C a C A t yp e � If C ` e ) M : A and C valid then M : A [ C ℄ . � If � ) C then C valid . Slide 19 � Typechecking is decidable. “Eta-conversion” of expressions v:{A:*}El A . � Suppose v and [A:*℄(v A) are indistinguishable by � The expressions typechecking.

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