data.finsupp.alist
⟷
Mathlib.Data.Finsupp.AList
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(last sync)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Violeta Hernández
-/
import Data.Finsupp.Basic
-import Data.List.Alist
+import Data.List.AList
#align_import data.finsupp.alist from "leanprover-community/mathlib"@"0ebfdb71919ac6ca5d7fbc61a082fa2519556818"
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -35,8 +35,8 @@ noncomputable def toAList (f : α →₀ M) : AList fun x : α => M :=
by
rw [List.NodupKeys, List.keys, List.map_map, Prod.fst_comp_toSigma, List.nodup_map_iff_inj_on]
· rintro ⟨b, m⟩ hb ⟨c, n⟩ hc (rfl : b = c)
- rw [Finset.mem_toList, Finsupp.mem_graph_iff] at hb hc
- dsimp at hb hc
+ rw [Finset.mem_toList, Finsupp.mem_graph_iff] at hb hc
+ dsimp at hb hc
rw [← hc.1, hb.1]
· apply Finset.nodup_toList⟩
#align finsupp.to_alist Finsupp.toAList
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -51,7 +51,8 @@ theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) : f.toAList.key
#print Finsupp.mem_toAlist /-
@[simp]
-theorem mem_toAlist {f : α →₀ M} {x : α} : x ∈ f.toAList ↔ f x ≠ 0 := by classical
+theorem mem_toAlist {f : α →₀ M} {x : α} : x ∈ f.toAList ↔ f x ≠ 0 := by
+ classical rw [AList.mem_keys, ← List.mem_toFinset, to_alist_keys_to_finset, mem_support_iff]
#align finsupp.mem_to_alist Finsupp.mem_toAlist
-/
@@ -74,7 +75,10 @@ noncomputable def lookupFinsupp (l : AList fun x : α => M) : α →₀ M
toFun a :=
haveI := Classical.decEq α
(l.lookup a).getD 0
- mem_support_toFun a := by classical
+ mem_support_toFun a := by
+ classical
+ simp_rw [mem_to_finset, List.mem_keys, List.mem_filter, ← mem_lookup_iff]
+ cases lookup a l <;> simp
#align alist.lookup_finsupp AList.lookupFinsupp
-/
@@ -108,7 +112,10 @@ theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun x : α => M} {
#print AList.empty_lookupFinsupp /-
@[simp]
-theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun x : α => M) = 0 := by classical
+theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun x : α => M) = 0 := by
+ classical
+ ext
+ simp
#align alist.empty_lookup_finsupp AList.empty_lookupFinsupp
-/
@@ -123,7 +130,7 @@ theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun x : α => M) (a :
#print AList.singleton_lookupFinsupp /-
@[simp]
theorem singleton_lookupFinsupp (a : α) (m : M) :
- (singleton a m).lookupFinsupp = Finsupp.single a m := by classical
+ (singleton a m).lookupFinsupp = Finsupp.single a m := by classical simp [← AList.insert_empty]
#align alist.singleton_lookup_finsupp AList.singleton_lookupFinsupp
-/
@@ -133,6 +140,12 @@ theorem Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.lookupFinsup
by
ext
classical
+ by_cases h : f a = 0
+ · suffices f.to_alist.lookup a = none by simp [h, this]
+ · simp [lookup_eq_none, h]
+ · suffices f.to_alist.lookup a = some (f a) by simp [h, this]
+ · apply mem_lookup_iff.2
+ simpa using h
#align finsupp.to_alist_lookup_finsupp Finsupp.toAList_lookupFinsupp
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -51,8 +51,7 @@ theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) : f.toAList.key
#print Finsupp.mem_toAlist /-
@[simp]
-theorem mem_toAlist {f : α →₀ M} {x : α} : x ∈ f.toAList ↔ f x ≠ 0 := by
- classical rw [AList.mem_keys, ← List.mem_toFinset, to_alist_keys_to_finset, mem_support_iff]
+theorem mem_toAlist {f : α →₀ M} {x : α} : x ∈ f.toAList ↔ f x ≠ 0 := by classical
#align finsupp.mem_to_alist Finsupp.mem_toAlist
-/
@@ -75,10 +74,7 @@ noncomputable def lookupFinsupp (l : AList fun x : α => M) : α →₀ M
toFun a :=
haveI := Classical.decEq α
(l.lookup a).getD 0
- mem_support_toFun a := by
- classical
- simp_rw [mem_to_finset, List.mem_keys, List.mem_filter, ← mem_lookup_iff]
- cases lookup a l <;> simp
+ mem_support_toFun a := by classical
#align alist.lookup_finsupp AList.lookupFinsupp
-/
@@ -112,10 +108,7 @@ theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun x : α => M} {
#print AList.empty_lookupFinsupp /-
@[simp]
-theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun x : α => M) = 0 := by
- classical
- ext
- simp
+theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun x : α => M) = 0 := by classical
#align alist.empty_lookup_finsupp AList.empty_lookupFinsupp
-/
@@ -130,7 +123,7 @@ theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun x : α => M) (a :
#print AList.singleton_lookupFinsupp /-
@[simp]
theorem singleton_lookupFinsupp (a : α) (m : M) :
- (singleton a m).lookupFinsupp = Finsupp.single a m := by classical simp [← AList.insert_empty]
+ (singleton a m).lookupFinsupp = Finsupp.single a m := by classical
#align alist.singleton_lookup_finsupp AList.singleton_lookupFinsupp
-/
@@ -140,12 +133,6 @@ theorem Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.lookupFinsup
by
ext
classical
- by_cases h : f a = 0
- · suffices f.to_alist.lookup a = none by simp [h, this]
- · simp [lookup_eq_none, h]
- · suffices f.to_alist.lookup a = some (f a) by simp [h, this]
- · apply mem_lookup_iff.2
- simpa using h
#align finsupp.to_alist_lookup_finsupp Finsupp.toAList_lookupFinsupp
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,8 +3,8 @@ Copyright (c) 2022 Violeta Hernández. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Violeta Hernández
-/
-import Mathbin.Data.Finsupp.Basic
-import Mathbin.Data.List.Alist
+import Data.Finsupp.Basic
+import Data.List.Alist
#align_import data.finsupp.alist from "leanprover-community/mathlib"@"0ebfdb71919ac6ca5d7fbc61a082fa2519556818"
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,15 +2,12 @@
Copyright (c) 2022 Violeta Hernández. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Violeta Hernández
-
-! This file was ported from Lean 3 source module data.finsupp.alist
-! leanprover-community/mathlib commit 0ebfdb71919ac6ca5d7fbc61a082fa2519556818
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Finsupp.Basic
import Mathbin.Data.List.Alist
+#align_import data.finsupp.alist from "leanprover-community/mathlib"@"0ebfdb71919ac6ca5d7fbc61a082fa2519556818"
+
/-!
# Connections between `finsupp` and `alist`
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -45,15 +45,19 @@ noncomputable def toAList (f : α →₀ M) : AList fun x : α => M :=
#align finsupp.to_alist Finsupp.toAList
-/
+#print Finsupp.toAList_keys_toFinset /-
@[simp]
theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) : f.toAList.keys.toFinset = f.support :=
by ext; simp [to_alist, AList.mem_keys, AList.keys, List.keys]
#align finsupp.to_alist_keys_to_finset Finsupp.toAList_keys_toFinset
+-/
+#print Finsupp.mem_toAlist /-
@[simp]
theorem mem_toAlist {f : α →₀ M} {x : α} : x ∈ f.toAList ↔ f x ≠ 0 := by
classical rw [AList.mem_keys, ← List.mem_toFinset, to_alist_keys_to_finset, mem_support_iff]
#align finsupp.mem_to_alist Finsupp.mem_toAlist
+-/
end Finsupp
@@ -81,44 +85,59 @@ noncomputable def lookupFinsupp (l : AList fun x : α => M) : α →₀ M
#align alist.lookup_finsupp AList.lookupFinsupp
-/
+#print AList.lookupFinsupp_apply /-
@[simp]
theorem lookupFinsupp_apply [DecidableEq α] (l : AList fun x : α => M) (a : α) :
l.lookupFinsupp a = (l.dlookup a).getD 0 := by convert rfl
#align alist.lookup_finsupp_apply AList.lookupFinsupp_apply
+-/
+#print AList.lookupFinsupp_support /-
@[simp]
theorem lookupFinsupp_support [DecidableEq α] [DecidableEq M] (l : AList fun x : α => M) :
l.lookupFinsupp.support = (l.1.filterₓ fun x => Sigma.snd x ≠ 0).keys.toFinset := by convert rfl
#align alist.lookup_finsupp_support AList.lookupFinsupp_support
+-/
+#print AList.lookupFinsupp_eq_iff_of_ne_zero /-
theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun x : α => M} {a : α} {x : M}
(hx : x ≠ 0) : l.lookupFinsupp a = x ↔ x ∈ l.dlookup a := by rw [lookup_finsupp_apply];
cases' lookup a l with m <;> simp [hx.symm]
#align alist.lookup_finsupp_eq_iff_of_ne_zero AList.lookupFinsupp_eq_iff_of_ne_zero
+-/
+#print AList.lookupFinsupp_eq_zero_iff /-
theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun x : α => M} {a : α} :
l.lookupFinsupp a = 0 ↔ a ∉ l ∨ (0 : M) ∈ l.dlookup a := by
rw [lookup_finsupp_apply, ← lookup_eq_none]; cases' lookup a l with m <;> simp
#align alist.lookup_finsupp_eq_zero_iff AList.lookupFinsupp_eq_zero_iff
+-/
+#print AList.empty_lookupFinsupp /-
@[simp]
theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun x : α => M) = 0 := by
classical
ext
simp
#align alist.empty_lookup_finsupp AList.empty_lookupFinsupp
+-/
+#print AList.insert_lookupFinsupp /-
@[simp]
theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun x : α => M) (a : α) (m : M) :
(l.insert a m).lookupFinsupp = l.lookupFinsupp.update a m := by ext b;
by_cases h : b = a <;> simp [h]
#align alist.insert_lookup_finsupp AList.insert_lookupFinsupp
+-/
+#print AList.singleton_lookupFinsupp /-
@[simp]
theorem singleton_lookupFinsupp (a : α) (m : M) :
(singleton a m).lookupFinsupp = Finsupp.single a m := by classical simp [← AList.insert_empty]
#align alist.singleton_lookup_finsupp AList.singleton_lookupFinsupp
+-/
+#print Finsupp.toAList_lookupFinsupp /-
@[simp]
theorem Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.lookupFinsupp = f :=
by
@@ -131,10 +150,13 @@ theorem Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.lookupFinsup
· apply mem_lookup_iff.2
simpa using h
#align finsupp.to_alist_lookup_finsupp Finsupp.toAList_lookupFinsupp
+-/
+#print AList.lookupFinsupp_surjective /-
theorem lookupFinsupp_surjective : Function.Surjective (@lookupFinsupp α M _) := fun f =>
⟨_, Finsupp.toAList_lookupFinsupp f⟩
#align alist.lookup_finsupp_surjective AList.lookupFinsupp_surjective
+-/
end AList
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -76,8 +76,8 @@ noncomputable def lookupFinsupp (l : AList fun x : α => M) : α →₀ M
(l.lookup a).getD 0
mem_support_toFun a := by
classical
- simp_rw [mem_to_finset, List.mem_keys, List.mem_filter, ← mem_lookup_iff]
- cases lookup a l <;> simp
+ simp_rw [mem_to_finset, List.mem_keys, List.mem_filter, ← mem_lookup_iff]
+ cases lookup a l <;> simp
#align alist.lookup_finsupp AList.lookupFinsupp
-/
@@ -104,8 +104,8 @@ theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun x : α => M} {
@[simp]
theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun x : α => M) = 0 := by
classical
- ext
- simp
+ ext
+ simp
#align alist.empty_lookup_finsupp AList.empty_lookupFinsupp
@[simp]
@@ -124,12 +124,12 @@ theorem Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.lookupFinsup
by
ext
classical
- by_cases h : f a = 0
- · suffices f.to_alist.lookup a = none by simp [h, this]
- · simp [lookup_eq_none, h]
- · suffices f.to_alist.lookup a = some (f a) by simp [h, this]
- · apply mem_lookup_iff.2
- simpa using h
+ by_cases h : f a = 0
+ · suffices f.to_alist.lookup a = none by simp [h, this]
+ · simp [lookup_eq_none, h]
+ · suffices f.to_alist.lookup a = some (f a) by simp [h, this]
+ · apply mem_lookup_iff.2
+ simpa using h
#align finsupp.to_alist_lookup_finsupp Finsupp.toAList_lookupFinsupp
theorem lookupFinsupp_surjective : Function.Surjective (@lookupFinsupp α M _) := fun f =>
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -38,8 +38,8 @@ noncomputable def toAList (f : α →₀ M) : AList fun x : α => M :=
by
rw [List.NodupKeys, List.keys, List.map_map, Prod.fst_comp_toSigma, List.nodup_map_iff_inj_on]
· rintro ⟨b, m⟩ hb ⟨c, n⟩ hc (rfl : b = c)
- rw [Finset.mem_toList, Finsupp.mem_graph_iff] at hb hc
- dsimp at hb hc
+ rw [Finset.mem_toList, Finsupp.mem_graph_iff] at hb hc
+ dsimp at hb hc
rw [← hc.1, hb.1]
· apply Finset.nodup_toList⟩
#align finsupp.to_alist Finsupp.toAList
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -45,23 +45,11 @@ noncomputable def toAList (f : α →₀ M) : AList fun x : α => M :=
#align finsupp.to_alist Finsupp.toAList
-/
-/- warning: finsupp.to_alist_keys_to_finset -> Finsupp.toAList_keys_toFinset is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] (f : Finsupp.{u1, u2} α M _inst_1), Eq.{succ u1} (Finset.{u1} α) (List.toFinset.{u1} α (fun (a : α) (b : α) => _inst_2 a b) (AList.keys.{u1, u2} α (fun (x : α) => M) (Finsupp.toAList.{u1, u2} α M _inst_1 f))) (Finsupp.support.{u1, u2} α M _inst_1 f)
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] (f : Finsupp.{u2, u1} α M _inst_1), Eq.{succ u2} (Finset.{u2} α) (List.toFinset.{u2} α (fun (a : α) (b : α) => _inst_2 a b) (AList.keys.{u2, u1} α (fun (x : α) => M) (Finsupp.toAList.{u2, u1} α M _inst_1 f))) (Finsupp.support.{u2, u1} α M _inst_1 f)
-Case conversion may be inaccurate. Consider using '#align finsupp.to_alist_keys_to_finset Finsupp.toAList_keys_toFinsetₓ'. -/
@[simp]
theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) : f.toAList.keys.toFinset = f.support :=
by ext; simp [to_alist, AList.mem_keys, AList.keys, List.keys]
#align finsupp.to_alist_keys_to_finset Finsupp.toAList_keys_toFinset
-/- warning: finsupp.mem_to_alist -> Finsupp.mem_toAlist is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] {f : Finsupp.{u1, u2} α M _inst_1} {x : α}, Iff (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasMem.{u1, u2} α (fun (x : α) => M)) x (Finsupp.toAList.{u1, u2} α M _inst_1 f)) (Ne.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.coeFun.{u1, u2} α M _inst_1) f x) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))))
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] {f : Finsupp.{u2, u1} α M _inst_1} {x : α}, Iff (Membership.mem.{u2, max u2 u1} α (AList.{u2, u1} α (fun (x : α) => M)) (AList.instMembershipAList.{u2, u1} α (fun (x : α) => M)) x (Finsupp.toAList.{u2, u1} α M _inst_1 f)) (Ne.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) f x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) x) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) x) _inst_1)))
-Case conversion may be inaccurate. Consider using '#align finsupp.mem_to_alist Finsupp.mem_toAlistₓ'. -/
@[simp]
theorem mem_toAlist {f : α →₀ M} {x : α} : x ∈ f.toAList ↔ f x ≠ 0 := by
classical rw [AList.mem_keys, ← List.mem_toFinset, to_alist_keys_to_finset, mem_support_iff]
@@ -93,56 +81,26 @@ noncomputable def lookupFinsupp (l : AList fun x : α => M) : α →₀ M
#align alist.lookup_finsupp AList.lookupFinsupp
-/
-/- warning: alist.lookup_finsupp_apply -> AList.lookupFinsupp_apply is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] (l : AList.{u1, u2} α (fun (x : α) => M)) (a : α), Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.coeFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) (Option.getD.{u2} M (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))))
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] (l : AList.{u2, u1} α (fun (x : α) => M)) (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a) (Option.getD.{u1} M (AList.lookup.{u2, u1} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1)))
-Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_apply AList.lookupFinsupp_applyₓ'. -/
@[simp]
theorem lookupFinsupp_apply [DecidableEq α] (l : AList fun x : α => M) (a : α) :
l.lookupFinsupp a = (l.dlookup a).getD 0 := by convert rfl
#align alist.lookup_finsupp_apply AList.lookupFinsupp_apply
-/- warning: alist.lookup_finsupp_support -> AList.lookupFinsupp_support is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] [_inst_3 : DecidableEq.{succ u2} M] (l : AList.{u1, u2} α (fun (x : α) => M)), Eq.{succ u1} (Finset.{u1} α) (Finsupp.support.{u1, u2} α M _inst_1 (AList.lookupFinsupp.{u1, u2} α M _inst_1 l)) (List.toFinset.{u1} α (fun (a : α) (b : α) => _inst_2 a b) (List.keys.{u1, u2} α (fun (x : α) => M) (List.filterₓ.{max u1 u2} (Sigma.{u1, u2} α (fun (x : α) => M)) (fun (x : Sigma.{u1, u2} α (fun (x : α) => M)) => Ne.{succ u2} M (Sigma.snd.{u1, u2} α (fun (x : α) => M) x) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1)))) (fun (a : Sigma.{u1, u2} α (fun (x : α) => M)) => Ne.decidable.{succ u2} ((fun (x : α) => M) (Sigma.fst.{u1, u2} α (fun (x : α) => M) a)) (fun (a : M) (b : M) => _inst_3 a b) (Sigma.snd.{u1, u2} α (fun (x : α) => M) a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1)))) (AList.entries.{u1, u2} α (fun (x : α) => M) l))))
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] [_inst_3 : DecidableEq.{succ u1} M] (l : AList.{u2, u1} α (fun (x : α) => M)), Eq.{succ u2} (Finset.{u2} α) (Finsupp.support.{u2, u1} α M _inst_1 (AList.lookupFinsupp.{u2, u1} α M _inst_1 l)) (List.toFinset.{u2} α (fun (a : α) (b : α) => _inst_2 a b) (List.keys.{u2, u1} α (fun (x : α) => M) (List.filter.{max u1 u2} (Sigma.{u2, u1} α (fun (_x : α) => M)) (fun (a : Sigma.{u2, u1} α (fun (x : α) => M)) => Decidable.decide (Ne.{succ u1} M (Sigma.snd.{u2, u1} α (fun (_x : α) => M) a) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1))) (instDecidableNot (Eq.{succ u1} M (Sigma.snd.{u2, u1} α (fun (_x : α) => M) a) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1))) (_inst_3 (Sigma.snd.{u2, u1} α (fun (_x : α) => M) a) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1))))) (AList.entries.{u2, u1} α (fun (x : α) => M) l))))
-Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_support AList.lookupFinsupp_supportₓ'. -/
@[simp]
theorem lookupFinsupp_support [DecidableEq α] [DecidableEq M] (l : AList fun x : α => M) :
l.lookupFinsupp.support = (l.1.filterₓ fun x => Sigma.snd x ≠ 0).keys.toFinset := by convert rfl
#align alist.lookup_finsupp_support AList.lookupFinsupp_support
-/- warning: alist.lookup_finsupp_eq_iff_of_ne_zero -> AList.lookupFinsupp_eq_iff_of_ne_zero is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] {l : AList.{u1, u2} α (fun (x : α) => M)} {a : α} {x : M}, (Ne.{succ u2} M x (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1)))) -> (Iff (Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.coeFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) x) (Membership.Mem.{u2, u2} M (Option.{u2} M) (Option.hasMem.{u2} M) x (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] {l : AList.{u2, u1} α (fun (x : α) => M)} {a : α} {x : M}, (Ne.{succ u1} M x (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1))) -> (Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a) x) (Membership.mem.{u1, u1} M (Option.{u1} M) (Option.instMembershipOption.{u1} M) x (AList.lookup.{u2, u1} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
-Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_eq_iff_of_ne_zero AList.lookupFinsupp_eq_iff_of_ne_zeroₓ'. -/
theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun x : α => M} {a : α} {x : M}
(hx : x ≠ 0) : l.lookupFinsupp a = x ↔ x ∈ l.dlookup a := by rw [lookup_finsupp_apply];
cases' lookup a l with m <;> simp [hx.symm]
#align alist.lookup_finsupp_eq_iff_of_ne_zero AList.lookupFinsupp_eq_iff_of_ne_zero
-/- warning: alist.lookup_finsupp_eq_zero_iff -> AList.lookupFinsupp_eq_zero_iff is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] {l : AList.{u1, u2} α (fun (x : α) => M)} {a : α}, Iff (Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.coeFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1)))) (Or (Not (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasMem.{u1, u2} α (fun (x : α) => M)) a l)) (Membership.Mem.{u2, u2} M (Option.{u2} M) (Option.hasMem.{u2} M) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))) (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] {l : AList.{u2, u1} α (fun (x : α) => M)} {a : α}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) _inst_1))) (Or (Not (Membership.mem.{u2, max u2 u1} α (AList.{u2, u1} α (fun (x : α) => M)) (AList.instMembershipAList.{u2, u1} α (fun (x : α) => M)) a l)) (Membership.mem.{u1, u1} M (Option.{u1} M) (Option.instMembershipOption.{u1} M) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1)) (AList.lookup.{u2, u1} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
-Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_eq_zero_iff AList.lookupFinsupp_eq_zero_iffₓ'. -/
theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun x : α => M} {a : α} :
l.lookupFinsupp a = 0 ↔ a ∉ l ∨ (0 : M) ∈ l.dlookup a := by
rw [lookup_finsupp_apply, ← lookup_eq_none]; cases' lookup a l with m <;> simp
#align alist.lookup_finsupp_eq_zero_iff AList.lookupFinsupp_eq_zero_iff
-/- warning: alist.empty_lookup_finsupp -> AList.empty_lookupFinsupp is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M], Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasEmptyc.{u1, u2} α (fun (x : α) => M)))) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) (Finsupp.zero.{u1, u2} α M _inst_1))))
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M], Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 (EmptyCollection.emptyCollection.{max u2 u1} (AList.{u2, u1} α (fun (x : α) => M)) (AList.instEmptyCollectionAList.{u2, u1} α (fun (x : α) => M)))) (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} α M _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} α M _inst_1) (Finsupp.zero.{u2, u1} α M _inst_1)))
-Case conversion may be inaccurate. Consider using '#align alist.empty_lookup_finsupp AList.empty_lookupFinsuppₓ'. -/
@[simp]
theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun x : α => M) = 0 := by
classical
@@ -150,35 +108,17 @@ theorem empty_lookupFinsupp : lookupFinsupp (∅ : AList fun x : α => M) = 0 :=
simp
#align alist.empty_lookup_finsupp AList.empty_lookupFinsupp
-/- warning: alist.insert_lookup_finsupp -> AList.insert_lookupFinsupp is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] (l : AList.{u1, u2} α (fun (x : α) => M)) (a : α) (m : M), Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 (AList.insert.{u1, u2} α (fun (a : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a m l)) (Finsupp.update.{u1, u2} α M _inst_1 (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a m)
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] (l : AList.{u2, u1} α (fun (x : α) => M)) (a : α) (m : M), Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 (AList.insert.{u2, u1} α (fun (a : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a m l)) (Finsupp.update.{u2, u1} α M _inst_1 (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a m)
-Case conversion may be inaccurate. Consider using '#align alist.insert_lookup_finsupp AList.insert_lookupFinsuppₓ'. -/
@[simp]
theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun x : α => M) (a : α) (m : M) :
(l.insert a m).lookupFinsupp = l.lookupFinsupp.update a m := by ext b;
by_cases h : b = a <;> simp [h]
#align alist.insert_lookup_finsupp AList.insert_lookupFinsupp
-/- warning: alist.singleton_lookup_finsupp -> AList.singleton_lookupFinsupp is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] (a : α) (m : M), Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 (AList.singleton.{u1, u2} α (fun (a : α) => M) a m)) (Finsupp.single.{u1, u2} α M _inst_1 a m)
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] (a : α) (m : M), Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 (AList.singleton.{u2, u1} α (fun (a : α) => M) a m)) (Finsupp.single.{u2, u1} α M _inst_1 a m)
-Case conversion may be inaccurate. Consider using '#align alist.singleton_lookup_finsupp AList.singleton_lookupFinsuppₓ'. -/
@[simp]
theorem singleton_lookupFinsupp (a : α) (m : M) :
(singleton a m).lookupFinsupp = Finsupp.single a m := by classical simp [← AList.insert_empty]
#align alist.singleton_lookup_finsupp AList.singleton_lookupFinsupp
-/- warning: finsupp.to_alist_lookup_finsupp -> Finsupp.toAList_lookupFinsupp is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] (f : Finsupp.{u1, u2} α M _inst_1), Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 (Finsupp.toAList.{u1, u2} α M _inst_1 f)) f
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] (f : Finsupp.{u2, u1} α M _inst_1), Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 (Finsupp.toAList.{u2, u1} α M _inst_1 f)) f
-Case conversion may be inaccurate. Consider using '#align finsupp.to_alist_lookup_finsupp Finsupp.toAList_lookupFinsuppₓ'. -/
@[simp]
theorem Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.lookupFinsupp = f :=
by
@@ -192,12 +132,6 @@ theorem Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.lookupFinsup
simpa using h
#align finsupp.to_alist_lookup_finsupp Finsupp.toAList_lookupFinsupp
-/- warning: alist.lookup_finsupp_surjective -> AList.lookupFinsupp_surjective is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M], Function.Surjective.{succ (max u1 u2), max (succ u1) (succ u2)} (AList.{u1, u2} α (fun (x : α) => M)) (Finsupp.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1)
-but is expected to have type
- forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M], Function.Surjective.{max (succ u2) (succ u1), max (succ u2) (succ u1)} (AList.{u2, u1} α (fun (x : α) => M)) (Finsupp.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1)
-Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_surjective AList.lookupFinsupp_surjectiveₓ'. -/
theorem lookupFinsupp_surjective : Function.Surjective (@lookupFinsupp α M _) := fun f =>
⟨_, Finsupp.toAList_lookupFinsupp f⟩
#align alist.lookup_finsupp_surjective AList.lookupFinsupp_surjective
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -53,9 +53,7 @@ but is expected to have type
Case conversion may be inaccurate. Consider using '#align finsupp.to_alist_keys_to_finset Finsupp.toAList_keys_toFinsetₓ'. -/
@[simp]
theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) : f.toAList.keys.toFinset = f.support :=
- by
- ext
- simp [to_alist, AList.mem_keys, AList.keys, List.keys]
+ by ext; simp [to_alist, AList.mem_keys, AList.keys, List.keys]
#align finsupp.to_alist_keys_to_finset Finsupp.toAList_keys_toFinset
/- warning: finsupp.mem_to_alist -> Finsupp.mem_toAlist is a dubious translation:
@@ -124,9 +122,7 @@ but is expected to have type
forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] {l : AList.{u2, u1} α (fun (x : α) => M)} {a : α} {x : M}, (Ne.{succ u1} M x (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1))) -> (Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a) x) (Membership.mem.{u1, u1} M (Option.{u1} M) (Option.instMembershipOption.{u1} M) x (AList.lookup.{u2, u1} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_eq_iff_of_ne_zero AList.lookupFinsupp_eq_iff_of_ne_zeroₓ'. -/
theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun x : α => M} {a : α} {x : M}
- (hx : x ≠ 0) : l.lookupFinsupp a = x ↔ x ∈ l.dlookup a :=
- by
- rw [lookup_finsupp_apply]
+ (hx : x ≠ 0) : l.lookupFinsupp a = x ↔ x ∈ l.dlookup a := by rw [lookup_finsupp_apply];
cases' lookup a l with m <;> simp [hx.symm]
#align alist.lookup_finsupp_eq_iff_of_ne_zero AList.lookupFinsupp_eq_iff_of_ne_zero
@@ -137,10 +133,8 @@ but is expected to have type
forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] {l : AList.{u2, u1} α (fun (x : α) => M)} {a : α}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) _inst_1))) (Or (Not (Membership.mem.{u2, max u2 u1} α (AList.{u2, u1} α (fun (x : α) => M)) (AList.instMembershipAList.{u2, u1} α (fun (x : α) => M)) a l)) (Membership.mem.{u1, u1} M (Option.{u1} M) (Option.instMembershipOption.{u1} M) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1)) (AList.lookup.{u2, u1} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_eq_zero_iff AList.lookupFinsupp_eq_zero_iffₓ'. -/
theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun x : α => M} {a : α} :
- l.lookupFinsupp a = 0 ↔ a ∉ l ∨ (0 : M) ∈ l.dlookup a :=
- by
- rw [lookup_finsupp_apply, ← lookup_eq_none]
- cases' lookup a l with m <;> simp
+ l.lookupFinsupp a = 0 ↔ a ∉ l ∨ (0 : M) ∈ l.dlookup a := by
+ rw [lookup_finsupp_apply, ← lookup_eq_none]; cases' lookup a l with m <;> simp
#align alist.lookup_finsupp_eq_zero_iff AList.lookupFinsupp_eq_zero_iff
/- warning: alist.empty_lookup_finsupp -> AList.empty_lookupFinsupp is a dubious translation:
@@ -164,9 +158,7 @@ but is expected to have type
Case conversion may be inaccurate. Consider using '#align alist.insert_lookup_finsupp AList.insert_lookupFinsuppₓ'. -/
@[simp]
theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun x : α => M) (a : α) (m : M) :
- (l.insert a m).lookupFinsupp = l.lookupFinsupp.update a m :=
- by
- ext b
+ (l.insert a m).lookupFinsupp = l.lookupFinsupp.update a m := by ext b;
by_cases h : b = a <;> simp [h]
#align alist.insert_lookup_finsupp AList.insert_lookupFinsupp
mathlib commit https://github.com/leanprover-community/mathlib/commit/62e8311c791f02c47451bf14aa2501048e7c2f33
@@ -60,7 +60,7 @@ theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) : f.toAList.key
/- warning: finsupp.mem_to_alist -> Finsupp.mem_toAlist is a dubious translation:
lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] {f : Finsupp.{u1, u2} α M _inst_1} {x : α}, Iff (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasMem.{u1, u2} α (fun (x : α) => M)) x (Finsupp.toAList.{u1, u2} α M _inst_1 f)) (Ne.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.hasCoeToFun.{u1, u2} α M _inst_1) f x) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))))
+ forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] {f : Finsupp.{u1, u2} α M _inst_1} {x : α}, Iff (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasMem.{u1, u2} α (fun (x : α) => M)) x (Finsupp.toAList.{u1, u2} α M _inst_1 f)) (Ne.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.coeFun.{u1, u2} α M _inst_1) f x) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))))
but is expected to have type
forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] {f : Finsupp.{u2, u1} α M _inst_1} {x : α}, Iff (Membership.mem.{u2, max u2 u1} α (AList.{u2, u1} α (fun (x : α) => M)) (AList.instMembershipAList.{u2, u1} α (fun (x : α) => M)) x (Finsupp.toAList.{u2, u1} α M _inst_1 f)) (Ne.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) x) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) f x) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) x) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) x) _inst_1)))
Case conversion may be inaccurate. Consider using '#align finsupp.mem_to_alist Finsupp.mem_toAlistₓ'. -/
@@ -97,7 +97,7 @@ noncomputable def lookupFinsupp (l : AList fun x : α => M) : α →₀ M
/- warning: alist.lookup_finsupp_apply -> AList.lookupFinsupp_apply is a dubious translation:
lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] (l : AList.{u1, u2} α (fun (x : α) => M)) (a : α), Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.hasCoeToFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) (Option.getD.{u2} M (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))))
+ forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] (l : AList.{u1, u2} α (fun (x : α) => M)) (a : α), Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.coeFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) (Option.getD.{u2} M (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))))
but is expected to have type
forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] (l : AList.{u2, u1} α (fun (x : α) => M)) (a : α), Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a) (Option.getD.{u1} M (AList.lookup.{u2, u1} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1)))
Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_apply AList.lookupFinsupp_applyₓ'. -/
@@ -119,7 +119,7 @@ theorem lookupFinsupp_support [DecidableEq α] [DecidableEq M] (l : AList fun x
/- warning: alist.lookup_finsupp_eq_iff_of_ne_zero -> AList.lookupFinsupp_eq_iff_of_ne_zero is a dubious translation:
lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] {l : AList.{u1, u2} α (fun (x : α) => M)} {a : α} {x : M}, (Ne.{succ u2} M x (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1)))) -> (Iff (Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.hasCoeToFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) x) (Membership.Mem.{u2, u2} M (Option.{u2} M) (Option.hasMem.{u2} M) x (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
+ forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] {l : AList.{u1, u2} α (fun (x : α) => M)} {a : α} {x : M}, (Ne.{succ u2} M x (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1)))) -> (Iff (Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.coeFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) x) (Membership.Mem.{u2, u2} M (Option.{u2} M) (Option.hasMem.{u2} M) x (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
but is expected to have type
forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] {l : AList.{u2, u1} α (fun (x : α) => M)} {a : α} {x : M}, (Ne.{succ u1} M x (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1))) -> (Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a) x) (Membership.mem.{u1, u1} M (Option.{u1} M) (Option.instMembershipOption.{u1} M) x (AList.lookup.{u2, u1} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_eq_iff_of_ne_zero AList.lookupFinsupp_eq_iff_of_ne_zeroₓ'. -/
@@ -132,7 +132,7 @@ theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun x : α =
/- warning: alist.lookup_finsupp_eq_zero_iff -> AList.lookupFinsupp_eq_zero_iff is a dubious translation:
lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] {l : AList.{u1, u2} α (fun (x : α) => M)} {a : α}, Iff (Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.hasCoeToFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1)))) (Or (Not (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasMem.{u1, u2} α (fun (x : α) => M)) a l)) (Membership.Mem.{u2, u2} M (Option.{u2} M) (Option.hasMem.{u2} M) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))) (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
+ forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M] [_inst_2 : DecidableEq.{succ u1} α] {l : AList.{u1, u2} α (fun (x : α) => M)} {a : α}, Iff (Eq.{succ u2} M (coeFn.{max (succ u1) (succ u2), max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (fun (_x : Finsupp.{u1, u2} α M _inst_1) => α -> M) (Finsupp.coeFun.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 l) a) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1)))) (Or (Not (Membership.Mem.{u1, max u1 u2} α (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasMem.{u1, u2} α (fun (x : α) => M)) a l)) (Membership.Mem.{u2, u2} M (Option.{u2} M) (Option.hasMem.{u2} M) (OfNat.ofNat.{u2} M 0 (OfNat.mk.{u2} M 0 (Zero.zero.{u2} M _inst_1))) (AList.lookup.{u1, u2} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
but is expected to have type
forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M] [_inst_2 : DecidableEq.{succ u2} α] {l : AList.{u2, u1} α (fun (x : α) => M)} {a : α}, Iff (Eq.{succ u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) (FunLike.coe.{max (succ u2) (succ u1), succ u2, succ u1} (Finsupp.{u2, u1} α M _inst_1) α (fun (_x : α) => (fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) _x) (Finsupp.funLike.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 l) a) (OfNat.ofNat.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) 0 (Zero.toOfNat0.{u1} ((fun (x._@.Mathlib.Data.Finsupp.Defs._hyg.779 : α) => M) a) _inst_1))) (Or (Not (Membership.mem.{u2, max u2 u1} α (AList.{u2, u1} α (fun (x : α) => M)) (AList.instMembershipAList.{u2, u1} α (fun (x : α) => M)) a l)) (Membership.mem.{u1, u1} M (Option.{u1} M) (Option.instMembershipOption.{u1} M) (OfNat.ofNat.{u1} M 0 (Zero.toOfNat0.{u1} M _inst_1)) (AList.lookup.{u2, u1} α (fun (x : α) => M) (fun (a : α) (b : α) => _inst_2 a b) a l)))
Case conversion may be inaccurate. Consider using '#align alist.lookup_finsupp_eq_zero_iff AList.lookupFinsupp_eq_zero_iffₓ'. -/
@@ -145,7 +145,7 @@ theorem lookupFinsupp_eq_zero_iff [DecidableEq α] {l : AList fun x : α => M} {
/- warning: alist.empty_lookup_finsupp -> AList.empty_lookupFinsupp is a dubious translation:
lean 3 declaration is
- forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M], Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasEmptyc.{u1, u2} α (fun (x : α) => M)))) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) (Finsupp.hasZero.{u1, u2} α M _inst_1))))
+ forall {α : Type.{u1}} {M : Type.{u2}} [_inst_1 : Zero.{u2} M], Eq.{max (succ u1) (succ u2)} (Finsupp.{u1, u2} α M _inst_1) (AList.lookupFinsupp.{u1, u2} α M _inst_1 (EmptyCollection.emptyCollection.{max u1 u2} (AList.{u1, u2} α (fun (x : α) => M)) (AList.hasEmptyc.{u1, u2} α (fun (x : α) => M)))) (OfNat.ofNat.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) 0 (OfNat.mk.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) 0 (Zero.zero.{max u1 u2} (Finsupp.{u1, u2} α M _inst_1) (Finsupp.zero.{u1, u2} α M _inst_1))))
but is expected to have type
forall {α : Type.{u2}} {M : Type.{u1}} [_inst_1 : Zero.{u1} M], Eq.{max (succ u2) (succ u1)} (Finsupp.{u2, u1} α M _inst_1) (AList.lookupFinsupp.{u2, u1} α M _inst_1 (EmptyCollection.emptyCollection.{max u2 u1} (AList.{u2, u1} α (fun (x : α) => M)) (AList.instEmptyCollectionAList.{u2, u1} α (fun (x : α) => M)))) (OfNat.ofNat.{max u2 u1} (Finsupp.{u2, u1} α M _inst_1) 0 (Zero.toOfNat0.{max u2 u1} (Finsupp.{u2, u1} α M _inst_1) (Finsupp.zero.{u2, u1} α M _inst_1)))
Case conversion may be inaccurate. Consider using '#align alist.empty_lookup_finsupp AList.empty_lookupFinsuppₓ'. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -127,10 +127,10 @@ theorem _root_.Finsupp.toAList_lookupFinsupp (f : α →₀ M) : f.toAList.looku
classical
by_cases h : f a = 0
· suffices f.toAList.lookup a = none by simp [h, this]
- · simp [lookup_eq_none, h]
+ simp [lookup_eq_none, h]
· suffices f.toAList.lookup a = some (f a) by simp [h, this]
- · apply mem_lookup_iff.2
- simpa using h
+ apply mem_lookup_iff.2
+ simpa using h
#align finsupp.to_alist_lookup_finsupp Finsupp.toAList_lookupFinsupp
theorem lookupFinsupp_surjective : Function.Surjective (@lookupFinsupp α M _) := fun f =>
@@ -117,7 +117,7 @@ theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun _x : α => M) (a :
theorem singleton_lookupFinsupp (a : α) (m : M) :
(singleton a m).lookupFinsupp = Finsupp.single a m := by
classical
- -- porting note: was `simp [← AList.insert_empty]` but timeout issues
+ -- porting note (#10745): was `simp [← AList.insert_empty]` but timeout issues
simp only [← AList.insert_empty, insert_lookupFinsupp, empty_lookupFinsupp, Finsupp.zero_update]
#align alist.singleton_lookup_finsupp AList.singleton_lookupFinsupp
@@ -117,7 +117,7 @@ theorem insert_lookupFinsupp [DecidableEq α] (l : AList fun _x : α => M) (a :
theorem singleton_lookupFinsupp (a : α) (m : M) :
(singleton a m).lookupFinsupp = Finsupp.single a m := by
classical
- -- porting note: was `simp [←AList.insert_empty]` but timeout issues
+ -- porting note: was `simp [← AList.insert_empty]` but timeout issues
simp only [← AList.insert_empty, insert_lookupFinsupp, empty_lookupFinsupp, Finsupp.zero_update]
#align alist.singleton_lookup_finsupp AList.singleton_lookupFinsupp
@@ -76,17 +76,15 @@ noncomputable def lookupFinsupp (l : AList fun _x : α => M) : α →₀ M
@[simp]
theorem lookupFinsupp_apply [DecidableEq α] (l : AList fun _x : α => M) (a : α) :
l.lookupFinsupp a = (l.lookup a).getD 0 := by
- -- porting note: was `convert rfl`
- simp only [lookupFinsupp, ne_eq, Finsupp.coe_mk]; congr
+ convert rfl; congr
#align alist.lookup_finsupp_apply AList.lookupFinsupp_apply
@[simp]
theorem lookupFinsupp_support [DecidableEq α] [DecidableEq M] (l : AList fun _x : α => M) :
l.lookupFinsupp.support = (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset := by
- -- porting note: was `convert rfl`
- simp only [lookupFinsupp, ne_eq, Finsupp.coe_mk]; congr
- · apply Subsingleton.elim
- · funext; congr
+ convert rfl; congr
+ · apply Subsingleton.elim
+ · funext; congr
#align alist.lookup_finsupp_support AList.lookupFinsupp_support
theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun _x : α => M} {a : α} {x : M}
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -22,7 +22,7 @@ import Mathlib.Data.List.AList
namespace Finsupp
-variable {α M : Type _} [Zero M]
+variable {α M : Type*} [Zero M]
/-- Produce an association list for the finsupp over its support using choice. -/
@[simps]
@@ -53,7 +53,7 @@ end Finsupp
namespace AList
-variable {α M : Type _} [Zero M]
+variable {α M : Type*} [Zero M]
open List
@@ -2,15 +2,12 @@
Copyright (c) 2022 Violeta Hernández. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Violeta Hernández
-
-! This file was ported from Lean 3 source module data.finsupp.alist
-! leanprover-community/mathlib commit 59694bd07f0a39c5beccba34bd9f413a160782bf
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Finsupp.Basic
import Mathlib.Data.List.AList
+#align_import data.finsupp.alist from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf"
+
/-!
# Connections between `Finsupp` and `AList`
This is the second half of the changes originally in #5699, removing all occurrences of ;
after a space and implementing a linter rule to enforce it.
In most cases this 2-character substring has a space after it, so the following command was run first:
find . -type f -name "*.lean" -exec sed -i -E 's/ ; /; /g' {} \;
The remaining cases were few enough in number that they were done manually.
@@ -65,8 +65,8 @@ absent keys to zero. -/
noncomputable def lookupFinsupp (l : AList fun _x : α => M) : α →₀ M
where
support := by
- haveI := Classical.decEq α ; haveI := Classical.decEq M ;
- exact (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset
+ haveI := Classical.decEq α; haveI := Classical.decEq M
+ exact (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset
toFun a :=
haveI := Classical.decEq α
(l.lookup a).getD 0
@@ -89,7 +89,7 @@ theorem lookupFinsupp_support [DecidableEq α] [DecidableEq M] (l : AList fun _x
-- porting note: was `convert rfl`
simp only [lookupFinsupp, ne_eq, Finsupp.coe_mk]; congr
· apply Subsingleton.elim
- · funext ; congr
+ · funext; congr
#align alist.lookup_finsupp_support AList.lookupFinsupp_support
theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun _x : α => M} {a : α} {x : M}
This PR is the result of running
find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;
which firstly replaces .
focusing dots with ·
and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.
@@ -88,8 +88,8 @@ theorem lookupFinsupp_support [DecidableEq α] [DecidableEq M] (l : AList fun _x
l.lookupFinsupp.support = (l.1.filter fun x => Sigma.snd x ≠ 0).keys.toFinset := by
-- porting note: was `convert rfl`
simp only [lookupFinsupp, ne_eq, Finsupp.coe_mk]; congr
- . apply Subsingleton.elim
- . funext ; congr
+ · apply Subsingleton.elim
+ · funext ; congr
#align alist.lookup_finsupp_support AList.lookupFinsupp_support
theorem lookupFinsupp_eq_iff_of_ne_zero [DecidableEq α] {l : AList fun _x : α => M} {a : α} {x : M}
by
s! (#3825)
This PR puts, with one exception, every single remaining by
that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh
. The exception is when the by
begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.
Essentially this is s/\n *by$/ by/g
, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated by
s".
@@ -32,17 +32,17 @@ variable {α M : Type _} [Zero M]
noncomputable def toAList (f : α →₀ M) : AList fun _x : α => M :=
⟨f.graph.toList.map Prod.toSigma,
by
- rw [List.NodupKeys, List.keys, List.map_map, Prod.fst_comp_toSigma, List.nodup_map_iff_inj_on]
- · rintro ⟨b, m⟩ hb ⟨c, n⟩ hc (rfl : b = c)
- rw [Finset.mem_toList, Finsupp.mem_graph_iff] at hb hc
- dsimp at hb hc
- rw [← hc.1, hb.1]
- · apply Finset.nodup_toList⟩
+ rw [List.NodupKeys, List.keys, List.map_map, Prod.fst_comp_toSigma, List.nodup_map_iff_inj_on]
+ · rintro ⟨b, m⟩ hb ⟨c, n⟩ hc (rfl : b = c)
+ rw [Finset.mem_toList, Finsupp.mem_graph_iff] at hb hc
+ dsimp at hb hc
+ rw [← hc.1, hb.1]
+ · apply Finset.nodup_toList⟩
#align finsupp.to_alist Finsupp.toAList
@[simp]
-theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) : f.toAList.keys.toFinset = f.support :=
- by
+theorem toAList_keys_toFinset [DecidableEq α] (f : α →₀ M) :
+ f.toAList.keys.toFinset = f.support := by
ext
simp [toAList, AList.mem_keys, AList.keys, List.keys]
#align finsupp.to_alist_keys_to_finset Finsupp.toAList_keys_toFinset
The unported dependencies are