Zulip Chat Archive

Stream: general

Topic: rw inside lambda


Kenny Lau (Sep 09 2018 at 21:11):

from my experience, simp can change things inside lambda, but rw cannot. Is there a way to bypass this and let rw change inside lambda?

Mario Carneiro (Sep 09 2018 at 21:11):

conv + rw

Reid Barton (Sep 09 2018 at 21:30):

Also see topic https://leanprover.zulipchat.com/#narrow/stream/113488-general/subject/rw.20under.20lambda/near/126107890 and the more verbose topic https://leanprover.zulipchat.com/#narrow/stream/113488-general/subject/Why.20can't.20.60rw.60.20look.20inside.20lambda.20expressions.3F/near/130212033

Kenny Lau (Sep 10 2018 at 06:01):

so exactly which tactics are avaiblale inside conv?

Kevin Buzzard (Sep 10 2018 at 06:30):

rw

Kenny Lau (Sep 10 2018 at 06:32):

I mean, a complete list of tactics available inside conv

Kevin Buzzard (Sep 10 2018 at 06:34):

There's probably a file in core which lists them. There's to_lhs, something called something like whnf and you might want to skim Patrick's docs

Kevin Buzzard (Sep 10 2018 at 06:45):

https://github.com/leanprover/lean/blob/master/library/init/meta/converter/interactive.lean

Kevin Buzzard (Sep 10 2018 at 06:45):

Maybe that's the definitive answer

Kevin Buzzard (Sep 10 2018 at 06:48):

Funext, change, simp and dsimp

Kevin Buzzard (Sep 10 2018 at 06:51):

https://github.com/leanprover/mathlib/blob/master/docs/extras/conv.md

Kevin Buzzard (Sep 10 2018 at 06:51):

Has a couple of nice tricks

Kenny Lau (Sep 10 2018 at 07:10):

well I would like to be able to use apply/exact/refine inside conv

Kenny Lau (Sep 10 2018 at 07:12):

conv inside conv would also be useful

Kenny Lau (Sep 10 2018 at 07:12):

I feel like conv has a lot of potential to be the most powerful tactic ever

Kenny Lau (Sep 10 2018 at 07:59):

@Mario Carneiro I don't understand why there's no basic tactics (i.e. exact) inside conv

Mario Carneiro (Sep 10 2018 at 08:03):

conv is a different monad from tactic

Mario Carneiro (Sep 10 2018 at 08:04):

exact doesn't even make sense

Kenny Lau (Sep 10 2018 at 08:04):

I mean, why didn't we implement exact inside conv

Kenny Lau (Sep 10 2018 at 08:04):

conv is just a bunch of congr_arg and funext right

Mario Carneiro (Sep 10 2018 at 08:05):

the tactic state in the conv monad is basically ?p : X = ?m where ?p and ?m are to be determined

Kenny Lau (Sep 10 2018 at 08:05):

if we have a + b = c + d, and I do conv { to_lhs, congr, skip, } then the current state is a + b = a + ?m right

Kenny Lau (Sep 10 2018 at 08:05):

if I do exact (sorry : b = foo b) then I can tell Lean exactly that ?m should be foo b right

Mario Carneiro (Sep 10 2018 at 08:05):

by comparison to the regular tactic state which is just ?m : t

Mario Carneiro (Sep 10 2018 at 08:07):

I think update_lhs does that

Johan Commelin (Sep 10 2018 at 08:08):

I've never heard about that one. Sounds good!

Johan Commelin (Sep 10 2018 at 08:09):

Can you also zoom out in conv?

Johan Commelin (Sep 10 2018 at 08:09):

You zoom in with congr and funext. But I sometimes also want to zoom out again.

Mario Carneiro (Sep 10 2018 at 08:09):

No, zoom out doesn't make sense

Mario Carneiro (Sep 10 2018 at 08:10):

what is possible instead is a split lhs/rhs that produces multiple subgoals

Mario Carneiro (Sep 10 2018 at 08:10):

also, lhs/rhs is so passe. We need rcases patterns in conv!

Kenny Lau (Sep 10 2018 at 08:12):

what is update_lhs?

Mario Carneiro (Sep 10 2018 at 08:12):

I guess it is not an interactive command, but it is available as a conv tactic

Mario Carneiro (Sep 10 2018 at 08:13):

meta def update_lhs (new_lhs : expr) (h : expr) : conv unit :=
do transitivity,
   rhs >>= unify new_lhs,
   exact h,
   t  target >>= instantiate_mvars,
   change t

Johan Commelin (Sep 10 2018 at 08:15):

@Mario Carneiro Why would zoom out not make sense? If I drill down into a nested sum, do some rw there, then I would want to zoom out again and play with the sum that is 1 level up.

Mario Carneiro (Sep 10 2018 at 08:16):

As I said, the conv monad has a state which is ?p : X = ?m. If you zoom in then ?m is assigned, so you can't return to it any more than you can rewind in a proof

Mario Carneiro (Sep 10 2018 at 08:19):

I think that to_lhs would make more sense as a tactic combinator, i.e. to_lhs { <conv> }, <conv>

Mario Carneiro (Sep 10 2018 at 08:19):

that would allow you to return to the outer context in the second part

Kenny Lau (Sep 10 2018 at 08:20):

also if I go deep inside using conv then all the variables have the same name and I can't even dedup

Mario Carneiro (Sep 10 2018 at 08:21):

note that find is actually a combinator like this inside conv, so you can use it to temporarily zoom in

Mario Carneiro (Sep 10 2018 at 08:22):

however, find patterns never work the way I want them to


Last updated: Dec 20 2023 at 11:08 UTC