/-
Copyright 2026 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/modulepublicimportMathlib.Analysis.Normed.Ring.BasicpublicimportMathlib.Combinatorics.SimpleGraph.Maps@[expose]publicsection
Homomorphism density for finite simple graphs
Mathlib does not (as of 2026-04) provide SimpleGraph.homDensity. We define a lightweight
version here, specialised to finite vertex types on the host G, and prove the basic
homDensity H G ≤ 1 upper bound used as a sanity check in Sidorenko-style arguments.
The extension to infinite hosts uses the same formula with Fintype.card replaced by
measure-theoretic integrals; we do not need that generality here.
namespaceSimpleGraphvariable{VW:Type*}
The number of graph homomorphisms H → G, as a natural number. For finite vertex
types this is just the cardinality of the Hom type.