coq-club AT inria.fr
Subject: The Coq mailing list
List archive
Re: [Coq-Club] need help with proof that indexes of true bools in list do index true bools
Chronological Thread
- From: Jason Gross <jasongross9 AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] need help with proof that indexes of true bools in list do index true bools
- Date: Wed, 22 Jul 2020 23:37:49 -0400
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jasongross9 AT gmail.com; spf=Pass smtp.mailfrom=jasongross9 AT gmail.com; spf=None smtp.helo=postmaster AT mail-ej1-f51.google.com
- Ironport-phdr: 9a23:ZBisUBK94fQfTdD809mcpTZWNBhigK39O0sv0rFitYgeKv/xwZ3uMQTl6Ol3ixeRBMOHsqwC1rKd7vmocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmTuwbalyIRmqogncttQaipZ+J6gszRfEvmFGcPlMy2NyIlKTkRf85sOu85Nm7i9dpfEv+dNeXKvjZ6g3QqBWAzogM2Au+c3krgLDQheV5nsdSWoZjBxFCBXY4R7gX5fxtiz6tvdh2CSfIMb7Q6w4VSik4qx2ThLjlSUJOCMj8GzPhcNwgqBUrhKvqRJ83oDafp2aOeFkca/BZ94XX3ZNUtpTWiFHH4iyb5EPD+0EPetAq4fyvUAOrRy4BQKxBe3v0DhIhmTt3aYn1OkhExvJ3BcnH9IIv3TUttL1NLwJUe2x16TIwjDDYOlX2Tf58oTHbhchofSVUL92bMHexlUhGRnfgVWMtYzqISmV1uIVvmWZ7edtSeOihmElpgxwvjWi2togh4nNi48RyV3J6yp3zYQ7K9ClS0N2ZcCoHptOui+aN4Z6X80vT3xptSomxbALv4OwcisSyJk/2RLTd/iKf5KL7x/jTuqdPyp0iXF/dL+/mhq/91WrxPfmWcmuyllKqzJIktnSuXAJ0Bze8s2HReF8/kelwDqAyQLT5vxdLUA6lafXNoQtwrE3lpoUvkTDGjH5lF/qg6+Rc0Uo4umo6+L5bbX6vpKQKZN4hwXkPqktmsGzG/o0PhUNUmSB+emwyaXv/UjjT7VLiv02nLPZsJffJckDpK62GRRV0oEl6xawFTem188YnWIDIV9edxKHipLmO1DKIPziEfi/hFGsnC9xx//aJr3hHonNLn/bnbj9erZ98ldQxxY3zdBC/J1ZEaoBIfL2Wk/prtPUFB45Mwquw+bmEtpxzI0eWXjcSpOeZajVqBqD4v8la72HY5ZQszLgIdAk4eTvhDk3gwlOU7Ou2M41YWu/GLxJOUKCejK4gN4aFmEFpA0lV73Ch1iLUDoVbHG3CfFvrgonAZ6rWN+QDrumh6aMiX/iQ89mI1teA1XJKk/GMoWJX/BWNXCXK85l1zEGDP2vFtZn2hapuwv3jbFgK7iMo3FKhdfYzNFwotbru1Qq7zUtVpaS1miMSyd/mWZaH2ZnjpA6mlR0zxK46YY9hvVZEdJJ4PYQC1U1MJfdy6pxDNWgAw8=
You need to generalize your theorem statement to be about truebits, maybe something like
Fixpoint are_truebits_gen (offset : nat) (ln:list nat)(lb:list bool) : Prop :=
match ln with
| i :: ln => nth_error (i - offset) lb = Some true /\ are_truebits_gen offset ln lb
| nil => True
end.
Theorem all_truebits_are_truebits_gen:
forall lb offset, are_truebits_gen offset (truebits offset lb) lb.
Now you should just be able to induct over lb (while still universally quantified over offset), and everything is structurally recursive over lb, so you can just simplify. Then you do a bit of arithmetic to apply your inductive hypothesis.
The general rule of thumb is that if your inductive hypothesis doesn't apply because some constant doesn't line up, you need to generalize your theorem statement to one that holds for all values of that constant.
I know there is a trick to this kind of proof, and I may have seen it a
few times, but I don't remember it. I would appreciate anyone's help
with this:
From Coq Require Import Lists.List.
Import ListNotations.
Fixpoint truebits(i:nat)(lb:list bool) : list nat :=
match lb with
| true :: lb => i :: truebits (S i) lb
| false :: lb => truebits (S i) lb
| nil => nil
end.
(*list of indexes of true in lb*)
Definition all_truebits lb := truebits 0 lb.
(*if all indexes in ln are indexes of true in lb*)
Fixpoint are_truebits(ln:list nat)(lb:list bool) : Prop :=
match ln with
| i :: ln => (nth i lb false) = true /\ are_truebits ln lb
| nil => True
end.
Theorem all_truebits_are_truebits:
forall lb, are_truebits (all_truebits lb) lb.
(*How to prove this?*)
- [Coq-Club] need help with proof that indexes of true bools in list do index true bools, jonikelee AT gmail.com, 07/23/2020
- Re: [Coq-Club] need help with proof that indexes of true bools in list do index true bools, Jason Gross, 07/23/2020
- Re: [Coq-Club] need help with proof that indexes of true bools in list do index true bools, jonikelee AT gmail.com, 07/23/2020
- Re: [Coq-Club] need help with proof that indexes of true bools in list do index true bools, Jason Gross, 07/23/2020
Archive powered by MHonArc 2.6.19+.