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: "jonikelee AT gmail.com" <jonikelee AT gmail.com>
- To: Jason Gross <jasongross9 AT gmail.com>
- Cc: 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: Thu, 23 Jul 2020 02:50:46 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt1-f173.google.com
- Ironport-phdr: 9a23:O/iWLBT6Ny1o8DmeD7nP3mCFoNpsv+yvbD5Q0YIujvd0So/mwa6zYhaN2/xhgRfzUJnB7Loc0qyK6v6mBDRLuM/b+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6KfroEYDOkcu3y/qy+5rOaAlUmTaxe7x/IAi3oAnLtsQanYRuJrssxhfXv3BFZ/lYyWR0KFyJgh3y/N2w/Jlt8yRRv/Iu6ctNWrjkcqo7ULJVEi0oP3g668P3uxbDSxCP5mYHXWUNjhVIGQnF4wrkUZr3ryD3q/By2CiePc3xULA0RTGv5LplRRP0lCsKMSMy/XrJgcJskq1UvBOhpwR+w4HKZoGVKOF+db7Zcd8DWGZNQtpdWylHD4ihbYUAEvABMP5WoYf9uVUAsBiwCguiBO3oxTBHmnD40LYm0+kjCwzKwBYtE84QvHnSsd77NL0SUeewzKTQwznDbfRW2TH86IjLbB8hpe+DUqxrfMrezEkgDQLFjlGKpYP5ODOV0+oBuHWc4upiUuKvjW8nqwJvrTir2MgjlJLEho0Qyl/e9CV5xJw5KsG/SE5+eNOpFoZbuC6GOYVsWMwiX31otzggyr0AoZO3YCcHxIk6yxPBa/GKcIuF7x39WeifLjp2inxodbyhixu88UWt1/DxWMm63VpXsCdLnMfBu3MD2RHX6saJSvhw80G80jiMzwDe8v9ILVwwmKbBKJMswqQ8mocSvEjfBCP6hUf7gaGOekk6++Wk9/nrb7D7qpKYK4B5jw7zP6UylsCjBOk1PRIBU3WF9em5ybHu/lH1TKtPg/IokKTZvp7aKMEVpqGnHgBY04Mu5hKiADqpztsVm2QMIkhfdxKdlYfpPknDIPDmAve7hFShiDJryOrHPr3lG5nNN2TDnKr4cbZz9kJRygQ+wcpQ55JTDbEBL/bzVVHruNPECR85NhS4w+fhCNpjyoMTQXyDDrOdPa/IslKF5vgjL/SNaYMJojrxNvoo6vD2gX88g1AdfK2p3ZUNaHC/G/RrO0eZYX3qgtcAEmcFoA4+Q/L0h1CZXj5TYmy9X6M45j0hFI2mCoLDSpi3gLOdxCe7AoFWZmdeB1+QFnfobpyIVOsIaCKPOcBsiScEVLikS485zx6irg76y7x9LurV4CIUr5zj1MImr9HUwDM77jtyR+uH1HqWBzV2l3gPQTAs27tk8GRyz16C1e5zhPkORvJJ4PYcGAU9M5/fwuh3Bvj9XwvAepGCT1PsCoGkBjcwTd81ztImbEN0GtHkhRfGiXn5S4QJnqCGUcRnupnX2GL8coMkky6fiPsRymI+S84KDlWIw7Zl/lGKVYHMmkSd0a2tcPZEhX+fxCK41WOL+Xpgfkt1WKTBU2oYYxKP/9v870LGCbSpDOZ+a1YT+Yu5MqJPL+bRoxBGSfPkYoqMZmuwnyKpGU/NyOrTN8zlfGIS2CibA08BwVge
Thanks, Jason.
I realized, from your clue about getting everything to recurse over lb,
that I could simplify the problem by using a predicate that more
closely mirrors the definition of truebits by recursing it over lb:
Fixpoint ok_truebits(i:nat)(ln:list nat)(lb:list bool) : Prop :=
match lb with
| true :: lb => In i ln /\ ok_truebits (S i) ln lb
| false :: lb => ok_truebits (S i) ln lb
| nil => True
end.
This, plus a few more simple lemmas, made it easy to prove
forall lb i, ok_truebits i (truebits i lb) lb. No offsets needed.
On Wed, 22 Jul 2020 23:37:49 -0400
Jason Gross <jasongross9 AT gmail.com> wrote:
> 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.
>
>
> On Wed, Jul 22, 2020, 23:30 jonikelee AT gmail.com <jonikelee AT gmail.com>
> wrote:
>
> > 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+.