450 likes | 578 Views
Logical Properties of CPS Transforms. Deepak Garg Fall, 2004. Introduction. CPS = Continuation Passing Style Studied to simulate cbv with cbn We look at CPS transforms as proof-transformations CPS transforms embed classical logic into intuitionistic logic. Simply Typed -calculus.
E N D
Logical Properties of CPS Transforms Deepak Garg Fall, 2004
Introduction • CPS = Continuation Passing Style • Studied to simulate cbv with cbn • We look at CPS transforms as proof-transformations • CPS transforms embed classical logic into intuitionistic logic
Simply Typed -calculus • Terms: • Types (Logical Propositions):
Evaluation and Typing Rules • Standard Typing Rules • Small step, call by value evaluation
What we have so far … • We have INTUITIONISTIC logic with ?
What we have now … • We have CLASSICAL logic! • Why? Rule of double negation elimination.
-calculus + A + C $ Classical logic Summary -calculus + A $ Intuitionistic logic with ?
CPS Transform: History • [1975] Plotkin. CPS studied formally. • [1986] Felleisen et al. Extended to control operators (call/cc, C and A). • [1993] Griffin. Typed CPS transforms. • [2003] Wadler. Duality with CPS transforms.
CPS Transform: Properties • Translate terms, types and proofs • On terms: • No control (C) operator in transformed terms • On types: • No double negation elimination in transformed proofs • Translates classical into intuitionistic logic!
CPS: Term Translation • -calculus • CPS translation • Each translated term expects a continuation
CPS: Operational Interpretation • Explicitly formalize evaluation in terms of continuations To evaluate (M N) in the continuation k, evaluate M in the continuation that binds its input to m and evaluates N in the continuation that binds its input to n and evaluates (m n) in the continuation k.
CPS: Type Translation • Translation for types: • Types:
CPS: A-Operator • k is thrown away like E[ ]
CPS: C-Operator • d is thrown away like E’[ ].
CPS as an Embedding Two more theorems (unrelated to proof-terms):
Representing Terms • Use HOAS
Classical and Intuitionistic Terms • The previous definition is not enough. • We have to distinguish classical and intuitionistic logic • Introduce two types of terms: • Classical: termc • Intuitionistic: termi
Representing the CPS Transform • Terms represented with HOAS • No direct representation for variables • How do we represent the following? • Create a judgment:
The solution • We make the translation a hypothetical judgment • Recall: • We get:
Input Coverage Problem: Problems: Soundness Theorem
Problem: Soundness Theorem Output External From worlds (soundnessblock) Make this an output? Can’t be changed (Needed for Induction)
Soundness Theorem Solution • New Theorem:
Soundness Theorem? • What have we shown? • What we need …
Soundness Theorem? • Are these theorems the same? • To us they are • Why? • We know that given A, there is exactly one A’ such that A* = A’. • We never told Twelf this fact • So, in Twelf these are different theorems!
Telling Twelf about Uniqueness • Can we tell Twelf that A* is unique? • Not directly! There is no uniqueness check • We can make an equality judgment
Telling Twelf about Uniqueness • Now we prove a theorem
A Typing-soundness Theorem • We also need the following theorem
True Soundness • Using all our previous theorems, we can now prove the soundness with correct modes.
Extensions • Can be extended to include conjunction and disjunction. • We can also use a call-by-name transform • Gives a translation from classical to minimal logic • Very similar to Kolmogrov’s double negation translation