Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic


Chronological Thread 
  • From: Ramkumar Ramachandra <artagnon AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] [HELP] Recovering information after the `generalize` tactic
  • Date: Wed, 17 Jan 2018 18:04:53 -0800
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=artagnon AT gmail.com; spf=Pass smtp.mailfrom=artagnon AT gmail.com; spf=None smtp.helo=postmaster AT mail-yw0-f171.google.com
  • Ironport-phdr: 9a23:GSwq9h8urtGzjv9uRHKM819IXTAuvvDOBiVQ1KB40uscTK2v8tzYMVDF4r011RmVBdyds6oMotGVmpioYXYH75eFvSJKW713fDhBt/8rmRc9CtWOE0zxIa2iRSU7GMNfSA0tpCnjYgBaF8nkelLdvGC54yIMFRXjLwp1Ifn+FpLPg8it2O2+54Dfbx9UiDahfLh/MAi4oQLNu8cMnIBsMLwxyhzHontJf+RZ22ZlLk+Nkhj/+8m94odt/zxftPw9+cFAV776f7kjQrxDEDsmKWE169b1uhTFUACC+2ETUmQSkhpPHgjF8BT3VYr/vyfmquZw3jSRMMvrRr42RDui9b9mRx3miCkHOTA383zZhNJsg69Auh2tuwZyzpTIbI2JNvdzeL7Wc9MARWpGW8ZcTzBPDZm5b4sMEuoBOPxXr5PgrFUStxS+ABOjC//vyjBSgH/5wLc63P48GgzBxgMgBc4Ov27brNXzM6cSV/u4zKbNzTrZbvNW3S3x55TPchAkuPyBW697f8nJyUQ3CQ/JklGdpZbmMj6VzOgBrmmW4/d6We6yiWMrtgd8qSW1yMg2kInGnIcVx0jE9SpnxIY1IsW1SEthbt6lFJtcriGbNoVqTs87TWFkpSQ3xqActZ60eygKz5snxxrBZPCdb4eI5RfjWP6QITd+mn1lZKqyiwiu/UWk0OHxVcm53ExXoidEj9XArG0B2h7O5sSfT/ty5Eah2TKB1wDJ7eFEJFg5mrDBK5492LEwmZwTsUPFHiLtl0X2ibWZdkQg+uSy9+vnZbDmqoeGN4BokgH+LrgumsunDOskNQgORnGX9vi41L3+5kL0W65Kj/0zkqnBqp/WP8UbpqijAw9UyIkv8Ri/Dy31mOgfyHIANRdOfA+Np4nvIVDHZv7iXtmlhFH5qj5uxO3DN6epOJzIJ3PDmbHtZ781v0dG1AM8y9dZz51RA7AFZvn0Xxmi55TjEhYlPlnskK7cA9Jn29ZGADPdMuqiKKrX9GSwyKcqKuiIapUSvW+kefcg7v/qy3Q+nA1EJPX77d4scHm9W89eDQCBe3O124UOFG4Lukw1S+m40ATfAw4WXG67WucH3h9+CI+iCt2dFIWkgbjEzTjjW5MPOTkABVeLHnPlMY6DXqVUZQ==

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




Archive powered by MHonArc 2.6.18.

Top of Page