Zulip Chat Archive

Stream: maths

Topic: Halving inequaities


Jakob von Raumer (Nov 16 2022 at 15:00):

Am I wrong or are the following inequalities missing?

lemma nat.le_half_of_le_of_half_lt_sub {a b : } (h : a / 2 < a - b) : b  a / 2

and

lemma nat.ge_half_of_sub_le_half {a b : } (h : a - b  a / 2) : b  a / 2

Riccardo Brasca (Nov 16 2022 at 15:04):

Do you really want to use / and - for natural numbers?

Riccardo Brasca (Nov 16 2022 at 15:04):

I mean, I don't even know if these are true (too lazy to check :grinning_face_with_smiling_eyes: )

Jakob von Raumer (Nov 16 2022 at 15:15):

"want" is a bit of a stretch but I have to :sweat_smile:

Kevin Buzzard (Nov 16 2022 at 17:11):

What does slim_check think about them?

Kevin Buzzard (Nov 16 2022 at 17:11):

By the way, no ge lemmas should be in mathlib, always write inequalities as le.

Kyle Miller (Nov 16 2022 at 17:12):

I was incidentally just checking it with slim_check

Kyle Miller (Nov 16 2022 at 17:13):

they seem to be ok

Kyle Miller (Nov 16 2022 at 17:28):

Here's the first one:

lemma nat.le_half_of_half_lt_sub {a b : } (h : a / 2 < a - b) : b  a / 2 :=
begin
  rw nat.le_div_iff_mul_le two_pos,
  rw [nat.div_lt_iff_lt_mul two_pos, nat.mul_sub_right_distrib, lt_tsub_iff_right] at h,
  linarith,
end

Kyle Miller (Nov 16 2022 at 17:41):

and the second:

lemma nat.half_le_of_sub_le_half {a b : } (h : a - b  a / 2) : a / 2  b :=
begin
  rw [nat.le_div_iff_mul_le two_pos, nat.mul_sub_right_distrib, tsub_le_iff_right,
    mul_two, add_le_add_iff_left] at h,
  rw [ nat.mul_div_left b two_pos],
  exact nat.div_le_div_right h,
end

Alex J. Best (Nov 16 2022 at 18:45):

I miss omega...

Kevin Buzzard (Nov 16 2022 at 21:21):

Why not write it in Lean 4 Alex!

Jakob von Raumer (Nov 16 2022 at 22:29):

@Kyle Miller Oh wow, thats much shorter than my solution

Jakob von Raumer (Nov 16 2022 at 22:31):

@Alex J. Best What's omega?

Yaël Dillies (Nov 16 2022 at 22:33):

tactic#omega

Jakob von Raumer (Nov 16 2022 at 22:35):

... and is it broken?

Kevin Buzzard (Nov 16 2022 at 22:36):

It got banned from mathlib, for unreasonable behaviour.

Ruben Van de Velde (Nov 16 2022 at 22:39):

I thought mostly for it not being maintained and probably not ported to lean4 any time soon, but maybe both :)

Jakob von Raumer (Nov 16 2022 at 22:51):

@Kyle Miller Is it okay if I PR those lemmas together with

lemma zmod.val_min_abs_neg_of_ne_half {n : } {a : zmod n} (ha : a.val  n / 2) :
  (-a).val_min_abs = -a.val_min_abs :=
begin
  cases n, refl,
  simp only [zmod.val_min_abs_def_pos, zmod.neg_val],
  split_ifs with h h' h'' h'' h' h'' h'';
    try { subst h, simp only [zmod.nat_cast_self, nat.cast_succ, zero_sub, neg_add_rev,
       zmod.val_zero, neg_zero', neg_neg, zero_le', not_true, ne.def] at *}; try { contradiction },
  { exfalso, apply not_le.mpr (lt_of_le_of_ne h'' ha) (nat.half_le_of_sub_le_half h') },
  { rw [neg_sub, nat.cast_sub], apply le_of_lt (zmod.val_lt a) },
  { rw [nat.cast_sub (le_of_lt (zmod.val_lt a))], simp only [sub_sub_cancel_left] },
  { exfalso, clear ha,
    rw [not_le] at h',
    exact h'' (nat.le_half_of_half_lt_sub h') }
end

Jakob von Raumer (Nov 16 2022 at 22:52):

We weirdly only have zmod.nat_abs_val_min_abs_neg right now

Jakob von Raumer (Nov 16 2022 at 22:55):

Ah I guess the whole definition is tailored to the Eisenstein lemmas

Kyle Miller (Nov 17 2022 at 10:58):

@Jakob von Raumer Feel free to take the two lemmas as your own! They seem potentially useful to have around.


Last updated: Dec 20 2023 at 11:08 UTC