lean4-htt/tests/lean/run/treemap.lean
Paul Reichert a3a99d3875
feat: more tree map lemmas about empty, isEmpty, contains, size, insert, erase (#7161)
This PR adds all missing tree map lemmas about the interactions of the
functions `empty`, `isEmpty`, `contains`, `size`, `insert(IfNew)` and
`erase`.

---------

Co-authored-by: Paul Reichert <6992158+datokrat@users.noreply.github.com>
2025-02-20 15:33:41 +00:00

41 lines
1.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-
Copyright (c) 2025 Lean FRO, LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Paul Reichert
-/
import Std.Data.TreeSet.Basic
import Std.Data.TreeSet.Lemmas
open Std
variable {α : Type u} {β : Type v} [Ord α]
def mkDTreeMapSingleton (a : α) (b : β) : DTreeMap α (fun _ => β) := Id.run do
let mut m : DTreeMap α (fun _ => β) := ∅
m := m.insert a b
return m
def mkTreeMapSingleton (a : α) (b : β) : TreeMap α β := Id.run do
let mut m : TreeMap α β := ∅
m := m.insert a b
return m
def mkTreeSetSingleton (a : α) : TreeSet α := Id.run do
let mut m : TreeSet α := ∅
m := m.insert a
return m
example [TransOrd α] [LawfulEqOrd α] (a : α) (b : β) : Option β :=
mkDTreeMapSingleton a b |>.get? a
example [TransOrd α] [LawfulEqOrd α] (a : α) (b : β) : Option β :=
(mkTreeMapSingleton a b)[a]?
example [TransOrd α] (a : α) (b : β) : (mkTreeMapSingleton a b).contains a := by
simp [mkTreeMapSingleton, Id.run]
example [TransOrd α] (a : α) (b : β) : (mkDTreeMapSingleton a b).contains a := by
simp [mkDTreeMapSingleton, Id.run]
example [TransOrd α] (a : α) : (mkTreeSetSingleton a).contains a := by
simp [mkTreeSetSingleton, Id.run]