Zulip Chat Archive
Stream: general
Topic: Tactic to eliminate `ite`
Adam Kurkiewicz (Jun 17 2024 at 14:25):
Is there a tactic I can use to eliminate ite
, which is used in Mathlib in e.g. Nat.add_div
?
More concretely, how can I fill in the sorry
?
import Mathlib.Tactic
theorem magic (H : (4 + 6)/2 = 4/2 + 6/2 + if 2 ≤ 4 % 2 + 6 % 2 then 1 else 0) : (4 + 6)/2 = 4/2 + 6/2 := by
have : ¬ (2 ≤ 4 % 2 + 6 % 2) := by
intro H
rw[show 2%2 = 0 by ring] at H
contradiction
sorry
#check Nat.add_div
llllvvuu (Jun 17 2024 at 14:35):
split_ifs at H with h
Adam Kurkiewicz (Jun 17 2024 at 14:37):
Thank you! I was going nuts here. I'll try to add this to the docs.
llllvvuu (Jun 17 2024 at 14:41):
More concretely, how can I fill in the
sorry
?
theorem magic (H : (4 + 6)/2 = 4/2 + 6/2 + if 2 ≤ 4 % 2 + 6 % 2 then 1 else 0) : (4 + 6)/2 = 4/2 + 6/2 :=
rfl
Edward van de Meent (Jun 17 2024 at 21:34):
also, lemmas like docs#if_pos and docs#if_neg exist, which are useful if you already have a proof of the condition or its negation
Adam Kurkiewicz (Jun 18 2024 at 06:09):
Thank you @Edward van de Meent , super helpful!
Last updated: May 02 2025 at 03:31 UTC