Zulip Chat Archive

Stream: general

Topic: WellFoundedRelation '<' for Bool outside mathlib


cmlsharp (Jan 27 2026 at 07:12):

Does

def Bool.lt_wfRel : WellFoundedRelation Bool where
  rel := (· < ·)
  wf := ...

Analogous to Nat.lt_wfRel exist outside of Mathlib? I found myself wanting to use it in a PR to Batteries.

Robin Arnez (Jan 27 2026 at 07:16):

You can also just use Bool.toNat as a termination measure

cmlsharp (Jan 27 2026 at 07:43):

Thanks, that will suffice

Kim Morrison (Jan 28 2026 at 03:20):

cmlsharp said:

Does

def Bool.lt_wfRel : WellFoundedRelation Bool where
  rel := (· < ·)
  wf := ...

Analogous to Nat.lt_wfRel exist outside of Mathlib? I found myself wanting to use it in a PR to Batteries.

I think this should be okay to PR upwards if you'd like.

cmlsharp (Jan 28 2026 at 03:38):

batteries#1639

Kim Morrison (Jan 28 2026 at 03:42):

Ugh, WellFoundedRelation is ugly, with the bundled relation... I guess it can't be helped immediately. WellFoundedLT and WellFoundedGT seem much nicer to expose to the world.

cmlsharp (Jan 28 2026 at 03:44):

Is there interest in a larger project to try and upstream WellFoundedLT/WellFoundedGT? I haven't looked into it too deeply. For my purposes WellFoundedRelation would have been sufficient (it just made for a convenient way to write the Finiteness relation for the scan iterator combinator )

cmlsharp (Jan 28 2026 at 03:45):

In the short term, I think upstreaming at least this makes sense

Kim Morrison (Jan 28 2026 at 03:46):

Could you add a comment in the module doc-string along the lines of "These are not instances, despite WellFoundedRelation being a class, as we provide versions for both < and >. If you need instances, you may use the WellFoundedLT and WellFoundedGT classes available in Mathlib."

cmlsharp (Jan 28 2026 at 03:48):

done

Kim Morrison (Jan 28 2026 at 03:54):

Oh, module doc, not the individual doc-strings.

cmlsharp (Jan 28 2026 at 03:57):

oop sorry, done


Last updated: Feb 28 2026 at 14:05 UTC