@@ -847,6 +847,23 @@ public theorem values_mapOnValues [LT α] [StrictLT α] [DecidableLT α] [Decida
847847 unfold mapOnValues values
848848 induction m.1 <;> simp
849849
850+ @[simp]
851+ public theorem mapOnValues_mapOnValues [LT α] [StrictLT α] [DecidableLT α] [DecidableEq α] {f : β → γ} {g : γ → φ} {m : Map α β} :
852+ (m.mapOnValues f).mapOnValues g = m.mapOnValues (g ∘ f)
853+ := by simp [mapOnValues]
854+
855+ public theorem mapOnValues_restricted_id {f : β → β} {m : Map α β} :
856+ (∀ b ∈ m.values, f b = b) →
857+ m.mapOnValues f = m
858+ := by
859+ simp only [mapOnValues]
860+ cases m ; simp only [toList_mk_id, mk.injEq]
861+ intro h
862+ apply List.map_restricted_id
863+ intro pair hpair
864+ simp [h pair.snd (Map.in_list_in_values hpair)]
865+
866+ @[simp]
850867public theorem mapOnValues₂_eq_mapOnValues {α β γ} [SizeOf α] [SizeOf β] (m : Map α β) (f : β → γ) :
851868 m.mapOnValues₂ (λ x : { x : β // sizeOf x < sizeOf m } => f x.1 ) = m.mapOnValues f
852869:= by
@@ -988,40 +1005,31 @@ public theorem find?_none_iff_findorErr_errors [LT α] [DecidableLT α] [Decidab
9881005 exact findOrErr_err_iff_find?_none.symm
9891006
9901007/--
991- Converse of `in_toList_in_mapOnValues`; requires the extra preconditions that `m`
992- is `WellFormed` and `f` is injective
1008+ Converse of `in_toList_in_mapOnValues`; requires the extra precondition that `f` is injective
9931009-/
994- public theorem in_mapOnValues_in_toList [LT α] [DecidableLT α] [StrictLT α] [DecidableEq α] {f : β → γ} {m : Map α β} {k : α} {v : β}
995- (wf : m.WellFormed) :
1010+ public theorem in_mapOnValues_in_toList [LT α] [DecidableLT α] [StrictLT α] [DecidableEq α] {f : β → γ} {m : Map α β} {k : α} {v : β} :
9961011 (k, f v) ∈ (m.mapOnValues f).toList →
9971012 (∀ v', f v = f v' → v = v') → -- require f to be injective
9981013 (k, v) ∈ m.toList
9991014:= by
1000- rw [mapOnValues_eq_make_map f wf]
1001- unfold toList
1002- intro h₁ h_inj
1003- replace h₁ := make_mem_list_mem h₁
1004- replace ⟨(k', v'), h₁, h₂⟩ := List.mem_map.mp h₁
1005- simp only [Prod.mk.injEq] at h₂ ; replace ⟨h₂', h₂⟩ := h₂ ; subst k'
1006- specialize h_inj v' h₂.symm
1015+ simp only [toList, mapOnValues, List.mem_map, Prod.mk.injEq, Prod.exists, forall_exists_index,
1016+ and_imp]
1017+ intro a b h₁ _ h₂ h_inj ; subst a
1018+ specialize h_inj b h₂.symm
10071019 subst h_inj
10081020 exact h₁
10091021
10101022/--
10111023 Slightly different formulation of `in_mapOnValues_in_toList`
10121024-/
1013- public theorem in_mapOnValues_in_toList' [LT α] [DecidableLT α] [StrictLT α] [DecidableEq α] {f : β → γ} {m : Map α β} {k : α} {v' : γ}
1014- (wf : m.WellFormed) :
1025+ public theorem in_mapOnValues_in_toList' [LT α] [DecidableLT α] [StrictLT α] [DecidableEq α] {f : β → γ} {m : Map α β} {k : α} {v' : γ} :
10151026 (k, v') ∈ (m.mapOnValues f).toList →
10161027 ∃ v, f v = v' ∧ (k, v) ∈ m.toList
10171028:= by
1018- rw [mapOnValues_eq_make_map f wf]
1019- unfold toList
1020- intro h₁
1021- replace h₁ := make_mem_list_mem h₁
1022- replace ⟨(k', v'), h₁, h₂⟩ := List.mem_map.mp h₁
1023- simp only [Prod.mk.injEq] at h₂ ; replace ⟨h₂', h₂⟩ := h₂ ; subst k' h₂
1024- exists v'
1029+ simp only [mapOnValues, toList, List.mem_map, Prod.mk.injEq, Prod.exists,
1030+ forall_exists_index, and_imp]
1031+ intro a b h₁ _ _ ; subst a v'
1032+ exists b
10251033
10261034/-! ### mapMOnValues -/
10271035
0 commit comments