-- PCF/Flat.lean

import «PCF».Domain

open Classical

-- Repository definitions used:
content: class Order (α) where
  R : α → α → Prop
  refl {x} : R x x
  trans {x y z} : R x y → R y z → R x z
  anti {x y} : R x y → R y x → x = y

content: infix:100 " ⊑ " => Order.R

-- Repository lemmas used:
content: theorem List.getElem_append_left{α : Type u_1} {l₁ l₂ : List α} {i : Nat} (hn : i < l₁.length) :\n(l₁ ++ l₂)[i] = l₁[i]

-- Local definitions used:
content: inductive Flat (α : Type) : Type where
  | none : Flat α
  | some : α → Flat α

-- Local lemmas used:
content: theorem Flat.invert {x : Flat α} (p : x ≠ .none) : ∃ k, x = .some k

-- Target theorem and proof:
theorem Flat.leq_none {a : Flat α} : a ⊑ .none → a = .none
:= by
  intro a_bf_n
  by_cases a = none
  case pos => assumption
  case neg h =>
    have ⟨n, a_eq_sn⟩ := Flat.invert h
    exact a_bf_n (by intro a_eq_n; injection a_eq_n.symm ⬝ a_eq_sn)