Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Retain branch information in match for holes.

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Retain branch information in match for holes.


Chronological Thread 
  • From: Suneel Sarswat <suneel.sarswat AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Retain branch information in match for holes.
  • Date: Sat, 14 Aug 2021 21:32:44 +0530
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=suneel.sarswat AT gmail.com; spf=Pass smtp.mailfrom=suneel.sarswat AT gmail.com; spf=None smtp.helo=postmaster AT mail-yb1-f169.google.com
  • Ironport-hdrordr: A9a23:Bn6cBKPw1cToGsBcTqKjsMiBIKoaSvp037BN7SBMoH1uE/Bw+PrEoB1273XJYVUqNk3I++rtBEDoexq1yXcf2+Ys1NmZMTXbhA==
  • Ironport-phdr: A9a23:vpb/3x9F/XVw//9uWcS8ngc9DxPPW53KNwIYoqAql6hJOvz6uci4ZAqPur4w0BfgZsby07p8ke3YsqTtCyQrwK2qlzQ8SqFKTAIPks4MngYtU4avAEz/K+P2PWRhRJwRHFBq8GumPkdLBc3we0PdomGo7T4VBx7zKRd5Kv76F4LMk8i7zeO/9p/cbwhIize2fK9/IgixoQjNrMcdnJFsKrw2yhvHo3tIf/pZyGZ1Ll+NnBjy+9m98od7/ytfp/wu+chAUb7nf6sjVrxXEC4mM2Eu68L1sxTIUBaC6WEdUmUSlRpIHhTF4RTnVZr/rif2quxw0zScMMbrT747RC6i4r9kRx/miigJNzA3/mLKhMJukK1WuwiuqwBlzoPOfI2ZKPhzc6XAdt0aX2pBWcNRWjRcDIOhaYsAEfQOPeJFpIfgvVQOtwC+BAe2C+Pz1zRFgWT23bA80+s/Dw7G2BYsH8kUv3TOt9X0Or0dUfyuwanHyDXMdfJW2TPn5IfUdRAhpOiBULRtesXe1UchDRnKjkmMqYP7JTOV0PwAv3ab4ediSe+il2Epph9+rDSz2ssihZTFipwaxF3K9Ch0zpo5KN65RUN5ZdOpEZtduS+GOodoQs4uXmBltiY4x7AApJW1fzAKxYw5yxLDb/GLaYuF7xL5WOqPPDt1gGhpdK++ihu290Wr1/fyWdOu0FlQqypIitnMuW4J1xzU8sWHT+Fy/kal2TqW1wHc8fxILVk6labGKpMsxqQ8lpUUsUTEES/2nFv5gLWKeUUj/+ik8+XnYrP4qZ+AL4J4lB3yP6A0lsG8Aek0KBYCU3Wf9OimybHu/En0TK1PjvIsk6nZtJ7aJd4cpq68GwJVyZsj6xChADi41NQUh2IHI0hfeBKcgYnmIU3OLev3Dfe6mVuskTNry+raMb3mB5XBNmLDn6v5fbZh905czxI+wsxY55JNE70OPPbzWlLqu9HDFR84Mwm0w/79B9ln14MeX3iPAq6DP6/Iv1+I/LFnH+7Zb4gM/T35NvJts/XplDoynUIXVaivx5oeLn6iSKdIOUKcNEHxhNoMFS8xtxAlU+X2wAmZTDheanL0RKsm/S4yFKqpCI7CQsamh7nXj3TzJYFfem0TUgPEKnzvbYjRA5/khwqdJ8ZglnoPUr3zEufJNDmrvQ7+jqttd6/ao3NJ853k09dx6qvYkhRgrVSc6uyS1miMSyd/mWZaH1cL

Thanks Gaëtan,
This worked for me but now unfolding and rewriting involving f is difficult to deal with!
I guess I should follow the book by Adam to hope to get what I am looking for.
Thanks again.
Regards,
Suneel

On Sat, Aug 14, 2021 at 7:32 PM Gaëtan Gilbert <gaetan.gilbert AT skyskimmer.net> wrote:
With tactics you can do

Fixpoint f (ell:list nat):(list r).
Proof.
   refine (match ell with
           | nil => nil
           | cons h ell' => _
           end).
   destruct (Nat.ltb h 5) eqn:H.
   - exact (f ell').
   - exact (cons (mkr h H) (f ell')).
Defined.

With a direct term:

Fixpoint f (ell:list nat) : list r :=
   match ell with
   | nil => nil
   | cons h ell' =>
     (if Nat.ltb h 5 as b return Nat.ltb h 5 = b -> list r
      then fun _ => f ell'
      else fun H => cons (mkr h H) (f ell'))
       eq_refl
   end.

Gaëtan Gilbert

On 14/08/2021 13:36, Suneel Sarswat wrote:
> I have a simple problem. I can't find any web link/document for this kind of situation. I have a record type r as
> * Record r:=mkr { x: nat; xc: Nat.ltb x 5 = false}.*
> Now I want to write a function which takes a list ell of natural numbers and returns a list of type r as
> *Fixpoint f (ell:list nat):(list r).
>   refine ( match ell with
>    |nil => nil
>    |h::ell' => if Nat.ltb h 5 then f ell' else (mkr h _)::f ell'
> end ).*
> The problem is it gives me a goal to prove "Nat.ltb h 5 = false" without the branch information or any condition on term h. In general how to extract branch information/pass dependent proof terms in a specific branch of function?
> Thanks in advance.
> Regards,
> Suneel



Archive powered by MHonArc 2.6.19+.

Top of Page