Skip to Content.
Sympa Menu

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

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[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: [Coq-Club] Program Fixpoint and a function involving two lists
  • Date: Tue, 11 Aug 2020 12:56:37 +0530
  • Authentication-results: mail3-smtp-sop.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:6Myrjh3N8MpLk1RjsmDT+DRfVm0co7zxezQtwd8ZseIXL/ad9pjvdHbS+e9qxAeQG9mCtbQU2qGP6vyocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmTuwbalxIRiyogndq9QajIR/Iast1xXFpWdFdf5Lzm1yP1KTmBj85sa0/JF99ilbpuws+c1dX6jkZqo0VbNXAigoPGAz/83rqALMTRCT6XsGU2UZiQRHDg7Y5xznRJjxsy/6tu1g2CmGOMD9UL45VSi+46ptVRTljjoMOTwk/2HNksF/g6JVrhyiqRJi3YDbfJqYO+Bicq7HZ94WWXZNU8RXWidcAo28dYwPD+8ZMOhFson9oUUBogW6BQKxGe3g0CVIhmT43KIgz+QqDAbL3Bc9H9IIrnvbstH1OL0JUe+v1qnI1jvCYOlK2Trm54jIdwouofCIXb5qbcXRzkwvGhrDg16NpoPrIymb2f4Rs2iH8eVgT+SvhnYppQ9/pjWiwtshhpTUi48X11zJ9Sp3zYkxKNCmVkJ1YdGqHpRUui2EOYZ7QMwvTm9otis517EItpC1cSgUxJkjwRPUdv+Jc5CQ7x79SOqcJS10iXFldb6lmRq+7Uutxvf8W8S61ltBszBLncPWtn8X0hze8siHReV5/kemwTuP0hrc6uBAIUwti6XUNoMtzqc+lpcTv0nPBCD2mELxjK+ZckUr5PKk5PjgYrXjvpOcNol0hR/iMqk2hMCzHeA1PhINUmWb4+iwyqHv8E7jTLhKgPA6iqzZv4rbJcQfqK65GQhV0oM75hakEjem1soXkmcDLF5fYxKIlZLpO0rAIf/iEfeymFuskDJxyPDHOr3tGInCLn/GkLv5Z7Zy91ZcyBYvzdBY/59bFrYBIOvqVkDtsNzYEwQ2Phevw+fnDdV9zpkRVXiOAq+fKqPSsEWH6vghI+mWN8cpv2P2LOFg7Przh1c4n0UcdO+nx8g5cne9S897JUiUZTLXi80aDm4W9l4lUernhVnESjdJfGm7Q4oz4zg6DMStCoKVFdPlu6CIwCruRs4eXWtBEF3ZSS65JbXBYO8FbWepGuEklzUFUba7TIp4jEOhsQb7z/xsKe+Go3RF56Km78B84qjorT939TFwCJ7AgWSETmUxk29RAjFrh+ZwpktyzlrF2q990aQBSY5joshRWwJ/DqbyivRgAomrCA3Ed9aNDl2hR4f+DA==

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