Zulip Chat Archive

Stream: new members

Topic: Using rewrite to simplify a bound variable expression


Ken Roe (Aug 06 2018 at 00:36):

theorem fsimp3 { x :  } : x=0  f x = 1 :=
begin
    intro, unfold f, rw a
end

theorem fsimp4 {e :  } : e=0  (λ x : , x+(f x)=1+x)=(λ x : , 1=1) :=
begin
    intro,
    rewrite fsimp3, simp
end

How do I get the "rewrite fsimp3" tactic to work in the "fsimp4" proof?

Scott Morrison (Aug 06 2018 at 00:37):

Probably use conv. Do you want to post an MWE?

Ken Roe (Aug 06 2018 at 00:40):

Go ahead and post

Scott Morrison (Aug 06 2018 at 00:42):

No, I was suggesting that _you_ post a minimal example that shows the problem --- in particular you haven't included the definition of f!

Scott Morrison (Aug 06 2018 at 00:42):

I think def f (x : ℕ) := x + 1 probably serves your purpose.

Mario Carneiro (Aug 06 2018 at 00:44):

rw does not work under a binder. You can either use simp instead, or use conv or funext to enter the binder

Reid Barton (Aug 06 2018 at 00:45):

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

Ken Roe (Aug 06 2018 at 00:45):

Oops--Missed that def

def f (x : ) := x+1

theorem fsimp3 { x :  } : x=0  f x = 1 :=
begin
    intro, unfold f, rw a
end

theorem fsimp4 {e :  } : e=0  (λ x : , x+(f x)=1+x)=(λ x : , 1=1) :=
begin
    intro,
    rewrite fsimp3, simp
end

Scott Morrison (Aug 06 2018 at 00:46):

I'm pretty confused how you intend to do anything using rw fsimp3, even under the binder.

Scott Morrison (Aug 06 2018 at 00:47):

You've only got e=0, but now want to say something about all x?

Ken Roe (Aug 06 2018 at 00:56):

It looks like conv fails:

theorem fsimp4 {e :  } : e=0  (λ x : , x+(f x)=1+x)=(λ x : , 1=1) :=
begin
    intro, simp, conv
    begin
        to_lhs,
        funext,
        rw fsimp3, reflexivity,
    end
end

I get the error:

convert tactic failed, there are unsolved goals
state:
e : ,
a : e = 0,
x : 
 x = 0

Reid Barton (Aug 06 2018 at 00:57):

That's because, as Scott pointed out, what you're trying to prove is not true

Ken Roe (Aug 06 2018 at 01:01):

Actually, I found the error:

theorem fsimp4 {e :  } : e=0  (λ x : , x+(f x)=1+x) e=(λ x : , 1=1) e :=
begin
    intro, conv
    begin
        to_lhs,
        simp, rw a,
        funext,
        rw fsimp3, skip, reflexivity
    end
end

However, the error I got is confusing. The "x=0" got changed to "x" on the screen in the message.

Mario Carneiro (Aug 06 2018 at 01:18):

this proof attempt is not valid for the same reason as before. You can't try to prove the functions are equal because they aren't. You can only prove that the functions evaluated at e are equal, so you need to do beta reduction first (using dsimp) and then try to prove it


Last updated: Dec 20 2023 at 11:08 UTC