Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Program and simpl/compute

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Program and simpl/compute


Chronological Thread 
  • From: Fabien Renaud <Fabien.Renaud AT inria.fr>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Program and simpl/compute
  • Date: Thu, 3 Oct 2013 11:07:54 +0200

Thanks guys,

I think I will use Function since I don't actually need any Program's features and I now understand how to use it.

Fabien


On Wed, Oct 2, 2013 at 3:48 PM, Vincent Laporte <vincent.laporte AT gmail.com> wrote:
Le 2013-10-02 11:39, Fabien Renaud a écrit :
> I tried with Function but simpl only expands to function_terminate
> and I'm stuck.

Hi,

If you use Function, then several objects will be defined: the function
itself and a couple of lemmas, one of them being test_equation.

Function test (l: list nat) {measure length} :=
match l with
| nil => 0
| X::R => (test (tl R))
end.
Proof.
  induction R; intuition.
Defined.

Check test_equation.
(* test_equation
     : forall l : list nat,
       test l = match l with
                | [] => 0
                | _ :: R => test (tl R)
                end
*)

You can use this lemma to simplify some terms. For instance:

Goal ∀ x l, test (x::l) = 0.
  intros x l. rewrite test_equation.
  (* the goal is now: test (tl l) = 0. *)
Abort.

Moreover, there is an induction principle associated with your function
(its name is test_ind but that does not matter much). It might help
proving facts about the function, as in the following:

Lemma foo l : test l = 0.
Proof.
  functional induction test l; auto.
Qed.

Regards,
--
Vincent.




Archive powered by MHonArc 2.6.18.

Top of Page