21 lines
589 B
Text
21 lines
589 B
Text
inductive StrictlyIncreasing : List Nat → Prop
|
|
| empty : StrictlyIncreasing []
|
|
| singleton : StrictlyIncreasing [x]
|
|
| cons : (∀a, a ∈ xs → a > x) → StrictlyIncreasing xs → StrictlyIncreasing (x::xs)
|
|
|
|
-- sorted set of natural numbers
|
|
abbrev NatSet := { xs : List Nat // StrictlyIncreasing xs }
|
|
|
|
namespace NatSet
|
|
|
|
def empty : NatSet := ⟨[], .empty⟩
|
|
def singleton (x : Nat) : NatSet := ⟨[x], .singleton⟩
|
|
|
|
def remove (x : Nat) : NatSet → NatSet
|
|
| ⟨[], _⟩ => empty
|
|
| ⟨a::xs, h⟩ =>
|
|
let tail := ⟨xs, by simp⟩
|
|
if a = x then tail
|
|
else
|
|
⟨a::xs, h⟩
|