coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Gaëtan Gilbert <gaetan.gilbert AT skyskimmer.net>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Retain branch information in match for holes.
- Date: Sat, 14 Aug 2021 16:01:33 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gaetan.gilbert AT skyskimmer.net; spf=Pass smtp.mailfrom=gaetan.gilbert AT skyskimmer.net; spf=None smtp.helo=postmaster AT relay4-d.mail.gandi.net
- Ironport-hdrordr: A9a23:6z2xXqGemuvwMkMwpLqE5ceALOsnbusQ8zAXPjNKOHhom6uj5qeTdZUgpHrJYVkqOU3I9eruBEDEewK/yXcX2/hzAV7BZmfbUQKTRekI0WKh+VHd8kbFnNK1u50MT0EzMr3NMWQ=
- Ironport-phdr: A9a23:3NTCNRBwXh5PRdY9uPmnUyQUrkMY04WdBeb1wqQuh78GSKm/5ZOqZBWZua81yg+WFtiHo9t/yMPu+5j6XmIB5ZvT+FsjS7drEyE/tMMNggY7C9SEA0CoZNTjbig9AdgQHAQ9pyLzPkdaAtvxaEPPqXOu8zESBg//NQ1oLejpB4Lelcu62/6u95HJYAhFhjWxbLN9IR6rsQjfq84ajJd4JK0s0BXJuHxIe+pXxWNsO12emgv369mz8pB+7Sleouot+MFcX6r0eaQ4VqFYAy89M28p/s3rtALMQhWJ63ABT2gZiBtIAwzC7BHnQpf8tzbxu+Rh1CWGO8D9ULY5Uimg4ah2Uh/lkDoJOSA38G/XicJ+gqxUrx2jqBNjzIDZe52VOflkc6/BYd8XS2hMU8BMXCJBGIO8aI4PAvIAM+lCs479u0EBrR2mCgetBePvziRHiWHs3a0mzu8sFg7G0xY+ENISqnvUqs/5NKgTUeCx16bH0y/Db+9N1Dfm64jJcgshofKNXbJ1dMre11MvGxnDjlqOtYzoJjWY3fkCvGaH9eRvT/6vi3I5pAFrpDii3scih43Ui44L113K+iZ0zYUoKdC5VEJ2ZdGpHYdfuiyeNIZ7XMwsTmJ2tSg0y7ALpJG2cSoFxpkj2hLSdf+KfYeO7xn+V+iROS91iGx4dL+9nRq/81SsxvfhWsS33ltGtDdJn93Nu30Lyhfd8NKISuFn8UekwTuP1x7c6uVDIU0sj6rUNZohzaQwl5ccqEjMAzX6mEDsg6+XckUo4Oeo5P7hYrr7p5+QLYl0hR/iMqg2m8y/B/o3MhQWUmSF5Oix1qfv8E/lTLlQk/E7kafUvIrHKckfp6O1GwpV3Zwi6xa7ATemytMYnXwfIVJKYh2IkZTpNEvIIPziAve/glCsnyx1yPDcIr3sGY7NLnvDkbf6frZ96ktcyA8twtBF/Z5UDK8OIO7rVk/rqNPYFgM5MxCzw+v/FNp90ZoeVXuTDa+dLaPdqkSF5vkvIumJfI8aoizxK/kj5/70jH82g0URfaez3chfVHftFfN/Zk6dfHDEg9EbEG5MsBBtYvbtjQitWL1PbnCFcKM47DwhFMryAo7OWomrxrOA2C22BIF+fWNXEVONFHLlbcOCVutaO3HaGdNojjFRDevpcIQmzxz77GcSKpJ9I+7d63FdudTm3dlxoeLakx0zszp5E5bFu4loZ3p3j3gLRjoz0bo5p0FhmA/rOUdQmP9JDt9S4vZESEE8OIKOloRH
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
- [Coq-Club] Retain branch information in match for holes., Suneel Sarswat, 08/14/2021
- Re: [Coq-Club] Retain branch information in match for holes., Gabriel Scherer, 08/14/2021
- Re: [Coq-Club] Retain branch information in match for holes., Suneel Sarswat, 08/14/2021
- Re: [Coq-Club] Retain branch information in match for holes., Suneel Sarswat, 08/14/2021
- Re: [Coq-Club] Retain branch information in match for holes., Adam Chlipala, 08/14/2021
- Re: [Coq-Club] Retain branch information in match for holes., Suneel Sarswat, 08/14/2021
- Re: [Coq-Club] Retain branch information in match for holes., Gaëtan Gilbert, 08/14/2021
- Re: [Coq-Club] Retain branch information in match for holes., Suneel Sarswat, 08/14/2021
- Re: [Coq-Club] Retain branch information in match for holes., Gabriel Scherer, 08/14/2021
Archive powered by MHonArc 2.6.19+.