Lean4
instance decidableRel [DecidableEq α] (r : α → α → Prop) [DecidableRel r] : DecidableRel (Lex r)
| l₁, [] => isFalse fun h => by cases h
| [], _ :: _ => isTrue Lex.nil
| a :: l₁, b :: l₂ => by
haveI := decidableRel r l₁ l₂
refine decidable_of_iff (r a b ∨ a = b ∧ Lex r l₁ l₂) ⟨fun h => ?_, fun h => ?_⟩
· rcases h with (h | ⟨rfl, h⟩)
· exact Lex.rel h
· exact Lex.cons h
· rcases h with (_ | h | h)
· exact Or.inl h
· exact Or.inr ⟨rfl, h⟩