File size: 5,998 Bytes
2fca478 | 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | import OAI.Geometry.PeriodicTiling.CycleTests
import OAI.Geometry.PeriodicTiling.SeedSymbols
import Mathlib.Data.Finset.Union
import Mathlib.Tactic.FinCases
namespace OAI
noncomputable section
namespace PeriodicTilingThree
variable {p : ℕ} [NeZero p]
def ordinaryCycle (p : ℕ) [NeZero p] : ZMod (p ^ 2) ↪ Channel p where
toFun j := .inl ((ZMod.finEquiv (p ^ 2)).symm j)
inj' _ _ h := (ZMod.finEquiv (p ^ 2)).symm.injective (Sum.inl.inj h)
def ordinaryCycleLabels (w : Word p) (j : ZMod (p ^ 2)) :
Label p (ordinaryCycle p j) :=
w ((ZMod.finEquiv (p ^ 2)).symm j)
def seedCycle (t : Fin 2) (n : Column p) : ZMod 2 ↪ Channel p where
toFun j := Fin.cases (.inr t) (fun _ => .inl n) j
inj' := by
intro i j h
fin_cases i <;> fin_cases j
· rfl
· change Sum.inr t = Sum.inl n at h
cases h
· change Sum.inl n = Sum.inr t at h
cases h
· rfl
@[simp] theorem seedCycle_zero
{p : ℕ} [NeZero p]
(t : Fin 2) (n : Column p) :
seedCycle t n 0 = .inr t := rfl
@[simp] theorem seedCycle_one
{p : ℕ} [NeZero p]
(t : Fin 2) (n : Column p) :
seedCycle t n 1 = .inl n := rfl
def seedCycleLabels (t : Fin 2) (n : Column p) (j : Symbol p) (z : ZMod 2) :
Label p (seedCycle t n z) :=
Fin.cases (motive := fun z : Fin 2 => Label p (seedCycle t n z))
() (fun _ => j) z
@[simp] theorem seedCycleLabels_zero
{p : ℕ} [NeZero p]
(t : Fin 2) (n : Column p) (j : Symbol p) :
seedCycleLabels t n j 0 = () := rfl
@[simp] theorem seedCycleLabels_one
{p : ℕ} [NeZero p]
(t : Fin 2) (n : Column p) (j : Symbol p) :
seedCycleLabels t n j 1 = j := rfl
variable (E : EncodingParameters p)
theorem ordinaryCycle_exclusion_iff (w : Word p) (o : GraphOutputs E)
(hdep : HasDependence E o) :
(∀ F ∈ cycleTiles E (ordinaryCycle p) (ordinaryCycleLabels w),
Tiles F (graph o)) ↔
∀ x, ¬ (∀ n : Column p, Active E o (.inl n) x (w n)) := by
classical
rw [cycle_exclusion_iff E (ordinaryCycle p) (ordinaryCycleLabels w) o hdep]
constructor
· intro h x hall
obtain ⟨z, hz⟩ := h x
exact hz (hall ((ZMod.finEquiv (p ^ 2)).symm z))
· intro h x
obtain ⟨n, hn⟩ := not_forall.mp (h x)
refine ⟨(ZMod.finEquiv (p ^ 2)) n, ?_⟩
exact Eq.mpr
(congrArg (fun m : Column p => ¬ Active E o (.inl m) x (w m))
((ZMod.finEquiv (p ^ 2)).symm_apply_apply n)) hn
theorem seedCycle_exclusion_iff (t : Fin 2) (n : Column p) (j : Symbol p)
(o : GraphOutputs E) (hdep : HasDependence E o) :
(∀ F ∈ cycleTiles E (seedCycle t n) (seedCycleLabels t n j),
Tiles F (graph o)) ↔
∀ x, ¬ (Active E o (.inr t) x () ∧ Active E o (.inl n) x j) := by
classical
rw [cycle_exclusion_iff E (seedCycle t n) (seedCycleLabels t n j) o hdep]
constructor
· intro h x hx
obtain ⟨z, hz⟩ := h x
fin_cases z
· exact hz hx.1
· exact hz hx.2
· intro h x
by_cases hs : Active E o (.inr t) x ()
· refine ⟨1, ?_⟩
change ¬ Active E o (.inl n) x j
intro hj
exact h x ⟨hs, hj⟩
· exact ⟨0, hs⟩
def wordConstraintTiles : Finset (Finset (Ambient E)) := by
classical
exact (Finset.univ.filter (fun w : Word p => w ∉ allowedWords p)).biUnion
(fun w => cycleTiles E (ordinaryCycle p) (ordinaryCycleLabels w))
def seedConstraintTiles : Finset (Finset (Ambient E)) := by
classical
exact (Finset.univ.filter (fun q : Fin 2 × Column p × Symbol p =>
q.2.2 ≠ seedSymbol E q.1)).biUnion
(fun q => cycleTiles E (seedCycle q.1 q.2.1) (seedCycleLabels q.1 q.2.1 q.2.2))
theorem nonempty_of_mem_wordConstraintTiles {F : Finset (Ambient E)}
(hF : F ∈ wordConstraintTiles E) : F.Nonempty := by
classical
obtain ⟨w, _, hF⟩ := Finset.mem_biUnion.mp hF
exact nonempty_of_mem_cycleTiles E (ordinaryCycle p) (ordinaryCycleLabels w) hF
theorem nonempty_of_mem_seedConstraintTiles {F : Finset (Ambient E)}
(hF : F ∈ seedConstraintTiles E) : F.Nonempty := by
classical
obtain ⟨q, _, hF⟩ := Finset.mem_biUnion.mp hF
exact nonempty_of_mem_cycleTiles E (seedCycle q.1 q.2.1)
(seedCycleLabels q.1 q.2.1 q.2.2) hF
theorem wordConstraintTiles_iff (o : GraphOutputs E) (hdep : HasDependence E o) :
(∀ F ∈ wordConstraintTiles E, Tiles F (graph o)) ↔
∀ x w, (∀ n : Column p, Active E o (.inl n) x (w n)) → Allowed p w := by
classical
constructor
· intro h x w hw
by_contra hnot
have hcycle : ∀ F ∈ cycleTiles E (ordinaryCycle p) (ordinaryCycleLabels w),
Tiles F (graph o) := by
intro F hF
apply h F
apply Finset.mem_biUnion.mpr
exact ⟨w, by simp [hnot], hF⟩
exact (ordinaryCycle_exclusion_iff E w o hdep).mp hcycle x hw
· intro h F hF
obtain ⟨w, hw, hF⟩ := Finset.mem_biUnion.mp hF
have hnot : ¬ Allowed p w := by simpa using (Finset.mem_filter.mp hw).2
apply (ordinaryCycle_exclusion_iff E w o hdep).mpr ?_ F hF
intro x hx
exact hnot (h x w hx)
theorem seedConstraintTiles_iff (o : GraphOutputs E) (hdep : HasDependence E o) :
(∀ F ∈ seedConstraintTiles E, Tiles F (graph o)) ↔
∀ t n x j, Active E o (.inr t) x () → Active E o (.inl n) x j →
j = seedSymbol E t := by
classical
constructor
· intro h t n x j hseed hord
by_contra hj
have hcycle : ∀ F ∈ cycleTiles E (seedCycle t n) (seedCycleLabels t n j),
Tiles F (graph o) := by
intro F hF
apply h F
apply Finset.mem_biUnion.mpr
exact ⟨(t, n, j), Finset.mem_filter.mpr ⟨Finset.mem_univ _, hj⟩, hF⟩
exact (seedCycle_exclusion_iff E t n j o hdep).mp hcycle x ⟨hseed, hord⟩
· intro h F hF
obtain ⟨⟨t, n, j⟩, hq, hF⟩ := Finset.mem_biUnion.mp hF
have hj : j ≠ seedSymbol E t := (Finset.mem_filter.mp hq).2
apply (seedCycle_exclusion_iff E t n j o hdep).mpr ?_ F hF
intro x hx
exact hj (h t n x j hx.1 hx.2)
end PeriodicTilingThree
end
end OAI
|