Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Simplifying a function (exactly) once?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Simplifying a function (exactly) once?


Chronological Thread 
  • From: Jason Gross <jasongross9 AT gmail.com>
  • To: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Simplifying a function (exactly) once?
  • Date: Tue, 25 Feb 2020 17:46:14 -0600
  • Authentication-results: mail2-smtp-roc.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-ed1-f53.google.com
  • Ironport-phdr: 9a23:0Y4khRy05ikbCTfXCy+O+j09IxM/srCxBDY+r6Qd1OMfIJqq85mqBkHD//Il1AaPAdyHraMfwLOK+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCeybL9oKBi7owrdutQZjIB/Nqs/1xzFr2dHdOhR2W5mP0+YkQzm5se38p5j8iBQtOwk+sVdT6j0fLk2QKJBAjg+PG87+MPktR/YTQuS/XQcSXkZkgBJAwfe8h73WIr6vzbguep83CmaOtD2TawxVD+/4apnVAPkhSEaPDE+7W/Xl9dwjLpFrx29uxxxzYnUYISPO/p/eKPWYNcWSGVFU8pUUSFKH4GyYJYVD+cZMulYoYvyqVsAoxW9GAeiGv/gxyRSiXPqx6A3yfgtHR3E0QEmAtkAsG7UrNLwNKoKVe661rLIzTLFb/hL2Dn98o/Icgs6ofqRWr9wc9DeyVIoFwPDgVWQs4vlPyiO1ukJqGWb4O9gWviui24jsQ1+vj+vxsI1h4TPm4kbxFfE9SBjz4Y0I921UEF7Yd+4EJtQqiGVLJF6QsIlQ2xupS00yaUGtIalcCQWzJkr3R3SZvydf4SW/h7uV/ydLDd2iX9jZbmxnQy98VK6xe35TsS00EhFri5CktTUs3ACzR3T6syeRvRj40itxC+D1w7T5+xKO0w0mq3bK5kuwr40iJUfq1jMHijzmEnuja+WcFsr+vSw5uj5frnrooWQOox0hw3kLKgihs+yDf44PwUAR2Sb/P6z1Lzn/U33WrVKifg2n7HbsJ/APsQboai5AwBP0oYk8Ba/FDOr3c8XnXkCNl1FeRaHg5L1NFHJJfD0Fe2/jEi0kDd32/DGOaXsDYnKLnjaibvuYbJ961NHxwco1tBe55dUCqkbL/7pW0/xssbYDh4jPACuzebnEoY16oRLUmWWR6SdLama5VSP/6ckJ/SGTI4Tojf0bfY/sa3Al3g8zH0UZq6vlbQNb2ujVqBkKl6eZ3X2hcwaQE8FuwM/SKrhj1jUAm0bXGq7Q69pvmJzM4mhF4qWGtH03e6xmRyjF5gTXVhoT1CBFXCyKteBUvYILS+ee4pvz2dCWr+mRIsskxqpsV2ikuY1Hq/v4iQd8Knb+p1t/eSKzEM98DV1C4KW1GTfFzglzFNNfCc/2eVEmWI4z16C1aZihPkBTI5c4vpIVkExMpuOluE=

The standard pattern I use for this is to define the fixpoint and the body separately:
Definition eval2_step {A: Type}
  (eval2 :  Monitor A -> list A -> bool * Monitor A)
  (mon: Monitor A) (l : list A) : (bool * Monitor A) :=
  match l with
  | nil => (false, mon)
  | (x :: xs) => let (_, mon') := eval2 mon xs in
               (mNext mon' x)
  end.
Fixpoint eval2 {A: Type} (mon: Monitor A) (l : list A) : (bool * Monitor A) :=
  eval2_step eval2 mon l.

Then you can run `simpl eval2` and `simpl eval2_step` (or `cbn [eval2]` and `cbn [eval2_step]`) separately.


On Tue, Feb 25, 2020 at 3:48 PM Jason -Zhong Sheng- Hu <fdhzs2010 AT hotmail.com> wrote:
I didn't test everything but i think there are a few ways to proceed. I do think that it's a good idea for Coq to implement a tactic, say, `eval_step`, which takes a list of reduction steps and perform them in sequence. in this case, I think it would be `eval_step [delta, iota]`. notice that delta reduction is only specified once, so it only unfold the outer `eval2` and iota evals the pattern matching and leave the inner `eval2` as is.

that said, you can probably simulate this action:

unfold eval2 in H3; cbn [iota] in H3.

in particular, `delta` is excluded from `cbn` so I hope `eval2` is not unfolded.

another way is to remember `a0 :: l` by doing

remember (a0 :: l) as l0 eqn:?.

I expect this replaces all `a0 :: l` with `l0`, which allows you to do `simpl in H3`.

another potential way is to specify the list to have two cons:

simpl (eval2 _ (_ :: _ :: _)) in H3.

i would be interested in knowing which one works. please let me know.


From: coq-club-request AT inria.fr <coq-club-request AT inria.fr> on behalf of Agnishom Chattopadhyay <agnishom AT cmi.ac.in>
Sent: February 25, 2020 4:18 PM
To: coq-club AT inria.fr <coq-club AT inria.fr>
Subject: [Coq-Club] Simplifying a function (exactly) once?
 
Is there a way to specify to simpl to stop simplifying after exactly one step?

Basically, I have something like f(f(x)) which simplifies to some _expression_ in f(x). I only wish to simply this once and NOT get rid of the inner f(x)

---

More details:

I have

Fixpoint eval2 {A: Type} (mon: Monitor A) (l : list A) : (bool * Monitor A) :=
  match l with
  | nil => (false, mon)
  | (x :: xs) => let (_, mon') := eval2 mon xs in
               (mNext mon' x)
  end.

In a certain proof, I have

E3 : eval2 (MonAnd mon1 mon2) (a0 :: l) = (bl, ml)
and
H3 : eval2 (MonAnd mon1 mon2) (a :: a0 :: l) = (true, x)

I wish to use E3 effectively after simplifying H3 by one step. However, when I try to use simpl in H3, I get

H3 : (let (_, mon') :=
          let (_, mon') := eval2 (MonAnd mon1 mon2) l in mNext mon' a0 in
        mNext mon' a) = (true, x)



Archive powered by MHonArc 2.6.18.

Top of Page