/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky ! This file was ported from Lean 3 source module data.list.cycle ! leanprover-community/mathlib commit 7413128c3bcb3b0818e3e18720abc9ea3100fb49 ! Please do not edit these lines, except to modify the commit id ! if you have ported upstream changes. -/ import Mathlib.Data.Multiset.Sort import Mathlib.Data.Fintype.List import Mathlib.Data.List.Rotate /-! # Cycles of a list Lists have an equivalence relation of whether they are rotational permutations of one another. This relation is defined as `IsRotated`. Based on this, we define the quotient of lists by the rotation relation, called `Cycle`. We also define a representation of concrete cycles, available when viewing them in a goal state or via `#eval`, when over representatble types. For example, the cycle `(2 1 4 3)` will be shown as `c[2, 1, 4, 3]`. Two equal cycles may be printed differently if their internal representation is different. -/ namespace List variable {α :α: Type ?u.2Type _} [DecidableEqType _: Type (?u.2+1)α] /-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/ defα: Type ?u.2nextOr : ∀ (nextOr: List α → α → α → α_ : List_: List αα) (α: Type ?u.14__: α_ :_: αα),α: Type ?u.14α | [], _,α: Type ?u.14default =>default: αdefault | [_], _,default: αdefault =>default: αdefault -- Handles the not-found and the wraparound case |default: αy ::y: αz ::z: αxs,xs: List αx,x: αdefault => ifdefault: αx =x: αy theny: αz elsez: αnextOr (nextOr: List α → α → α → αz ::z: αxs)xs: List αxx: αdefault #align list.next_ordefault: αList.nextOr @[simp] theorem nextOr_nil (List.nextOr: {α : Type u_1} → [inst : DecidableEq α] → List α → α → α → αxx: αd :d: αα) :α: Type ?u.807nextOrnextOr: {α : Type ?u.824} → [inst : DecidableEq α] → List α → α → α → α[][]: List ?m.828xx: αd =d: αd := rfl #align list.next_or_nild: αList.nextOr_nil @[simp] theoremList.nextOr_nil: ∀ {α : Type u_1} [inst : DecidableEq α] (x d : α), nextOr [] x d = dnextOr_singleton (nextOr_singleton: ∀ {α : Type u_1} [inst : DecidableEq α] (x y d : α), nextOr [y] x d = dxx: αyy: αd :d: αα) :α: Type ?u.924nextOr [nextOr: {α : Type ?u.943} → [inst : DecidableEq α] → List α → α → α → αy]y: αxx: αd =d: αd := rfl #align list.next_or_singletond: αList.nextOr_singleton @[simp] theoremList.nextOr_singleton: ∀ {α : Type u_1} [inst : DecidableEq α] (x y d : α), nextOr [y] x d = dnextOr_self_cons_cons (xs : Listxs: List αα) (α: Type ?u.1052xx: αyy: αd :d: αα) :α: Type ?u.1052nextOr (nextOr: {α : Type ?u.1074} → [inst : DecidableEq α] → List α → α → α → αx ::x: αy ::y: αxs)xs: List αxx: αd =d: αy := if_pos rfl #align list.next_or_self_cons_cons List.nextOr_self_cons_cons theoremy: αnextOr_cons_of_ne (xs : Listxs: List αα) (α: Type ?u.1199yy: αxx: αd :d: αα) (α: Type ?u.1199h :h: x ≠ yx ≠x: αy) :y: αnextOr (nextOr: {α : Type ?u.1225} → [inst : DecidableEq α] → List α → α → α → αy ::y: αxs)xs: List αxx: αd =d: αnextOrnextOr: {α : Type ?u.1270} → [inst : DecidableEq α] → List α → α → α → αxsxs: List αxx: αd :=d: αGoals accomplished! 🐙Goals accomplished! 🐙#align list.next_or_cons_of_ne List.nextOr_cons_of_ne /-- `nextOr` does not depend on the default value, if the next value appears. -/ theoremGoals accomplished! 🐙nextOr_eq_nextOr_of_mem_of_ne (xs : Listxs: List αα) (α: Type ?u.1421xx: αdd: αd' :d': αα) (α: Type ?u.1421x_mem :x_mem: x ∈ xsx ∈x: αxs) (x_ne :xs: List αx ≠x: αxs.getLast (ne_nil_of_memxs: List αx_mem)) :x_mem: x ∈ xsnextOrnextOr: {α : Type ?u.1497} → [inst : DecidableEq α] → List α → α → α → αxsxs: List αxx: αd =d: αnextOrnextOr: {α : Type ?u.1539} → [inst : DecidableEq α] → List α → α → α → αxsxs: List αxx: αd' :=d': αGoals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
x_mem: x ∈ []
x_ne: x ≠ getLast [] (_ : [] ≠ [])
nilα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y: α
ys: List α
IH: ∀ (x_mem : x ∈ ys), x ≠ getLast ys (_ : ys ≠ []) → nextOr ys x d = nextOr ys x d'
x_mem: x ∈ y :: ys
x_ne: x ≠ getLast (y :: ys) (_ : y :: ys ≠ [])
consα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
x_mem: x ∈ []
x_ne: x ≠ getLast [] (_ : [] ≠ [])
nilα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y: α
ys: List α
IH: ∀ (x_mem : x ∈ ys), x ≠ getLast ys (_ : ys ≠ []) → nextOr ys x d = nextOr ys x d'
x_mem: x ∈ y :: ys
x_ne: x ≠ getLast (y :: ys) (_ : y :: ys ≠ [])
consGoals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y: α
IH: ∀ (x_mem : x ∈ []), x ≠ getLast [] (_ : [] ≠ []) → nextOr [] x d = nextOr [] x d'
x_mem: x ∈ [y]
x_ne: x ≠ getLast [y] (_ : [y] ≠ [])
cons.nilα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
cons.consα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y: α
IH: ∀ (x_mem : x ∈ []), x ≠ getLast [] (_ : [] ≠ []) → nextOr [] x d = nextOr [] x d'
x_mem: x ∈ [y]
x_ne: x ≠ getLast [y] (_ : [y] ≠ [])
cons.nilα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
cons.consGoals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: x = y
posz = zGoals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_memα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_neα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_memα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_neα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_memα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_memα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_neGoals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_neα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d, d': α
x_mem✝: x ∈ xs
x_ne✝: x ≠ getLast xs (_ : xs ≠ [])
y, z: α
zs: List α
IH: ∀ (x_mem : x ∈ z :: zs), x ≠ getLast (z :: zs) (_ : z :: zs ≠ []) → nextOr (z :: zs) x d = nextOr (z :: zs) x d'
x_mem: x ∈ y :: z :: zs
x_ne: x ≠ getLast (y :: z :: zs) (_ : y :: z :: zs ≠ [])
h: ¬x = y
neg.x_ne#align list.next_or_eq_next_or_of_mem_of_ne List.nextOr_eq_nextOr_of_mem_of_ne theoremGoals accomplished! 🐙mem_of_nextOr_ne {xs : Listxs: List αα} {α: Type ?u.18047xx: αd :d: αα} (h :α: Type ?u.18047nextOrnextOr: {α : Type ?u.18068} → [inst : DecidableEq α] → List α → α → α → αxsxs: List αxx: αd ≠d: αd) :d: αx ∈x: αxs :=xs: List αGoals accomplished! 🐙Goals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
h✝: nextOr xs x d ≠ d
y: α
IH: nextOr [] x d ≠ d → x ∈ []
h: nextOr [y] x d ≠ d
cons.nilx ∈ [y]α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
h✝: nextOr xs x d ≠ d
y, z: α
zs: List α
IH: nextOr (z :: zs) x d ≠ d → x ∈ z :: zs
h: nextOr (y :: z :: zs) x d ≠ d
cons.consα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
h✝: nextOr xs x d ≠ d
y: α
IH: nextOr [] x d ≠ d → x ∈ []
h: nextOr [y] x d ≠ d
cons.nilx ∈ [y]α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
h✝: nextOr xs x d ≠ d
y, z: α
zs: List α
IH: nextOr (z :: zs) x d ≠ d → x ∈ z :: zs
h: nextOr (y :: z :: zs) x d ≠ d
cons.consGoals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
h✝: nextOr xs x d ≠ d
y, z: α
zs: List α
IH: nextOr (z :: zs) x d ≠ d → x ∈ z :: zs
h: nextOr (y :: z :: zs) x d ≠ d
hx: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
h✝: nextOr xs x d ≠ d
y, z: α
zs: List α
IH: nextOr (z :: zs) x d ≠ d → x ∈ z :: zs
h: nextOr (y :: z :: zs) x d ≠ d
hx: ¬x = y
negα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
h✝: nextOr xs x d ≠ d
y, z: α
zs: List α
IH: nextOr (z :: zs) x d ≠ d → x ∈ z :: zs
h: nextOr (y :: z :: zs) x d ≠ d
hx: x = y
posα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
h✝: nextOr xs x d ≠ d
y, z: α
zs: List α
IH: nextOr (z :: zs) x d ≠ d → x ∈ z :: zs
h: nextOr (y :: z :: zs) x d ≠ d
hx: ¬x = y
negGoals accomplished! 🐙#align list.mem_of_next_or_ne List.mem_of_nextOr_ne theoremGoals accomplished! 🐙nextOr_concat {xs : Listxs: List αα} {α: Type ?u.41483x :x: αα} (α: Type ?u.41483d :d: αα) (h :α: Type ?u.41483x ∉x: αxs) :xs: List αnextOr (nextOr: {α : Type ?u.41520} → [inst : DecidableEq α] → List α → α → α → αxs ++ [xs: List αx])x: αxx: αd =d: αd :=d: αGoals accomplished! 🐙Goals accomplished! 🐙#align list.next_or_concat List.nextOr_concat theoremGoals accomplished! 🐙nextOr_mem {xs : Listxs: List αα} {α: Type ?u.41937xx: αd :d: αα} (α: Type ?u.41937hd :hd: d ∈ xsd ∈d: αxs) :xs: List αnextOrnextOr: {α : Type ?u.42002} → [inst : DecidableEq α] → List α → α → α → αxsxs: List αxx: αd ∈d: αxs :=xs: List αGoals accomplished! 🐙Goals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
hxs': ∀ (x : α), x ∈ [] → x ∈ xs'
nilα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y: α
ys: List α
ih: (∀ (x : α), x ∈ ys → x ∈ xs') → nextOr ys x d ∈ xs'
hxs': ∀ (x : α), x ∈ y :: ys → x ∈ xs'
consα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
hxs': ∀ (x : α), x ∈ [] → x ∈ xs'
nilα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y: α
ys: List α
ih: (∀ (x : α), x ∈ ys → x ∈ xs') → nextOr ys x d ∈ xs'
hxs': ∀ (x : α), x ∈ y :: ys → x ∈ xs'
consGoals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y: α
ih: (∀ (x : α), x ∈ [] → x ∈ xs') → nextOr [] x d ∈ xs'
hxs': ∀ (x : α), x ∈ [y] → x ∈ xs'
cons.nilα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y, z: α
zs: List α
ih: (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs'
hxs': ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs'
cons.consα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y: α
ih: (∀ (x : α), x ∈ [] → x ∈ xs') → nextOr [] x d ∈ xs'
hxs': ∀ (x : α), x ∈ [y] → x ∈ xs'
cons.nilα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y, z: α
zs: List α
ih: (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs'
hxs': ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs'
cons.consGoals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y, z: α
zs: List α
ih: (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs'
hxs': ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs'
h: x = y
cons.cons.inlz ∈ xs'α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y, z: α
zs: List α
ih: (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs'
hxs': ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs'
h: ¬x = y
cons.cons.inrα: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y, z: α
zs: List α
ih: (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs'
hxs': ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs'
h: x = y
cons.cons.inlz ∈ xs'α: Type u_1
inst✝: DecidableEq α
xs: List α
x, d: α
xs': List α
hxs'✝: ∀ (x : α), x ∈ xs → x ∈ xs'
hd: d ∈ xs'
y, z: α
zs: List α
ih: (∀ (x : α), x ∈ z :: zs → x ∈ xs') → nextOr (z :: zs) x d ∈ xs'
hxs': ∀ (x : α), x ∈ y :: z :: zs → x ∈ xs'
h: ¬x = y
cons.cons.inrGoals accomplished! 🐙#align list.next_or_mem List.nextOr_mem /-- Given an element `x : α` of `l : List α` such that `x ∈ l`, get the next element of `l`. This works from head to tail, (including a check for last element) so it will match on first hit, ignoring later duplicates. For example: * `next [1, 2, 3] 2 _ = 3` * `next [1, 2, 3] 3 _ = 1` * `next [1, 2, 3, 2, 4] 2 _ = 3` * `next [1, 2, 3, 2] 2 _ = 3` * `next [1, 1, 2, 3, 2] 1 _ = 1` -/ defGoals accomplished! 🐙next (next: {α : Type u_1} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αl : Listl: List αα) (α: Type ?u.43550x :x: αα) (α: Type ?u.43550h :h: x ∈ lx ∈x: αl) :l: List αα :=α: Type ?u.43550nextOrnextOr: {α : Type ?u.43600} → [inst : DecidableEq α] → List α → α → α → αll: List αx (x: αl.get ⟨l: List α0, length_pos_of_mem0: ?m.43691h⟩) #align list.nexth: x ∈ lList.next /-- Given an element `x : α` of `l : List α` such that `x ∈ l`, get the previous element of `l`. This works from head to tail, (including a check for last element) so it will match on first hit, ignoring later duplicates. * `prev [1, 2, 3] 2 _ = 1` * `prev [1, 2, 3] 1 _ = 3` * `prev [1, 2, 3, 2, 4] 2 _ = 1` * `prev [1, 2, 3, 4, 2] 2 _ = 1` * `prev [1, 1, 2] 1 _ = 2` -/ defList.next: {α : Type u_1} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αprev : ∀ (prev: {α : Type u_1} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αl : Listl: List αα) (α: Type ?u.43876x :x: αα) (α: Type ?u.43876_h :_h: x ∈ lx ∈x: αl),l: List αα | [], _,α: Type ?u.43876h =>h: x✝ ∈ []Goals accomplished! 🐙α| [Goals accomplished! 🐙y], _, _ =>y: αy |y: αy ::y: αz ::z: αxs,xs: List αx, h => ifx: αhx :hx: ?m.44069x =x: αy then getLast (y: αz ::z: αxs) (cons_ne_nilxs: List α__: ?m.44076_) else if_: List ?m.44076x =x: αz thenz: αy else prev (y: αz ::z: αxs)xs: List αx (x: αGoals accomplished! 🐙) #align list.prevGoals accomplished! 🐙List.prev variable (List.prev: {α : Type u_1} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αl : Listl: List αα) (α: Type ?u.58478x :x: αα) @[simp] theoremα: Type ?u.84991next_singleton (next_singleton: ∀ {α : Type u_1} [inst : DecidableEq α] (x y : α) (h : x ∈ [y]), next [y] x h = yxx: αy :y: αα) (α: Type ?u.58478h :h: x ∈ [y]x ∈ [x: αy]) :y: αnext [next: {α : Type ?u.58533} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αy]y: αxx: αh =h: x ∈ [y]y := rfl #align list.next_singletony: αList.next_singleton @[simp] theoremList.next_singleton: ∀ {α : Type u_1} [inst : DecidableEq α] (x y : α) (h : x ∈ [y]), next [y] x h = yprev_singleton (prev_singleton: ∀ {α : Type u_1} [inst : DecidableEq α] (x y : α) (h : x ∈ [y]), prev [y] x h = yxx: αy :y: αα) (α: Type ?u.58651h :h: x ∈ [y]x ∈ [x: αy]) :y: αprev [prev: {α : Type ?u.58706} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αy]y: αxx: αh =h: x ∈ [y]y := rfl #align list.prev_singletony: αList.prev_singleton theorem next_cons_cons_eq' (List.prev_singleton: ∀ {α : Type u_1} [inst : DecidableEq α] (x y : α) (h : x ∈ [y]), prev [y] x h = yyy: αz :z: αα) (h :α: Type ?u.58814x ∈x: αy ::y: αz ::z: αl) (l: List αhx :hx: x = yx =x: αy) :y: αnext (next: {α : Type ?u.58873} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αy ::y: αz ::z: αl)l: List αx h =x: αz :=z: αGoals accomplished! 🐙#align list.next_cons_cons_eq' List.next_cons_cons_eq' @[simp] theoremGoals accomplished! 🐙next_cons_cons_eq (z :z: αα) (h :α: Type ?u.59679x ∈x: αx ::x: αz ::z: αl) :l: List αnext (next: {α : Type ?u.59732} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αx ::x: αz ::z: αl)l: List αx h =x: αz := next_cons_cons_eq'z: αll: List αxx: αxx: αz h rfl #align list.next_cons_cons_eq List.next_cons_cons_eq theoremz: αnext_ne_head_ne_getLast (h :h: x ∈ lx ∈x: αl) (l: List αy :y: αα) (h :α: Type ?u.59864x ∈x: αy ::y: αl) (l: List αhy :hy: x ≠ yx ≠x: αy) (hx :y: αx ≠ getLast (x: αy ::y: αl) (cons_ne_nill: List α__: ?m.59944_)) :_: List ?m.59944next (next: {α : Type ?u.59958} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αy ::y: αl)l: List αx h =x: αnextnext: {α : Type ?u.60002} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αll: List αx (x: αGoals accomplished! 🐙) :=Goals accomplished! 🐙Goals accomplished! 🐙α: Type u_1
inst✝: DecidableEq α
l: List α
x: α
h✝: x ∈ l
y: α
h: x ∈ y :: l
hy: x ≠ y
hx: x ≠ getLast (y :: l) (_ : y :: l ≠ [])α: Type u_1
inst✝: DecidableEq α
l: List α
x: α
h✝: x ∈ l
y: α
h: x ∈ y :: l
hy: x ≠ y
hx: x ≠ getLast (y :: l) (_ : y :: l ≠ [])
d'αα: Type u_1
inst✝: DecidableEq α
l: List α
x: α
h✝: x ∈ l
y: α
h: x ∈ y :: l
hy: x ≠ y
hx: x ≠ getLast (y :: l) (_ : y :: l ≠ [])
x_memx ∈ lα: Type u_1
inst✝: DecidableEq α
l: List α
x: α
h✝: x ∈ l
y: α
h: x ∈ y :: l
hy: x ≠ y
hx: x ≠ getLast (y :: l) (_ : y :: l ≠ [])
x_neGoals accomplished! 🐙Goals accomplished! 🐙Goals accomplished! 🐙#align list.next_ne_head_ne_last List.next_ne_head_ne_getLast theoremGoals accomplished! 🐙next_cons_concat (y :y: αα) (α: Type ?u.65160hy :hy: x ≠ yx ≠x: αy) (hx :y: αx ∉x: αl) (h :l: List αx ∈x: αy ::y: αl ++ [l: List αx] := mem_append_rightx: α_ (mem_singleton_self_: List ?m.65263x)) :x: αnext (next: {α : Type ?u.65284} → [inst : DecidableEq α] → (l : List α) → (x : α) → x ∈ l → αy ::y: αl ++ [l: List αx])x: αx h =x: αy :=y: αGoals accomplished! 🐙