Skip to content

Commit 213105f

Browse files
fix: removed (incorrect) test for symm, trans attributes (#857)
Fixes error I made: introducing a test for `symm` and `trans` attributes to check that the lemmas were "genuinely" symm/trans lemmas. However the tests had false positives, e.g. #855 (which has been added to the tests). This short commit removes the tests. They were not present in `mathlib3` anyway and the worst that happens if a lemma is incorrectly labelled is that the `symm` tactic tries and fails with this. As a warning it may be useful to have a test, but it should have no false positives. For now it seems the best approach is to drop the test.
1 parent a2d57a9 commit 213105f

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

Mathlib/Tactic/Relation/Symm.lean

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ initialize registerBuiltinAttribute {
3232
let (xs, _, targetTy) ← withReducible <| forallMetaTelescopeReducing declTy
3333
let fail := throwError
3434
"@[symm] attribute only applies to lemmas proving x ∼ y → y ∼ x, got {declTy}"
35-
let some finalHyp := xs.back? | fail
36-
let .app (.app rel lhs) rhs := targetTy | fail
37-
let flip := .app (.app rel rhs) lhs
38-
let .true ← withNewMCtxDepth <| isDefEqGuarded flip (← inferType finalHyp) | fail
35+
let some _ := xs.back? | fail
36+
let targetTy ← reduce targetTy
37+
let .app (.app rel _) _ := targetTy | fail
3938
let key ← withReducible <| DiscrTree.mkPath rel
4039
symmExt.add (decl, key) kind
4140
}

Mathlib/Tactic/Relation/Trans.lean

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,11 @@ initialize registerBuiltinAttribute {
3232
let (xs, _, targetTy) ← withReducible <| forallMetaTelescopeReducing declTy
3333
let fail := throwError
3434
"@[trans] attribute only applies to lemmas proving x ∼ y → y ∼ z → x ∼ z, got {declTy}"
35-
let .app (.app rel x₂) z₂ := targetTy | fail
35+
let .app (.app rel _) _ := targetTy | fail
3636
let some yzHyp := xs.back? | fail
3737
let some xyHyp := xs.pop.back? | fail
38-
let .app (.app rel₂ y₂) z₁ ← inferType yzHyp | fail
39-
let .app (.app rel₁ x₁) y₁ ← inferType xyHyp | fail
40-
let .true ← withNewMCtxDepth <|
41-
isDefEq x₁ x₂ <&&> isDefEq y₁ y₂ <&&> isDefEq z₁ z₂ <&&>
42-
isDefEq rel rel₁ <&&> isDefEq rel rel₂ | fail
38+
let .app (.app _ _) _ ← inferType yzHyp | fail
39+
let .app (.app _ _) _ ← inferType xyHyp | fail
4340
let key ← withReducible <| DiscrTree.mkPath rel
4441
transExt.add (decl, key) kind
4542
}

test/symm.lean

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Mathlib.Tactic.Relation.Symm
22
import Std.Tactic.ShowTerm
3-
3+
import Mathlib.Algebra.Hom.Group
4+
import Mathlib.Logic.Equiv.Basic
45
-- testing that the attribute is recognized
56
@[symm] def eq_symm {α : Type} (a b : α) : a = b → b = a := Eq.symm
67

@@ -13,3 +14,23 @@ def sameParity : Nat → Nat → Prop
1314
@[symm] def sameParity_symm (n m : Nat) : sameParity n m → sameParity m n := Eq.symm
1415

1516
example (a b : Nat) : sameParity a b → sameParity b a := by intros; symm; assumption
17+
18+
19+
def MulHom.inverse [Mul M] [Mul N] (f : M →ₙ* N) (g : N → M) (h₁ : Function.LeftInverse g f)
20+
(h₂ : Function.RightInverse g f) : N →ₙ* M where
21+
toFun := g
22+
map_mul' x y :=
23+
calc
24+
g (x * y) = g (f (g x) * f (g y)) := by rw [h₂ x, h₂ y]
25+
_ = g (f (g x * g y)) := by rw [f.map_mul]
26+
_ = g x * g y := h₁ _
27+
28+
structure MulEquiv (M N : Type u) [Mul M] [Mul N] extends M ≃ N, M →ₙ* N
29+
30+
#check @MulEquiv
31+
32+
infixl:25 " ≃* " => MulEquiv
33+
34+
@[symm]
35+
def foo_symm {M N : Type _} [Mul M] [Mul N] (h : M ≃* N) : N ≃* M :=
36+
{ h.toEquiv.symm with map_mul' := (h.toMulHom.inverse h.toEquiv.symm h.left_inv h.right_inv).map_mul }

0 commit comments

Comments
 (0)