mechanizing metatheory without typing contexts types 2011 september 10, 2011 jonghyun park,...

24
Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 nghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Le Pohang University of Science and Technology, Korea Hankyong National University, Korea*

Upload: brian-boone

Post on 18-Jan-2016

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

Mechanizing Metatheory without Typing Contexts

TYPES 2011

September 10, 2011

Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee*Pohang University of Science and Technology, Korea

Hankyong National University, Korea*

Page 2: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

2

Mechanizing Metatheory• Formalizing metatheory using proof assistants

• POPLmark Challenge for mechanizing System F<:

Page 3: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

3

Techniques for Facilitating Mechanization

• Representing binders – de Bruijn indexes– locally named/nameless representation

• free parameters and bound variables– nominal representation– higher-order abstract syntax

• Quantifying variables– exists-fresh/for-all quantification– cofinite quantification

• eliminates renaming lemmas

Page 4: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

4

Structural Lemmas• Due to the use of typing contexts

• Examples

• Often used without proofs in pencil-and-paper proofs• Must be proved in mechanized proofs• The whole development becomes more complex.

Page 5: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

5

Entailments vs Hypothetical Proofs

• Entailment relations – syntactic representations of hypothetical proofs– display only hypotheses and conclusion– hide internal structures

• Hypothetical proofs– no structural lemmas necessary– suitable for mechanized proofs

Page 6: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

6

Eliminating Typing Contexts• Use the locally nameless/named representation

– bound variables: with binders– free parameters: without binders

• Convert bindings in typing contexts to annotations of free parameters

Page 7: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

7

System F>: with Typing Contexts• Definitions

• Judgments

• Type safety

Page 8: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

8

System F>: without Typing Contexts

• Definitions– annotate every type parameter with its supertype– annotate every term parameter with its type

• Judgments

Page 9: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

9

Unbound Type Variables in Annotations?

• Examples

• Local closure

• Substitutions (propagated into annotations)

) Source of all serious complications

Page 10: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

10

No Unbound Type Variables in Annotations

1. Local closure

2. Substitutions(no propagation)

3. Rules

– Cf. Parameter substitution

Page 11: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

11

Simpler Lemmas• With typing contexts

– In the proof, we need to show:

• Without typing contexts

Page 12: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

12

No Need for Unusual Tricks• With typing contexts (renaming lemma)

– need to show:

– strengthening followed by weakening???• No, because weakening itself requires

renaming.• Without typing contexts: no such complication

Page 13: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

13

Type Safety

Page 14: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

14

If Unbound Type Variables in Annotations

• Need two lemmas:

• Impossible to prove

Page 15: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

15

Equivalence between the Two Systems

• The proof is far from straightforward:

• What is your view?

1. You need to prove the equivalence.

2. You don't need to prove the equivalence.

Page 16: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

16

Coq Developments for POPLmark (1A and 2A)

• Representing binders– locally named/nameless

• Quantifying variables– exists-fresh, cofinite

• Consistent programming style

Page 17: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

17

Analysis of the Complexity

• Eliminating typing contexts is more effective than the cofinite quantification.

Page 18: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

18

Related Work: PTSs with Explicit Contexts (Geuvers et al '10)

• The key idea is the same:– distinguish between parameters and variables– annotate every parameter with its type

• Variable substitutions are not propagated into annotations of parameters.

• Main theorem: correspondence between the two type

systems

• Substantiates our work, and vice versa

Page 19: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

19

Conclusion• Three guidelines when eliminating typing contexts

1. all annotations of parameters are locally closed

2. do not propagate variable substitutions into annotations of parameters

3. typing rules generate parameters with locally closed annotations

• A case study confirms the validity of the guidelines– System F extended with linear types

(Mazurak et al '10)• Simple, yet as effective as cofinite quantification!

Page 20: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

http://pl.postech.ac.kr/poplmark/

Thank you.

Page 21: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

21

Operational Semantics

Page 22: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

22

Page 23: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

23

Page 24: Mechanizing Metatheory without Typing Contexts TYPES 2011 September 10, 2011 Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University

24

Equivalence between the Two Systems