Zulip Chat Archive

Stream: Is there code for X?

Topic: a.or (some b) = a.getD b


Violeta Hernández (Sep 25 2024 at 22:52):

What it says in the title.

Violeta Hernández (Sep 25 2024 at 22:52):

theorem Option.or_some_right {α : Type*} (a : Option α) (b : α) :
    a.or (some b) = a.getD b := by
  cases a <;> rfl

Kim Morrison (Sep 26 2024 at 00:35):

Probably could just be called or_some.

Kim Morrison (Sep 26 2024 at 00:35):

But yes, seems plausible. I guess we already have simp lemmas for the other three cases?

Violeta Hernández (Sep 26 2024 at 00:35):

docs#Option.or_some is already a different lemma

Violeta Hernández (Sep 26 2024 at 00:36):

Yep, we seem to have the other three

Violeta Hernández (Sep 26 2024 at 00:36):

docs#Option.none_or and docs#Option.or_none

Kim Morrison (Sep 26 2024 at 00:38):

Ugh, okay or_some should be renamed to some_or, and then your suggestion can become some_or.

Kim Morrison (Sep 26 2024 at 00:38):

Would you be able to PR that?

Violeta Hernández (Sep 26 2024 at 00:38):

Sure, just give me a couple of hours

Violeta Hernández (Sep 26 2024 at 00:38):

(I also still have to PR the pmap lemma)

Kim Morrison (Sep 26 2024 at 00:39):

If we wanted to be really conservative we would first rename or_some, add a deprecation, and then only add the new lemma (at least) one release later.

Kim Morrison (Sep 26 2024 at 00:39):

Actually, lets do that...

If you could do the rename, but for now add the new lemma as or_some', with a doc-string saying that it will be renamed to or_some once the existing deprecation is removed.

Kim Morrison (Sep 26 2024 at 00:40):

Painful, I realise. :-)

Kim Morrison (Sep 26 2024 at 00:40):

Thank you!

Damiano Testa (Sep 26 2024 at 04:31):

To remember about removing the prime, you could add an (untested) assert_exists Option.or_some next to or_some' so that once the deprecated lemma is removed, you'll get a warning.

Violeta Hernández (Nov 02 2024 at 21:10):

#5926

Violeta Hernández (Nov 02 2024 at 21:41):

Is alias not available in core?

Violeta Hernández (Nov 02 2024 at 22:06):

(also, how do I link a core PR?)

Yaël Dillies (Nov 02 2024 at 22:08):

lean4#5926

Yaël Dillies (Nov 02 2024 at 22:08):

alias is from batteries


Last updated: May 02 2025 at 03:31 UTC