Zulip Chat Archive

Stream: lean4

Topic: Redundant alternative in deriving Ord


ohhaimark (Mar 18 2024 at 00:07):

I have the following:

abbrev Var := Int

inductive Ty where
  | int
  | bool

@[reducible] def Ty.type : Ty  Type
  | .int => Int
  | .bool => Bool

inductive Expr : Ty  Type where
  | litInt : Int  Expr .int
  | litBool : Bool  Expr .bool
  | varInt : Var  Expr .int
  | add : Expr .int  Expr .int  Expr .int
  | minus : Expr .int  Expr .int
  | lt : Expr .int  Expr .int  Expr .bool
  | eq : Expr .int  Expr .int  Expr .bool
deriving Ord

but I have this error on the deriving: redudant alternative. I'd really like to not have to manually write this Ord instance.
I'm on leanprover/lean4:v4.7.0-rc2

ohhaimark (Mar 18 2024 at 00:13):

Smaller repro

inductive Ty where
  | int
  | bool
inductive Expr : Ty  Type where
  | a : Expr .int
  | b : Expr .bool
deriving Ord

ohhaimark (Mar 18 2024 at 00:18):

Well now I realize I don't need that Ord instance, but still a bug.

Kim Morrison (Mar 18 2024 at 00:19):

@ohhaimark, could you please open an issue on the Lean repo?

ohhaimark (Mar 18 2024 at 00:33):

https://github.com/leanprover/lean4/issues/3706

ohhaimark (Mar 21 2024 at 06:14):

Where does lean implement deriving tactics? More specifically, where can I find Ord's?

Chris Bailey (Mar 21 2024 at 07:14):

https://github.com/leanprover/lean4/blob/master/src/Lean/Elab/Deriving/Ord.lean


Last updated: May 02 2025 at 03:31 UTC