Zulip Chat Archive

Stream: general

Topic: linarith with abs


ZHAO Jinxiang (Aug 23 2022 at 05:55):

Is there any tactic like linarith with abs support?

Mario Carneiro (Aug 23 2022 at 06:55):

you could rewrite with theorems like docs#le_abs and then call linarith

ZHAO Jinxiang (Aug 27 2022 at 13:02):

For example:

example (a b x: ) (h : a < x  x < b): x + |x - b| = x + (b - x) :=
begin
  refine congr_arg (λ y, x + y) _,
  cases h,
  rw abs_neg,
  simp,
  exact le_of_lt h_right,
end

Is there any tactic to simplify it?

Kevin Buzzard (Aug 27 2022 at 14:07):

example (a b x: ) (h : a < x  x < b): x + |x - b| = x + (b - x) :=
begin
  congr',
  rw [abs_sub_comm, abs_eq_self],
  linarith,
end

is a bit shorter


Last updated: Dec 20 2023 at 11:08 UTC