Map MOn Values preserves keys
Cedar.Data.Map.mapMOnValues_preserves_keys
Plain-language statement
This is not stated in terms of Map.keys because Map.keys produces a Set, and we want the even stronger property that it not only preserves the key-set, but also the key-order. (We'll use this to prove mapMOnValues_some_wf.)
Exact Lean statement
public theorem mapMOnValues_preserves_keys [LT α] [DecidableLT α] [StrictLT α] {f : β → Option γ} {m₁ : Map α β} {m₂ : Map α γ} :
m₁.mapMOnValues f = some m₂ →
m₁.toList.map Prod.fst = m₂.toList.map Prod.fstFormal artifact
Lean source
public theorem mapMOnValues_preserves_keys [LT α] [DecidableLT α] [StrictLT α] {f : β → Option γ} {m₁ : Map α β} {m₂ : Map α γ} : m₁.mapMOnValues f = some m₂ → m₁.toList.map Prod.fst = m₂.toList.map Prod.fst:= by intro h₁ simp only [mapMOnValues, Option.pure_def, Option.bind_eq_bind, Option.bind_eq_some_iff, Option.some.injEq] at h₁ replace ⟨xs, h₁, h₂⟩ := h₁ subst h₂ cases h₂ : m₁.toList <;> simp only [h₂, List.mapM_nil, List.mapM_cons, Option.pure_def, Option.bind_eq_bind, Option.bind_eq_some_iff, Option.some.injEq] at h₁ case nil => simp [h₁] case cons kv tl => have (k, v) := kv ; clear kv replace ⟨(k', y), ⟨y', h₁, h₃⟩, ⟨tl', h₄, h₅⟩⟩ := h₁ subst h₅ simp only [Prod.mk.injEq, List.map_cons, toList_mk_id, List.cons.injEq] at * replace ⟨h₃, h₃'⟩ := h₃ subst k' y' have ih := mapMOnValues_preserves_keys (m₁ := mk tl) (m₂ := mk tl') (f := f) simp only [mapMOnValues, Option.pure_def, Option.bind_eq_bind, toList_mk_id, Option.bind_eq_some_iff, Option.some.injEq, mk.injEq, exists_eq_right] at ih specialize ih h₄ simp [ih, and_self]- Project
- Cedar Specification
- License
- Apache-2.0
- Commit
- 3f093947b8ae
- Source
- cedar-lean/Cedar/Thm/Data/Map.lean:1110-1133
Reuse this declaration
Bring the exact result into your workflow
The import identifies the source module. Your project still needs the pinned package dependency shown on this page.
What this badge means
This completion status comes from the project or community source. It has not yet been represented here as an independent rebuild and axiom audit.
Continue in this project
Related declarations
Find? ext
Cedar.Data.Map.find?_ext
Plain-language statement
Two well-formed maps are equal if they have the same find? for every key.
Source project: Cedar Specification
Person-level attribution pending.
Find? notmem keys
Cedar.Data.Map.find?_notmem_keys
Plain-language statement
Inverse of find?_mem_toList, except that this requires wf
Source project: Cedar Specification
Person-level attribution pending.
Find? some iff in values
Cedar.Data.Map.find?_some_iff_in_values
Plain-language statement
The mp direction of this does not need the wf precondition and, in fact, is available separately as find?_some_implies_in_values above
Source project: Cedar Specification
Person-level attribution pending.