Skip to content

Commit ad232f9

Browse files
committed
feat: RelIso.copy (#24323)
Should I introduce `Equiv.copy` too?
1 parent 2ca4d81 commit ad232f9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Mathlib/Order/RelIso/Basic.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,21 @@ protected theorem surjective (e : r ≃r s) : Surjective e :=
694694
theorem eq_iff_eq (f : r ≃r s) {a b} : f a = f b ↔ a = b :=
695695
f.injective.eq_iff
696696

697+
/-- Copy of a `RelIso` with a new `toFun` and `invFun` equal to the old ones.
698+
Useful to fix definitional equalities. -/
699+
def copy (e : r ≃r s) (f : α → β) (g : β → α) (hf : f = e) (hg : g = e.symm) : r ≃r s where
700+
toFun := f
701+
invFun := g
702+
left_inv _ := by simp [hf, hg]
703+
right_inv _ := by simp [hf, hg]
704+
map_rel_iff' := by simp [hf, e.map_rel_iff]
705+
706+
@[simp, norm_cast]
707+
lemma coe_copy (e : r ≃r s) (f : α → β) (g : β → α) (hf hg) : e.copy f g hf hg = f := rfl
708+
709+
lemma copy_eq (e : r ≃r s) (f : α → β) (g : β → α) (hf hg) : e.copy f g hf hg = e :=
710+
DFunLike.coe_injective hf
711+
697712
/-- Any equivalence lifts to a relation isomorphism between `s` and its preimage. -/
698713
protected def preimage (f : α ≃ β) (s : β → β → Prop) : f ⁻¹'o s ≃r s :=
699714
⟨f, Iff.rfl⟩

0 commit comments

Comments
 (0)