adam@297: (* Copyright (c) 2008-2011, Adam Chlipala adamc@175: * adamc@175: * This work is licensed under a adamc@175: * Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 adamc@175: * Unported License. adamc@175: * The license text is available at: adamc@175: * http://creativecommons.org/licenses/by-nc-nd/3.0/ adamc@175: *) adamc@175: adamc@175: (* begin hide *) adamc@175: Require Import String List. adamc@175: adam@297: Require Import Tactics DepList. adamc@175: adamc@175: Set Implicit Arguments. adamc@175: (* end hide *) adamc@175: adamc@175: adamc@181: (** %\chapter{Extensional Transformations}% *) adamc@175: adamc@256: (** Last chapter's constant folding example was particularly easy to verify, because that transformation used the same source and target language. In this chapter, we verify a different translation, illustrating the added complexities in translating between languages. adamc@175: adamc@256: Program transformations can be classified as %\textit{%##intensional##%}%, when they require some notion of inequality between variables; or %\textit{%##extensional##%}%, otherwise. This chapter's example is extensional, and the next chapter deals with the trickier intensional case. *) adamc@175: adamc@175: adamc@256: (** * CPS Conversion for Simply-Typed Lambda Calculus *) adamc@175: adamc@256: (** A convenient method for compiling functional programs begins with conversion to %\textit{%##continuation-passing style##%}%, or CPS. In this restricted form, function calls never return; instead, we pass explicit return pointers, much as in assembly language. Additionally, we make order of evaluation explicit, breaking complex expressions into sequences of primitive operations. adamc@175: adamc@256: Our translation will operate over the same source language that we used in the first part of last chapter, so we omit most of the language definition. However, we do make one significant change: since we will be working with multiple languages that involve similar constructs, we use Coq's %\textit{%##notation scope##%}% mechanism to disambiguate. For instance, the span of code dealing with type notations looks like this: *) adamc@175: adamc@256: (* begin hide *) adamc@256: Module Source. adamc@256: Inductive type : Type := adamc@256: | TNat : type adamc@256: | Arrow : type -> type -> type. adamc@256: (* end hide *) adamc@175: adamc@256: Notation "'Nat'" := TNat : source_scope. adam@292: (** printing --> $\longrightarrow$ *) adamc@256: Infix "-->" := Arrow (right associativity, at level 60) : source_scope. adamc@175: adamc@256: Open Scope source_scope. adamc@256: Bind Scope source_scope with type. adamc@256: Delimit Scope source_scope with source. adamc@175: adamc@256: (** We explicitly place our notations inside a scope named [source_scope], and we associate a delimiting key [source] with [source_scope]. Without further commands, our notations would only be used in expressions like [(...)%source]. We also open our scope locally within this module, so that we avoid repeating [%source] in many places. Further, we %\textit{%##bind##%}% our scope to [type]. In some circumstances where Coq is able to infer that some subexpression has type [type], that subexpression will automatically be parsed in [source_scope]. *) adamc@175: adamc@256: (* begin hide *) adamc@256: Section vars. adamc@256: Variable var : type -> Type. adamc@175: adamc@256: Inductive exp : type -> Type := adamc@256: | Var : forall t, adamc@256: var t adamc@256: -> exp t adamc@175: adamc@256: | Const : nat -> exp Nat adamc@256: | Plus : exp Nat -> exp Nat -> exp Nat adamc@175: adamc@256: | App : forall t1 t2, adamc@256: exp (t1 --> t2) adamc@256: -> exp t1 adamc@256: -> exp t2 adamc@256: | Abs : forall t1 t2, adamc@256: (var t1 -> exp t2) adamc@256: -> exp (t1 --> t2). adamc@256: End vars. adamc@175: adamc@256: Definition Exp t := forall var, exp var t. adamc@175: adamc@256: Implicit Arguments Var [var t]. adamc@256: Implicit Arguments Const [var]. adamc@256: Implicit Arguments Plus [var]. adamc@256: Implicit Arguments App [var t1 t2]. adamc@256: Implicit Arguments Abs [var t1 t2]. adamc@175: adamc@256: Notation "# v" := (Var v) (at level 70) : source_scope. adamc@175: adamc@256: Notation "^ n" := (Const n) (at level 70) : source_scope. adamc@256: Infix "+^" := Plus (left associativity, at level 79) : source_scope. adamc@175: adamc@256: Infix "@" := App (left associativity, at level 77) : source_scope. adamc@256: Notation "\ x , e" := (Abs (fun x => e)) (at level 78) : source_scope. adamc@256: Notation "\ ! , e" := (Abs (fun _ => e)) (at level 78) : source_scope. adamc@175: adamc@256: Bind Scope source_scope with exp. adamc@256: adamc@257: Example zero : Exp Nat := fun _ => ^0. adamc@257: Example one : Exp Nat := fun _ => ^1. adamc@257: Example zpo : Exp Nat := fun _ => zero _ +^ one _. adamc@257: Example ident : Exp (Nat --> Nat) := fun _ => \x, #x. adamc@257: Example app_ident : Exp Nat := fun _ => ident _ @ zpo _. adamc@257: Example app : Exp ((Nat --> Nat) --> Nat --> Nat) := fun _ => adamc@256: \f, \x, #f @ #x. adamc@257: Example app_ident' : Exp Nat := fun _ => app _ @ ident _ @ zpo _. adamc@256: adamc@256: Fixpoint typeDenote (t : type) : Set := adamc@256: match t with adamc@256: | Nat => nat adamc@256: | t1 --> t2 => typeDenote t1 -> typeDenote t2 adamc@256: end. adamc@256: adamc@256: Fixpoint expDenote t (e : exp typeDenote t) : typeDenote t := adamc@256: match e with adamc@256: | Var _ v => v adamc@256: adamc@256: | Const n => n adamc@256: | Plus e1 e2 => expDenote e1 + expDenote e2 adamc@256: adamc@256: | App _ _ e1 e2 => (expDenote e1) (expDenote e2) adamc@256: | Abs _ _ e' => fun x => expDenote (e' x) adamc@256: end. adamc@256: adamc@256: Definition ExpDenote t (e : Exp t) := expDenote (e _). adamc@256: (* end hide *) adamc@256: adamc@256: (** The other critical new ingredient is a generalization of the [Closed] relation from two chapters ago. The new relation [exp_equiv] characters when two expressions may be considered syntactically equal. We need to be able to handle cases where each expression uses a different [var] type. Intuitively, we will want to compare expressions that use their variables to store source-level and target-level values. We express pairs of equivalent variables using a list parameter to the relation; variable expressions will be considered equivalent if and only if their variables belong to this list. The rule for function abstraction extends the list in a higher-order way. The remaining rules just implement the obvious congruence over expressions. *) adamc@176: adamc@180: (* begin thide *) adamc@256: Section exp_equiv. adamc@256: Variables var1 var2 : type -> Type. adamc@176: adamc@256: Inductive exp_equiv : list { t : type & var1 t * var2 t }%type adamc@256: -> forall t, exp var1 t -> exp var2 t -> Prop := adamc@256: | EqVar : forall G t (v1 : var1 t) v2, adamc@256: In (existT _ t (v1, v2)) G adamc@256: -> exp_equiv G (#v1) (#v2) adamc@176: adamc@256: | EqConst : forall G n, adam@292: exp_equiv G (^ n) (^ n) adamc@256: | EqPlus : forall G x1 y1 x2 y2, adamc@256: exp_equiv G x1 x2 adamc@256: -> exp_equiv G y1 y2 adamc@256: -> exp_equiv G (x1 +^ y1) (x2 +^ y2) adamc@176: adamc@256: | EqApp : forall G t1 t2 (f1 : exp _ (t1 --> t2)) (x1 : exp _ t1) f2 x2, adamc@256: exp_equiv G f1 f2 adamc@256: -> exp_equiv G x1 x2 adamc@256: -> exp_equiv G (f1 @ x1) (f2 @ x2) adamc@256: | EqAbs : forall G t1 t2 (f1 : var1 t1 -> exp var1 t2) f2, adamc@256: (forall v1 v2, exp_equiv (existT _ t1 (v1, v2) :: G) (f1 v1) (f2 v2)) adamc@256: -> exp_equiv G (Abs f1) (Abs f2). adamc@256: End exp_equiv. adamc@176: adamc@256: (** It turns out that, for any parametric expression [E], any two instantiations of [E] with particular [var] types must be equivalent, with respect to an empty variable list. The parametricity of Gallina guarantees this, in much the same way that it guaranteed the truth of the axiom about [Closed]. Thus, we assert an analogous axiom here. *) adamc@256: adamc@256: Axiom Exp_equiv : forall t (E : Exp t) var1 var2, adamc@256: exp_equiv nil (E var1) (E var2). adamc@180: (* end thide *) adamc@256: End Source. adamc@175: adamc@256: (** Now we need to define the CPS language, where binary function types are replaced with unary continuation types, and we add product types because they will be useful in our translation. *) adamc@175: adamc@256: Module CPS. adamc@256: Inductive type : Type := adamc@256: | TNat : type adamc@256: | Cont : type -> type adamc@256: | Prod : type -> type -> type. adamc@175: adamc@256: Notation "'Nat'" := TNat : cps_scope. adam@292: (** printing ---> $\Longrightarrow$ *) adamc@256: Notation "t --->" := (Cont t) (at level 61) : cps_scope. adamc@256: Infix "**" := Prod (right associativity, at level 60) : cps_scope. adamc@175: adamc@256: Bind Scope cps_scope with type. adamc@256: Delimit Scope cps_scope with cps. adamc@175: adamc@256: Section vars. adamc@256: Variable var : type -> Type. adamc@175: adamc@256: (** A CPS program is a series of bindings of primitive operations (primops), followed by either a halt with a final program result or by a call to a continuation. The arguments to these program-ending operations are enforced to be variables. To use the values of compound expressions instead, those expressions must be decomposed into bindings of primops. The primop language itself similarly forces variables for all arguments besides bodies of function abstractions. *) adamc@175: adamc@256: Inductive prog : Type := adamc@256: | PHalt : adamc@256: var Nat adamc@256: -> prog adamc@256: | App : forall t, adamc@256: var (t --->) adamc@256: -> var t adamc@256: -> prog adamc@256: | Bind : forall t, adamc@256: primop t adamc@256: -> (var t -> prog) adamc@256: -> prog adamc@175: adamc@256: with primop : type -> Type := adamc@256: | Const : nat -> primop Nat adamc@256: | Plus : var Nat -> var Nat -> primop Nat adamc@256: adamc@256: | Abs : forall t, adamc@256: (var t -> prog) adamc@256: -> primop (t --->) adamc@175: adamc@256: | Pair : forall t1 t2, adamc@256: var t1 adamc@256: -> var t2 adamc@256: -> primop (t1 ** t2) adamc@256: | Fst : forall t1 t2, adamc@256: var (t1 ** t2) adamc@256: -> primop t1 adamc@256: | Snd : forall t1 t2, adamc@256: var (t1 ** t2) adamc@256: -> primop t2. adamc@256: End vars. adamc@175: adamc@256: Implicit Arguments PHalt [var]. adamc@256: Implicit Arguments App [var t]. adamc@175: adamc@256: Implicit Arguments Const [var]. adamc@256: Implicit Arguments Plus [var]. adamc@256: Implicit Arguments Abs [var t]. adamc@256: Implicit Arguments Pair [var t1 t2]. adamc@256: Implicit Arguments Fst [var t1 t2]. adamc@256: Implicit Arguments Snd [var t1 t2]. adamc@175: adamc@256: Notation "'Halt' x" := (PHalt x) (no associativity, at level 75) : cps_scope. adamc@256: Infix "@@" := App (no associativity, at level 75) : cps_scope. adamc@256: Notation "x <- p ; e" := (Bind p (fun x => e)) adamc@256: (right associativity, at level 76, p at next level) : cps_scope. adamc@256: Notation "! <- p ; e" := (Bind p (fun _ => e)) adamc@256: (right associativity, at level 76, p at next level) : cps_scope. adamc@175: adamc@256: Notation "^ n" := (Const n) (at level 70) : cps_scope. adamc@256: Infix "+^" := Plus (left associativity, at level 79) : cps_scope. adamc@175: adamc@256: Notation "\ x , e" := (Abs (fun x => e)) (at level 78) : cps_scope. adamc@256: Notation "\ ! , e" := (Abs (fun _ => e)) (at level 78) : cps_scope. adamc@175: adamc@256: Notation "[ x1 , x2 ]" := (Pair x1 x2) : cps_scope. adamc@256: Notation "#1 x" := (Fst x) (at level 72) : cps_scope. adamc@256: Notation "#2 x" := (Snd x) (at level 72) : cps_scope. adamc@175: adamc@256: Bind Scope cps_scope with prog primop. adamc@175: adamc@256: Open Scope cps_scope. adamc@175: adamc@256: (** In interpreting types, we treat continuations as functions with codomain [nat], choosing [nat] as our arbitrary program result type. *) adamc@175: adamc@256: Fixpoint typeDenote (t : type) : Set := adamc@256: match t with adamc@256: | Nat => nat adamc@256: | t' ---> => typeDenote t' -> nat adamc@256: | t1 ** t2 => (typeDenote t1 * typeDenote t2)%type adamc@256: end. adamc@175: adamc@256: (** A mutually-recursive definition establishes the meanings of programs and primops. *) adamc@175: adamc@256: Fixpoint progDenote (e : prog typeDenote) : nat := adamc@256: match e with adamc@256: | PHalt n => n adamc@256: | App _ f x => f x adamc@256: | Bind _ p x => progDenote (x (primopDenote p)) adamc@256: end adamc@175: adamc@256: with primopDenote t (p : primop typeDenote t) : typeDenote t := adamc@256: match p with adamc@256: | Const n => n adamc@256: | Plus n1 n2 => n1 + n2 adamc@175: adamc@256: | Abs _ e => fun x => progDenote (e x) adamc@175: adamc@256: | Pair _ _ v1 v2 => (v1, v2) adamc@256: | Fst _ _ v => fst v adamc@256: | Snd _ _ v => snd v adamc@256: end. adamc@256: adamc@256: Definition Prog := forall var, prog var. adamc@256: Definition Primop t := forall var, primop var t. adamc@256: Definition ProgDenote (E : Prog) := progDenote (E _). adamc@256: Definition PrimopDenote t (P : Primop t) := primopDenote (P _). adamc@256: End CPS. adamc@256: adamc@256: Import Source CPS. adamc@256: adamc@256: (** The translation itself begins with a type-level compilation function. We change every function into a continuation whose argument is a pair, consisting of the translation of the original argument and of an explicit return pointer. *) adamc@175: adamc@180: (* begin thide *) adamc@256: Fixpoint cpsType (t : Source.type) : CPS.type := adamc@256: match t with adamc@256: | Nat => Nat%cps adam@292: | t1 --> t2 => (cpsType t1 ** (cpsType t2 ---> ) ---> )%cps adamc@256: end%source. adamc@175: adamc@256: (** Now we can define the expression translation. The notation [x <-- e1; e2] stands for translating source-level expression [e1], binding [x] to the CPS-level result of running the translated program, and then evaluating CPS-level expression [e2] in that context. *) adamc@175: adam@292: (** printing <-- $\longleftarrow$ *) adamc@256: Reserved Notation "x <-- e1 ; e2" (right associativity, at level 76, e1 at next level). adamc@175: adamc@256: Section cpsExp. adamc@256: Variable var : CPS.type -> Type. adamc@175: adamc@256: Import Source. adamc@256: Open Scope cps_scope. adamc@175: adamc@256: (** We implement a well-known variety of higher-order, one-pass CPS translation. The translation [cpsExp] is parameterized not only by the expression [e] to translate, but also by a meta-level continuation. The idea is that [cpsExp] evaluates the translation of [e] and calls the continuation on the result. With this convention, [cpsExp] itself is a natural match for the notation we just reserved. *) adamc@175: adamc@256: Fixpoint cpsExp t (e : exp (fun t => var (cpsType t)) t) adamc@256: : (var (cpsType t) -> prog var) -> prog var := adamc@256: match e with adamc@256: | Var _ v => fun k => k v adamc@175: adamc@256: | Const n => fun k => adam@292: x <- ^ n; adamc@256: k x adamc@256: | Plus e1 e2 => fun k => adamc@256: x1 <-- e1; adamc@256: x2 <-- e2; adamc@256: x <- x1 +^ x2; adamc@256: k x adamc@175: adamc@256: | App _ _ e1 e2 => fun k => adamc@256: f <-- e1; adamc@256: x <-- e2; adam@292: kf <- \ r, k r; adamc@256: p <- [x, kf]; adamc@256: f @@ p adamc@256: | Abs _ _ e' => fun k => adamc@256: f <- CPS.Abs (var := var) (fun p => adamc@256: x <- #1 p; adamc@256: kf <- #2 p; adamc@256: r <-- e' x; adamc@256: kf @@ r); adamc@256: k f adamc@256: end adamc@175: adamc@256: where "x <-- e1 ; e2" := (cpsExp e1 (fun x => e2)). adamc@256: End cpsExp. adamc@256: adamc@256: (** Since notations do not survive the closing of sections, we redefine the notation associated with [cpsExp]. *) adamc@256: adamc@256: Notation "x <-- e1 ; e2" := (cpsExp e1 (fun x => e2)) : cps_scope. adamc@256: adamc@256: Implicit Arguments cpsExp [var t]. adamc@256: adamc@256: (** We wrap [cpsExp] into the parametric version [CpsExp], passing an always-halt continuation at the root of the recursion. *) adamc@256: adamc@256: Definition CpsExp (E : Exp Nat) : Prog := adamc@256: fun _ => cpsExp (E _) (PHalt (var := _)). adamc@180: (* end thide *) adamc@175: adamc@256: Eval compute in CpsExp zero. adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = fun var : type -> Type => x <- ^0; Halt x adamc@256: : Prog adam@302: ]] adam@302: *) adamc@175: adamc@256: Eval compute in CpsExp one. adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = fun var : type -> Type => x <- ^1; Halt x adamc@256: : Prog adam@302: ]] adam@302: *) adamc@256: adamc@256: Eval compute in CpsExp zpo. adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = fun var : type -> Type => x <- ^0; x0 <- ^1; x1 <- (x +^ x0); Halt x1 adamc@256: : Prog adam@302: ]] adam@302: *) adamc@256: adamc@256: Eval compute in CpsExp app_ident. adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = fun var : type -> Type => adamc@256: f <- (\ p, x <- #1 p; kf <- #2 p; kf @@ x); adamc@256: x <- ^0; adamc@256: x0 <- ^1; x1 <- (x +^ x0); kf <- (\ r, Halt r); p <- [x1, kf]; f @@ p adamc@256: : Prog adam@302: ]] adam@302: *) adamc@256: adamc@256: Eval compute in CpsExp app_ident'. adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = fun var : type -> Type => adamc@256: f <- adamc@256: (\ p, adamc@256: x <- #1 p; adamc@256: kf <- #2 p; adamc@256: f <- adamc@256: (\ p0, adamc@256: x0 <- #1 p0; adamc@256: kf0 <- #2 p0; kf1 <- (\ r, kf0 @@ r); p1 <- [x0, kf1]; x @@ p1); adamc@256: kf @@ f); adamc@256: f0 <- (\ p, x <- #1 p; kf <- #2 p; kf @@ x); adamc@256: kf <- adamc@256: (\ r, adamc@256: x <- ^0; adamc@256: x0 <- ^1; adamc@256: x1 <- (x +^ x0); kf <- (\ r0, Halt r0); p <- [x1, kf]; r @@ p); adamc@256: p <- [f0, kf]; f @@ p adamc@256: : Prog adam@302: ]] adam@302: *) adamc@256: adamc@256: Eval compute in ProgDenote (CpsExp zero). adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = 0 adamc@256: : nat adam@302: ]] adam@302: *) adamc@256: adamc@256: Eval compute in ProgDenote (CpsExp one). adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = 1 adamc@256: : nat adam@302: ]] adam@302: *) adamc@256: adamc@256: Eval compute in ProgDenote (CpsExp zpo). adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = 1 adamc@256: : nat adam@302: ]] adam@302: *) adamc@256: adamc@256: Eval compute in ProgDenote (CpsExp app_ident). adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = 1 adamc@256: : nat adam@302: ]] adam@302: *) adamc@256: adamc@256: Eval compute in ProgDenote (CpsExp app_ident'). adamc@256: (** %\vspace{-.15in}% [[ adamc@256: = 1 adamc@256: : nat adam@302: ]] adam@302: *) adamc@256: adamc@256: adamc@256: (** Our main inductive lemma about [cpsExp] needs a notion of compatibility between source-level and CPS-level values. We express compatibility with a %\textit{%##logical relation##%}%; that is, we define a binary relation by recursion on type structure, and the function case of the relation considers functions related if they map related arguments to related results. In detail, the function case is slightly more complicated, since it must deal with our continuation-based calling convention. *) adamc@175: adamc@180: (* begin thide *) adamc@256: Fixpoint lr (t : Source.type) adamc@256: : Source.typeDenote t -> CPS.typeDenote (cpsType t) -> Prop := adamc@256: match t with adamc@256: | Nat => fun n1 n2 => n1 = n2 adamc@256: | t1 --> t2 => fun f1 f2 => adamc@256: forall x1 x2, lr _ x1 x2 adamc@256: -> forall k, exists r, adamc@256: f2 (x2, k) = k r adamc@256: /\ lr _ (f1 x1) r adamc@256: end%source. adamc@176: adamc@256: (** The main lemma is now easily stated and proved. The most surprising aspect of the statement is the presence of %\textit{%##two##%}% versions of the expression to be compiled. The first, [e1], uses a [var] choice that makes it a suitable argument to [expDenote]. The second expression, [e2], uses a [var] choice that makes its compilation, [cpsExp e2 k], a suitable argument to [progDenote]. We use [exp_equiv] to assert that [e1] and [e2] have the same underlying structure, up to a variable correspondence list [G]. A hypothesis about [G] ensures that all of its pairs of variables belong to the logical relation [lr]. We also use [lr], in concert with some quantification over continuations and program results, in the conclusion of the lemma. adamc@256: adamc@256: The lemma's proof should be unsurprising by now. It uses our standard bag of Ltac tricks to help out with quantifier instantiation; [crush] and [eauto] can handle the rest. *) adamc@256: adamc@256: Lemma cpsExp_correct : forall G t (e1 : exp _ t) (e2 : exp _ t), adamc@256: exp_equiv G e1 e2 adamc@256: -> (forall t v1 v2, In (existT _ t (v1, v2)) G -> lr t v1 v2) adamc@256: -> forall k, exists r, adamc@256: progDenote (cpsExp e2 k) = progDenote (k r) adamc@256: /\ lr t (expDenote e1) r. adamc@256: induction 1; crush; adamc@256: repeat (match goal with adamc@256: | [ H : forall k, exists r, progDenote (cpsExp ?E k) = _ /\ _ adamc@176: |- context[cpsExp ?E ?K] ] => adamc@256: generalize (H K); clear H adamc@256: | [ |- exists r, progDenote (_ ?R) = progDenote (_ r) /\ _ ] => adamc@256: exists R adamc@256: | [ t1 : Source.type |- _ ] => adamc@256: match goal with adamc@256: | [ Hlr : lr t1 ?X1 ?X2, IH : forall v1 v2, _ |- _ ] => adamc@256: generalize (IH X1 X2); clear IH; intro IH; adamc@256: match type of IH with adamc@256: | ?P -> _ => assert P adamc@256: end adamc@256: end adamc@256: end; crush); eauto. adamc@256: Qed. adamc@176: adamc@256: (** A simple lemma establishes the degenerate case of [cpsExp_correct]'s hypothesis about [G]. *) adamc@176: adamc@256: Lemma vars_easy : forall t v1 v2, adamc@256: In (existT (fun t0 => (Source.typeDenote t0 * typeDenote (cpsType t0))%type) t adamc@256: (v1, v2)) nil -> lr t v1 v2. adamc@256: crush. adamc@256: Qed. adamc@256: adamc@256: (** A manual application of [cpsExp_correct] proves a version applicable to [CpsExp]. This is where we use the axiom [Exp_equiv]. *) adamc@256: adamc@256: Theorem CpsExp_correct : forall (E : Exp Nat), adamc@256: ProgDenote (CpsExp E) = ExpDenote E. adamc@256: unfold ProgDenote, CpsExp, ExpDenote; intros; adamc@256: generalize (cpsExp_correct (e1 := E _) (e2 := E _) adamc@256: (Exp_equiv _ _ _) vars_easy (PHalt (var := _))); crush. adamc@256: Qed. adamc@180: (* end thide *) adamc@176: adamc@177: adamc@181: (** * Exercises *) adamc@181: adamc@181: (** %\begin{enumerate}%#