Skip to content

Commit 6490098

Browse files
committed
feat(gcongr): use mdata instead of template (#30739)
This PR changes the implementation of `gcongr` patterns. Instead of carrying around another expression of the same shape, we put a metadata annotation in the actual goal, in order to keep track of where we want to apply more `gcongr` lemmas. This makes the implementation neater, and this is a necessary step towards supporting more operations in `gcongr`, such as those from the `congr!` tactic. This also means that the pattern given to the `gcongr` tactic is checked to be fully correct. This helped fix one pattern in mathlib that was `∑ _ : α, ?_`, but should have been `∑ _ : β, ?_`. Another change that this PR makes is that if the goal relation is `a → b`, then we run reducible `whnf` on `a` and `b` before getting the two sides of the relation. This means that `x > y` is reduced to `y < x`. This is needed because this refactor now is keeping track of which side is which side, and to do this consistently, we need `x > y` to be swapped into `y < x`.
1 parent 056b907 commit 6490098

File tree

6 files changed

+163
-163
lines changed

6 files changed

+163
-163
lines changed

Mathlib/NumberTheory/SiegelsLemma.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private lemma image_T_subset_S [DecidableEq α] [DecidableEq β] (v) (hv : v ∈
7575
refine ⟨fun i ↦ ?_, fun i ↦ ?_⟩
7676
all_goals
7777
simp only [mul_neg]
78-
gcongr ∑ _ : α, ?_ with j _ -- Get rid of sums
78+
gcongr ∑ _ : β, ?_ with j _ -- Get rid of sums
7979
rw [← mul_comm (v j)] -- Move A i j to the right of the products
8080
rcases le_total 0 (A i j) with hsign | hsign-- We have to distinguish cases: we have now 4 goals
8181
· rw [negPart_eq_zero.2 hsign]

Mathlib/Order/Basic.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ theorem forall_ge_iff_le : (∀ ⦃c⦄, a ≤ c → b ≤ c) ↔ b ≤ a :=
195195

196196
namespace Mathlib.Tactic.GCongr
197197

198-
@[gcongr] theorem gt_imp_gt (h₁ : a ≤ c) (h₂ : d ≤ b) : a > b → c > d := lt_imp_lt_of_le_of_le h₂ h₁
199-
200198
/-- See if the term is `a < b` and the goal is `a ≤ b`. -/
201199
@[gcongr_forward] def exactLeOfLt : ForwardExt where
202200
eval h goal := do goal.assignIfDefEq (← Lean.Meta.mkAppM ``le_of_lt #[h])

0 commit comments

Comments
 (0)