Zulip Chat Archive
Stream: mathlib4
Topic: gcongr does not work with ite
Michael Stoll (Nov 22 2024 at 21:54):
I'd expect this to work, but it fails:
import Mathlib
open Classical
example (P : ℕ → Prop) (n : ℕ) {a b : ℝ} (h : a ≤ b) :
(if P n then 0 else a) ≤ if P n then 0 else b := by
gcongr -- gcongr did not make progress
Is there an easy fix?
Edward van de Meent (Nov 22 2024 at 21:57):
use split
Eric Wieser (Nov 22 2024 at 21:59):
I think we could add a lemma for this for gcongr
Eric Wieser (Nov 22 2024 at 22:02):
Though this doesn't work either
import Mathlib
@[gcongr]
theorem ite_le_ite {α : Type*} (P : Prop) [Decidable P] [LE α] {a b c d : α} (h : a ≤ c) (h : b ≤ d):
(if P then a else b) ≤ if P then c else d := by
split <;> assumption
example (P : ℕ → Prop) [DecidablePred P] (n : ℕ) {a b : ℝ} (h : a ≤ b) :
(if P n then 0 else a) ≤ if P n then 0 else b := by
gcongr
Heather Macbeth (Nov 23 2024 at 00:32):
You need to add more gcongr
lemmas, for the other possible choices for the set of "varying arguments":
@[gcongr]
theorem ite_le_ite_left {α : Type*} (P : Prop) [Decidable P] [Preorder α] {a b c : α} (h : a ≤ c) :
(if P then a else b) ≤ if P then c else b :=
ite_le_ite P h (le_refl _)
@[gcongr]
theorem ite_le_ite_right {α : Type*} (P : Prop) [Decidable P] [Preorder α] {a b d : α} (h : b ≤ d) :
(if P then a else b) ≤ if P then a else d :=
ite_le_ite P (le_refl _) h
Eric Wieser (Nov 23 2024 at 02:35):
Would it be possible to make that clearer in the docstring, or am I guilty of not being able to read?
Eric Wieser (Nov 23 2024 at 02:36):
(also, I'm struggling to work out what @[gcongr wat]
means, which appears to be legal syntax)
Michael Stoll (Nov 23 2024 at 10:17):
Where should these lemmas go to make it work with, say, import Mathlib.Tactic
?
Last updated: May 02 2025 at 03:31 UTC