leanprover / leanprover/lean4

RFC: replace `compareOfLessAndEq` with `compareOfLT`

Open
#12,867 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

RFC
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Proposal

I suggest replacing compareOfLessAndEq with the following definition:

def compareOfLT {α} [LT α] [DecidableLT α] (x y : α) : Ordering :=
  if x < y then Ordering.lt
  else if y < x then Ordering.gt
  else Ordering.eq

It can be used for any Std.LawfulBOrd without le_antisymm, and it also makes the proofs of basic lemmas simpler. Currently, lemmas like compareOfLessAndEq_eq_gt require some hypotheses about LE and Eq.

Community Feedback

Zulip

Impact

Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the documented compareOfLessAndEq entry point and the compareOfLessAndEq_eq_gt lemma linked in the issue. Check the linked Zulip discussion before changing the ordering definition. Done means compareOfLT is available as proposed, the old comparison is replaced, and the affected basic lemmas still hold without the former hypotheses.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.