File size: 2,479 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import OAI.NumberTheory.TwoPoint.Walks.ForestCode
namespace OAI
/-!
# Counting the finite column-code universe
The shape is a typed plane forest on at most `N` vertices. Binary marks
record boundaries and run types. Omitted runs and imperfect positions
store representative indices; regular segments store their two endpoints.
-/
namespace TwoPointCorrelations
instance boundedForestFinite (N : β) : Finite {t : BinaryTree Bool // t.numNodes β€ N} :=
Finite.of_injective (boundedForestCode N) (boundedForestCode_injective N)
noncomputable instance boundedForestFintype (N : β) :
Fintype {t : BinaryTree Bool // t.numNodes β€ N} := Fintype.ofFinite _
/-- Fixed-size slots can be padded once the nonempty index universe is fixed. -/
abbrev ColumnCode (N segments omitted imperfect : β) :=
{t : BinaryTree Bool // t.numNodes β€ N} Γ
(Fin (2 * N) β Bool) Γ (Fin segments β Fin N Γ Fin N) Γ
(Fin omitted β Fin N) Γ (Fin imperfect β Fin N)
/-- The code count is uniform over every numerical realization. -/
theorem card_columnCode_le (N segments omitted imperfect : β) :
Fintype.card (ColumnCode N segments omitted imperfect) β€
2 ^ (5 * N + 1) * N ^ (2 * segments + omitted + imperfect) := by
have hshape : Fintype.card {t : BinaryTree Bool // t.numNodes β€ N} β€ 2 ^ (3 * N + 1) := by
simpa only [Nat.card_eq_fintype_card] using card_bounded_forests N
simp only [ColumnCode, Fintype.card_prod, Fintype.card_fun, Fintype.card_fin,
Fintype.card_bool]
calc
_ β€ 2 ^ (3 * N + 1) *
(2 ^ (2 * N) * ((N * N) ^ segments * (N ^ omitted * N ^ imperfect))) := by
exact Nat.mul_le_mul_right _ hshape
_ = _ := by
rw [mul_pow]
simp only [β pow_add]
ring_nf
/-- A decoder makes different equality patterns use different codes, with
no numerical coefficients present in the finite counting universe. -/
theorem patterns_le_columnCode {Pattern : Type*} [Fintype Pattern]
(N segments omitted imperfect : β)
(encode : Pattern β ColumnCode N segments omitted imperfect)
(decode : ColumnCode N segments omitted imperfect β Pattern)
(hdecode : β p, decode (encode p) = p) :
Fintype.card Pattern β€ 2 ^ (5 * N + 1) * N ^ (2 * segments + omitted + imperfect) := by
apply (Fintype.card_le_of_injective encode ?_).trans (card_columnCode_le _ _ _ _)
intro p q heq
have h := congrArg decode heq
simpa only [hdecode] using h
end TwoPointCorrelations
end OAI
|