Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat: two easy lemmas about List.Lex #6395

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Mathlib/Data/List/Lex.lean
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ theorem not_nil_right (r : α → α → Prop) (l : List α) : ¬Lex r l [] :=
fun.
#align list.lex.not_nil_right List.Lex.not_nil_right

theorem nil_left_or_nil_eq {r : α → α → Prop} (l : List α) : List.Lex r [] l ∨ [] = l := by
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a version assuming IsRefl r that says List.Lex r [] l?

Copy link
Collaborator Author

@dagurtomas dagurtomas Aug 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That result is not true. List.Lex is not reflexive even though r is.

Indeed, we have: List.Lex.not_nil_right : ¬List.Lex r l [], in particular ¬List.Lex r [] []

induction l with
| nil => exact Or.inr rfl
| cons a as _ => exact Or.inl (by apply nil)

@[simp]
theorem singleton_iff {r : α → α → Prop} (a b : α) : List.Lex r [a] [b] ↔ r a b := by
refine' ⟨fun h ↦ _, List.Lex.rel⟩
by_contra h'
cases h
· apply not_nil_right r []; assumption
· apply h'; assumption

instance isOrderConnected (r : α → α → Prop) [IsOrderConnected α r] [IsTrichotomous α r] :
IsOrderConnected (List α) (Lex r) where
conn := aux where
Expand Down