Zulip Chat Archive
Stream: new members
Topic: How to specify where "apply" applies
Jakob Scholbach (Jan 28 2021 at 19:35):
Another a newbie question (I never felt this stupid!):
example : min (min a b) c = min a (min b c) :=
begin
apply le_antisymm,
{
apply le_min,
{
-- the goal here is: min (min a b) c ≤ a
},
{
}
},
{
}
end
In this example, at the indicated spot I would like to do "apply min_le_left to the outer min". How do I specify where apply does its job?
Riccardo Brasca (Jan 28 2021 at 19:38):
min_le_left
takes two argument, you can specify them writing min_le_left x y
explicitly
Jakob Scholbach (Jan 28 2021 at 19:42):
OK, I see. If I add apply min_le_left (min a b) c,
it says invalid apply tactic, failed to unify min (min a b) c ≤ a with min (min a b) c ≤ min a b. I guess I further need to combine this inequality I got from here with min a b \le a. Is there a quick way to do this or do I need to write something like have h : ... and then say apply h?
Riccardo Brasca (Jan 28 2021 at 19:43):
min_le_left (min a b) c
says that min (min a b) c ≤ min a b
, but your goal is min (min a b) c ≤ min b c
so you cannot use it
Riccardo Brasca (Jan 28 2021 at 19:44):
How is your proof with pen and paper?
Ruben Van de Velde (Jan 28 2021 at 19:44):
transitivity (min b c),
, perhaps
Riccardo Brasca (Jan 28 2021 at 19:45):
I guess it is an exercise... if we can use the full mathlib min_assoc a b c
says exactly min (min a b) c = min a (min b c)
Jakob Scholbach (Jan 28 2021 at 19:49):
@Riccardo Brasca : yes, I would like to "save" as an intermediate step min (min a b) c \le min a b
, then apply min a b \le a
and use transitivity of min.
Riccardo Brasca (Jan 28 2021 at 19:55):
Indeed the actual proof uses it
Ruben Van de Velde (Jan 28 2021 at 19:58):
Or with calc
:
import data.nat.basic
example (a b c : nat) : min (min a b) c = min a (min b c) :=
begin
apply le_antisymm,
{ apply le_min,
{ calc min (min a b) c
≤ min a b : min_le_left _ _
... ≤ a : min_le_left _ _ },
{ sorry } },
{ sorry }
end
Last updated: Dec 20 2023 at 11:08 UTC