Mechanizing Metatheory without Typing Contexts

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*

description

Mechanizing Metatheory without Typing Contexts. Jonghyun Park, Jeongbong Seo, Sungwoo Park, Gyesik Lee* Pohang University of Science and Technology, Korea Hankyong National University, Korea*. TYPES 2011 September 10, 2011. Mechanizing Metatheory. - PowerPoint PPT Presentation

Transcript of Mechanizing Metatheory without Typing Contexts

Page 1: Mechanizing Metatheory  without Typing Contexts

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

2

Mechanizing Metatheory• Formalizing metatheory using proof assistants

• POPLmark Challenge for mechanizing System F<:

Page 3: Mechanizing Metatheory  without Typing Contexts

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

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

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

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

7

System F>: with Typing Contexts• Definitions

• Judgments

• Type safety

Page 8: Mechanizing Metatheory  without Typing Contexts

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

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

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

11

Simpler Lemmas• With typing contexts

– In the proof, we need to show:

• Without typing contexts

Page 12: Mechanizing Metatheory  without Typing Contexts

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

13

Type Safety

Page 14: Mechanizing Metatheory  without Typing Contexts

14

If Unbound Type Variables in Annotations

• Need two lemmas:

• Impossible to prove

Page 15: Mechanizing Metatheory  without Typing Contexts

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

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

17

Analysis of the Complexity

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

Page 18: Mechanizing Metatheory  without Typing Contexts

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

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

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

Thank you.

Page 21: Mechanizing Metatheory  without Typing Contexts

21

Operational Semantics

Page 22: Mechanizing Metatheory  without Typing Contexts

22

Page 23: Mechanizing Metatheory  without Typing Contexts

23

Page 24: Mechanizing Metatheory  without Typing Contexts

24

Equivalence between the Two Systems