Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Program Fixpoint and a function involving two lists

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Program Fixpoint and a function involving two lists


Chronological Thread 
  • From: Suneel Sarswat <suneel.sarswat AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Program Fixpoint and a function involving two lists
  • Date: Tue, 11 Aug 2020 13:26:41 +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-ed1-f53.google.com
  • Ironport-phdr: 9a23:0dEs8xFTkWnaie9nk/i5R51GYnF86YWxBRYc798ds5kLTJ7zocuwAkXT6L1XgUPTWs2DsrQY0rSQ4/GrADVQqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba5zIRmsrgjcssYajZZ/Jqsy1xDEvmZGd+NKyG1yOFmdhQz85sC+/J5i9yRfpfcs/NNeXKv5Yqo1U6VWACwpPG4p6sLrswLDTRaU6XsHTmoWiBtIDBPb4xz8Q5z8rzH1tut52CmdIM32UbU5Uims4qt3VBPljjoMOjgk+2/Vl8NwlrpWrx2vpxN9w4DaboKbOudgcKzBZt4VX3ZNU9xLWiBdHo+xbY0CBPcBM+ZCqIn9okMDowajBQmqGuzg1DtIjWLr06IgyeQhCg/H0xY8H9kTt3nUt8j1NKEMXu+ryKnE1y7DYOlM2Tfm5onHaAwhrOqDXbJ1a8XRyE0vGxnZgVWXrIzoJjWY3fkCvGaH9eRvT/6vi3I5pAFrpDii3scih4jLi44J1F3J8SR0zZo1K9C6VkJ1b9qpHIZTui+aK4Z7TN8vTmBntSonxLMIuZG1ciYIxZkmxBPTd+CLfoyO7xn+WuiRJjJ4i2hkeLK5nxu97EmgyvbgWcmzzVZKtDFFncfWunACzRzT7dWHSuN780y82jiPzxje5v9YLU0wj6bWKJ4szqQumpYPsknPBC/7lUvwgaSLbEsr4PKo5P7iYrj+pp+TKYt0igbmP6QrgMO/AOA4PhEQUGeG5OiwzbPj8E33TblQgf02la7ZsJ/eJcsFvKK2HwhV0oM75xa+CTepzsgYkGEZIF5ZfB+LlYvkNlHULPzmEfuygE6gnTdlyvzeO73uGJTNLnzNkLf7erZ97lZRyBEuzdBZ+Z1bFLUBLOjoWkDrrtzYFRE4PBaow+v8B9V905kRWWOLAqODLKzStlqI6vo1I+aQfI8VpCr9K/896vHyin85gEYRcrWt3ZsKc3+1Be9mIkWcYXr0mNgNC2YKvgwkTOzrklKOSzBTZ2zhF547szo8EcetCZrJboGrmr2ImimhTbNMYWUTMU2KHHrsP76NQewTYT7adtR8lDEJUf66QpU6yhiynAD/wrtjaOHT/3tL5trYyNFp6riLxlkJ/jtuApHFijDffyRPhmoNAgQO8uV6qE15xE2E1PEh0fNdHN1XofhOV1VjbMKO/6lBE9n3Hzn5UJKRUl//G4epBDgwSpQ6xNpcOx8gSeXntQjK2m+RO5FQl7GPA8ZpoKfV3ny0Ksokjnibj+8uiF4pRsYJPmqj1PZy

Dear Yishuai,
Thanks for the quick response. I shall surely look into it. Besides this, any info on Program Fixpoint and proofs involving them will be of great help to me.
Regards,
Suneel

On Tue, Aug 11, 2020 at 1:18 PM Yishuai Li <yishuai AT cis.upenn.edu> wrote:
Hi Suneel,

I've asked a similar question before:
https://coq.discourse.group/t/fixpoint-with-two-decreasing-arguments/544
Alternative solution are internal auxiliary fixpoint and Equations,
which are shown under that thread.

Hope it helps,
Yishuai

Suneel Sarswat <suneel.sarswat AT gmail.com> 于2020年8月11日周二 上午3:27写道:
>
> I am trying to write a function involving two lists. In each iteration, one of the lists decreases strictly. The Fixpoint doesn't work so tried Program Fixpoint with the measure on the sum of the length of the two lists. Here is a minimum working example
>
> Require Import Wf.
> Program Fixpoint either (l1:list nat) (l2: list nat) {measure (|l1| + |l2|)}:=
> match (l1,l2) with
> |(nil, _) => nil
> |(_,nil) => nil
> |(a1::l1',a2::l2') => match (Nat.leb a1 a2) with
>   |true  => a1::either l1' ((a2 -a1)::l2')
>   |false => a2::either ((a1-a2)::l1') l2'
>   end
>   end.
>
> Next Obligation.
> simpl. omega. Qed.
>
> Lemma trivial1 (l1: list nat) (l2: list nat): (hd (either l1 l2)) = (hd l1)\/(hd (either l1 l2)) = (hd l2).
> Proof. simpl. induction l1 as [| a1 l1']. left. auto. case l2 as [|a2 l2']. right. auto.
> destruct (Nat.leb a1 a2) eqn:H1. right. unfold either. unfold either_func.
>
> After the last tactic, I got stuck. It gives me a huge goal which let alone proving, I don't even understand.
> I tried finding this out on the internet. I got a post on stack exchange regarding this but that is not working. I got an error "fix_sub_eq_ext" not recognized when I run 'rewrite fix_sub_eq_ext' as per the instruction on the post. Besides this, I also did not understand how do these tactics work. Is there any tutorial or paper where I can learn more about Program Fixpoint related tactics with a lot of examples?
>
> Besides this, is there an alternative way to write functions involving two or more lists where only one of them is strictly decreasing in each iteration. And prove their properties.
>
> Thanks,
> Suneel
>



Archive powered by MHonArc 2.6.19+.

Top of Page