The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V33. Data structures and computation

Mathlib.Data.Finmap

128 declarations. Mathlib docs · Source

Finite maps over Multiset

Multisets of sigma types

Finmap

Lifting from AList

Induction

extensionality

mem

keys

empty

singleton

lookup

replace

foldl

erase

sdiff

insert

extract

union

Disjoint

theorem Finmap.mk.injEq E0 #

∀ {α : Type u} {β : α → Type v} (entries : Multiset (Sigma β)) (nodupKeys : entries.NodupKeys)
  (entries_1 : Multiset (Sigma β)) (nodupKeys_1 : entries_1.NodupKeys),
  ({ entries := entries, nodupKeys := nodupKeys } = { entries := entries_1, nodupKeys := nodupKeys_1 }) =
    (entries = entries_1)

theorem Finmap.lookup.congr_simp E1 #

∀ {α : Type u} {β : α → Type v} {inst : DecidableEq α} [inst_1 : DecidableEq α] (a : α) (s s_1 : Finmap β),
  s = s_1 → Finmap.lookup a s = Finmap.lookup a s_1

theorem Finmap.liftOn.congr_simp E1 #

∀ {α : Type u} {β : α → Type v} {γ : Type u_1} (s s_1 : Finmap β),
  s = s_1 →
    ∀ (f f_1 : AList β → γ) (e_f : f = f_1) (H : ∀ (a b : AList β), a.entries.Perm b.entries → f a = f b),
      s.liftOn f H = s_1.liftOn f_1 ⋯

theorem Finmap.mk.inj E1 #

∀ {α : Type u} {β : α → Type v} {entries : Multiset (Sigma β)} {nodupKeys : entries.NodupKeys}
  {entries_1 : Multiset (Sigma β)} {nodupKeys_1 : entries_1.NodupKeys},
  { entries := entries, nodupKeys := nodupKeys } = { entries := entries_1, nodupKeys := nodupKeys_1 } →
    entries = entries_1

def Finmap.ctorIdx E1 #

{α : Type u} → {β : α → Type v} → Finmap β → ℕ

theorem Finmap.liftOn₂.congr_simp E1 #

∀ {α : Type u} {β : α → Type v} {γ : Type u_1} (s₁ s₁_1 : Finmap β),
  s₁ = s₁_1 →
    ∀ (s₂ s₂_1 : Finmap β),
      s₂ = s₂_1 →
        ∀ (f f_1 : AList β → AList β → γ) (e_f : f = f_1)
          (H : ∀ (a₁ b₁ a₂ b₂ : AList β), a₁.entries.Perm a₂.entries → b₁.entries.Perm b₂.entries → f a₁ b₁ = f a₂ b₂),
          s₁.liftOn₂ s₂ f H = s₁_1.liftOn₂ s₂_1 f_1 ⋯

theorem Finmap.mk.congr_simp E1 #

∀ {α : Type u} {β : α → Type v} (entries entries_1 : Multiset (Sigma β)) (e_entries : entries = entries_1)
  (nodupKeys : entries.NodupKeys),
  { entries := entries, nodupKeys := nodupKeys } = { entries := entries_1, nodupKeys := ⋯ }

def Multiset.keys E1 #

{α : Type u} → {β : α → Type v} → Multiset (Sigma β) → Multiset α

Multiset of keys of an association multiset.

theorem Multiset.coe_keys E0 #

∀ {α : Type u} {β : α → Type v} {l : List (Sigma β)}, (↑l).keys = ↑l.keys

theorem Multiset.keys_zero E0 #

∀ {α : Type u} {β : α → Type v}, Multiset.keys 0 = 0

theorem Multiset.keys_cons E0 #

∀ {α : Type u} {β : α → Type v} {a : α} {b : β a} {s : Multiset (Sigma β)}, (⟨a, b⟩ ::ₘ s).keys = a ::ₘ s.keys

theorem Multiset.keys_singleton E0 #

∀ {α : Type u} {β : α → Type v} {a : α} {b : β a}, {⟨a, b⟩}.keys = {a}

def Multiset.NodupKeys E1 #

{α : Type u} → {β : α → Type v} → Multiset (Sigma β) → Prop

NodupKeys s means that s has no duplicate keys.

theorem Multiset.coe_nodupKeys E0 #

∀ {α : Type u} {β : α → Type v} {l : List (Sigma β)}, (↑l).NodupKeys ↔ l.NodupKeys

theorem Multiset.nodup_keys E1 #

∀ {α : Type u} {β : α → Type v} {m : Multiset ((a : α) × β a)}, m.keys.Nodup ↔ m.NodupKeys

theorem Multiset.NodupKeys.nodup_keys E1 #

∀ {α : Type u} {β : α → Type v} {m : Multiset ((a : α) × β a)}, m.NodupKeys → m.keys.Nodup

Alias of the reverse direction of Multiset.nodup_keys.

theorem Multiset.NodupKeys.nodup E1 #

∀ {α : Type u} {β : α → Type v} {m : Multiset ((a : α) × β a)}, m.NodupKeys → m.Nodup

structure Finmap E3 #

{α : Type u} → (α → Type v) → Type (max u v)

Finmap β is the type of finite maps over a multiset. It is effectively a quotient of AList β by permutation of the underlying list.

ctor Finmap.mk E0 #

{α : Type u} → {β : α → Type v} → (entries : Multiset (Sigma β)) → entries.NodupKeys → Finmap β

abbrev Finmap.entries E1 #

{α : Type u} → {β : α → Type v} → Finmap β → Multiset (Sigma β)

The underlying Multiset of a Finmap

theorem Finmap.nodupKeys E1 #

∀ {α : Type u} {β : α → Type v} (self : Finmap β), self.entries.NodupKeys

There are no duplicate keys in entries

def AList.toFinmap E1 #

{α : Type u} → {β : α → Type v} → AList β → Finmap β

The quotient map from AList to Finmap.

theorem AList.toFinmap_eq E0 #

∀ {α : Type u} {β : α → Type v} {s₁ s₂ : AList β}, s₁.toFinmap = s₂.toFinmap ↔ s₁.entries.Perm s₂.entries

theorem AList.toFinmap_entries E0 #

∀ {α : Type u} {β : α → Type v} (s : AList β), s.toFinmap.entries = ↑s.entries

def List.toFinmap E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → List (Sigma β) → Finmap β

Given l : List (Sigma β), create a term of type Finmap β by removing entries with duplicate keys.

theorem Finmap.nodup_entries E1 #

∀ {α : Type u} {β : α → Type v} (f : Finmap β), f.entries.Nodup

def Finmap.liftOn E1 #

{α : Type u} →
  {β : α → Type v} →
    {γ : Type u_1} → Finmap β → (f : AList β → γ) → (∀ (a b : AList β), a.entries.Perm b.entries → f a = f b) → γ

Lift a permutation-respecting function on AList to Finmap.

theorem Finmap.liftOn_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} {γ : Type u_1} (s : AList β) (f : AList β → γ)
  (H : ∀ (a b : AList β), a.entries.Perm b.entries → f a = f b), s.toFinmap.liftOn f H = f s

def Finmap.liftOn₂ E1 #

{α : Type u} →
  {β : α → Type v} →
    {γ : Type u_1} →
      Finmap β →
        Finmap β →
          (f : AList β → AList β → γ) →
            (∀ (a₁ b₁ a₂ b₂ : AList β), a₁.entries.Perm a₂.entries → b₁.entries.Perm b₂.entries → f a₁ b₁ = f a₂ b₂) → γ

Lift a permutation-respecting function on 2 ALists to 2 Finmaps.

theorem Finmap.liftOn₂_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} {γ : Type u_1} (s₁ s₂ : AList β) (f : AList β → AList β → γ)
  (H : ∀ (a₁ b₁ a₂ b₂ : AList β), a₁.entries.Perm a₂.entries → b₁.entries.Perm b₂.entries → f a₁ b₁ = f a₂ b₂),
  s₁.toFinmap.liftOn₂ s₂.toFinmap f H = f s₁ s₂

theorem Finmap.induction_on E1 #

∀ {α : Type u} {β : α → Type v} {C : Finmap β → Prop} (s : Finmap β), (∀ (a : AList β), C a.toFinmap) → C s

theorem Finmap.induction_on₂ E1 #

∀ {α : Type u} {β : α → Type v} {C : Finmap β → Finmap β → Prop} (s₁ s₂ : Finmap β),
  (∀ (a₁ a₂ : AList β), C a₁.toFinmap a₂.toFinmap) → C s₁ s₂

theorem Finmap.induction_on₃ E1 #

∀ {α : Type u} {β : α → Type v} {C : Finmap β → Finmap β → Finmap β → Prop} (s₁ s₂ s₃ : Finmap β),
  (∀ (a₁ a₂ a₃ : AList β), C a₁.toFinmap a₂.toFinmap a₃.toFinmap) → C s₁ s₂ s₃

theorem Finmap.ext E1 #

∀ {α : Type u} {β : α → Type v} {s t : Finmap β}, s.entries = t.entries → s = t

theorem Finmap.ext_iff E0 #

∀ {α : Type u} {β : α → Type v} {s t : Finmap β}, s = t ↔ s.entries = t.entries

theorem Finmap.ext_iff' E0 #

∀ {α : Type u} {β : α → Type v} {s t : Finmap β}, s.entries = t.entries ↔ s = t

instance Finmap.instMembership E0 #

{α : Type u} → {β : α → Type v} → Membership α (Finmap β)

The predicate a ∈ s means that s has a value associated to the key a.

theorem Finmap.mem_def E0 #

∀ {α : Type u} {β : α → Type v} {a : α} {s : Finmap β}, a ∈ s ↔ a ∈ s.entries.keys

theorem Finmap.mem_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} {a : α} {s : AList β}, a ∈ s.toFinmap ↔ a ∈ s

def Finmap.keys E1 #

{α : Type u} → {β : α → Type v} → Finmap β → Finset α

The set of keys of a finite map.

theorem Finmap.keys_val E0 #

∀ {α : Type u} {β : α → Type v} (s : AList β), s.toFinmap.keys.val = ↑s.keys

theorem Finmap.keys_ext E0 #

∀ {α : Type u} {β : α → Type v} {s₁ s₂ : AList β}, s₁.toFinmap.keys = s₂.toFinmap.keys ↔ s₁.keys.Perm s₂.keys

theorem Finmap.mem_keys E0 #

∀ {α : Type u} {β : α → Type v} {a : α} {s : Finmap β}, a ∈ s.keys ↔ a ∈ s

instance Finmap.instEmptyCollection E0 #

{α : Type u} → {β : α → Type v} → EmptyCollection (Finmap β)

The empty map.

instance Finmap.instInhabited E0 #

{α : Type u} → {β : α → Type v} → Inhabited (Finmap β)

theorem Finmap.empty_toFinmap E0 #

∀ {α : Type u} {β : α → Type v}, ∅.toFinmap = ∅

theorem Finmap.toFinmap_nil E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α], [].toFinmap = ∅

theorem Finmap.notMem_empty E1 #

∀ {α : Type u} {β : α → Type v} {a : α}, a ∉ ∅

theorem Finmap.keys_empty E0 #

∀ {α : Type u} {β : α → Type v}, ∅.keys = ∅

def Finmap.singleton E1 #

{α : Type u} → {β : α → Type v} → (a : α) → β a → Finmap β

The singleton map.

theorem Finmap.keys_singleton E0 #

∀ {α : Type u} {β : α → Type v} (a : α) (b : β a), (Finmap.singleton a b).keys = {a}

theorem Finmap.mem_singleton E0 #

∀ {α : Type u} {β : α → Type v} (x y : α) (b : β y), x ∈ Finmap.singleton y b ↔ x = y

instance Finmap.decidableEq E0 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → [(a : α) → DecidableEq (β a)] → DecidableEq (Finmap β)

def Finmap.lookup E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → (a : α) → Finmap β → Option (β a)

Look up the value associated to a key in a map.

theorem Finmap.lookup_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (s : AList β),
  Finmap.lookup a s.toFinmap = AList.lookup a s

theorem Finmap.dlookup_list_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (s : List (Sigma β)),
  Finmap.lookup a s.toFinmap = List.dlookup a s

theorem Finmap.lookup_empty E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α), Finmap.lookup a ∅ = none

theorem Finmap.lookup_isSome E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {s : Finmap β}, (Finmap.lookup a s).isSome = true ↔ a ∈ s

theorem Finmap.lookup_eq_none E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {s : Finmap β}, Finmap.lookup a s = none ↔ a ∉ s

theorem Finmap.mem_lookup_iff E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s : Finmap β} {a : α} {b : β a},
  b ∈ Finmap.lookup a s ↔ ⟨a, b⟩ ∈ s.entries

theorem Finmap.lookup_eq_some_iff E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s : Finmap β} {a : α} {b : β a},
  Finmap.lookup a s = some b ↔ ⟨a, b⟩ ∈ s.entries

theorem Finmap.sigma_keys_lookup E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (s : Finmap β),
  (s.keys.sigma fun i ↦ (Finmap.lookup i s).toFinset) = { val := s.entries, nodup := ⋯ }

theorem Finmap.lookup_singleton_eq E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b : β a},
  Finmap.lookup a (Finmap.singleton a b) = some b

instance Finmap.instDecidableMem E0 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → (a : α) → (s : Finmap β) → Decidable (a ∈ s)

theorem Finmap.mem_iff E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {s : Finmap β}, a ∈ s ↔ ∃ b, Finmap.lookup a s = some b

theorem Finmap.mem_of_lookup_eq_some E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b : β a} {s : Finmap β},
  Finmap.lookup a s = some b → a ∈ s

theorem Finmap.ext_lookup E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s₁ s₂ : Finmap β},
  (∀ (x : α), Finmap.lookup x s₁ = Finmap.lookup x s₂) → s₁ = s₂

def Finmap.keysLookupEquiv E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → Finmap β ≃ { f // ∀ (i : α), (f.2 i).isSome = true ↔ i ∈ f.1 }

An equivalence between Finmap β and pairs (keys : Finset α, lookup : ∀ a, Option (β a)) such that (lookup a).isSome ↔ a ∈ keys.

theorem Finmap.keysLookupEquiv_apply_coe_snd E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (s : Finmap β) (i : α),
  (↑(Finmap.keysLookupEquiv s)).2 i = Finmap.lookup i s

theorem Finmap.keysLookupEquiv_apply_coe_fst E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (s : Finmap β), (↑(Finmap.keysLookupEquiv s)).1 = s.keys

theorem Finmap.keysLookupEquiv_symm_apply_keys E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (f : { f // ∀ (i : α), (f.2 i).isSome = true ↔ i ∈ f.1 }),
  (Finmap.keysLookupEquiv.symm f).keys = (↑f).1

theorem Finmap.keysLookupEquiv_symm_apply_lookup E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (f : { f // ∀ (i : α), (f.2 i).isSome = true ↔ i ∈ f.1 })
  (a : α), Finmap.lookup a (Finmap.keysLookupEquiv.symm f) = (↑f).2 a

def Finmap.replace E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → (a : α) → β a → Finmap β → Finmap β

Replace a key with a given value in a finite map. If the key is not present it does nothing.

theorem Finmap.replace_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (b : β a) (s : AList β),
  Finmap.replace a b s.toFinmap = (AList.replace a b s).toFinmap

theorem Finmap.keys_replace E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (b : β a) (s : Finmap β),
  (Finmap.replace a b s).keys = s.keys

theorem Finmap.mem_replace E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a a' : α} {b : β a} {s : Finmap β},
  a' ∈ Finmap.replace a b s ↔ a' ∈ s

def Finmap.foldl E1 #

{α : Type u} →
  {β : α → Type v} →
    {δ : Type w} →
      (f : δ → (a : α) → β a → δ) →
        (∀ (d : δ) (a₁ : α) (b₁ : β a₁) (a₂ : α) (b₂ : β a₂), f (f d a₁ b₁) a₂ b₂ = f (f d a₂ b₂) a₁ b₁) →
          δ → Finmap β → δ

Fold a commutative function over the key-value pairs in the map

def Finmap.any E1 #

{α : Type u} → {β : α → Type v} → ((x : α) → β x → Bool) → Finmap β → Bool

any f s returns true iff there exists a value v in s such that f v = true.

def Finmap.all E1 #

{α : Type u} → {β : α → Type v} → ((x : α) → β x → Bool) → Finmap β → Bool

all f s returns true iff f v = true for all values v in s.

def Finmap.erase E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → α → Finmap β → Finmap β

Erase a key from the map. If the key is not present it does nothing.

theorem Finmap.erase_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (s : AList β),
  Finmap.erase a s.toFinmap = (AList.erase a s).toFinmap

theorem Finmap.keys_erase_toFinset E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (s : AList β),
  (AList.erase a s).toFinmap.keys = s.toFinmap.keys.erase a

theorem Finmap.keys_erase E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (s : Finmap β), (Finmap.erase a s).keys = s.keys.erase a

theorem Finmap.mem_erase E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a a' : α} {s : Finmap β},
  a' ∈ Finmap.erase a s ↔ a' ≠ a ∧ a' ∈ s

theorem Finmap.notMem_erase_self E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {s : Finmap β}, a ∉ Finmap.erase a s

theorem Finmap.lookup_erase E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (s : Finmap β), Finmap.lookup a (Finmap.erase a s) = none

theorem Finmap.lookup_erase_ne E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a a' : α} {s : Finmap β},
  a ≠ a' → Finmap.lookup a (Finmap.erase a' s) = Finmap.lookup a s

theorem Finmap.erase_erase E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a a' : α} {s : Finmap β},
  Finmap.erase a (Finmap.erase a' s) = Finmap.erase a' (Finmap.erase a s)

def Finmap.sdiff E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → Finmap β → Finmap β → Finmap β

sdiff s s' consists of all key-value pairs from s and s' where the keys are in s or s' but not both.

instance Finmap.instSDiff E0 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → SDiff (Finmap β)

def Finmap.insert E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → (a : α) → β a → Finmap β → Finmap β

Insert a key-value pair into a finite map, replacing any existing pair with the same key.

theorem Finmap.insert_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (b : β a) (s : AList β),
  Finmap.insert a b s.toFinmap = (AList.insert a b s).toFinmap

theorem Finmap.entries_insert_of_notMem E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b : β a} {s : Finmap β},
  a ∉ s → (Finmap.insert a b s).entries = ⟨a, b⟩ ::ₘ s.entries

theorem Finmap.mem_insert E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a a' : α} {b' : β a'} {s : Finmap β},
  a ∈ Finmap.insert a' b' s ↔ a = a' ∨ a ∈ s

theorem Finmap.lookup_insert E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b : β a} (s : Finmap β),
  Finmap.lookup a (Finmap.insert a b s) = some b

theorem Finmap.lookup_insert_of_ne E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a a' : α} {b : β a} (s : Finmap β),
  a' ≠ a → Finmap.lookup a' (Finmap.insert a b s) = Finmap.lookup a' s

theorem Finmap.insert_insert E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b b' : β a} (s : Finmap β),
  Finmap.insert a b' (Finmap.insert a b s) = Finmap.insert a b' s

theorem Finmap.insert_insert_of_ne E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a a' : α} {b : β a} {b' : β a'} (s : Finmap β),
  a ≠ a' → Finmap.insert a' b' (Finmap.insert a b s) = Finmap.insert a b (Finmap.insert a' b' s)

theorem Finmap.toFinmap_cons E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (b : β a) (xs : List (Sigma β)),
  (⟨a, b⟩ :: xs).toFinmap = Finmap.insert a b xs.toFinmap

theorem Finmap.mem_list_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (xs : List (Sigma β)), a ∈ xs.toFinmap ↔ ∃ b, ⟨a, b⟩ ∈ xs

theorem Finmap.insert_singleton_eq E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b b' : β a},
  Finmap.insert a b (Finmap.singleton a b') = Finmap.singleton a b

def Finmap.extract E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → (a : α) → Finmap β → Option (β a) × Finmap β

Erase a key from the map, and return the corresponding value, if found.

theorem Finmap.extract_eq_lookup_erase E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (s : Finmap β),
  Finmap.extract a s = (Finmap.lookup a s, Finmap.erase a s)

def Finmap.union E1 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → Finmap β → Finmap β → Finmap β

s₁ ∪ s₂ is the key-based union of two finite maps. It is left-biased: if there exists an a ∈ s₁, lookup a (s₁ ∪ s₂) = lookup a s₁.

instance Finmap.instUnion E0 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → Union (Finmap β)

theorem Finmap.mem_union E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {s₁ s₂ : Finmap β}, a ∈ s₁ ∪ s₂ ↔ a ∈ s₁ ∨ a ∈ s₂

theorem Finmap.union_toFinmap E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (s₁ s₂ : AList β), s₁.toFinmap ∪ s₂.toFinmap = (s₁ ∪ s₂).toFinmap

theorem Finmap.keys_union E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s₁ s₂ : Finmap β}, (s₁ ∪ s₂).keys = s₁.keys ∪ s₂.keys

theorem Finmap.lookup_union_left E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {s₁ s₂ : Finmap β},
  a ∈ s₁ → Finmap.lookup a (s₁ ∪ s₂) = Finmap.lookup a s₁

theorem Finmap.lookup_union_right E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {s₁ s₂ : Finmap β},
  a ∉ s₁ → Finmap.lookup a (s₁ ∪ s₂) = Finmap.lookup a s₂

theorem Finmap.lookup_union_left_of_not_in E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {s₁ s₂ : Finmap β},
  a ∉ s₂ → Finmap.lookup a (s₁ ∪ s₂) = Finmap.lookup a s₁

theorem Finmap.mem_lookup_union' E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b : β a} {s₁ s₂ : Finmap β},
  Finmap.lookup a (s₁ ∪ s₂) = some b ↔ b ∈ Finmap.lookup a s₁ ∨ a ∉ s₁ ∧ b ∈ Finmap.lookup a s₂

simp-normal form of mem_lookup_union

theorem Finmap.mem_lookup_union E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b : β a} {s₁ s₂ : Finmap β},
  b ∈ Finmap.lookup a (s₁ ∪ s₂) ↔ b ∈ Finmap.lookup a s₁ ∨ a ∉ s₁ ∧ b ∈ Finmap.lookup a s₂

theorem Finmap.mem_lookup_union_middle E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b : β a} {s₁ s₂ s₃ : Finmap β},
  b ∈ Finmap.lookup a (s₁ ∪ s₃) → a ∉ s₂ → b ∈ Finmap.lookup a (s₁ ∪ s₂ ∪ s₃)

theorem Finmap.insert_union E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {a : α} {b : β a} {s₁ s₂ : Finmap β},
  Finmap.insert a b (s₁ ∪ s₂) = Finmap.insert a b s₁ ∪ s₂

theorem Finmap.union_assoc E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s₁ s₂ s₃ : Finmap β}, s₁ ∪ s₂ ∪ s₃ = s₁ ∪ (s₂ ∪ s₃)

theorem Finmap.empty_union E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s₁ : Finmap β}, ∅ ∪ s₁ = s₁

theorem Finmap.union_empty E0 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s₁ : Finmap β}, s₁ ∪ ∅ = s₁

theorem Finmap.erase_union_singleton E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (a : α) (b : β a) (s : Finmap β),
  Finmap.lookup a s = some b → Finmap.erase a s ∪ Finmap.singleton a b = s

def Finmap.Disjoint E1 #

{α : Type u} → {β : α → Type v} → Finmap β → Finmap β → Prop

Disjoint s₁ s₂ holds if s₁ and s₂ have no keys in common.

theorem Finmap.disjoint_empty E1 #

∀ {α : Type u} {β : α → Type v} (x : Finmap β), ∅.Disjoint x

theorem Finmap.Disjoint.symm E1 #

∀ {α : Type u} {β : α → Type v} (x y : Finmap β), x.Disjoint y → y.Disjoint x

theorem Finmap.Disjoint.symm_iff E0 #

∀ {α : Type u} {β : α → Type v} (x y : Finmap β), x.Disjoint y ↔ y.Disjoint x

instance Finmap.instDecidableRelDisjoint E0 #

{α : Type u} → {β : α → Type v} → [DecidableEq α] → DecidableRel Finmap.Disjoint

theorem Finmap.disjoint_union_left E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (x y z : Finmap β),
  (x ∪ y).Disjoint z ↔ x.Disjoint z ∧ y.Disjoint z

theorem Finmap.disjoint_union_right E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] (x y z : Finmap β),
  x.Disjoint (y ∪ z) ↔ x.Disjoint y ∧ x.Disjoint z

theorem Finmap.union_comm_of_disjoint E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s₁ s₂ : Finmap β}, s₁.Disjoint s₂ → s₁ ∪ s₂ = s₂ ∪ s₁

theorem Finmap.union_cancel E1 #

∀ {α : Type u} {β : α → Type v} [inst : DecidableEq α] {s₁ s₂ s₃ : Finmap β},
  s₁.Disjoint s₃ → s₂.Disjoint s₃ → (s₁ ∪ s₃ = s₂ ∪ s₃ ↔ s₁ = s₂)