Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logical Properties of CPS Transforms Deepak Garg Fall, 2004.

Similar presentations


Presentation on theme: "Logical Properties of CPS Transforms Deepak Garg Fall, 2004."— Presentation transcript:

1 Logical Properties of CPS Transforms Deepak Garg Fall, 2004

2 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

3 Simply Typed -calculus Terms: Types (Logical Propositions):

4 Evaluation and Typing Rules Standard Typing Rules Small step, call by value evaluation

5 Abort (A) Operator

6 What we have so far … We have INTUITIONISTIC logic with ?

7 Control (C) Operator

8 What we have now … We have CLASSICAL logic! Why? Rule of double negation elimination.

9 Summary -calculus + A $ Intuitionistic logic with ? -calculus + A + C $ Classical logic

10 CPS Transforms

11 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.

12 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!

13 CPS: Term Translation -calculus CPS translation Each translated term expects a continuation

14 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.

15 CPS: Type Translation Translation for types: Types:

16 CPS: Logical Interpretation

17 CPS: A-Operator k is thrown away like E[ ]

18 Soundness: A-Operator

19 CPS: C-Operator d is thrown away like E’[ ].

20 Soundness: C-Operator

21 CPS: Logical Interpretation

22 Summary of CPS

23 CPS as an Embedding

24

25

26 Two more theorems (unrelated to proof- terms):

27 Doing it all in Twelf

28 Representing Terms Use HOAS

29 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

30 Classical and Intuitionistic Terms

31 Representing the CPS Transform Terms represented with HOAS No direct representation for variables How do we represent the following? Create a judgment:

32 More Trouble …

33 The solution We make the translation a hypothetical judgment Recall: We get:

34 The solution

35 Soundness Theorem

36 Problems: Soundness Theorem Input Coverage Problem:

37 Problem: Soundness Theorem From worlds (soundnessblock) Output External Can’t be changed (Needed for Induction) Make this an output?

38 Soundness Theorem Solution New Theorem:

39 Soundness Theorem? What have we shown? What we need …

40 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!

41 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

42 Telling Twelf about Uniqueness Now we prove a theorem

43 A Typing-soundness Theorem We also need the following theorem

44 True Soundness Using all our previous theorems, we can now prove the soundness with correct modes.

45 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


Download ppt "Logical Properties of CPS Transforms Deepak Garg Fall, 2004."

Similar presentations


Ads by Google