Download data/lean/OAI/Computability/WitnessedChoice/SupportedForms.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 46.7 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/WitnessedChoice/SupportedForms.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/WitnessedChoice/SupportedForms.lean
-
curl -L -o SupportedForms.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/WitnessedChoice/SupportedForms.lean
46.7 kB
import OAI.Computability.WitnessedChoice.Homogeneity
namespace OAI
namespace WitnessedSeparation.Grid
noncomputable section
open Classical Finset
variable {n M : β} {b b' : Vertex n β Scalar}
theorem boundary_eq_incidence : (boundary : (Edge n β Scalar) ββ[Scalar] (Vertex n β Scalar)) =
Flows.incidence tail head := rfl
def GiantBound (n M : β) : Prop :=
((12*(M:β))/boxConstant)^((3:β)/2) < ((n+1)^3:β)
theorem giant_exists_of_bound (hbound : GiantBound n M) (T : Finset (Edge n)) (hT : T.card β€ 6*M) :
β v, Flows.IsGiant tail head T v := by
have hnum : ((2*T.card:β)/boxConstant)^((3:β)/2) < ((n+1)^3:β) := by
apply lt_of_le_of_lt _ hbound
apply Real.rpow_le_rpow (div_nonneg (by positivity) boxConstant_pos.le) _ (by norm_num)
apply div_le_div_of_nonneg_right _ boxConstant_pos.le
have hh : (T.card:β) β€ 6*M := by exact_mod_cast hT
linarith
obtain β¨c,hcβ© := exists_giant T hnum
refine β¨c.out,?_β©
change Fintype.card (Vertex n) < 2*(Flows.cell tail head T c).card
have hcard : Fintype.card (Vertex n) = (n+1)^3 := by
simp only [Vertex,Fintype.card_prod,Fintype.card_fin]; ring
simpa only [hcard] using hc
theorem defect_transport (hbound : GiantBound n M) (T U : Finset (Edge n)) (hTU : T β U)
(hU : U.card β€ 6*M) (t : Edge n β Scalar) (w : Vertex n)
(hw : Flows.IsGiant tail head T w) (ht : boundary t = b'-b-Pi.single w 1) :
β t' : Edge n β Scalar, β w' : Vertex n,
Flows.IsGiant tail head U w' β§ boundary t' = b'-b-Pi.single w' 1 β§ β e β T, t' e = t e := by
obtain β¨w',hw'β© := giant_exists_of_bound hbound U hU
have hc := Flows.giants_connected tail head (Flows.giant_mono tail head hTU hw') hw
obtain β¨p,hp,hdβ© := Flows.path_flow tail head T hc
refine β¨t+p,w',hw',?_,?_β©
Β· rw [map_add,ht,boundary_eq_incidence,hd]
abel
Β· intro e he; simp [hp e he]
def CompatibleAssignment {I : Type*} [DecidableEq I] (names : Finset I)
(a : I β Atom b) (a' : I β Atom b') : Prop :=
β t : Edge n β Scalar, β w : Vertex n,
Flows.IsGiant tail head (touches names a) w β§ boundary t = b'-b-Pi.single w 1 β§
β i β names, AtomShift t (a i) (a' i)
theorem CompatibleAssignment.mono {I : Type*} [DecidableEq I] {names small : Finset I}
(hs : small β names) {a : I β Atom b} {a' : I β Atom b'}
(h : CompatibleAssignment names a a') : CompatibleAssignment small a a' := by
obtain β¨t,w,hw,ht,haβ© := h
exact β¨t,w,Flows.giant_mono tail head (touches_mono hs a) hw,ht,fun i hi => ha i (hs hi)β©
theorem CompatibleAssignment.extend (hn : 1 β€ n) (hbound : GiantBound n M)
(names : Finset (Fin M)) (a : Fin M β Atom b) (a' : Fin M β Atom b')
(h : CompatibleAssignment names a a') (i : Fin M) :
β e : Atom b β Atom b', β x,
CompatibleAssignment (insert i (names.erase i)) (Function.update a i x) (Function.update a' i (e x)) := by
obtain β¨t,w,hw,ht,haβ© := h.mono (erase_subset i names)
let T := touches (names.erase i) a
have hcard : (names.erase i).card + 1 β€ M := by
have hsub : names.erase i β (univ : Finset (Fin M)).erase i := erase_subset_erase i (subset_univ _)
have hh := card_le_card hsub
have hpos := i.isLt
rw [card_erase_of_mem (mem_univ _),card_univ,Fintype.card_fin] at hh
omega
have hj (J : Block n) : (T βͺ blockEdges J).card β€ 6*M := by
calc
_ β€ T.card + (blockEdges J).card := card_union_le _ _
_ β€ 6*(names.erase i).card + 6 := Nat.add_le_add (touches_card _ _) (blockEdges_card _)
_ β€ 6*M := by omega
have hmove (J : Block n) := defect_transport hbound T (T βͺ blockEdges J)
subset_union_left (hj J) t w hw ht
choose tj wj hjg hjd hjs using hmove
have hV : 2 β€ Fintype.card (Vertex n) := by
have hc : Fintype.card (Vertex n) = (n+1)^3 := by
simp only [Vertex,Fintype.card_prod,Fintype.card_fin]; ring
rw [hc]
have hh : 2^3 β€ (n+1)^3 := Nat.pow_le_pow_left (by omega) 3
omega
have hv (v : Vertex n) : boundary (tj (.inr v)) v = b' v-b v := by
have hwv : wj (.inr v) β v := Flows.giant_ne_isolated tail head hV (hjg (.inr v)) (by
intro e he
exact mem_union_right _ (by simpa [blockEdges,incident,or_comm] using he))
have hh := congrFun (hjd (.inr v)) v
simpa [Pi.single_apply,Ne.symm hwv] using hh
let e := blockShiftEquiv (fun e => tj (.inl e)) (fun v => tj (.inr v)) hv
refine β¨e,fun x => ?_β©
let J := atomBlock x
refine β¨tj J,wj J,?_,hjd J,?_β©
Β· rw [touches_insert_update]
exact hjg J
Β· intro j hj'
rcases mem_insert.mp hj' with rfl | hj'
Β· simp only [Function.update_self]
cases x with
| inl x => rcases x with β¨f,sβ©; exact AtomShift.edge f s
| inr x => rcases x with β¨v,sβ©; exact AtomShift.config v s (hv v)
Β· have hji := (mem_erase.mp hj').1
simp only [Function.update_of_ne hji]
exact (ha j hj').congr (fun f hf => (hjs J f (touch_subset_touches _ _ hj' hf)).symm)
theorem base_equivalence_numeric (hn : 1 β€ n) (hbound : GiantBound n M) (vstar : Vertex n)
(Ο : Counting.Formula AnalysisSymbol (Fin M)) (hΟ : Ο.free = β
)
(a : Fin M β Atom (0 : Vertex n β Scalar))
(a' : Fin M β Atom (Pi.single vstar 1)) :
Ο.eval (analysisStructure (0 : Vertex n β Scalar)) a β
Ο.eval (analysisStructure (Pi.single vstar 1)) a' := by
have heq : β (names : Finset (Fin M)) (v : Fin M β Atom (0 : Vertex n β Scalar))
(w : Fin M β Atom (Pi.single vstar 1)), CompatibleAssignment names v w β β i β names, β j β names,
(v i = v j β w i = w j) := by
intro names v w β¨t,x,hg,hb,haβ© i hi j hj
exact (ha i hi).equal_iff (ha j hj)
have hrel : β (names : Finset (Fin M)) (v : Fin M β Atom (0 : Vertex n β Scalar))
(w : Fin M β Atom (Pi.single vstar 1)), CompatibleAssignment names v w β β r i, i β names β β j, j β names β
((analysisStructure (0 : Vertex n β Scalar)).rel r (v i) (v j) β
(analysisStructure (Pi.single vstar 1)).rel r (w i) (w j)) := by
intro names v w β¨t,x,hg,hb,haβ© r i hi j hj
exact (ha i hi).analysisRelation (ha j hj) r
apply Counting.Formula.eval_of_partialBijectionSystem _ _ CompatibleAssignment heq hrel
(fun names v w hh i => CompatibleAssignment.extend hn hbound names v w hh i) Ο β
a a' _ (by simp [hΟ])
refine β¨0,vstar,?_,by simp,by simpβ©
simpa [touches] using grid_empty_giant vstar
end
end WitnessedSeparation.Grid
namespace WitnessedSeparation.Forms
noncomputable section
open Classical
open Counting Hereditary
variable {R I J A B : Type*}
inductive Form (J L : Type*)
| atom (j : J)
| set (n : β) (child : Fin n β Form J L) (label : Fin n β L)
namespace Form
variable [Fintype I] [Fintype J] [DecidableEq I]
variable [Fintype A] [Nonempty A]
def value (S : Structure R A) (e : J β J βͺ I) :
Form J (Set (Formula R I)) β (J β A) β HF A
| .atom j, a => Hereditary.atom (a j)
| .set _n child label, a => Hereditary.ofFinset
(Finset.univ.biUnion fun i =>
(Finset.univ.filter fun b : J β A =>
tupleType S e (Sum.elim b a) = label i).image (value S e (child i)))
omit [Fintype I] in
@[simp] theorem value_atom (S : Structure R A) (e : J β J βͺ I) (j : J) (a : J β A) :
value S e (.atom j) a = Hereditary.atom (a j) := rfl
omit [Fintype I] in
@[simp] theorem value_set_isSet (S : Structure R A) (e : J β J βͺ I)
(n : β) (child : Fin n β Form J (Set (Formula R I))) (label : Fin n β Set (Formula R I))
(a : J β A) : isSet (value S e (.set n child label) a) = true := rfl
omit [Fintype I] in
@[simp] theorem mem_value_set (S : Structure R A) (e : J β J βͺ I)
(n : β) (child : Fin n β Form J (Set (Formula R I))) (label : Fin n β Set (Formula R I))
(a : J β A) (x : HF A) :
x β value S e (.set n child label) a β
β i b, tupleType S e (Sum.elim b a) = label i β§ value S e (child i) b = x := by
classical
simp only [value,mem_ofFinset,Finset.mem_biUnion,Finset.mem_univ,true_and,
Finset.mem_image,Finset.mem_filter,true_and]
omit [Fintype I] in
theorem value_iso [Fintype B] [Nonempty B]
(S : Structure R A) (T : Structure R B) (e : J β J βͺ I) (f : A β B)
(hf : β r a b, S.rel r a b β T.rel r (f a) (f b))
(Ο : Form J (Set (Formula R I))) (a : J β A) :
Hereditary.map f (value S e Ο a) = value T e Ο (f β a) := by
induction Ο generalizing a with
| atom j => rfl
| set n child label ih =>
apply Hereditary.ext_sets (by simp [value]) (by simp)
intro x
change x β elements (Hereditary.map f (value S e (.set n child label) a)) β _
rw [Hereditary.elements_map]
simp only [Finset.mem_image]
constructor
Β· rintro β¨y,hy,rflβ©
obtain β¨i,b,ht,rflβ© := (mem_value_set S e n child label a y).mp hy
apply (mem_value_set T e n child label (f β a) _).mpr
refine β¨i,f β b,?_,(ih i b).symmβ©
have heq : Sum.elim (f β b) (f β a) = f β Sum.elim b a := by
funext j; cases j <;> rfl
rw [heq,β tupleType_iso S T e f hf,ht]
Β· intro hx
obtain β¨i,b,ht,hxβ© := (mem_value_set T e n child label (f β a) x).mp hx
let c := f.symm β b
have hc : f β c = b := by funext j; simp [c]
refine β¨value S e (child i) c,?_,?_β©
Β· apply (mem_value_set S e n child label a _).mpr
refine β¨i,c,?_,rflβ©
rw [tupleType_iso S T e f hf]
have heq : f β Sum.elim c a = Sum.elim b (f β a) := by
funext j; cases j <;> simp [c]
rw [heq,ht]
Β· rw [ih,hc,hx]
end Form
def cross31 : J β J βͺ (J β J) β J where
toFun := Sum.elim Sum.inr (fun j => Sum.inl (Sum.inl j))
inj' := by intro a b h; cases a <;> cases b <;> simp_all
def cross42 : J β J βͺ ((J β J) β J) β J where
toFun := Sum.elim Sum.inr (fun j => Sum.inl (Sum.inl (Sum.inr j)))
inj' := by intro a b h; cases a <;> cases b <;> simp_all
def cross34 : J β J βͺ ((J β J) β J) β J where
toFun := Sum.elim (fun j => Sum.inl (Sum.inr j)) Sum.inr
inj' := by intro a b h; cases a <;> cases b <;> simp_all
theorem swap_type [Fintype J] [DecidableEq I] [Nonempty A] [Nonempty B]
(S : Structure R A) (T : Structure R B) (e : J β J βͺ I)
(a b : J β A) (a' b' : J β B)
(h : tupleType S e (Sum.elim a b) = tupleType T e (Sum.elim a' b')) :
tupleType S e (Sum.elim b a) = tupleType T e (Sum.elim b' a') := by
have ht := tupleType_project S T e e (Equiv.sumComm J J).toEmbedding _ _ h
have h1 : Sum.elim a b β (Equiv.sumComm J J).toEmbedding = Sum.elim b a := by
funext j; cases j <;> rfl
have h2 : Sum.elim a' b' β (Equiv.sumComm J J).toEmbedding = Sum.elim b' a' := by
funext j; cases j <;> rfl
simpa only [h1,h2] using ht
@[simp] theorem elim_comp_cross31 (a b c : J β A) :
Sum.elim (Sum.elim a b) c β cross31 = Sum.elim c a := by
funext j; cases j <;> rfl
@[simp] theorem elim_comp_cross42 (a b c d : J β A) :
Sum.elim (Sum.elim (Sum.elim a b) c) d β cross42 = Sum.elim d b := by
funext j; cases j <;> rfl
@[simp] theorem elim_comp_cross34 (a b c d : J β A) :
Sum.elim (Sum.elim (Sum.elim a b) c) d β cross34 = Sum.elim c d := by
funext j; cases j <;> rfl
section AtomicTransfer
variable [Fintype I] [Fintype J] [DecidableEq I]
variable [Fintype A] [Nonempty A] [Fintype B] [Nonempty B]
variable (S : Structure R A) (T : Structure R B)
variable (e2 : J β J βͺ I) (e3 : (J β J) β J βͺ I)
variable (e4 : ((J β J) β J) β J βͺ I)
open Form
include e3 e4
private theorem set_subset_transfer
(n k : β) (child : Fin n β Form J (Set (Formula R I)))
(other : Fin k β Form J (Set (Formula R I)))
(label : Fin n β Set (Formula R I)) (lab : Fin k β Set (Formula R I))
(hc : β i j (c d : J β A) (c' d' : J β B),
tupleType S e2 (Sum.elim c d) = tupleType T e2 (Sum.elim c' d') β
(value S e2 (child i) c = value S e2 (other j) d β
value T e2 (child i) c' = value T e2 (other j) d'))
(a b : J β A) (a' b' : J β B)
(ht : tupleType S e2 (Sum.elim a b) = tupleType T e2 (Sum.elim a' b'))
(hsub : β x, x β value S e2 (.set n child label) a β
x β value S e2 (.set k other lab) b) :
β x, x β value T e2 (.set n child label) a' β
x β value T e2 (.set k other lab) b' := by
intro x hx
obtain β¨i,c',hl,rflβ© := (mem_value_set T e2 n child label a' x).mp hx
obtain β¨c,h3β© := tupleType_append T S e2 e3 (Sum.elim a' b') (Sum.elim a b) c' ht.symm
have hca := tupleType_project T S e3 e2 cross31 _ _ h3
simp only [elim_comp_cross31] at hca
have hmem : value S e2 (child i) c β value S e2 (.set n child label) a :=
(mem_value_set S e2 n child label a _).mpr β¨i,c,hca.symm.trans hl,rflβ©
obtain β¨j,d,hlab,heqβ© := (mem_value_set S e2 k other lab b _).mp (hsub _ hmem)
obtain β¨d',h4β© := tupleType_append S T e3 e4 (Sum.elim (Sum.elim a b) c)
(Sum.elim (Sum.elim a' b') c') d h3.symm
have hdb := tupleType_project S T e4 e2 cross42 _ _ h4
have hcd := tupleType_project S T e4 e2 cross34 _ _ h4
simp only [elim_comp_cross42] at hdb
simp only [elim_comp_cross34] at hcd
exact (mem_value_set T e2 k other lab b' _).mpr
β¨j,d',hdb.symm.trans hlab,((hc i j c d c' d' hcd).mp heq.symm).symmβ©
private theorem set_eq_forward
(n k : β) (child : Fin n β Form J (Set (Formula R I)))
(other : Fin k β Form J (Set (Formula R I)))
(label : Fin n β Set (Formula R I)) (lab : Fin k β Set (Formula R I))
(hc : β i j (c d : J β A) (c' d' : J β B),
tupleType S e2 (Sum.elim c d) = tupleType T e2 (Sum.elim c' d') β
(value S e2 (child i) c = value S e2 (other j) d β
value T e2 (child i) c' = value T e2 (other j) d'))
(a b : J β A) (a' b' : J β B)
(ht : tupleType S e2 (Sum.elim a b) = tupleType T e2 (Sum.elim a' b'))
(h : value S e2 (.set n child label) a = value S e2 (.set k other lab) b) :
value T e2 (.set n child label) a' = value T e2 (.set k other lab) b' := by
apply Hereditary.ext_sets (by simp) (by simp)
intro x
constructor
Β· exact set_subset_transfer S T e2 e3 e4 n k child other label lab hc a b a' b' ht
(fun z hz => by rw [βh]; exact hz) x
Β· apply set_subset_transfer S T e2 e3 e4 k n other child lab label
(fun j i c d c' d' ht' => ?_) b a b' a' (swap_type S T e2 a b a' b' ht)
(fun z hz => by rw [h]; exact hz) x
have hh := hc i j d c d' c' (swap_type S T e2 c d c' d' ht')
exact β¨fun he => (hh.mp he.symm).symm,fun he => (hh.mpr he.symm).symmβ©
theorem equality_transfer (Ο Ο : Form J (Set (Formula R I)))
(a b : J β A) (a' b' : J β B)
(ht : tupleType S e2 (Sum.elim a b) = tupleType T e2 (Sum.elim a' b')) :
value S e2 Ο a = value S e2 Ο b β value T e2 Ο a' = value T e2 Ο b' := by
induction Ο generalizing Ο a b a' b' with
| atom i =>
cases Ο with
| atom j =>
have he := (typeOf_eq_iff S T (tupleNames e2) _ _).mp ht
(.equal (e2 (.inl i)) (e2 (.inr j))) (by
intro p hp
simp only [Formula.free,Finset.mem_insert,Finset.mem_singleton] at hp
rcases hp with rfl | rfl <;> exact (mem_tupleNames _ _).mpr β¨_,rflβ©)
simpa only [Formula.eval,tupleAssignment_apply,Sum.elim_inl,Sum.elim_inr,
value_atom,Hereditary.atom_injective.eq_iff] using he
| set k other lab =>
have hfalseA : value S e2 (.atom i) a β value S e2 (.set k other lab) b := by
intro h; have hh := congrArg isSet h; simp at hh
have hfalseB : value T e2 (.atom i) a' β value T e2 (.set k other lab) b' := by
intro h; have hh := congrArg isSet h; simp at hh
exact iff_of_false hfalseA hfalseB
| set n child label ih =>
cases Ο with
| atom j =>
have hfalseA : value S e2 (.set n child label) a β value S e2 (.atom j) b := by
intro h; have hh := congrArg isSet h; simp at hh
have hfalseB : value T e2 (.set n child label) a' β value T e2 (.atom j) b' := by
intro h; have hh := congrArg isSet h; simp at hh
exact iff_of_false hfalseA hfalseB
| set k other lab =>
constructor
Β· exact set_eq_forward S T e2 e3 e4 n k child other label lab
(fun i j c d c' d' ht' => ih i (other j) c d c' d' ht') a b a' b' ht
Β· exact set_eq_forward T S e2 e3 e4 n k child other label lab
(fun i j c' d' c d ht' => (ih i (other j) c d c' d' ht'.symm).symm)
a' b' a b ht.symm
private theorem membership_forward (Ο : Form J (Set (Formula R I)))
(k : β) (other : Fin k β Form J (Set (Formula R I)))
(lab : Fin k β Set (Formula R I))
(a b : J β A) (a' b' : J β B)
(ht : tupleType S e2 (Sum.elim a b) = tupleType T e2 (Sum.elim a' b'))
(hm : value S e2 Ο a β value S e2 (.set k other lab) b) :
value T e2 Ο a' β value T e2 (.set k other lab) b' := by
obtain β¨i,c,hl,heqβ© := (mem_value_set S e2 k other lab b _).mp hm
obtain β¨c',h3β© := tupleType_append S T e2 e3 (Sum.elim b a) (Sum.elim b' a') c
(swap_type S T e2 a b a' b' ht)
have hcb := tupleType_project S T e3 e2 cross31 _ _ h3
simp only [elim_comp_cross31] at hcb
let u : J β J βͺ (J β J) β J :=
cross31.trans (Function.Embedding.sumMap (Equiv.sumComm J J).toEmbedding
(Function.Embedding.refl J))
have hca := tupleType_project S T e3 e2 u _ _ h3
have hueq (a b c : J β A) : Sum.elim (Sum.elim b a) c β u = Sum.elim c a := by
funext j; cases j <;> rfl
have hueq' (a b c : J β B) : Sum.elim (Sum.elim b a) c β u = Sum.elim c a := by
funext j; cases j <;> rfl
rw [hueq,hueq'] at hca
exact (mem_value_set T e2 k other lab b' _).mpr β¨i,c',hcb.symm.trans hl,
(equality_transfer S T e2 e3 e4 (other i) Ο c a c' a' hca).mp heqβ©
theorem membership_transfer (Ο Ο : Form J (Set (Formula R I)))
(a b : J β A) (a' b' : J β B)
(ht : tupleType S e2 (Sum.elim a b) = tupleType T e2 (Sum.elim a' b')) :
value S e2 Ο a β value S e2 Ο b β value T e2 Ο a' β value T e2 Ο b' := by
cases Ο with
| atom j => simp
| set k other lab =>
exact β¨membership_forward S T e2 e3 e4 Ο k other lab a b a' b' ht,
membership_forward T S e2 e3 e4 Ο k other lab a' b' a b ht.symmβ©
end AtomicTransfer
variable {G : Type*} [Group G] [MulAction G A]
variable [Fintype I] [DecidableEq I] [Fintype A] [Nonempty A] {s : β}
variable (S : Structure R A) (e2 : Fin s β Fin s βͺ I)
variable (hAut : β (g : G) r a b, S.rel r (g β’ a) (g β’ b) β S.rel r a b)
open Form
include hAut in
omit [Fintype I] in
theorem value_smul (g : G) (Ο : Form (Fin s) (Set (Formula R I))) (a : Fin s β A) :
g β’ value S e2 Ο a = value S e2 Ο (fun i => g β’ a i) := by
exact value_iso S S e2 (MulAction.toPerm g) (fun r a b => (hAut g r a b).symm) Ο a
include hAut in
omit [Fintype I] in
theorem value_supported (Ο : Form (Fin s) (Set (Formula R I))) (a : Fin s β A) :
Supports (G := G) a (value S e2 Ο a) := by
intro g hg
rw [value_smul S e2 hAut]
exact congrArg (value S e2 Ο) (funext hg)
omit [Fintype A] [Nonempty A] in
private theorem hereditary_mem {x y : HF A}
(hx : HereditarilySupported (G := G) s x) (hy : y β x) :
HereditarilySupported (G := G) s y := by
intro z hz
exact hx z (hz.trans (Relation.ReflTransGen.single hy))
omit [Fintype A] [Nonempty A] in
private theorem hereditary_intro (x : HF A) (hx : Supported (G := G) s x)
(hm : β y β x, HereditarilySupported (G := G) s y) :
HereditarilySupported (G := G) s x := by
intro y hy
cases hy with
| refl => exact hx
| tail hpath hstep => exact hm _ hstep _ hpath
include hAut in
omit [Fintype I] in
theorem value_hereditarily_supported (Ο : Form (Fin s) (Set (Formula R I)))
(a : Fin s β A) : HereditarilySupported (G := G) s (value S e2 Ο a) := by
induction Ο generalizing a with
| atom i =>
apply hereditary_intro _ β¨a,value_supported S e2 hAut _ aβ©
intro y hy
exact (not_mem_atom y (a i) hy).elim
| set n child label ih =>
apply hereditary_intro _ β¨a,value_supported S e2 hAut _ aβ©
intro y hy
obtain β¨i,b,ht,rflβ© := (mem_value_set S e2 n child label a y).mp hy
exact ih i b
omit [Fintype A] [Nonempty A] in
private theorem smul_mem (g : G) {x y : HF A} (h : y β x) : g β’ y β g β’ x := by
change Hereditary.map (fun a => g β’ a) y β
elements (Hereditary.map (fun a => g β’ a) x)
let := Hereditary.instDecidableEqHF (A := A)
rw [elements_map]
exact Finset.mem_image.mpr β¨y,h,rflβ©
include hAut in
omit [Fintype I] in
theorem representation (hs : 0 < s)
(hHom : β p q : Fin s β Fin s β A,
tupleType S e2 p = tupleType S e2 q β β g : G, β i, g β’ p i = q i)
(x : HF A) (hx : HereditarilySupported (G := G) s x) :
β Ο : Form (Fin s) (Set (Formula R I)), β a : Fin s β A, value S e2 Ο a = x := by
induction x using mem_wellFounded.induction with
| h x ih =>
rcases atom_or_set x with β¨b,rflβ© | hxset
Β· exact β¨.atom β¨0,hsβ©,fun _ => b,rflβ©
Β· obtain β¨a,haβ© := hx x Relation.ReflTransGen.refl
have hr : β y : {y // y β elements x},
β Ο : Form (Fin s) (Set (Formula R I)), β b : Fin s β A,
value S e2 Ο b = y.1 := by
intro y
exact ih y.1 y.2 (hereditary_mem hx y.2)
choose form mol hvalue using hr
let n := Fintype.card {y // y β elements x}
let en : Fin n β {y // y β elements x} := (Fintype.equivFin _).symm
let child : Fin n β Form (Fin s) (Set (Formula R I)) := fun i => form (en i)
let Ξ² : Fin n β Fin s β A := fun i => mol (en i)
let label : Fin n β Set (Formula R I) := fun i => tupleType S e2 (Sum.elim (Ξ² i) a)
refine β¨.set n child label,a,?_β©
apply Hereditary.ext_sets (by simp) (by rw [hxset]; rfl)
intro y
constructor
Β· intro hy
obtain β¨i,b,ht,rflβ© := (mem_value_set S e2 n child label a y).mp hy
obtain β¨g,hgβ© := hHom (Sum.elim (Ξ² i) a) (Sum.elim b a) ht.symm
have hga : β j, g β’ a j = a j := fun j => hg (.inr j)
have hgb : (fun j => g β’ Ξ² i j) = b := funext (fun j => hg (.inl j))
have hyx : (en i).1 β x := (en i).2
have hmap := smul_mem g hyx
rw [ha g hga] at hmap
have hv : value S e2 (child i) b = g β’ (en i).1 := by
rw [βhgb,βvalue_smul S e2 hAut]
exact congrArg (fun z : HF A => g β’ z) (hvalue (en i))
rw [hv]
exact hmap
Β· intro hy
let y' : {y // y β elements x} := β¨y,hyβ©
let i := en.symm y'
apply (mem_value_set S e2 n child label a y).mpr
refine β¨i,Ξ² i,rfl,?_β©
have hv := hvalue (en i)
simpa only [child,Ξ²,i,Equiv.apply_symm_apply] using hv
end
end WitnessedSeparation.Forms
namespace WitnessedSeparation.Counting
noncomputable section
open Classical
variable {R I J A B : Type*} [DecidableEq I]
def triangular {X Y : Type*} (e : X β Y) (f : X β A β B) : X Γ A β Y Γ B where
toFun p := (e p.1, f p.1 p.2)
invFun p := (e.symm p.1, (f (e.symm p.1)).symm p.2)
left_inv p := by simp
right_inv p := by simp
def snocTuple {n : β} (a : Fin n β A) (x : A) : Fin (n+1) β A :=
Fin.lastCases x a
@[simp] theorem snocTuple_castSucc {n : β} (a : Fin n β A) (x : A) (i : Fin n) :
snocTuple a x i.castSucc = a i := by simp [snocTuple]
@[simp] theorem snocTuple_last {n : β} (a : Fin n β A) (x : A) :
snocTuple a x (Fin.last n) = x := by simp [snocTuple]
def snocEquiv (n : β) : (Fin (n+1) β A) β (Fin n β A) Γ A where
toFun a := (fun i => a i.castSucc, a (Fin.last n))
invFun p := snocTuple p.1 p.2
left_inv a := by
funext i
induction i using Fin.lastCases <;> simp
right_inv p := by ext <;> simp
def appendPosition (J : Type*) (n : β) : (J β Fin n) β Unit β J β Fin (n+1) where
toFun := Sum.elim (Sum.elim Sum.inl (fun i => Sum.inr i.castSucc)) (fun _ => Sum.inr (Fin.last n))
invFun := Sum.elim (fun j => Sum.inl (Sum.inl j))
(Fin.lastCases (Sum.inr ()) (fun i => Sum.inl (Sum.inr i)))
left_inv p := by rcases p with (j|i)|u <;> simp
right_inv p := by
rcases p with j|i
Β· rfl
Β· induction i using Fin.lastCases <;> simp
variable [Fintype I] [Fintype J] [Fintype A] [Fintype B] [Nonempty A] [Nonempty B]
theorem tupleType_append_one_bijection (S : Structure R A) (T : Structure R B)
(e : J βͺ I) (E : J β Unit βͺ I) (a : J β A) (b : J β B)
(ht : tupleType S e a = tupleType T e b) :
β f : A β B, β x, tupleType S E (Sum.elim a (fun _ => x)) =
tupleType T E (Sum.elim b (fun _ => f x)) := by
let ep := Function.Embedding.inl.trans E
let i := E (Sum.inr ())
have hp := tupleType_project S T e ep (Function.Embedding.refl J) a b ht
change tupleType S ep a = tupleType T ep b at hp
have hi : i β tupleNames ep := by
rintro hh
obtain β¨j,hjβ© := (mem_tupleNames ep i).mp hh
have hh := E.injective hj
cases hh
have hn : insert i (tupleNames ep) = tupleNames E := by
ext p
simp only [Finset.mem_insert,mem_tupleNames]
constructor
Β· rintro (rfl|β¨j,rflβ©)
Β· exact β¨Sum.inr (),rflβ©
Β· exact β¨Sum.inl j,rflβ©
Β· rintro β¨j,rflβ©
rcases j with j|u
Β· exact Or.inr β¨j,rflβ©
Β· cases u; exact Or.inl rfl
have ha (x : A) : tupleType S E (Sum.elim a (fun _ => x)) =
typeOf S (tupleNames E) (Function.update (tupleAssignment ep a) i x) := by
apply tupleType_assignment
intro j
rcases j with j|u
Β· have hne : E (Sum.inl j) β i := by
intro h; have hh := E.injective h; cases hh
rw [Function.update_of_ne hne]
exact tupleAssignment_apply ep a j
Β· cases u; simp [i]
have hb (x : B) : tupleType T E (Sum.elim b (fun _ => x)) =
typeOf T (tupleNames E) (Function.update (tupleAssignment ep b) i x) := by
apply tupleType_assignment
intro j
rcases j with j|u
Β· have hne : E (Sum.inl j) β i := by
intro h; have hh := E.injective h; cases hh
rw [Function.update_of_ne hne]
exact tupleAssignment_apply ep b j
Β· cases u; simp [i]
obtain β¨f,hfβ© := extension_bijection S T (tupleNames ep) i hi
(tupleAssignment ep a) (tupleAssignment ep b) hp
refine β¨f,fun x => ?_β©
rw [ha,hb]
simpa only [hn] using hf x
theorem tupleType_append_fin_bijection (S : Structure R A) (T : Structure R B)
(e : J βͺ I) (n : β) (E : J β Fin n βͺ I) (a : J β A) (b : J β B)
(ht : tupleType S e a = tupleType T e b) :
β f : (Fin n β A) β (Fin n β B), β c,
tupleType S E (Sum.elim a c) = tupleType T E (Sum.elim b (f c)) := by
induction n with
| zero =>
let f : (Fin 0 β A) β (Fin 0 β B) :=
β¨fun _ => Fin.elim0,fun _ => Fin.elim0,
fun _ => Subsingleton.elim _ _,fun _ => Subsingleton.elim _ _β©
refine β¨f,fun c => ?_β©
let u : J β Fin 0 βͺ J :=
β¨Sum.elim id Fin.elim0,by
intro x y h
rcases x with x|x
Β· rcases y with y|y
Β· exact congrArg Sum.inl h
Β· exact Fin.elim0 y
Β· exact Fin.elim0 xβ©
have h := tupleType_project S T e E u a b ht
have ha : a β u = Sum.elim a c := by
funext j; rcases j with j|i
Β· rfl
Β· exact Fin.elim0 i
have hb : b β u = Sum.elim b (f c) := by
funext j; rcases j with j|i
Β· rfl
Β· exact Fin.elim0 i
simpa only [ha,hb] using h
| succ n ih =>
let pre : J β Fin n βͺ J β Fin (n+1) :=
Function.Embedding.sumMap (Function.Embedding.refl J) Fin.castSuccEmb
let ep := pre.trans E
obtain β¨f,hfβ© := ih ep
let E1 := (appendPosition J n).toEmbedding.trans E
have h1 (c : Fin n β A) : β g : A β B, β x,
tupleType S E1 (Sum.elim (Sum.elim a c) (fun _ => x)) =
tupleType T E1 (Sum.elim (Sum.elim b (f c)) (fun _ => g x)) :=
tupleType_append_one_bijection S T ep E1 _ _ (hf c)
choose g hg using h1
let F := (snocEquiv (A:=A) n).trans
((triangular f g).trans (snocEquiv (A:=B) n).symm)
refine β¨F,fun c => ?_β©
have hh := tupleType_project S T E1 E (appendPosition J n).symm.toEmbedding
_ _ (hg (fun i => c i.castSucc) (c (Fin.last n)))
have ha : (Sum.elim (Sum.elim a (fun i => c i.castSucc))
(fun _ => c (Fin.last n))) β (appendPosition J n).symm = Sum.elim a c := by
funext j
rcases j with j|i
Β· rfl
Β· induction i using Fin.lastCases <;> simp [appendPosition]
have hb : (Sum.elim (Sum.elim b (f (fun i => c i.castSucc)))
(fun _ => g (fun i => c i.castSucc) (c (Fin.last n)))) β
(appendPosition J n).symm = Sum.elim b (F c) := by
funext j
rcases j with j|i
Β· rfl
Β· induction i using Fin.lastCases <;>
simp [appendPosition,F,snocEquiv,triangular,snocTuple]
simpa only [Equiv.coe_toEmbedding,ha,hb] using hh
theorem tupleType_append_bijection {D : Type*} [Fintype D]
(S : Structure R A) (T : Structure R B)
(e : J βͺ I) (E : J β D βͺ I) (a : J β A) (b : J β B)
(ht : tupleType S e a = tupleType T e b) :
β f : (D β A) β (D β B), β c,
tupleType S E (Sum.elim a c) = tupleType T E (Sum.elim b (f c)) := by
let en := Fintype.equivFin D
let E' := (Equiv.sumCongr (Equiv.refl J) en.symm).toEmbedding.trans E
obtain β¨f,hfβ© := tupleType_append_fin_bijection S T e (Fintype.card D) E' a b ht
let F := (Equiv.arrowCongr en (Equiv.refl A)).trans
(f.trans (Equiv.arrowCongr en.symm (Equiv.refl B)))
refine β¨F,fun c => ?_β©
have hh := tupleType_project S T E' E
(Equiv.sumCongr (Equiv.refl J) en).toEmbedding _ _ (hf (c β en.symm))
have ha : (Sum.elim a (c β en.symm)) β (Equiv.sumCongr (Equiv.refl J) en) =
Sum.elim a c := by
funext j; rcases j with j|j <;> simp
have hb : (Sum.elim b (f (c β en.symm))) β (Equiv.sumCongr (Equiv.refl J) en) =
Sum.elim b (F c) := by
funext j; rcases j with j|j <;> rfl
simpa only [Equiv.coe_toEmbedding,ha,hb] using hh
theorem tupleType_extension_equiv {D : Type*} [Fintype D]
(S : Structure R A) (T : Structure R B)
(e : J βͺ I) (E : J β D βͺ I) (a : J β A) (b : J β B)
(ht : tupleType S e a = tupleType T e b) (Ο : Set (Formula R I)) :
Nonempty ({c : D β A // tupleType S E (Sum.elim a c) = Ο} β
{d : D β B // tupleType T E (Sum.elim b d) = Ο}) := by
obtain β¨f,hfβ© := tupleType_append_bijection S T e E a b ht
exact β¨f.subtypeEquiv (fun c => by rw [hf c])β©
end
end WitnessedSeparation.Counting
namespace WitnessedSeparation.Forms
noncomputable section
open Classical Counting Hereditary
open scoped BigOperators
private theorem card_eq_mul_fiber {X Y : Type*} [Fintype X] [Fintype Y]
(f : X β Y) (yβ : Y)
(h : β y, Fintype.card {x // f x = y} = Fintype.card {x // f x = yβ}) :
Fintype.card X = Fintype.card Y * Fintype.card {x // f x = yβ} := by
calc
Fintype.card X = Fintype.card (Ξ£ y, {x // f x = y}) :=
Fintype.card_congr (Equiv.sigmaFiberEquiv f).symm
_ = β y, Fintype.card {x // f x = y} := Fintype.card_sigma
_ = _ := by simp only [h,Finset.sum_const,Finset.card_univ,smul_eq_mul]
private theorem card_eq_of_uniform_fibers {X X' Y Y' : Type*}
[Fintype X] [Fintype X'] [Fintype Y] [Fintype Y']
(f : X β Y) (f' : X' β Y') (y : Y) (y' : Y')
(hx : Fintype.card X = Fintype.card X')
(hf : β z, Fintype.card {x // f x = z} = Fintype.card {x // f x = y})
(hf' : β z, Fintype.card {x // f' x = z} = Fintype.card {x // f' x = y'})
(hy : 0 < Fintype.card {x // f x = y})
(he : Fintype.card {x // f x = y} = Fintype.card {x // f' x = y'}) :
Fintype.card Y = Fintype.card Y' := by
have h := (card_eq_mul_fiber f y hf).symm.trans
(hx.trans (card_eq_mul_fiber f' y' hf'))
rw [βhe] at h
exact Nat.eq_of_mul_eq_mul_right hy h
private theorem range_card_mul_fiber {X Y : Type*} [Fintype X]
(f : X β Y) (xβ : X)
(h : β x, Nat.card {z // f z = f x} = Nat.card {z // f z = f xβ}) :
Fintype.card X = Nat.card (Set.range f) * Nat.card {z // f z = f xβ} := by
let := (Set.finite_range f).fintype
let fR : X β Set.range f := fun x => β¨f x,β¨x,rflβ©β©
have k (y : Set.range f) : Nat.card {x // fR x = y} =
Nat.card {z // f z = f xβ} := by
have hp (x : X) : fR x = y β f x = y.1 := Subtype.ext_iff
rw [Nat.card_congr (Equiv.subtypeEquivRight hp)]
obtain β¨x,hxβ© := y.2
rw [βhx]
exact h x
have hh := card_eq_mul_fiber fR (fR xβ) (fun y => by
simpa only [βNat.card_eq_fintype_card] using (k y).trans (k (fR xβ)).symm)
have hh' : Nat.card X = Nat.card (Set.range f) * Nat.card {x // fR x = fR xβ} := by
simpa only [βNat.card_eq_fintype_card] using hh
rw [k] at hh'
simpa only [βNat.card_eq_fintype_card] using hh'
variable {R I A B P : Type*} [Fintype I] [DecidableEq I]
variable [Fintype A] [Fintype B] [Nonempty A] [Nonempty B] [Fintype P]
variable {s : β}
def Molecules (S : Structure R A) (ep : P β Fin s βͺ I)
(p : P β A) (Ο : Set (Formula R I)) :=
{a : Fin s β A // tupleType S ep (Sum.elim p a) = Ο}
instance (S : Structure R A) (ep : P β Fin s βͺ I)
(p : P β A) (Ο : Set (Formula R I)) : Fintype (Molecules S ep p Ο) :=
inferInstanceAs (Fintype {a : Fin s β A // tupleType S ep (Sum.elim p a) = Ο})
def labelValues (S : Structure R A) (ep : P β Fin s βͺ I)
(e2 : Fin s β Fin s βͺ I) (p : P β A) (Ο : Set (Formula R I))
(Ο : Form (Fin s) (Set (Formula R I))) : Set (HF A) :=
Set.range (fun a : Molecules S ep p Ο => Form.value S e2 Ο a.1)
instance (S : Structure R A) (ep : P β Fin s βͺ I)
(e2 : Fin s β Fin s βͺ I) (p : P β A) (Ο : Set (Formula R I))
(Ο : Form (Fin s) (Set (Formula R I))) : Fintype (labelValues S ep e2 p Ο Ο) :=
(Set.finite_range _).fintype
section Group
variable {G : Type*} [Group G] [MulAction G A]
variable (S : Structure R A) (ep : P β Fin s βͺ I) (e2 : Fin s β Fin s βͺ I)
variable (hAut : β (g : G) r a b, S.rel r (g β’ a) (g β’ b) β S.rel r a b)
variable (p : P β A) (Ο : Set (Formula R I))
include hAut in
omit [Fintype I] [Fintype A] in
private theorem mol_type_smul (g : G) (hp : β i, g β’ p i = p i) (a : Fin s β A) :
tupleType S ep (Sum.elim p (fun i => g β’ a i)) = tupleType S ep (Sum.elim p a) := by
have hh := tupleType_iso S S ep (MulAction.toPerm g) (fun r a b => (hAut g r a b).symm)
(Sum.elim p a)
have hh' : (MulAction.toPerm g) β Sum.elim p a = Sum.elim p (fun i => g β’ a i) := by
funext i; rcases i with i|i
Β· exact hp i
Β· rfl
rw [hh'] at hh
exact hh.symm
def moleculesPerm (g : G) (hp : β i, g β’ p i = p i) :
Molecules S ep p Ο β Molecules S ep p Ο :=
(Equiv.piCongrRight (fun _ : Fin s => MulAction.toPerm g)).subtypeEquiv
(fun a => by
change tupleType S ep (Sum.elim p a) = Ο β
tupleType S ep (Sum.elim p (fun i => g β’ a i)) = Ο
rw [mol_type_smul S ep hAut p g hp a])
include hAut in
omit [Fintype I] in
theorem uniform_value_fibers
(hHom : β a b : P β Fin s β A,
tupleType S ep a = tupleType S ep b β β g : G, β i, g β’ a i = b i)
(Ο : Form (Fin s) (Set (Formula R I))) (a a' : Molecules S ep p Ο) :
Fintype.card {b : Molecules S ep p Ο // Form.value S e2 Ο b.1 = Form.value S e2 Ο a.1} =
Fintype.card {b : Molecules S ep p Ο // Form.value S e2 Ο b.1 = Form.value S e2 Ο a'.1} := by
obtain β¨g,hgβ© := hHom (Sum.elim p a.1) (Sum.elim p a'.1) (a.2.trans a'.2.symm)
have hp : β i, g β’ p i = p i := fun i => hg (.inl i)
have ha : (fun i => g β’ a.1 i) = a'.1 := funext (fun i => hg (.inr i))
let f := moleculesPerm S ep hAut p Ο g hp
have hv (b : Molecules S ep p Ο) :
Form.value S e2 Ο (f b).1 = g β’ Form.value S e2 Ο b.1 := by
exact (value_smul S e2 hAut g Ο b.1).symm
have hv' : Form.value S e2 Ο a'.1 = g β’ Form.value S e2 Ο a.1 := by
rw [βha]
exact (value_smul S e2 hAut g Ο a.1).symm
apply Fintype.card_congr
apply f.subtypeEquiv
intro b
rw [hv,hv']
exact (MulAction.injective g).eq_iff.symm
include hAut in
omit [Fintype I] in
private theorem label_orbit
(hHom : β a b : P β Fin s β A,
tupleType S ep a = tupleType S ep b β β g : G, β i, g β’ a i = b i)
(Ο : Form (Fin s) (Set (Formula R I))) (x y : HF A)
(hx : x β labelValues S ep e2 p Ο Ο) (hy : y β labelValues S ep e2 p Ο Ο) :
β g : G, (β i, g β’ p i = p i) β§ g β’ x = y := by
obtain β¨a,rflβ© := hx
obtain β¨b,rflβ© := hy
obtain β¨g,hgβ© := hHom (Sum.elim p a.1) (Sum.elim p b.1) (a.2.trans b.2.symm)
refine β¨g,fun i => hg (.inl i),?_β©
rw [value_smul S e2 hAut]
exact congrArg (Form.value S e2 Ο) (funext (fun i => hg (.inr i)))
include hAut in
omit [Fintype I] in
private theorem label_smul_mem (g : G) (hp : β i, g β’ p i = p i)
(Ο : Form (Fin s) (Set (Formula R I))) (x : HF A)
(hx : x β labelValues S ep e2 p Ο Ο) : g β’ x β labelValues S ep e2 p Ο Ο := by
obtain β¨a,rflβ© := hx
refine β¨moleculesPerm S ep hAut p Ο g hp a,?_β©
exact (value_smul S e2 hAut g Ο a.1).symm
include hAut in
omit [Fintype I] in
theorem label_partition
(hHom : β a b : P β Fin s β A,
tupleType S ep a = tupleType S ep b β β g : G, β i, g β’ a i = b i)
(Ο Ο : Form (Fin s) (Set (Formula R I))) (Ο : Set (Formula R I)) (x : HF A)
(hx : x β labelValues S ep e2 p Ο Ο) (hx' : x β labelValues S ep e2 p Ο Ο) :
labelValues S ep e2 p Ο Ο = labelValues S ep e2 p Ο Ο := by
ext y
constructor
Β· intro hy
obtain β¨g,hp,hgβ© := label_orbit S ep e2 hAut p Ο hHom Ο x y hx hy
rw [βhg]
exact label_smul_mem S ep e2 hAut p Ο g hp Ο x hx'
Β· intro hy
obtain β¨g,hp,hgβ© := label_orbit S ep e2 hAut p Ο hHom Ο x y hx' hy
rw [βhg]
exact label_smul_mem S ep e2 hAut p Ο g hp Ο x hx
end Group
variable (S : Structure R A) (T : Structure R B)
variable (ep : P β Fin s βͺ I) (epp : (P β Fin s) β Fin s βͺ I)
variable (e2 : Fin s β Fin s βͺ I)
variable (e3 : (Fin s β Fin s) β Fin s βͺ I)
variable (e4 : ((Fin s β Fin s) β Fin s) β Fin s βͺ I)
private def skipMiddle : P β Fin s βͺ (P β Fin s) β Fin s :=
Function.Embedding.sumMap Function.Embedding.inl (Function.Embedding.refl _)
private def lastTwo : Fin s β Fin s βͺ (P β Fin s) β Fin s :=
Function.Embedding.sumMap Function.Embedding.inr (Function.Embedding.refl _)
omit [Fintype A] [Nonempty A] [Fintype P] in
@[simp] private theorem elim_skipMiddle (p : P β A) (a b : Fin s β A) :
(Sum.elim (Sum.elim p a) b) β skipMiddle = Sum.elim p b := by
funext j; cases j <;> rfl
omit [Fintype A] [Nonempty A] [Fintype P] in
@[simp] private theorem elim_lastTwo (p : P β A) (a b : Fin s β A) :
(Sum.elim (Sum.elim p a) b) β lastTwo = Sum.elim a b := by
funext j; cases j <;> rfl
include epp e3 e4 in
theorem value_fiber_equiv (p : P β A) (q : P β B) (Ο : Set (Formula R I))
(Ο : Form (Fin s) (Set (Formula R I)))
(a : Molecules S ep p Ο) (a' : Molecules T ep q Ο) :
Nonempty ({b : Molecules S ep p Ο // Form.value S e2 Ο b.1 = Form.value S e2 Ο a.1} β
{b : Molecules T ep q Ο // Form.value T e2 Ο b.1 = Form.value T e2 Ο a'.1}) := by
obtain β¨f,hfβ© := tupleType_append_bijection S T ep epp
(Sum.elim p a.1) (Sum.elim q a'.1) (a.2.trans a'.2.symm)
have htype (b : Fin s β A) : tupleType S ep (Sum.elim p b) =
tupleType T ep (Sum.elim q (f b)) := by
have hh := tupleType_project S T epp ep skipMiddle _ _ (hf b)
simpa only [elim_skipMiddle] using hh
have hval (b : Fin s β A) : Form.value S e2 Ο b = Form.value S e2 Ο a.1 β
Form.value T e2 Ο (f b) = Form.value T e2 Ο a'.1 := by
have hh := tupleType_project S T epp e2 lastTwo _ _ (hf b)
simp only [elim_lastTwo] at hh
simpa only [eq_comm] using equality_transfer S T e2 e3 e4 Ο Ο a.1 b a'.1 (f b) hh
let F : {b : Fin s β A // tupleType S ep (Sum.elim p b) = Ο β§
Form.value S e2 Ο b = Form.value S e2 Ο a.1} β
{b : Fin s β B // tupleType T ep (Sum.elim q b) = Ο β§
Form.value T e2 Ο b = Form.value T e2 Ο a'.1} := f.subtypeEquiv (fun b => show
(tupleType S ep (Sum.elim p b) = Ο β§ Form.value S e2 Ο b = Form.value S e2 Ο a.1) β
(tupleType T ep (Sum.elim q (f b)) = Ο β§ Form.value T e2 Ο (f b) = Form.value T e2 Ο a'.1)
from and_congr (by rw [htype b]) (hval b))
exact β¨(Equiv.subtypeSubtypeEquivSubtypeInter _ _).trans
(F.trans (Equiv.subtypeSubtypeEquivSubtypeInter _ _).symm)β©
include epp e3 e4 in
theorem label_overlap_transfer (e0 : P βͺ I) (p : P β A) (q : P β B)
(hp : tupleType S e0 p = tupleType T e0 q)
(Ο Ο : Form (Fin s) (Set (Formula R I))) (Ο Ο : Set (Formula R I))
(hx : β x, x β labelValues S ep e2 p Ο Ο β§ x β labelValues S ep e2 p Ο Ο) :
β y, y β labelValues T ep e2 q Ο Ο β§ y β labelValues T ep e2 q Ο Ο := by
obtain β¨x,β¨a,haβ©,β¨b,hbβ©β© := hx
obtain β¨a',ha'β© := tupleType_append S T e0 ep p q a.1 hp
obtain β¨b',hb'β© := tupleType_append S T ep epp
(Sum.elim p a.1) (Sum.elim q a') b.1 ha'
have ht := tupleType_project S T epp ep skipMiddle _ _ hb'
simp only [elim_skipMiddle] at ht
have he := tupleType_project S T epp e2 lastTwo _ _ hb'
simp only [elim_lastTwo] at he
have hv := (equality_transfer S T e2 e3 e4 Ο Ο a.1 b.1 a' b' he).mp (ha.trans hb.symm)
refine β¨Form.value T e2 Ο a',?_,?_β©
Β· exact β¨β¨a',ha'.symm.trans a.2β©,rflβ©
Β· exact β¨β¨b',ht.symm.trans b.2β©,hv.symmβ©
include epp e3 e4 in
theorem label_values_card
{G H : Type*} [Group G] [MulAction G A] [Group H] [MulAction H B]
(hAutA : β (g : G) r a b, S.rel r (g β’ a) (g β’ b) β S.rel r a b)
(hAutB : β (g : H) r a b, T.rel r (g β’ a) (g β’ b) β T.rel r a b)
(hHomA : β a b : P β Fin s β A,
tupleType S ep a = tupleType S ep b β β g : G, β i, g β’ a i = b i)
(hHomB : β a b : P β Fin s β B,
tupleType T ep a = tupleType T ep b β β g : H, β i, g β’ a i = b i)
(p : P β A) (q : P β B) (Ο : Set (Formula R I))
(Ο : Form (Fin s) (Set (Formula R I)))
(a : Molecules S ep p Ο) (a' : Molecules T ep q Ο) :
Nat.card (labelValues S ep e2 p Ο Ο) = Nat.card (labelValues T ep e2 q Ο Ο) := by
let va : Molecules S ep p Ο β HF A := fun b => Form.value S e2 Ο b.1
let vb : Molecules T ep q Ο β HF B := fun b => Form.value T e2 Ο b.1
have ha := range_card_mul_fiber va a (fun b => by simpa only [βNat.card_eq_fintype_card] using uniform_value_fibers S ep e2 hAutA p Ο hHomA Ο b a)
have hb := range_card_mul_fiber vb a' (fun b => by simpa only [βNat.card_eq_fintype_card] using uniform_value_fibers T ep e2 hAutB q Ο hHomB Ο b a')
let e0 := Function.Embedding.inl.trans ep
have hp := tupleType_project S T ep e0 Function.Embedding.inl
(Sum.elim p a.1) (Sum.elim q a'.1) (a.2.trans a'.2.symm)
change tupleType S e0 p = tupleType T e0 q at hp
obtain β¨fβ© := tupleType_extension_equiv S T e0 ep p q hp Ο
have hn : Fintype.card (Molecules S ep p Ο) = Fintype.card (Molecules T ep q Ο) :=
Fintype.card_congr f
obtain β¨fvβ© := value_fiber_equiv S T ep epp e2 e3 e4 p q Ο Ο a a'
have he : Nat.card {b // va b = va a} = Nat.card {b // vb b = vb a'} :=
Nat.card_congr fv
have hpos : 0 < Nat.card {b // va b = va a} := by
rw [Nat.card_eq_fintype_card]
exact Fintype.card_pos_iff.mpr β¨β¨a,rflβ©β©
have hc := ha.symm.trans (hn.trans hb)
rw [βhe] at hc
have hh := Nat.eq_of_mul_eq_mul_right hpos hc
simpa only [βNat.card_eq_fintype_card,labelValues,va,vb] using hh
end
end WitnessedSeparation.Forms
namespace WitnessedSeparation
noncomputable section
open Classical
private def cellSetoid {L X : Type*} (C : L β Set X) : Setoid L :=
β¨fun l k => C l = C k,β¨fun _ => rfl,Eq.symm,Eq.transβ©β©
theorem glue_finite_cells {L X Y : Type*} (C : L β Set X) (D : L β Set Y)
(coverC : β x, β l, x β C l) (coverD : β y, β l, y β D l)
(partC : β l k x, x β C l β x β C k β C l = C k)
(partD : β l k y, y β D l β y β D k β D l = D k)
(same : β l k, C l = C k β D l = D k)
(finC : β l, (C l).Finite) (finD : β l, (D l).Finite)
(card : β l, Nat.card (C l) = Nat.card (D l)) :
β f : X β Y, β x, β l, x β C l β§ f x β D l := by
let Q := Quotient (cellSetoid C)
let lc : X β L := fun x => (coverC x).choose
let ld : Y β L := fun y => (coverD y).choose
have hc (x : X) : x β C (lc x) := (coverC x).choose_spec
have hd (y : Y) : y β D (ld y) := (coverD y).choose_spec
let c : X β Q := fun x => Quotient.mk _ (lc x)
let d : Y β Q := fun y => Quotient.mk _ (ld y)
have ce (x : X) (q : Q) : c x = q β x β C q.out := by
constructor
Β· intro h
have he : C (lc x) = C q.out := Quotient.exact (h.trans (Quotient.out_eq q).symm)
rw [βhe]; exact hc x
Β· intro h
have he := partC (lc x) q.out x (hc x) h
exact (Quotient.sound he).trans (Quotient.out_eq q)
have de (y : Y) (q : Q) : d y = q β y β D q.out := by
constructor
Β· intro h
have he : C (ld y) = C q.out := Quotient.exact (h.trans (Quotient.out_eq q).symm)
rw [β(same _ _).mp he]; exact hd y
Β· intro h
have he := (same _ _).mpr (partD (ld y) q.out y (hd y) h)
exact (Quotient.sound he).trans (Quotient.out_eq q)
have ef (q : Q) : Nonempty ({x // c x = q} β {y // d y = q}) := by
let := (finC q.out).fintype
let := (finD q.out).fintype
have hcard : Fintype.card (C q.out) = Fintype.card (D q.out) := by
simpa only [Nat.card_eq_fintype_card] using card q.out
let e := Fintype.equivOfCardEq hcard
exact β¨(Equiv.subtypeEquivRight (fun x => ce x q)).trans
(e.trans (Equiv.subtypeEquivRight (fun y => de y q)).symm)β©
let F := Equiv.ofFiberEquiv (fun q => Classical.choice (ef q))
refine β¨F,fun x => β¨(c x).out,(ce x (c x)).mp rfl,?_β©β©
apply (de (F x) (c x)).mp
exact Equiv.ofFiberEquiv_map _ x
end
end WitnessedSeparation
end OAI
import OAI.Computability.WitnessedChoice.Homogeneity
namespace OAI
namespace WitnessedSeparation.Grid
noncomputable section
open Classical Finset
variable {n M : β} {b b' : Vertex n β Scalar}
theorem boundary_eq_incidence : (boundary : (Edge n β Scalar) ββ[Scalar] (Vertex n β Scalar)) =
Flows.incidence tail head := rfl
def GiantBound (n M : β) : Prop :=
((12*(M:β))/boxConstant)^((3:β)/2) < ((n+1)^3:β)
theorem giant_exists_of_bound (hbound : GiantBound n M) (T : Finset (Edge n)) (hT : T.card β€ 6*M) :
β v, Flows.IsGiant tail head T v := by
have hnum : ((2*T.card:β)/boxConstant)^((3:β)/2) < ((n+1)^3:β) := by
apply lt_of_le_of_lt _ hbound
apply Real.rpow_le_rpow (div_nonneg (by positivity) boxConstant_pos.le) _ (by norm_num)
apply div_le_div_of_nonneg_right _ boxConstant_pos.le
have hh : (T.card:β) β€ 6*M := by exact_mod_cast hT
linarith
obtain β¨c,hcβ© := exists_giant T hnum
refine β¨c.out,?_β©
change Fintype.card (Vertex n) < 2*(Flows.cell tail head T c).card
have hcard : Fintype.card (Vertex n) = (n+1)^3 := by
simp only [Vertex,Fintype.card_prod,Fintype.card_fin]; ring
simpa only [hcard] using hc
theorem defect_transport (hbound : GiantBound n M) (T U : Finset (Edge n)) (hTU : T β U)
(hU : U.card β€ 6*M) (t : Edge n β Scalar) (w : Vertex n)
(hw : Flows.IsGiant tail head T w) (ht : boundary t = b'-b-Pi.single w 1) :
β t' : Edge n β Scalar, β w' : Vertex n,
Flows.IsGiant tail head U w' β§ boundary t' = b'-b-Pi.single w' 1 β§ β e β T, t' e = t e := by
obtain β¨w',hw'β© := giant_exists_of_bound hbound U hU
have hc := Flows.giants_connected tail head (Flows.giant_mono tail head hTU hw') hw
obtain β¨p,hp,hdβ© := Flows.path_flow tail head T hc
refine β¨t+p,w',hw',?_,?_β©
Β· rw [map_add,ht,boundary_eq_incidence,hd]
abel
Β· intro e he; simp [hp e he]
def CompatibleAssignment {I : Type*} [DecidableEq I] (names : Finset I)
(a : I β Atom b) (a' : I β Atom b') : Prop :=
β t : Edge n β Scalar, β w : Vertex n,
Flows.IsGiant tail head (touches names a) w β§ boundary t = b'-b-Pi.single w 1 β§
β i β names, AtomShift t (a i) (a' i)
theorem CompatibleAssignment.mono {I : Type*} [DecidableEq I] {names small : Finset I}
(hs : small β names) {a : I β Atom b} {a' : I β Atom b'}
(h : CompatibleAssignment names a a') : CompatibleAssignment small a a' := by
obtain β¨t,w,hw,ht,haβ© := h
exact β¨t,w,Flows.giant_mono tail head (touches_mono hs a) hw,ht,fun i hi => ha i (hs hi)β©
theorem CompatibleAssignment.extend (hn : 1 β€ n) (hbound : GiantBound n M)
(names : Finset (Fin M)) (a : Fin M β Atom b) (a' : Fin M β Atom b')
(h : CompatibleAssignment names a a') (i : Fin M) :
β e : Atom b β Atom b', β x,
CompatibleAssignment (insert i (names.erase i)) (Function.update a i x) (Function.update a' i (e x)) := by
obtain β¨t,w,hw,ht,haβ© := h.mono (erase_subset i names)
let T := touches (names.erase i) a
have hcard : (names.erase i).card + 1 β€ M := by
have hsub : names.erase i β (univ : Finset (Fin M)).erase i := erase_subset_erase i (subset_univ _)
have hh := card_le_card hsub
have hpos := i.isLt
rw [card_erase_of_mem (mem_univ _),card_univ,Fintype.card_fin] at hh
omega
have hj (J : Block n) : (T βͺ blockEdges J).card β€ 6*M := by
calc
_ β€ T.card + (blockEdges J).card := card_union_le _ _
_ β€ 6*(names.erase i).card + 6 := Nat.add_le_add (touches_card _ _) (blockEdges_card _)
_ β€ 6*M := by omega
have hmove (J : Block n) := defect_transport hbound T (T βͺ blockEdges J)
subset_union_left (hj J) t w hw ht
choose tj wj hjg hjd hjs using hmove
have hV : 2 β€ Fintype.card (Vertex n) := by
have hc : Fintype.card (Vertex n) = (n+1)^3 := by
simp only [Vertex,Fintype.card_prod,Fintype.card_fin]; ring
rw [hc]
have hh : 2^3 β€ (n+1)^3 := Nat.pow_le_pow_left (by omega) 3
omega
have hv (v : Vertex n) : boundary (tj (.inr v)) v = b' v-b v := by
have hwv : wj (.inr v) β v := Flows.giant_ne_isolated tail head hV (hjg (.inr v)) (by
intro e he
exact mem_union_right _ (by simpa [blockEdges,incident,or_comm] using he))
have hh := congrFun (hjd (.inr v)) v
simpa [Pi.single_apply,Ne.symm hwv] using hh
let e := blockShiftEquiv (fun e => tj (.inl e)) (fun v => tj (.inr v)) hv
refine β¨e,fun x => ?_β©
let J := atomBlock x
refine β¨tj J,wj J,?_,hjd J,?_β©
Β· rw [touches_insert_update]
exact hjg J
Β· intro j hj'
rcases mem_insert.mp hj' with rfl | hj'