Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Functions that differ at exactly one point

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Functions that differ at exactly one point


chronological Thread 
  • From: Mathieu Boespflug <mboes AT tweag.net>
  • To: Bernard Hurley <bernard AT marcade.biz>
  • Cc: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Functions that differ at exactly one point
  • Date: Sun, 29 Apr 2012 13:38:55 -0400

Hi Bernard,

> But is it possible to define a function that differs at an arbitrary
> integer as the following incorrect code is trying to do:
> 
> +++++++++++++++++++++++++++++++++
>   Variable f : nat -> nat.
>   Variable m : nat.
> 
>   Fixpoint g (n : nat) : nat :=
>     match n with
>       | m => 2
>       | _ => f n
>     end.
> ++++++++++++++++++++++++++++++++++

The second branch you wrote above is effectively a dead branch, because
the pattern in the first branch always matches. I think you meant to
write something like:

Require Import EqNat.

Section Example.

Variable f : nat -> nat.
Variable m : nat.

Fixpoint g (n : nat) : nat :=
  if eq_nat_decide m n then 2 else f n.

End Example.

Hope this helps,

-- Mathieu



Archive powered by MhonArc 2.6.16.

Top of Page