Since OrderIso is defined as an abbrev of RelIso, @[simps!] automatically uses RelIso.symm for the symm_apply projection, so in the code below the automatically generated lemma foo_symm_apply actually has type (RelIso.symm foo) a✝ = f a✝, which is undesirable (and doesn't use OrderIso.symm.
Unfortunately, there are no easy ways to fix this, since we have 52 automatically generated lemmas involving RelIso.symm _ _ = _ and 59 manually proved lemmas involving e.symm _ = _.
The possible solutions are:
- Go through each of the 52 lemmas generated by
simps, manually remove them and prove the OrderIso.symm version, and then add a linter against using @[simps!] on OrderIso. Resistance: the smallest.
- Remove
OrderIso.symm entirely, and just use RelIso.symm. Resistance: this is still defeq abuse, and the resulting term would not have the correct type, i.e. the resulting term will have type RelIso instead of OrderIso.
- Allow
simps to be configured on definitions, not just structure. Resistance: probably will take a long time until this actually happens.
- Have a simp lemma
e.symm x = RelIso.symm e x. Resistance: this will break the 59 simp lemmas above.
- Have a simp lemma
RelIso.symm e x = e.symm x. Resistance: this doesn't actually fix the problem, because @[simps!] will still generate the wrong lemma.
For now, 1. seems to be the least of the evils.
import Mathlib
axiom f : ℕ → ℕ
axiom f_eq {n} : f n = n
@[simps!] noncomputable def foo : ℕ ≃o ℕ where
toFun := f
invFun := f
left_inv _ := by simp [f_eq]
right_inv _ := by simp [f_eq]
map_rel_iff' := by simp [f_eq]
#check foo_symm_apply -- (RelIso.symm foo) a✝ = f a✝
example (n) : foo.symm n = sorry := by simp -- no progress
(Link to web editor)
Since
OrderIsois defined as anabbrevofRelIso,@[simps!]automatically usesRelIso.symmfor thesymm_applyprojection, so in the code below the automatically generated lemmafoo_symm_applyactually has type(RelIso.symm foo) a✝ = f a✝, which is undesirable (and doesn't useOrderIso.symm.Unfortunately, there are no easy ways to fix this, since we have 52 automatically generated lemmas involving
RelIso.symm _ _ = _and 59 manually proved lemmas involvinge.symm _ = _.The possible solutions are:
simps, manually remove them and prove theOrderIso.symmversion, and then add a linter against using@[simps!]onOrderIso. Resistance: the smallest.OrderIso.symmentirely, and just useRelIso.symm. Resistance: this is still defeq abuse, and the resulting term would not have the correct type, i.e. the resulting term will have typeRelIsoinstead ofOrderIso.simpsto be configured on definitions, not just structure. Resistance: probably will take a long time until this actually happens.e.symm x = RelIso.symm e x. Resistance: this will break the 59 simp lemmas above.RelIso.symm e x = e.symm x. Resistance: this doesn't actually fix the problem, because@[simps!]will still generate the wrong lemma.For now,
1.seems to be the least of the evils.(Link to web editor)