240 likes | 398 Views
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.
E N D
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 • Formalizing metatheory using proof assistants • POPLmark Challenge for mechanizing System F<:
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
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.
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
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
System F>: with Typing Contexts • Definitions • Judgments • Type safety
System F>: without Typing Contexts • Definitions • annotate every type parameter with its supertype • annotate every term parameter with its type • Judgments
Unbound Type Variables in Annotations? • Examples • Local closure • Substitutions (propagated into annotations) ) Source of all serious complications
No Unbound Type Variables in Annotations 1. Local closure 2. Substitutions(no propagation) 3. Rules • Cf. Parameter substitution
Simpler Lemmas • With typing contexts • In the proof, we need to show: • Without typing contexts
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
If Unbound Type Variables in Annotations • Need two lemmas: • Impossible to prove
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.
Coq Developments for POPLmark (1A and 2A) • Representing binders • locally named/nameless • Quantifying variables • exists-fresh, cofinite • Consistent programming style
Analysis of the Complexity • Eliminating typing contexts is more effective than the cofinite quantification.
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
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!