Skip to content

refactor: retire setoids - #533

Merged
Kaptch merged 17 commits into
leanprover-community:masterfrom
Kaptch:eq-leaves
Jul 27, 2026
Merged

refactor: retire setoids#533
Kaptch merged 17 commits into
leanprover-community:masterfrom
Kaptch:eq-leaves

Conversation

@Kaptch

@Kaptch Kaptch commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Description

Pass over deprecating equiv in favor of eq. The remaining task is a small cleanup. I've tried to keep this one minimal by preserving the proofs as much as possible, while eliminating equiv in signatures. I'll make a pass over proofs in a separate PR.

@Kaptch
Kaptch marked this pull request as ready for review July 24, 2026 09:19
@Kaptch

Kaptch commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

Short summary: deprecated OFE.Equiv, maps to/from equality, congruence rules wrt OFE.Equiv, then went fixing the downstream proofs, until none of the code is using those. At this point, OFE.Equiv should be safely deleted (can also do it now, but I would wait a week or two in case any downstream project continues to use it).
I tried to preserve all signatures by just changing OFE.Equiv to equality. The only naming changes come from congruence rules for BigOps, because they combine extensionality and congruence. There, I made a pass to merge some lemmas.

The proofs are mostly the same, and I'll make a separate pass to use simp/rw in them instead of manual chains of equalities.
I can also split the PR a bit, but it seems that is the cleanest way to change all signatures in one go to avoid to_eq/from_eq casting.

@markusdemedeiros

Copy link
Copy Markdown
Collaborator

Don't worry about breaking downstream projects (a week or two changes nothing since they should be using the versioned releases anyways). I'll do my best to review this promptly!

@markusdemedeiros markusdemedeiros left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usual nits. Read them, but I'll leave the final say to you on if you want the edits.

I'd suggest removing the deprecated stuff now, or in a follow-up PR. No need to keep that around.

Comment thread Iris/Iris/Algebra/Lib/DFracAgree.lean Outdated
@[rocq_alias to_dfrac_agree_discrete]
instance mk_discrete {d : DFrac} {a : A} [DiscreteE a] : DiscreteE (mk d a) :=
⟨fun h n => ⟨(is_discrete.discrete h.1) n, (Agree.toAgree.is_discrete.discrete h.2) n⟩⟩
⟨fun h => OFE.eq_dist.mpr <| by

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
⟨fun h => OFE.eq_dist.mpr <| by
⟨fun h => OFE.eq_dist.mpr <| fun n => ⟨(is_discrete.discrete h.1).dist, (Agree.toAgree.is_discrete.discrete h.2).dist⟩⟩

Comment thread Iris/Iris/Algebra/BigOp.lean Outdated
simp
theorem bigOpL_snoc_eq (Φ : Nat → A → M) (l : List A) (a : A) :
([^ op list] k ↦ x ∈ l ++ [a], Φ k x) = op ([^ op list] k ↦ x ∈ l, Φ k x) (Φ l.length a) := by
rw [bigOpL_append_eq]; simp [op_right_id]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rw [bigOpL_append_eq]; simp [op_right_id]
simp [bigOpL_append_eq, op_right_id]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps?

Comment thread Iris/Iris/Algebra/BigOp.lean Outdated
theorem bigOpM_eq_strong [OFE A] {Φ Ψ : K → A → M} {m1 m2 : M' A} (hm : ∀ k, get? m1 k = get? m2 k)
(hf : ∀ {k y1 y2}, get? m1 k = some y1 → get? m2 k = some y2 → y1 = y2 → Φ k y1 = Ψ k y2) :
([^ op map] k ↦ x ∈ m1, Φ k x) = ([^ op map] k ↦ x ∈ m2, Ψ k x) :=
bigOpM_gen_proper_2 id ⟨fun _ => rfl, Eq.symm, Eq.trans⟩ (· ▸ · ▸ rfl) (fun k => by rw [hm k])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun _ => rfl, Eq.symm, Eq.trans⟩

Extract to definition (probably already exists)

refine (intuitionistically_ownM_core a).trans ?_
refine intuitionistically_mono ?_
exact (ownM_eqv (core_eqv_self a).symm).mpr
simp only [core_eqv_self, BIBase.Entails.rfl]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
simp only [core_eqv_self, BIBase.Entails.rfl]
simp [core_eqv_self, BIBase.Entails.rfl]

refine (persistently_ownM_core a).trans ?_
exact persistently_mono (ownM_eqv (core_eqv_self a)).mp
refine persistently_mono ?_
simp only [core_eqv_self, BIBase.Entails.rfl]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
simp only [core_eqv_self, BIBase.Entails.rfl]
simp [core_eqv_self, BIBase.Entails.rfl]

Comment thread Iris/Iris/Algebra/OFE.lean Outdated
refine NonExpansive₂.eqv (f := fA) Hp.symm ?_
(fA : α -c> β -n> α) (fB : α -c> β -c> β) (Hp : fA p q = p) (Hq : fB p q = q) :
p = (fixpointA fA fB) := by
have hq : q = fixpointAB fB p := fixpoint_unique Hq.symm

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline this?

Comment thread Iris/Iris/Algebra/View.lean Outdated
⟨(mono · Ha Hb.symm.to_incN n.le_refl), (mono · Ha.symm Hb.to_incN n.le_refl)⟩

@[rocq_alias view_rel_proper]
@[rocq_alias view_rel_proper, deprecated "OFE is Leibniz; use `congrArg`/`rw`" (since := "2026-07")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Comment thread Iris/Iris/Algebra/View.lean Outdated
simp only [Pcore, Option.some.injEq]
rcases cx
simp only [mk.injEq, and_imp]
intro H1 H2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rintro rfl rfl instead

Comment thread Iris/Iris/Algebra/View.lean Outdated
have Hle : g y1 ≼ g y2 := ⟨g z, congrArg g Hy2⟩
obtain ⟨_, Hcgy2, x, Hcx⟩ :=
CMRA.pcore_mono' Hle (Hg_core.mp Hy1)
exact ⟨_, rfl, f x,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One line

Comment thread Iris/Iris/Algebra/View.lean Outdated
have hf : f1 = f2 := funext fun a => (h1 a).to_eq
have hg : g1 = g2 := funext fun b => (h2 b).to_eq
View.map R' f1 g1 v = View.map R' f2 g2 v := by
have hf : f1 = f2 := funext fun a => OFE.eq_dist.mpr (h1 a)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
have hf : f1 = f2 := funext fun a => OFE.eq_dist.mpr (h1 a)
obtain rfl : f1 = f2 := funext fun a => OFE.eq_dist.mpr (h1 a)
obtain rfl : g1 = g2 := funext fun a => OFE.eq_dist.mpr (h2 b)
rfl

@Kaptch

Kaptch commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks, @markusdemedeiros! I'll remove the deprecated things and do a final minor pass over proofs.
I'll later do a more involved pass in a separate PR to see where it's possible to significantly shorten stuff by rewriting within 1-2 weeks.

@Kaptch Kaptch mentioned this pull request Jul 27, 2026
53 tasks
@Kaptch
Kaptch merged commit 1f6eaa0 into leanprover-community:master Jul 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants