coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Pierre Courtieu <pierre.courtieu AT gmail.com>
- To: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic
- Date: Thu, 18 Jan 2018 18:03:56 +0100
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=pierre.courtieu AT gmail.com; spf=Pass smtp.mailfrom=pierre.courtieu AT gmail.com; spf=None smtp.helo=postmaster AT mail-ot0-f179.google.com
- Ironport-phdr: 9a23:IrGVoRWaxEcYAfAk/BOerqQ0t/TV8LGtZVwlr6E/grcLSJyIuqrYYxOOt8tkgFKBZ4jH8fUM07OQ7/i5HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba9vIBmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KpwVhTmlDkIOCI48GHPi8x/kqRboA66pxdix4LYeZyZOOZicq/Ye94RWGhPUdtLVyFZAIy8YYsBAeQCM+hFsYfyu0ADrQeiCQS2GO/j1iNEi33w0KYn0+ohCwbG3Ak4EtwUsXTbss/1NL0MXuuo0qTIyijDb+lK2Tf89ofIbw0qrPaUXbJxb8XR01MvGB3fglqMrozlIimV1vgMs2eF8uptTu2vi2s9pAFwpjij3Nsjio7Mho8MzF3P6CZ3wJ4tKNC6R0N3e8OoHIVQui2ANIZ6XNkuT3xqtSs+zLANpIS1czIQyJs9wh7Sc/yHfJaM4hLkTOuRJC13hHNheL6mgBay7VSsxvTyVsWp0ltHqjBJktbLtnAK2BzT7taIRuFh8Uem3DaDzwHT6udaLkAojafWKZEszqQtmpYNsUnPBCz7lFvsgKOLdEgp/vCk6+H9bbXnop+cOZV0igb7Mqk2gsy/APo3MhIUX2eF4+izyLrj/VDjQLVWj/05jLTZvYvVJcQevKG5AgtV3pw/5Ba4CjeqyM4YkmUfLFJZZBKHiJDkNE3JIPDhFPuwn1CskCpwyP3dJb3gApDNLmDZn7v7fLZ97VRcyAspwtxF6ZJUEOJJHPWmcUjo/PfcExVxZwez2qPsDMh3/oIYQ2OGRKGDZvD8q1iNs9ouLvOWacc+vyvnN/ko+ra6lX40g0UQO6KuwIELaX2lNvtjKkSdJ3Hrh4FSQi8xogMiQbmy2xW5WjlJaiP3Bvpkv2BpOMedFY7GA7uVrvmE1Sa/EIdRYzkfWF+JGHbsMY6DXqVVMX7AEopaijUBEIOZZco5zxj37V31zrNmKqzf/ShK7cu+hugw3PXakFQJzRIxD8mZ1DvTHWR9n2dNQCNuma4m/h07xVCE3qx1xfdfEI4L6g==
I don't think you use generalize the right way. The effect of
"generalize T." here is to transform "a::e" into "l". That is a
generalization since "l" catches more possibilites than "a::e".
Here you *need* to keep the information about a::e.
Theorem runningCounters_noUpdate : forall e t,
noUpdateRunningCounters e <-> updateRunningCounters e t = t.
Proof.
intros.
induction e; simpl.
- intuition.
unfold noUpdateRunningCounters; simpl.
trivial.
- split;intro.
then you are left with two subgoal that look OK but need some more
work to be proved.
One last remark:
Definition noUpdateRunningCounters (e : block) : Prop :=
why don't you use an inductive to define this property? You would have
more tools to deduce things (inversion, destruct, induction).
Here is a more or less idiomatic way of doing things (ony one
direction proved sorry lack of time):
Inductive noUpdateRunningCounters : block -> Prop :=
| noup1: noUpdateRunningCounters nil
| noup2: forall e n, noUpdateRunningCounters e ->
noUpdateRunningCounters (B n::e).
Theorem runningCounters_noUpdate : forall e t,
noUpdateRunningCounters e <-> updateRunningCounters e t = t.
Proof.
intros e t.
split;intro h.
- induction h.
+ cbn. reflexivity.
+ lazy beta delta [updateRunningCounters].
rewrite (fold_right_app _ (B n :: nil) e).
replace (fold_right
(fun (reg : registration) (acc : serverState) =>
match reg with
| A _ => match acc with
| {| q := a |} => {| q := S a |}
end
| B _ => t
end) t e) with (updateRunningCounters e t) by reflexivity.
cbn.
reflexivity.
-
2018-01-18 3:04 GMT+01:00 Ramkumar Ramachandra
<artagnon AT gmail.com>:
> Hi Pierre,
>
> There's way too much code there to fit in an email to coq-club (the mailing
> list rejects messages larger than a certain size). Let me attempt to hand
> you a reduced case.
>
> From Coq Require Import
> Lists.List
> Arith.PeanoNat.
>
> Inductive registration : Type :=
> | A : nat -> registration
> | B : nat -> registration.
>
> Record serverState : Type := mkServerState {
> q : nat
> }.
>
> Definition block := list registration.
>
> Definition updateRunningCounters (e : block) (t : serverState) : serverState
> :=
> fold_left (fun acc reg =>
> match reg with
> | A _ => (match acc with
> | mkServerState a => mkServerState (S a)
> end)
> | _ => t
> end) e t.
>
> (* Proposition not defined in terms of implementation; needs to be proved *)
> Definition noUpdateRunningCounters (e : block) : Prop :=
> fold_left (fun acc reg =>
> acc \/ match reg with
> | A _ => False
> | _ => True
> end) e True.
>
> Theorem runningCounters_noUpdate : forall e t,
> noUpdateRunningCounters e <-> updateRunningCounters e t = t.
> Proof.
> intros.
> induction e; simpl.
> intuition.
> unfold noUpdateRunningCounters; simpl.
> trivial.
> generalize (a :: e); intro l.
> Admitted.
>
>
> The hypotheses/goals look like:
>
> a: registration
> e: list registration
> t: serverState
> IHe: noUpdateRunningCounters e <-> updateRunningCounters e t = t
> l: list registration
>
> 1/1noUpdateRunningCounters l <-> updateRunningCounters l t = t
>
> Now what?
>
> Thanks!
>
> Ram
>
> On Wed, Jan 17, 2018 at 3:46 AM, Pierre Courtieu
> <pierre.courtieu AT gmail.com>
> wrote:
>>
>> Please give a SELF CONTAINED code. So that we can replay your code.
>> Best
>> Pierre
>>
>> 2018-01-17 0:14 GMT+01:00 Ramkumar Ramachandra
>> <artagnon AT gmail.com>:
>> > Hi Guillaume and Pierre,
>> >
>> > Thanks for the help. I now have:
>> >
>> > Theorem readEvalLoop_ind : forall steps blk t,
>> > let blk' := augmentBlk (blk ++ issueVerdicts t) t in
>> > let t' := commitBlock blk' (updateRunningCounters blk' t) in
>> > readEvalLoop (steps + 3) propose blk t =
>> > readEvalLoop steps propose blk' t'.
>> > Proof.
>> > intros.
>> > induction steps.
>> > rewrite add_0_1; reflexivity.
>> > generalize (eq_refl (S steps)).
>> > generalize (S steps) at -2; intro n.
>> > induction n.
>> > intuition.
>> > generalize dependent (S n); intro n0.
>> > Abort.
>> >
>> > With the following hypotheses/goals:
>> >
>> > steps: nat
>> > blk: list registration
>> > t: serverState
>> > blk':= augmentBlk (blk ++ issueVerdicts t) t : block
>> > t':= commitBlock blk' (updateRunningCounters blk' t) : serverState
>> > IHsteps: readEvalLoop (steps + 3) propose blk t = readEvalLoop steps
>> > propose
>> > blk' t'
>> > n: nat
>> > IHn: n = S steps -> readEvalLoop (n + 3) propose blk t = readEvalLoop n
>> > propose blk' t'
>> > n0: nat
>> >
>> > 1/1n0 = S steps -> readEvalLoop (n0 + 3) propose blk t = readEvalLoop n0
>> > propose blk' t'
>> >
>> > Ofcourse, I'm unable to unify with `IHn`, because `n` and `n0` are
>> > superficially different. How am I supposed to convince Coq that they're
>> > really the same? I've included some additional code because Pierre
>> > requested
>> > it.
>> >
>> > (* stageHandler will take a given block and run it through a single
>> > stageStep *)
>> > Definition stageHandler (s : stageStep) (blk : block) (t : serverState)
>> > : (stageStep * serverState) :=
>> > match s with
>> > | propose => let blk' := blk ++ (issueVerdicts t) in
>> > (preVote (augmentBlk blk' t), t)
>> > | preVote blk => ((preCommit blk), t)
>> > | preCommit blk => (propose, (commitBlock blk (updateRunningCounters blk
>> > t)))
>> > end.
>> >
>> > (* readEvalLoop will run for a given number of steps: in real-world,
>> > forever
>> > *)
>> > Fixpoint readEvalLoop (steps : nat) (s : stageStep) (blk : block) (t :
>> > serverState)
>> > : serverState :=
>> > match steps with
>> > | O => t
>> > | (S n') => let (s', t') := stageHandler s blk t in readEvalLoop n' s'
>> > blk
>> > t'
>> > end.
>> >
>> >
>> > Cheers.
>> >
>> > Ram
>
>
- [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Ramkumar Ramachandra, 01/16/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Guillaume Melquiond, 01/16/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Pierre Courtieu, 01/16/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Ramkumar Ramachandra, 01/17/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Pierre Courtieu, 01/17/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Ramkumar Ramachandra, 01/18/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Pierre Courtieu, 01/18/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Ramkumar Ramachandra, 01/18/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Pierre Courtieu, 01/17/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Ramkumar Ramachandra, 01/17/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Pierre Courtieu, 01/16/2018
- Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic, Guillaume Melquiond, 01/16/2018
Archive powered by MHonArc 2.6.18.