Zulip Chat Archive
Stream: general
Topic: proving transitivity with simp
Bernd Losert (Dec 14 2021 at 21:38):
So I'm trying to prove this goal:
∀ {x : a} {l l' : filter a}, l ≤ l' → l' ≤ pure x → l ≤ pure x
When I use by simp
to prove it, it get's confused and produces this goal:
∀ {x : a} {l l' : filter a}, l ≤ l' → {x} ∈ l' → {x} ∈ l
Is this unavoidable?
Adam Topaz (Dec 14 2021 at 21:39):
#mwe ?
Adam Topaz (Dec 14 2021 at 21:40):
Also, what do you expect simp
to do? l' ≤ pure x
simplifies to {x} ∈ l'
.
Yaël Dillies (Dec 14 2021 at 21:41):
Apply transitivity maybe?
Bernd Losert (Dec 14 2021 at 21:42):
Well, when I write out the proof, it look like this:
le_conv := begin
assume x : a,
assume l l' : filter a,
assume h : l <= l',
assume h' : l' <= pure x,
exact le_trans h h',
end,
Adam Topaz (Dec 14 2021 at 21:42):
import order.filter.basic
open filter
example {α} (F G : filter α) (x : α) (h : F ≤ G) (hh : G ≤ (pure x : filter α)) :
F ≤ pure x :=
le_trans h hh
Bernd Losert (Dec 14 2021 at 21:43):
Is simp
not smart enough to apply le_trans
for me?
Patrick Massot (Dec 14 2021 at 21:43):
example {a : Type*} {x : a} {l l' : filter a} : l ≤ l' → l' ≤ pure x → l ≤ pure x :=
λ hl hl', hl.trans hl'
Patrick Massot (Dec 14 2021 at 21:43):
Adam was faster
Adam Topaz (Dec 14 2021 at 21:43):
simp
is not a tactic that solves simple
things. Rather it's a tactic that simplifies expressions using lemmas tagged with simp
.
Patrick Massot (Dec 14 2021 at 21:44):
This is not at all simp
's job
Bernd Losert (Dec 14 2021 at 21:44):
Well, I guess I'm confused about the purpose of simp
.
Adam Topaz (Dec 14 2021 at 21:44):
In this case, it applies docs#filter.le_pure_iff
Bernd Losert (Dec 14 2021 at 21:45):
In some cases, it automagically works. In others, I have to write the proofs.
Patrick Massot (Dec 14 2021 at 21:45):
https://leanprover-community.github.io/extras/simp.html
Adam Topaz (Dec 14 2021 at 21:45):
Notice the @[simp]
tag above the statement of the lemma.
Patrick Massot (Dec 14 2021 at 21:45):
Bernd, everybody goes through this stage.
Bernd Losert (Dec 14 2021 at 21:45):
Is there a tactic that applies le_trans for me?
Adam Topaz (Dec 14 2021 at 21:47):
import order.filter.basic
open filter
example {α} (F G : filter α) (x : α) (h : F ≤ G) (hh : G ≤ (pure x : filter α)) :
F ≤ pure x :=
begin
transitivity',
assumption'
end
Bernd Losert (Dec 14 2021 at 21:47):
I would like to write a one-liner, like by le_trans
or something similar.
Adam Topaz (Dec 14 2021 at 21:47):
Although if you look at the goals after transitivity'
, you will see some metavariables, so this is not an ideal solution.
Bernd Losert (Dec 14 2021 at 21:48):
Alright. Thanks guys. I'll stick with the long proof.
Patrick Massot (Dec 14 2021 at 21:50):
Note that the proof is done by tauto
, but this is a coincidence depending on the precise implementation of those definitions.
Bernd Losert (Dec 14 2021 at 21:52):
Where is tauto
? I keep getting unknown identifier 'tauto'
.
Patrick Massot (Dec 14 2021 at 21:53):
You should import tactic
to make sure you have (almost) every toy at hand.
Bernd Losert (Dec 14 2021 at 21:54):
For some reason, that's not working for me. Do I need to say by tauto
or just tauto
?
Bernd Losert (Dec 14 2021 at 21:55):
OK, it's by tauto
.
Patrick Massot (Dec 14 2021 at 21:55):
Sure, you asked for a tactic, not a proof term.
Bernd Losert (Dec 14 2021 at 21:55):
I never know when to use by
and when not to use it.
Patrick Massot (Dec 14 2021 at 21:55):
by
enters tactic mode, it's a shorter version of begin end
Bernd Losert (Dec 14 2021 at 21:56):
Ah. I'll have to remember. Thanks.
Patrick Massot (Dec 14 2021 at 21:56):
Bernd Losert (Dec 14 2021 at 21:56):
So there's by
, {}
and begin end
.
Bernd Losert (Dec 14 2021 at 21:57):
Any more?
Patrick Massot (Dec 14 2021 at 21:57):
{}
is grouping stuff, but it doesn't enter tactic mode.
Bernd Losert (Dec 14 2021 at 21:58):
Oh...
Patrick Massot (Dec 14 2021 at 21:58):
Writing { tauto }
instead of by tauto
wouldn't work
Bernd Losert (Dec 14 2021 at 22:00):
I guess I got confused because begin end
is also used for grouping.
Bernd Losert (Dec 14 2021 at 22:00):
Or at least, I think it is.
Johan Commelin (Dec 14 2021 at 22:55):
You can use it for grouping, but it's a pretty verbose variant.
Last updated: Dec 20 2023 at 11:08 UTC