adamc@2: (* Copyright (c) 2008, Adam Chlipala adamc@2: * adamc@2: * This work is licensed under a adamc@2: * Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 adamc@2: * Unported License. adamc@2: * The license text is available at: adamc@2: * http://creativecommons.org/licenses/by-nc-nd/3.0/ adamc@2: *) adamc@2: adamc@3: (* begin hide *) adamc@2: Require Import List. adamc@2: adamc@2: Require Import Tactics. adamc@3: (* end hide *) adamc@2: adamc@2: adamc@9: (** I will start off by jumping right in to a fully-worked set of examples, building certified compilers from increasingly complicated source languages to stack machines. We will meet a few useful tactics and see how they can be used in manual proofs, and we will also see how easily these proofs can be automated instead. I assume that you have installed Coq and Proof General. adamc@9: adamc@11: As always, you can step through the source file %\texttt{%##StackMachine.v##%}% for this chapter interactively in Proof General. Alternatively, to get a feel for the whole lifecycle of creating a Coq development, you can enter the pieces of source code in this chapter in a new %\texttt{%##.v##%}% file in an Emacs buffer. If you do the latter, include a line [Require Import List Tactics] at the start of the file, to match some code hidden from the chapter source, and be sure to run the Coq binary %\texttt{%##coqtop##%}% with the command-line argument %\texttt{%##-I SRC##%}%, where %\texttt{%##SRC##%}% is the path to a directory containing the source for this book. In either case, if you have installed Proof General properly, it should start automatically when you visit a %\texttt{%##.v##%}% buffer in Emacs. adamc@11: adamc@11: With Proof General, the portion of a buffer that Coq has processed is highlighted in some way, like being given a blue background. You step through Coq source files by positioning the point at the position you want Coq to run to and pressing C-C C-RET. This can be used both for normal step-by-step coding, by placing the point inside some command past the end of the highlighted region; and for undoing, by placing the point inside the highlighted region. *) adamc@9: adamc@9: adamc@2: (** * Arithmetic expressions over natural numbers *) adamc@2: adamc@9: (** We will begin with that staple of compiler textbooks, arithemtic expressions over a single type of numbers. *) adamc@9: adamc@9: (** ** Source language *) adamc@9: adamc@9: (** We begin with the syntax of the source language. *) adamc@2: adamc@4: Inductive binop : Set := Plus | Times. adamc@2: adamc@9: (** Our first line of Coq code should be unsurprising to ML and Haskell programmers. We define an algebraic datatype [binop] to stand for the binary operators of our source language. There are just two wrinkles compared to ML and Haskell. First, we use the keyword [Inductive], in place of %\texttt{%##data##%}%, %\texttt{%##datatype##%}%, or %\texttt{%##type##%}%. This is not just a trivial surface syntax difference; inductive types in Coq are much more expressive than garden variety algebraic datatypes, essentially enabling us to encode all of mathematics, though we begin humbly in this chapter. Second, there is the [: Set] fragment, which declares that we are defining a datatype that should be thought of as a constituent of programs. Later, we will see other options for defining datatypes in the universe of proofs or in an infinite hierarchy of universes, encompassing both programs and proofs, that is useful in higher-order constructions. *) adamc@9: adamc@4: Inductive exp : Set := adamc@4: | Const : nat -> exp adamc@4: | Binop : binop -> exp -> exp -> exp. adamc@2: adamc@9: (** Now we define the type of arithmetic expressions. We write that a constant may be built from one argument, a natural number; and a binary operation may be built from a choice of operator and two operand expressions. adamc@9: adamc@9: A note for readers following along in the PDF version: coqdoc supports pretty-printing of tokens in LaTeX or HTML. Where you see a right arrow character, the source contains the ASCII text %\texttt{%##->##%}%. Other examples of this substitution appearing in this chapter are a double right arrow for %\texttt{%##=>##%}% and the inverted 'A' symbol for %\texttt{%##forall##%}%. When in doubt about the ASCII version of a symbol, you can consult the chapter source code. adamc@9: adamc@9: %\medskip% adamc@9: adamc@9: Now we are ready to say what these programs mean. We will do this by writing an interpreter that can be thought of as a trivial operational or denotational semantics. (If you are not familiar with these semantic techniques, no need to worry; we will stick to "common sense" constructions.) *) adamc@9: adamc@4: Definition binopDenote (b : binop) : nat -> nat -> nat := adamc@4: match b with adamc@4: | Plus => plus adamc@4: | Times => mult adamc@4: end. adamc@2: adamc@9: (** The meaning of a binary operator is a binary function over naturals, defined with pattern-matching notation analogous to the %\texttt{%##case##%}% and %\texttt{%##match##%}% of ML and Haskell, and referring to the functions [plus] and [mult] from the Coq standard library. The keyword [Definition] is Coq's all-purpose notation for binding a term of the programming language to a name, with some associated syntactic sugar, like the notation we see here for defining a function. That sugar could be expanded to yield this definition: adamc@9: adamc@9: [[ adamc@9: Definition binopDenote : binop -> nat -> nat -> nat := fun (b : binop) => adamc@9: match b with adamc@9: | Plus => plus adamc@9: | Times => mult adamc@9: end. adamc@9: adamc@9: In this example, we could also omit all of the type annotations, arriving at: adamc@9: adamc@9: [[ adamc@9: Definition binopDenote := fun b => adamc@9: match b with adamc@9: | Plus => plus adamc@9: | Times => mult adamc@9: end. adamc@9: adamc@9: Languages like Haskell and ML have a convenient %\textit{%##principal typing##%}% property, which gives us strong guarantees about how effective type inference will be. Unfortunately, Coq's type system is so expressive that any kind of "complete" type inference is impossible, and the task even seems to be hard heuristically in practice. Nonetheless, Coq includes some very helpful heuristics, many of them copying the workings of Haskell and ML type-checkers for programs that fall in simple fragments of Coq's language. adamc@9: adamc@9: This is as good a time as any to mention the preponderance of different languages associated with Coq. The theoretical foundation of Coq is a formal system called the %\textit{%##Calculus of Inductive Constructions (CIC)##%}%, which is an extension of the older %\textit{%##Calculus of Constructions (CoC)##%}%. CIC is quite a spartan foundation, which is helpful for proving metatheory but not so helpful for real development. Still, it is nice to know that it has been proved that CIC enjoys properties like %\textit{%##strong normalization##%}%, meaning that every program (and, more importantly, every proof term) terminates; and %\textit{%##relative consistency##%}% with systems like versions of Zermelo Fraenkel set theory, which roughly means that you can believe that Coq proofs mean that the corresponding propositions are "really true," if you believe in set theory. adamc@9: adamc@9: Coq is actually based on an extension of CIC called %\textit{%##Gallina##%}%. The text after the [:=] and before the period in the last code example is a term of Gallina. Gallina adds many useful features that are not compiled internalluy to more primitive CIC features. The important metatheorems about CIC have not been extended to the full breadth of these features, but most Coq users do not seem to lose much sleep over this omission. adamc@9: adamc@9: Commands like [Inductive] and [Definition] are part of %\textit{%##the vernacular##%}%, which includes all sorts of useful queries and requests to the Coq system. adamc@9: adamc@9: Finally, there is %\textit{%##Ltac##%}%, Coq's domain-specific language for writing proofs and decision procedures. We will see some basic examples of Ltac later in this chapter, and much of this book is devoted to more involved Ltac examples. adamc@9: adamc@9: %\medskip% adamc@9: adamc@9: We can give a simple definition of the meaning of an expression: *) adamc@9: adamc@4: Fixpoint expDenote (e : exp) : nat := adamc@4: match e with adamc@4: | Const n => n adamc@4: | Binop b e1 e2 => (binopDenote b) (expDenote e1) (expDenote e2) adamc@4: end. adamc@2: adamc@9: (** We declare explicitly that this is a recursive definition, using the keyword [Fixpoint]. The rest should be old hat for functional programmers. *) adamc@2: adamc@9: adamc@9: (** ** Target language *) adamc@2: adamc@10: (** We will compile our source programs onto a simple stack machine, whose syntax is: *) adamc@10: adamc@4: Inductive instr : Set := adamc@4: | IConst : nat -> instr adamc@4: | IBinop : binop -> instr. adamc@2: adamc@4: Definition prog := list instr. adamc@4: Definition stack := list nat. adamc@2: adamc@10: (** An instruction either pushes a constant onto the stack or pops two arguments, applies a binary operator to them, and pushes the result onto the stack. A program is a list of instructions, and a stack is a list of natural numbers. adamc@10: adamc@10: We can give instructions meanings as functions from stacks to optional stacks, where running an instruction results in [None] in case of a stack underflow and results in [Some s'] when the result of execution is the new stack [s']. [::] is the "list cons" operator from the Coq standard library. *) adamc@10: adamc@4: Definition instrDenote (i : instr) (s : stack) : option stack := adamc@4: match i with adamc@4: | IConst n => Some (n :: s) adamc@4: | IBinop b => adamc@4: match s with adamc@4: | arg1 :: arg2 :: s' => Some ((binopDenote b) arg1 arg2 :: s') adamc@4: | _ => None adamc@4: end adamc@4: end. adamc@2: adamc@10: (** With [instrDenote] defined, it is easy to define a function [progDenote], which iterates application of [instrDenote] through a whole program. *) adamc@10: adamc@4: Fixpoint progDenote (p : prog) (s : stack) {struct p} : option stack := adamc@4: match p with adamc@4: | nil => Some s adamc@4: | i :: p' => adamc@4: match instrDenote i s with adamc@4: | None => None adamc@4: | Some s' => progDenote p' s' adamc@4: end adamc@4: end. adamc@2: adamc@10: (** There is one interesting difference compared to our previous example of a [Fixpoint]. This recursive function takes two arguments, [p] and [s]. It is critical for the soundness of Coq that every program terminate, so a shallow syntactic termination check is imposed on every recursive function definition. One of the function parameters must be designated to decrease monotonically across recursive calls. That is, every recursive call must use a version of that argument that has been pulled out of the current argument by some number of [match] expressions. [expDenote] has only one argument, so we did not need to specify which of its arguments decreases. For [progDenote], we resolve the ambiguity by writing [{struct p}] to indicate that argument [p] decreases structurally. *) adamc@10: adamc@2: adamc@9: (** ** Translation *) adamc@2: adamc@10: (** Our compiler itself is now unsurprising. [++] is the list concatenation operator from the Coq standard library. *) adamc@10: adamc@4: Fixpoint compile (e : exp) : prog := adamc@4: match e with adamc@4: | Const n => IConst n :: nil adamc@4: | Binop b e1 e2 => compile e2 ++ compile e1 ++ IBinop b :: nil adamc@4: end. adamc@2: adamc@2: adamc@9: (** ** Translation correctness *) adamc@2: adamc@11: (** We are ready to prove that our compiler is implemented correctly. We can use a new vernacular command [Theorem] to start a correctness proof, in terms of the semantics we defined earlier: *) adamc@11: adamc@11: Theorem compileCorrect : forall e, progDenote (compile e) nil = Some (expDenote e :: nil). adamc@11: (* begin hide *) adamc@11: Abort. adamc@11: (* end hide *) adamc@11: adamc@11: (** Though a pencil-and-paper proof might clock out at this point, writing "by a routine induction on [e]," it turns out not to make sense to attack this proof directly. We need to use the standard trick of %\textit{%##strengthening the induction hypothesis##%}%. We do that by proving an auxiliary lemma: adamc@11: *) adamc@11: adamc@4: Lemma compileCorrect' : forall e s p, progDenote (compile e ++ p) s = adamc@4: progDenote p (expDenote e :: s). adamc@11: adamc@11: (** After the period in the [Lemma] command, we are in %\textit{%##the interactive proof-editing mode##%}%. We find ourselves staring at this ominous screen of text: adamc@11: adamc@11: [[ adamc@11: 1 subgoal adamc@11: adamc@11: ============================ adamc@11: forall (e : exp) (s : stack) (p : list instr), adamc@11: progDenote (compile e ++ p) s = progDenote p (expDenote e :: s) adamc@11: ]] adamc@11: adamc@11: Coq seems to be restating the lemma for us. What we are seeing is a limited case of a more general protocol for describing where we are in a proof. We are told that we have a single subgoal. In general, during a proof, we can have many pending subgoals, each of which is a logical proposition to prove. Subgoals can be proved in any order, but it usually works best to prove them in the order that Coq chooses. adamc@11: adamc@11: Next in the output, we see our single subgoal described in full detail. There is a double-dashed line, above which would be our free variables and hypotheses, if we had any. Below the line is the conclusion, which, in general, is to be proved from the hypotheses. adamc@11: adamc@11: We manipulate the proof state by running commands called %\textit{%##tactics##%}%. Let us start out by running one of the most important tactics: adamc@11: *) adamc@11: adamc@4: induction e. adamc@2: adamc@11: (** We declare that this proof will proceed by induction on the structure of the expression [e]. This swaps out our initial subgoal for two new subgoals, one for each case of the inductive proof: adamc@11: adamc@11: [[ adamc@11: 2 subgoals adamc@11: adamc@11: n : nat adamc@11: ============================ adamc@11: forall (s : stack) (p : list instr), adamc@11: progDenote (compile (Const n) ++ p) s = adamc@11: progDenote p (expDenote (Const n) :: s) adamc@11: ]] adamc@11: [[ adamc@11: subgoal 2 is: adamc@11: forall (s : stack) (p : list instr), adamc@11: progDenote (compile (Binop b e1 e2) ++ p) s = adamc@11: progDenote p (expDenote (Binop b e1 e2) :: s) adamc@11: ]] adamc@11: adamc@11: The first and current subgoal is displayed with the double-dashed line below free variables and hypotheses, while later subgoals are only summarized with their conclusions. We see an example of a free variable in the first subgoal; [n] is a free variable of type [nat]. The conclusion is the original theorem statement where [e] has been replaced by [Const n]. In a similar manner, the second case has [e] replaced by a generalized invocation of the [Binop] expression constructor. We can see that proving both cases corresponds to a standard proof by structural induction. adamc@11: adamc@11: We begin the first case with another very common tactic. adamc@11: *) adamc@11: adamc@4: intros. adamc@11: adamc@11: (** The current subgoal changes to: adamc@11: [[ adamc@11: adamc@11: n : nat adamc@11: s : stack adamc@11: p : list instr adamc@11: ============================ adamc@11: progDenote (compile (Const n) ++ p) s = adamc@11: progDenote p (expDenote (Const n) :: s) adamc@11: ]] adamc@11: adamc@11: We see that [intros] changes [forall]-bound variables at the beginning of a goal into free variables. adamc@11: adamc@11: To progress further, we need to use the definitions of some of the functions appearing in the goal. The [unfold] tactic replaces an identifier with its definition. adamc@11: *) adamc@11: adamc@4: unfold compile. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: n : nat adamc@11: s : stack adamc@11: p : list instr adamc@11: ============================ adamc@11: progDenote ((IConst n :: nil) ++ p) s = adamc@11: progDenote p (expDenote (Const n) :: s) adamc@11: ]] *) adamc@11: adamc@4: unfold expDenote. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: n : nat adamc@11: s : stack adamc@11: p : list instr adamc@11: ============================ adamc@11: progDenote ((IConst n :: nil) ++ p) s = progDenote p (n :: s) adamc@11: ]] adamc@11: adamc@11: We only need to unfold the first occurrence of [progDenote] to prove the goal: *) adamc@11: adamc@11: unfold progDenote at 1. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: n : nat adamc@11: s : stack adamc@11: p : list instr adamc@11: ============================ adamc@11: (fix progDenote (p0 : prog) (s0 : stack) {struct p0} : adamc@11: option stack := adamc@11: match p0 with adamc@11: | nil => Some s0 adamc@11: | i :: p' => adamc@11: match instrDenote i s0 with adamc@11: | Some s' => progDenote p' s' adamc@11: | None => None (A:=stack) adamc@11: end adamc@11: end) ((IConst n :: nil) ++ p) s = adamc@11: progDenote p (n :: s) adamc@11: ]] adamc@11: adamc@11: This last [unfold] has left us with an anonymous fixpoint version of [progDenote], which will generally happen when unfolding recursive definitions. Fortunately, in this case, we can eliminate such complications right away, since the structure of the argument [(IConst n :: nil) ++ p] is known, allowing us to simplify the internal pattern match with the [simpl] tactic: adamc@11: *) adamc@11: adamc@4: simpl. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: n : nat adamc@11: s : stack adamc@11: p : list instr adamc@11: ============================ adamc@11: (fix progDenote (p0 : prog) (s0 : stack) {struct p0} : adamc@11: option stack := adamc@11: match p0 with adamc@11: | nil => Some s0 adamc@11: | i :: p' => adamc@11: match instrDenote i s0 with adamc@11: | Some s' => progDenote p' s' adamc@11: | None => None (A:=stack) adamc@11: end adamc@11: end) p (n :: s) = progDenote p (n :: s) adamc@11: ]] adamc@11: adamc@11: Now we can unexpand the definition of [progDenote]: adamc@11: *) adamc@11: adamc@11: fold progDenote. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: n : nat adamc@11: s : stack adamc@11: p : list instr adamc@11: ============================ adamc@11: progDenote p (n :: s) = progDenote p (n :: s) adamc@11: ]] adamc@11: adamc@11: It looks like we are at the end of this case, since we have a trivial equality. Indeed, a single tactic finishes us off: adamc@11: *) adamc@11: adamc@4: reflexivity. adamc@2: adamc@11: (** On to the second inductive case: adamc@11: adamc@11: [[ adamc@11: adamc@11: b : binop adamc@11: e1 : exp adamc@11: IHe1 : forall (s : stack) (p : list instr), adamc@11: progDenote (compile e1 ++ p) s = progDenote p (expDenote e1 :: s) adamc@11: e2 : exp adamc@11: IHe2 : forall (s : stack) (p : list instr), adamc@11: progDenote (compile e2 ++ p) s = progDenote p (expDenote e2 :: s) adamc@11: ============================ adamc@11: forall (s : stack) (p : list instr), adamc@11: progDenote (compile (Binop b e1 e2) ++ p) s = adamc@11: progDenote p (expDenote (Binop b e1 e2) :: s) adamc@11: ]] adamc@11: adamc@11: We see our first example of hypotheses above the double-dashed line. They are the inductive hypotheses [IHe1] and [IHe2] corresponding to the subterms [e1] and [e2], respectively. adamc@11: adamc@11: We start out the same way as before, introducing new free variables and unfolding and folding the appropriate definitions. The seemingly frivolous [unfold]/[fold] pairs are actually accomplishing useful work, because [unfold] will sometimes perform easy simplifications. *) adamc@11: adamc@4: intros. adamc@4: unfold compile. adamc@4: fold compile. adamc@4: unfold expDenote. adamc@4: fold expDenote. adamc@11: adamc@11: (** Now we arrive at a point where the tactics we have seen so far are insufficient: adamc@11: adamc@11: [[ adamc@11: adamc@11: b : binop adamc@11: e1 : exp adamc@11: IHe1 : forall (s : stack) (p : list instr), adamc@11: progDenote (compile e1 ++ p) s = progDenote p (expDenote e1 :: s) adamc@11: e2 : exp adamc@11: IHe2 : forall (s : stack) (p : list instr), adamc@11: progDenote (compile e2 ++ p) s = progDenote p (expDenote e2 :: s) adamc@11: s : stack adamc@11: p : list instr adamc@11: ============================ adamc@11: progDenote ((compile e2 ++ compile e1 ++ IBinop b :: nil) ++ p) s = adamc@11: progDenote p (binopDenote b (expDenote e1) (expDenote e2) :: s) adamc@11: ]] adamc@11: adamc@11: What we need is the associative law of list concatenation, available as a theorem [app_ass] in the standard library. *) adamc@11: adamc@11: Check app_ass. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: app_ass adamc@11: : forall (A : Type) (l m n : list A), (l ++ m) ++ n = l ++ m ++ n adamc@11: ]] adamc@11: adamc@11: We use it to perform a rewrite: *) adamc@11: adamc@4: rewrite app_ass. adamc@11: adamc@11: (** changing the conclusion to: [[ adamc@11: adamc@11: progDenote (compile e2 ++ (compile e1 ++ IBinop b :: nil) ++ p) s = adamc@11: progDenote p (binopDenote b (expDenote e1) (expDenote e2) :: s) adamc@11: ]] adamc@11: adamc@11: Now we can notice that the lefthand side of the equality matches the lefthand side of the second inductive hypothesis, so we can rewrite with that hypothesis, too: *) adamc@11: adamc@4: rewrite IHe2. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: progDenote ((compile e1 ++ IBinop b :: nil) ++ p) (expDenote e2 :: s) = adamc@11: progDenote p (binopDenote b (expDenote e1) (expDenote e2) :: s) adamc@11: ]] adamc@11: adamc@11: The same process lets us apply the remaining hypothesis. *) adamc@11: adamc@4: rewrite app_ass. adamc@4: rewrite IHe1. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: progDenote ((IBinop b :: nil) ++ p) (expDenote e1 :: expDenote e2 :: s) = adamc@11: progDenote p (binopDenote b (expDenote e1) (expDenote e2) :: s) adamc@11: ]] adamc@11: adamc@11: Now we can apply a similar sequence of tactics to that that ended the proof of the first case. adamc@11: *) adamc@11: adamc@11: unfold progDenote at 1. adamc@4: simpl. adamc@11: fold progDenote. adamc@4: reflexivity. adamc@11: adamc@11: (** And the proof is completed, as indicated by the message: adamc@11: adamc@11: [[ adamc@11: Proof completed. adamc@11: adamc@11: And there lies our first proof. Already, even for simple theorems like this, the final proof script is unstructured and not very enlightening to readers. If we extend this approach to more serious theorems, we arrive at the unreadable proof scripts that are the favorite complaints of opponents of tactic-based proving. Fortunately, Coq has rich support for scripted automation, and we can take advantage of such a scripted tactic (defined elsewhere) to make short work of this lemma. We abort the old proof attempt and start again. adamc@11: *) adamc@11: adamc@4: Abort. adamc@2: adamc@4: Lemma compileCorrect' : forall e s p, progDenote (compile e ++ p) s = adamc@4: progDenote p (expDenote e :: s). adamc@4: induction e; crush. adamc@4: Qed. adamc@2: adamc@11: (** We need only to state the basic inductive proof scheme and call a tactic that automates the tedious reasoning in between. In contrast to the period tactic terminator from our last proof, the semicolon tactic separator supports structured, compositional proofs. The tactic [t1; t2] has the effect of running [t1] and then running [t2] on each remaining subgoal. The semicolon is one of the most fundamental building blocks of effective proof automation. The period terminator is very useful for exploratory proving, where you need to see intermediate proof states, but final proofs of any serious complexity should have just one period, terminating a single compound tactic that probably uses semicolons. adamc@11: adamc@11: The proof of our main theorem is now easy. We prove it with four period-terminated tactics, though separating them with semicolons would work as well; the version here is easier to step through. *) adamc@11: adamc@4: Theorem compileCorrect : forall e, progDenote (compile e) nil = Some (expDenote e :: nil). adamc@11: intros. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: e : exp adamc@11: ============================ adamc@11: progDenote (compile e) nil = Some (expDenote e :: nil) adamc@11: ]] adamc@11: adamc@11: At this point, we want to massage the lefthand side to match the statement of [compileCorrect']. A theorem from the standard library is useful: *) adamc@11: adamc@11: Check app_nil_end. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: app_nil_end adamc@11: : forall (A : Type) (l : list A), l = l ++ nil adamc@11: ]] *) adamc@11: adamc@4: rewrite (app_nil_end (compile e)). adamc@11: adamc@11: (** This time, we explicitly specify the value of the variable [l] from the theorem statement, since multiple expressions of list type appear in the conclusion. [rewrite] might choose the wrong place to rewrite if we did not specify which we want. adamc@11: adamc@11: [[ adamc@11: adamc@11: e : exp adamc@11: ============================ adamc@11: progDenote (compile e ++ nil) nil = Some (expDenote e :: nil) adamc@11: ]] adamc@11: adamc@11: Now we can apply the lemma. *) adamc@11: adamc@4: rewrite compileCorrect'. adamc@11: adamc@11: (** [[ adamc@11: adamc@11: e : exp adamc@11: ============================ adamc@11: progDenote nil (expDenote e :: nil) = Some (expDenote e :: nil) adamc@11: ]] adamc@11: adamc@11: We are almost done. The lefthand and righthand sides can be seen to match by simple symbolic evaluation. That means we are in luck, because Coq identifies any pair of terms as equal whenever they normalize to the same result by symbolic evaluation. By the definition of [progDenote], that is the case here, but we do not need to worry about such details. A simple invocation of [reflexivity] does the normalization and checks that the two results are syntactically equal. *) adamc@11: adamc@4: reflexivity. adamc@4: Qed.