theoremcongr {I : Type v} (hCH : CH.{u}) {c d : TupleI→Colors.Palette.{u}}
(t : TupleI) (h : ∀ m (e : Fin (m + 1) ↪o Fin (t.1 + 1)), c (sub t e) = d (sub t e)) :
Test hCH c t ↔Test hCH d t :=by
proof · 3
lines
havehe : (fun m (e : Fin (m + 1) ↪o Fin (t.1 + 1)) => c (sub t e)) =
(fun m (e : Fin (m + 1) ↪o Fin (t.1 + 1)) => d (sub t e)) := funext (fun m => funext (h m))
exact iff_of_eq (congrArg (Passes hCH) he)
@[simp]theoremmap {IJ : Type u} (hCH : CH.{u}) (f : I ↪ J)
(c : TupleJ→Colors.Palette.{u}) (t : TupleI) :
Test hCH c (Tuples.map f t) ↔Test hCH (fun s => c (Tuples.map f s)) t :=Iff.rfl
@[simp]theoremMap.colors_base (f : MapMN) (t : TupleM.I) (b : M.B) :
f.colors t (f.base b) = M.colors t b :=by
proof · 10
lines
apply ULift.ext
change Colors.color _ = Colors.color _
havehe : (fun n =>N.bits (Tuples.map f.index t) n (f.base b) ^^
decide (f.base b ∈ f.rowShift t n)) =
(fun n =>M.bits t n b ^^ decide (n ∈ f.colShift t b)) :=by
funext n
have h := f.bit_agrees t n b
dsimp [Matrix.bit] at h
rw [← h, Bool.xor_assoc, Bool.xor_self, Bool.xor_false]
rw [he, color_column]
classical
apply Set.countable_iUnion
intro m
apply Set.countable_iUnion
intro e
exact Set.countable_iUnion (fun n => (f.rowShift (sub t e) n).countable_toSet)
theoremMap.test_away (f : MapMN) (hCH : CH.{u}) (t : TupleM.I) (b : N.B)
(hb : b ∉ f.exceptions t) :
Tests.Test hCH (fun s => f.colors s b) t ↔Tests.Test hCH (fun s =>N.colors s b) (Tuples.map f.index t) :=by
proof · 8
lines
rw [Tests.map]
apply Tests.congr
intro m e
havehn : ∀ n, b ∉ f.rowShift (sub t e) n :=by
intro n h
apply hb
exact Set.mem_iUnion.2 ⟨m, Set.mem_iUnion.2 ⟨e, Set.mem_iUnion.2 ⟨n, h⟩⟩⟩
simp only [Map.colors, Data.colors, hn, decide_false, Bool.xor_false]
constructor
· constructor
intro x hx y hy z hz
obtain ⟨a, rfl⟩ := hx
obtain ⟨b, rfl⟩ := hy
obtain ⟨c, rfl⟩ := hg.convex.out (by exact ⟨f.base a, rfl⟩)
(by exact ⟨f.base b, rfl⟩) hz
havehc : c ∈Set.Icc (f.base a) (f.base b) :=by
exact ⟨g.base.le_iff_le.1 hz.1, g.base.le_iff_le.1 hz.2⟩
obtain ⟨d, rfl⟩ := hf.convex.out ⟨a, rfl⟩ ⟨b, rfl⟩ hc
exact ⟨d, rfl⟩
· intro t b hb
by_cases hbg : b ∈Set.range g.base
· obtain ⟨c, rfl⟩ := hbg
havehc : c ∉Set.range f.base :=by
rintro ⟨d, rfl⟩
exact hb ⟨d, rfl⟩
simpa only [Map.comp_colors_base] using hf.outside t c hc
· have h := hg.outside (Tuples.map f.index t) b hbg
rw [Tests.map] at h
simpa only [Map.comp_colors_outside g f _ b hbg] using h
classical
letei : M.I ≃ N.I:=Equiv.ofBijective f.index ⟨f.index.injective, hi⟩
leteb : M.B ≃ N.B:=Equiv.ofBijective f.base ⟨f.base.injective, hb⟩
havehfin : ∀s : FinsetN.B, ∃v : FinsetM.B, v.map f.base.toEmbedding = s :=by
intro s
refine ⟨s.map eb.symm.toEmbedding, ?_⟩
rw [Finset.map_map]
havehe : eb.symm.toEmbedding.trans f.base.toEmbedding = Function.Embedding.refl N.B:=by
ext b
exact eb.apply_symm_apply b
rw [he, Finset.map_refl]
havehtup : Function.Surjective (Tuples.map f.index) := (Tuples.mapEquiv ei).surjective
intro p
cases p with
| index i => obtain ⟨j, rfl⟩ := hi i; exact ⟨.index j, rfl⟩
| base b => obtain ⟨a, rfl⟩ := hb b; exact ⟨.base a, rfl⟩
| group s => obtain ⟨v, rfl⟩ := hfin s; exact ⟨.group v, rfl⟩
| star v => exact ⟨.star v, rfl⟩
| row t n s =>
obtain ⟨r, rfl⟩ := htup t
obtain ⟨v, hv⟩ := hfin (f.rowShift r n ∆ s)
exact ⟨.row r n v, by simp [Map.onPoint, hv]⟩
| col t b v =>
obtain ⟨r, rfl⟩ := htup t
obtain ⟨a, rfl⟩ := hb b
exact ⟨.col r a (f.colShift r a ∆ v), by simp [Map.onPoint]⟩
have h :=funt : TupleM.I=>Matrix.normalize (M.bits t)
(fun n b =>N.bits (Tuples.map ei.toEmbedding t) n (eb b))
choose UV hUV using h
exact {
index := ei.toEmbedding
base := eb.toOrderEmbedding
rowShift :=fun t n => (U t n).map eb.toOrderEmbedding.toEmbedding
colShift :=V
bit_agrees :=fun t n b =>by
simpa only [Matrix.bit, Finset.mem_map, OrderIso.coe_toOrderEmbedding,
RelEmbedding.coe_toEmbedding, eb.injective.eq_iff, exists_eq_right] using hUV t n b }
theorementriesList_injective {I : Type u} : Function.Injective (@entriesList I) :=by
proof · 10
lines
rintro ⟨n, a⟩ ⟨m, b⟩ h
have hn := congrArg List.length h
simp only [entriesList, List.length_ofFn] at hn
havehe : n = m :=Nat.add_right_cancel hn
subst m
congr 1
apply Function.Embedding.ext
intro i
have hv := congrArg (funl : ListI=> l[i.val]?) h
simpa only [entriesList, List.getElem?_ofFn, i.isLt, dite_eq_left, Option.some.injEq] using hv
have h := (f.relates .group [.group s]).2 trivial
cases he : f.toEmbedding (.group s) <;> simp only [List.map_cons, List.map_nil, he,
Data.rawRel] at h
case group v =>
congr 1
ext b
have hs := f.supports s b
simp only [he, Data.rawRel, f.base_apply, Point.base.injEq] at hs
simpa only [Finset.mem_map, RelEmbedding.coe_toEmbedding, RawEmbedding.baseEmb_apply] using hs
@[simp]theoremRawEmbedding.star_apply (v : Finsetℕ) : f.toEmbedding (.star v) = .star v :=by
proof · 4
lines
have h := (f.relates (.label v) [.star v]).2 rfl
cases he : f.toEmbedding (.star v) <;> simp only [List.map_cons, List.map_nil, he,
Data.rawRel] at h
case star w => exact congrArg Point.star h.symm
theoremRawEmbedding.row_exists (t : TupleM.I) (n : ℕ) (s : FinsetM.B) :
∃ v, f.toEmbedding (.row t n s) = .row (Tuples.map f.indexEmb t) n v :=by
proof · 14
lines
have hu := (f.relates (.row t.1 n) [.row t n s]).2 ⟨rfl, rfl⟩
have hp := (f.relates (.rowProjection t.1 n)
(.row t n s :: List.ofFn (fun i =>Point.index (t.2 i)))).2 ⟨rfl, rfl, rfl⟩
cases he : f.toEmbedding (.row t n s) <;>
simp only [List.map_cons, List.map_nil, he, Data.rawRel] at hu
case row r m v =>
obtain ⟨hk, rfl⟩ := hu
simp only [List.map_cons, List.map_ofFn, Function.comp_def, he, f.index_apply, Data.rawRel, true_and] at hp
haveht : r = Tuples.map f.indexEmb t :=by
apply Tuples.entriesList_injective
apply (showFunction.Injective (Point.index (I:=N.I) (B:=N.B)) fromfun _ _ h =>Point.index.inj h).list_map
simp only [Tuples.entriesList, List.map_ofFn]
exact hp.2.symm
exact ⟨v, by rw [ht]⟩
theoremRawEmbedding.col_exists (t : TupleM.I) (b : M.B) (v : Finsetℕ) :
∃ w, f.toEmbedding (.col t b v) = .col (Tuples.map f.indexEmb t) (f.base b) w :=by
proof · 14
lines
have hu := (f.relates (.col t.1) [.col t b v]).2 rfl
have hp := (f.relates (.colProjection t.1)
(.col t b v :: .base b :: List.ofFn (fun i =>Point.index (t.2 i)))).2 ⟨rfl, rfl, rfl⟩
cases he : f.toEmbedding (.col t b v) <;>
simp only [List.map_cons, List.map_nil, he, Data.rawRel] at hu
case col r c w =>
simp only [List.map_cons, List.map_ofFn, Function.comp_def, he, f.index_apply, f.base_apply, Data.rawRel,
Point.base.injEq] at hp
haveht : r = Tuples.map f.indexEmb t :=by
apply Tuples.entriesList_injective
apply (showFunction.Injective (Point.index (I:=N.I) (B:=N.B)) fromfun _ _ h =>Point.index.inj h).list_map
simp only [Tuples.entriesList, List.map_ofFn]
exact hp.2.2.symm
exact ⟨w, by rw [ht, ← hp.2.1]⟩
@[simp]theoremRawEmbedding.col_zero (t : TupleM.I) (b : M.B) :
f.toEmbedding (.col t b ∅) = .col (Tuples.map f.indexEmb t) (f.base b) (f.colShift t b) :=
@[simp]theoremRawEmbedding.row_apply (t : TupleM.I) (n : ℕ) (s : FinsetM.B) :
f.toEmbedding (.row t n s) = .row (Tuples.map f.indexEmb t) n
(f.rowShift t n ∆ s.map f.baseEmb.toEmbedding) :=by
proof · 6
lines
obtain ⟨v, hv⟩ := f.row_exists t n s
have h := (f.relates .rowAct [.row t n ∅, .group s, .row t n s]).2
⟨rfl, rfl, (bot_symmDiff s).symm⟩
simp only [List.map_cons, List.map_nil, f.row_zero, f.group_apply, hv, Data.rawRel,
true_and] at h
rw [hv, h]
@[simp]theoremRawEmbedding.col_apply (t : TupleM.I) (b : M.B) (v : Finsetℕ) :
f.toEmbedding (.col t b v) = .col (Tuples.map f.indexEmb t) (f.base b)
(f.colShift t b ∆ v) :=by
proof · 6
lines
obtain ⟨w, hw⟩ := f.col_exists t b v
have h := (f.relates .colAct [.col t b ∅, .star v, .col t b v]).2
⟨rfl, rfl, (bot_symmDiff v).symm⟩
simp only [List.map_cons, List.map_nil, f.col_zero, f.star_apply, hw, Data.rawRel,
true_and] at h
rw [hw, h]
index := f.indexEmb
base := f.baseEmb
rowShift := f.rowShift
colShift := f.colShift
bit_agrees t n b :=byhave h := f.relates .bit [.row t n ∅, .col t b ∅]
simp only [List.map_cons, List.map_nil, f.row_zero, f.col_zero, Data.rawRel,
true_and] at h
havehe : Matrix.bit (M.bits t) n ∅ b ∅ = M.bits t n b :=by simp [Matrix.bit]
rw [he] at h
exact Bool.eq_iff_iff.2 h