@@ -45,7 +45,7 @@ non-pointwise multiplication.
45
45
* `finsupp.update`: Changes one value of a `finsupp`.
46
46
* `finsupp.erase`: Replaces one value of a `finsupp` by `0`.
47
47
* `finsupp.on_finset`: The restriction of a function to a `finset` as a `finsupp`.
48
- * `finsupp.map_range`: Composition of a `zero_hom` with a`finsupp`.
48
+ * `finsupp.map_range`: Composition of a `zero_hom` with a `finsupp`.
49
49
* `finsupp.emb_domain`: Maps the domain of a `finsupp` by an embedding.
50
50
* `finsupp.map_domain`: Maps the domain of a `finsupp` by a function and by summing.
51
51
* `finsupp.comap_domain`: Postcomposition of a `finsupp` with a function injective on the preimage
@@ -722,6 +722,60 @@ by rw [← support_eq_empty, support_erase, support_zero, erase_empty]
722
722
723
723
end erase
724
724
725
+ /-! ### Declarations about `graph` -/
726
+
727
+ section graph
728
+
729
+ variable [has_zero M]
730
+
731
+ /-- The graph of a finitely supported function over its support, i.e. the finset of input and output
732
+ pairs with non-zero outputs. -/
733
+ def graph (f : α →₀ M) : finset (α × M) :=
734
+ f.support.map ⟨λ a, prod.mk a (f a), λ x y h, (prod.mk.inj h).1 ⟩
735
+
736
+ lemma mk_mem_graph_iff {a : α} {m : M} {f : α →₀ M} : (a, m) ∈ f.graph ↔ f a = m ∧ m ≠ 0 :=
737
+ begin
738
+ simp_rw [graph, mem_map, mem_support_iff],
739
+ split,
740
+ { rintro ⟨b, ha, rfl, -⟩,
741
+ exact ⟨rfl, ha⟩ },
742
+ { rintro ⟨rfl, ha⟩,
743
+ exact ⟨a, ha, rfl⟩ }
744
+ end
745
+
746
+ @[simp] lemma mem_graph_iff {c : α × M} {f : α →₀ M} : c ∈ f.graph ↔ f c.1 = c.2 ∧ c.2 ≠ 0 :=
747
+ by { cases c, exact mk_mem_graph_iff }
748
+
749
+ lemma mk_mem_graph (f : α →₀ M) {a : α} (ha : a ∈ f.support) : (a, f a) ∈ f.graph :=
750
+ mk_mem_graph_iff.2 ⟨rfl, mem_support_iff.1 ha⟩
751
+
752
+ lemma apply_eq_of_mem_graph {a : α} {m : M} {f : α →₀ M} (h : (a, m) ∈ f.graph) : f a = m :=
753
+ (mem_graph_iff.1 h).1
754
+
755
+ @[simp] lemma not_mem_graph_snd_zero (a : α) (f : α →₀ M) : (a, (0 : M)) ∉ f.graph :=
756
+ λ h, (mem_graph_iff.1 h).2 .irrefl
757
+
758
+ @[simp] lemma image_fst_graph (f : α →₀ M) : f.graph.image prod.fst = f.support :=
759
+ by simp only [graph, map_eq_image, image_image, embedding.coe_fn_mk, (∘), image_id']
760
+
761
+ lemma graph_injective (α M) [has_zero M] : injective (@graph α M _) :=
762
+ begin
763
+ intros f g h,
764
+ have hsup : f.support = g.support, by rw [← image_fst_graph, h, image_fst_graph],
765
+ refine ext_iff'.2 ⟨hsup, λ x hx, apply_eq_of_mem_graph $ h.symm ▸ _⟩,
766
+ exact mk_mem_graph _ (hsup ▸ hx)
767
+ end
768
+
769
+ @[simp] lemma graph_inj {f g : α →₀ M} : f.graph = g.graph ↔ f = g :=
770
+ (graph_injective α M).eq_iff
771
+
772
+ @[simp] lemma graph_zero : graph (0 : α →₀ M) = ∅ := by simp [graph]
773
+
774
+ @[simp] lemma graph_eq_empty {f : α →₀ M} : f.graph = ∅ ↔ f = 0 :=
775
+ (graph_injective α M).eq_iff' graph_zero
776
+
777
+ end graph
778
+
725
779
/-!
726
780
### Declarations about `sum` and `prod`
727
781
0 commit comments