Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Destructing dependent match

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Destructing dependent match


chronological Thread 
  • From: Matthieu Sozeau <matthieu.sozeau AT gmail.com>
  • To: Guillaume Melquiond <guillaume.melquiond AT inria.fr>
  • Cc: Coq Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Destructing dependent match
  • Date: Thu, 16 Dec 2010 12:21:15 +0100
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=HnksxajWDeRSrKVJF+hh9KE0pD5ZBNAPuRGqOOyyCXtw1f3JLIOo1F/a0tZ5tgDphf NtIDADu15/bG7L9YvNP03CuIccO8elik2EGttbLWufdrXI9CaBnixcCHdQwIJhNNGdNw CiCwoYG2PVOm0m9NWsPLRxKDleUcKlqh+C3R4=


Le 16 déc. 2010 à 11:38, Guillaume Melquiond a écrit :

> Hi,
> 
> I'm having some trouble handling matchs when they have a dependent
> return type. Below is a simplified example. I would like to perform a
> case analysis on (f x) in order to simplify the goal. Ideally, that
> would produce two goals, one of them being:
> 
> x: nat
> H: f x = true
> =============
> P (A1 x H)
> 
> Standard tactics aren't helpful. I also tried writing a complete proof
> term, but I didn't succeed. Does anyone know of a tactic doing this kind
> of job or a way to write the proof term?

Hi Guillaume,

  there is one way to do it by transforming the case into a non-dependent one:

Require Import Sumbool.

Lemma if_bool_to_sumbool {B} (a : bool) 
  (b1 : forall p : a = true, B)
  (b2 : forall p : a = false, B)
  : 
  (if a as a' return a = a' -> B then b1 else b2) (refl_equal a) =
  (match sumbool_of_bool a with
     | left p => b1 p
     | right p => b2 p
   end).
Proof. destruct a; auto. Qed.

Goal forall x, P (
 (if f x as b return (f x = b -> A) then fun H => A1 x H else fun _ => A2)
 (@refl_equal _ (f x))).
intros x. rewrite if_bool_to_sumbool.
case (sumbool_of_bool (f x)); intros.
apply H1. apply H2.
Qed.

-- Matthieu



Archive powered by MhonArc 2.6.16.

Top of Page