Download data/lean/OAI/Computability/WitnessedChoice/FormTransfer.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 42.1 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/WitnessedChoice/FormTransfer.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/WitnessedChoice/FormTransfer.lean
-
curl -L -o FormTransfer.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/WitnessedChoice/FormTransfer.lean
42.1 kB
| import OAI.Computability.WitnessedChoice.SupportedForms | |
| namespace OAI | |
| namespace WitnessedSeparation.Forms | |
| noncomputable section | |
| open Classical Counting Hereditary | |
| variable {R I A B P G H : Type*} | |
| variable [Fintype I] [DecidableEq I] [Fintype A] [Fintype B] | |
| variable [Nonempty A] [Nonempty B] [Fintype P] | |
| variable [Group G] [MulAction G A] [Group H] [MulAction H B] | |
| variable {s : β} | |
| abbrev Domain (G : Type*) [Group G] [MulAction G A] (s : β) := | |
| {x : HF A // HereditarilySupported (G := G) s x} | |
| def Cell (S : Structure R A) (ep : P β Fin s βͺ I) (e2 : Fin s β Fin s βͺ I) | |
| (p : P β A) (Ο : Form (Fin s) (Set (Formula R I))) (Ο : Set (Formula R I)) : | |
| Set (Domain (A := A) G s) := | |
| {x | x.1 β labelValues S ep e2 p Ο Ο} | |
| 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) (e3 : (Fin s β Fin s) β Fin s βͺ I) | |
| variable (e4 : ((Fin s β Fin s) β Fin s) β Fin s βͺ I) | |
| variable (hAutA : β (g : G) r a b, S.rel r (g β’ a) (g β’ b) β S.rel r a b) | |
| variable (hAutB : β (g : H) r a b, T.rel r (g β’ a) (g β’ b) β T.rel r a b) | |
| def cellEquiv (p : P β A) (Ο : Form (Fin s) (Set (Formula R I))) (Ο : Set (Formula R I)) : | |
| Cell (G := G) S ep e2 p Ο Ο β labelValues S ep e2 p Ο Ο := | |
| Equiv.subtypeSubtypeEquivSubtype | |
| (p := HereditarilySupported (G := G) s) | |
| (q := fun x => x β labelValues S ep e2 p Ο Ο) (fun hx => by | |
| obtain β¨a,rflβ© := hx | |
| exact value_hereditarily_supported S e2 hAutA Ο a.1) | |
| include hAutA in | |
| omit [Fintype I] in | |
| private theorem cell_finite (p : P β A) (Ο : Form (Fin s) (Set (Formula R I))) (Ο : Set (Formula R I)) : | |
| (Cell (G := G) S ep e2 p Ο Ο).Finite := by | |
| let := Fintype.ofEquiv (labelValues S ep e2 p Ο Ο) (cellEquiv S ep e2 hAutA p Ο Ο).symm | |
| exact Set.toFinite _ | |
| include hAutA hAutB epp e3 e4 in | |
| theorem supported_domain_bijection (hs : 0 < s) (e0 : P βͺ I) | |
| (hHomA2 : β a b : Fin s β Fin s β A, | |
| tupleType S e2 a = tupleType S e2 b β β g : G, β i, g β’ a i = b i) | |
| (hHomB2 : β a b : Fin s β Fin s β B, | |
| tupleType T e2 a = tupleType T e2 b β β g : H, β i, g β’ a i = b i) | |
| (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) (hp : tupleType S e0 p = tupleType T e0 q) : | |
| β f : Domain (A := A) G s β Domain (A := B) H s, | |
| β x, β Ο : Form (Fin s) (Set (Formula R I)), β a : Fin s β A, β b : Fin s β B, | |
| Form.value S e2 Ο a = x.1 β§ Form.value T e2 Ο b = (f x).1 β§ | |
| tupleType S ep (Sum.elim p a) = tupleType T ep (Sum.elim q b) := by | |
| let L := {l : Form (Fin s) (Set (Formula R I)) Γ Set (Formula R I) // | |
| Nonempty (Molecules S ep p l.2)} | |
| let C : L β Set (Domain (A := A) G s) := fun l => Cell S ep e2 p l.1.1 l.1.2 | |
| let D : L β Set (Domain (A := B) H s) := fun l => Cell T ep e2 q l.1.1 l.1.2 | |
| have nonemptyB (l : L) : Nonempty (Molecules T ep q l.1.2) := by | |
| obtain β¨fβ© := tupleType_extension_equiv S T e0 ep p q hp l.1.2 | |
| exact Nonempty.map f l.2 | |
| have coverC : β x, β l, x β C l := by | |
| intro x | |
| obtain β¨Ο,a,haβ© := representation S e2 hAutA hs hHomA2 x.1 x.2 | |
| let Ο := tupleType S ep (Sum.elim p a) | |
| let l : L := β¨(Ο,Ο),β¨β¨a,rflβ©β©β© | |
| exact β¨l,β¨β¨a,rflβ©,haβ©β© | |
| have coverD : β y, β l, y β D l := by | |
| intro y | |
| obtain β¨Ο,b,hbβ© := representation T e2 hAutB hs hHomB2 y.1 y.2 | |
| obtain β¨a,haβ© := tupleType_append T S e0 ep q p b hp.symm | |
| let Ο := tupleType T ep (Sum.elim q b) | |
| let l : L := β¨(Ο,Ο),β¨β¨a,ha.symmβ©β©β© | |
| exact β¨l,β¨β¨b,rflβ©,hbβ©β© | |
| have partC : β l k x, x β C l β x β C k β C l = C k := by | |
| intro l k x hx hk | |
| have hh := label_partition S ep e2 hAutA p l.1.2 hHomA l.1.1 k.1.1 k.1.2 x.1 hx hk | |
| exact congrArg (fun Z : Set (HF A) => {x : Domain G s | x.1 β Z}) hh | |
| have partD : β l k x, x β D l β x β D k β D l = D k := by | |
| intro l k x hx hk | |
| have hh := label_partition T ep e2 hAutB q l.1.2 hHomB l.1.1 k.1.1 k.1.2 x.1 hx hk | |
| exact congrArg (fun Z : Set (HF B) => {x : Domain H s | x.1 β Z}) hh | |
| have same : β l k, C l = C k β D l = D k := by | |
| intro l k | |
| constructor | |
| Β· intro he | |
| obtain β¨aβ© := l.2 | |
| let x : Domain G s := β¨Form.value S e2 l.1.1 a.1, | |
| value_hereditarily_supported S e2 hAutA _ _β© | |
| have hx : x β C l := β¨a,rflβ© | |
| have hk : x β C k := he βΈ hx | |
| obtain β¨y,hy,hy'β© := label_overlap_transfer S T ep epp e2 e3 e4 e0 p q hp | |
| l.1.1 k.1.1 l.1.2 k.1.2 β¨x.1,hx,hkβ© | |
| have hsupp : HereditarilySupported (G := H) s y := by | |
| obtain β¨b,rflβ© := hy | |
| exact value_hereditarily_supported T e2 hAutB _ _ | |
| exact partD l k β¨y,hsuppβ© hy hy' | |
| Β· intro he | |
| obtain β¨bβ© := nonemptyB l | |
| let y : Domain H s := β¨Form.value T e2 l.1.1 b.1, | |
| value_hereditarily_supported T e2 hAutB _ _β© | |
| have hy : y β D l := β¨b,rflβ© | |
| have hk : y β D k := he βΈ hy | |
| obtain β¨x,hx,hx'β© := label_overlap_transfer T S ep epp e2 e3 e4 e0 q p hp.symm | |
| l.1.1 k.1.1 l.1.2 k.1.2 β¨y.1,hy,hkβ© | |
| have hsupp : HereditarilySupported (G := G) s x := by | |
| obtain β¨a,rflβ© := hx | |
| exact value_hereditarily_supported S e2 hAutA _ _ | |
| exact partC l k β¨x,hsuppβ© hx hx' | |
| have card : β l, Nat.card (C l) = Nat.card (D l) := by | |
| intro l | |
| obtain β¨aβ© := l.2 | |
| obtain β¨bβ© := nonemptyB l | |
| have hh := label_values_card S T ep epp e2 e3 e4 hAutA hAutB hHomA hHomB | |
| p q l.1.2 l.1.1 a b | |
| have he := Nat.card_congr (cellEquiv S ep e2 hAutA p l.1.1 l.1.2) | |
| have hf := Nat.card_congr (cellEquiv T ep e2 hAutB q l.1.1 l.1.2) | |
| exact he.trans (hh.trans hf.symm) | |
| obtain β¨f,hfβ© := WitnessedSeparation.glue_finite_cells C D coverC coverD partC partD same | |
| (fun l => cell_finite S ep e2 hAutA p l.1.1 l.1.2) | |
| (fun l => cell_finite T ep e2 hAutB q l.1.1 l.1.2) card | |
| refine β¨f,fun x => ?_β© | |
| obtain β¨l,β¨a,haβ©,β¨b,hbβ©β© := hf x | |
| exact β¨l.1.1,a.1,b.1,ha,hb,a.2.trans b.2.symmβ© | |
| end | |
| noncomputable section | |
| open Classical Counting Hereditary | |
| variable {R I A B V G H : Type*} | |
| variable [Fintype I] [DecidableEq I] [Fintype A] [Fintype B] | |
| variable [Nonempty A] [Nonempty B] [Fintype V] [DecidableEq V] | |
| variable [Group G] [MulAction G A] [Group H] [MulAction H B] | |
| variable {s : β} | |
| inductive HFRelation (R : Type*) | |
| | mem | atom | base (r : R) | |
| def hfStructure (S : Structure R A) : Structure (HFRelation R) (Domain (A := A) G s) where | |
| rel | |
| | .mem, x, y => x.1 β y.1 | |
| | .atom, x, _ => isSet x.1 = false | |
| | .base r, x, y => β a b, x.1 = Hereditary.atom a β§ y.1 = Hereditary.atom b β§ S.rel r a b | |
| def Represented (S : Structure R A) (T : Structure R B) | |
| (ef : V Γ Fin s βͺ I) (e2 : Fin s β Fin s βͺ I) | |
| (v : V β Domain (A := A) G s) (w : V β Domain (A := B) H s) : Prop := | |
| β Ο : V β Form (Fin s) (Set (Formula R I)), β a : V Γ Fin s β A, | |
| β b : V Γ Fin s β B, | |
| (β i, Form.value S e2 (Ο i) (fun j => a (i,j)) = (v i).1) β§ | |
| (β i, Form.value T e2 (Ο i) (fun j => b (i,j)) = (w i).1) β§ | |
| tupleType S ef a = tupleType T ef b | |
| def twoBlocks (i j : V) (h : i β j) : Fin s β Fin s βͺ V Γ Fin s where | |
| toFun := Sum.elim (Prod.mk i) (Prod.mk j) | |
| inj' := by | |
| intro a b hab | |
| cases a <;> cases b <;> simp only [Sum.elim_inl,Sum.elim_inr,Prod.mk.injEq] at hab | |
| Β· congr 1; exact hab.2 | |
| Β· exact (h hab.1).elim | |
| Β· exact (h hab.1.symm).elim | |
| Β· congr 1; exact hab.2 | |
| omit [Fintype A] [Nonempty A] [Fintype V] [DecidableEq V] in | |
| @[simp] theorem comp_twoBlocks (i j : V) (h : i β j) (a : V Γ Fin s β A) : | |
| a β twoBlocks i j h = Sum.elim (fun k => a (i,k)) (fun k => a (j,k)) := by | |
| funext x; cases x <;> rfl | |
| def splitBlock (i : V) : ({j : V // j β i} Γ Fin s) β Fin s β V Γ Fin s where | |
| toFun := Sum.elim (fun x => (x.1.1,x.2)) (fun j => (i,j)) | |
| invFun := fun x => if h : x.1 = i then .inr x.2 else .inl (β¨x.1,hβ©,x.2) | |
| left_inv := by | |
| intro x; cases x with | |
| | inl x => simp [x.1.2] | |
| | inr j => simp | |
| right_inv := by | |
| intro x; by_cases h : x.1 = i | |
| Β· simp [h]; exact Prod.ext h.symm rfl | |
| Β· simp [h] | |
| variable (S : Structure R A) (T : Structure R B) | |
| variable (ef : V Γ Fin s βͺ I) (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) | |
| include e3 e4 in | |
| theorem represented_equal (v : V β Domain (A := A) G s) (w : V β Domain (A := B) H s) | |
| (h : Represented S T ef e2 v w) (i j : V) : v i = v j β w i = w j := by | |
| by_cases hij : i = j | |
| Β· subst j; simp | |
| obtain β¨Ο,a,b,ha,hb,htβ© := h | |
| have hh := tupleType_project S T ef e2 (twoBlocks i j hij) a b ht | |
| simp only [comp_twoBlocks] at hh | |
| have he := equality_transfer S T e2 e3 e4 (Ο i) (Ο j) _ _ _ _ hh | |
| simpa only [ha,hb,Subtype.ext_iff] using he | |
| include e3 e4 in | |
| theorem represented_mem (v : V β Domain (A := A) G s) (w : V β Domain (A := B) H s) | |
| (h : Represented S T ef e2 v w) (i j : V) : (v i).1 β (v j).1 β (w i).1 β (w j).1 := by | |
| by_cases hij : i = j | |
| Β· subst j | |
| exact iff_of_false (fun h => (Nat.lt_irrefl _ (rank_lt_of_mem h))) | |
| (fun h => (Nat.lt_irrefl _ (rank_lt_of_mem h))) | |
| obtain β¨Ο,a,b,ha,hb,htβ© := h | |
| have hh := tupleType_project S T ef e2 (twoBlocks i j hij) a b ht | |
| simp only [comp_twoBlocks] at hh | |
| have he := membership_transfer S T e2 e3 e4 (Ο i) (Ο j) _ _ _ _ hh | |
| simpa only [ha,hb] using he | |
| omit [Fintype I] [DecidableEq V] in | |
| theorem represented_atom (v : V β Domain (A := A) G s) (w : V β Domain (A := B) H s) | |
| (h : Represented S T ef e2 v w) (i : V) : isSet (v i).1 = false β isSet (w i).1 = false := by | |
| obtain β¨Ο,a,b,ha,hb,htβ© := h | |
| rw [βha i,βhb i] | |
| cases Ο i <;> simp | |
| omit [Fintype I] in | |
| private theorem base_value (Ο Ο : Form (Fin s) (Set (Formula R I))) | |
| (a b : Fin s β A) (r : R) : | |
| (β x y, Form.value S e2 Ο a = Hereditary.atom x β§ | |
| Form.value S e2 Ο b = Hereditary.atom y β§ S.rel r x y) β | |
| match Ο,Ο with | |
| | .atom i, .atom j => S.rel r (a i) (b j) | |
| | _, _ => False := by | |
| have hn (n : β) (child : Fin n β Form (Fin s) (Set (Formula R I))) | |
| (label : Fin n β Set (Formula R I)) (c : Fin s β A) (x : A) : | |
| Form.value S e2 (.set n child label) c β Hereditary.atom x := by | |
| intro h; have hh := congrArg isSet h; simp at hh | |
| cases Ο <;> cases Ο <;> simp [Form.value_atom,atom_injective.eq_iff,hn] | |
| omit [DecidableEq V] in | |
| omit [Fintype I] in | |
| theorem represented_base (v : V β Domain (A := A) G s) (w : V β Domain (A := B) H s) | |
| (h : Represented S T ef e2 v w) (r : R) (i j : V) : | |
| (hfStructure S).rel (.base r) (v i) (v j) β (hfStructure T).rel (.base r) (w i) (w j) := by | |
| obtain β¨Ο,a,b,ha,hb,htβ© := h | |
| change (β x y, (v i).1 = Hereditary.atom x β§ (v j).1 = Hereditary.atom y β§ S.rel r x y) β | |
| (β x y, (w i).1 = Hereditary.atom x β§ (w j).1 = Hereditary.atom y β§ T.rel r x y) | |
| rw [βha i,βha j,βhb i,βhb j,base_value S e2,base_value T e2] | |
| cases hi : Ο i with | |
| | set n child label => simp | |
| | atom k => | |
| cases hj : Ο j with | |
| | set n child label => simp | |
| | atom l => | |
| have he := (typeOf_eq_iff S T (tupleNames ef) _ _).mp ht | |
| (.relation r (ef (i,k)) (ef (j,l))) (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] using he | |
| omit [Fintype V] in | |
| @[simp] theorem splitBlock_symm_new (i : V) (k : Fin s) : | |
| (splitBlock (s := s) i).symm (i,k) = .inr k := by simp [splitBlock] | |
| omit [Fintype V] in | |
| @[simp] theorem splitBlock_symm_old (i j : V) (h : j β i) (k : Fin s) : | |
| (splitBlock (s := s) i).symm (j,k) = .inl (β¨j,hβ©,k) := by simp [splitBlock,h] | |
| omit [Fintype I] [Fintype A] in | |
| private theorem homogeneity_reindex {J K : Type*} [Fintype J] [Fintype K] | |
| (S : Structure R A) (e : J βͺ I) (f : K βͺ I) (u : K β J) | |
| (hh : β a b : J β A, tupleType S e a = tupleType S e b β | |
| β g : G, β j, g β’ a j = b j) : | |
| β a b : K β A, tupleType S f a = tupleType S f b β β g : G, β j, g β’ a j = b j := by | |
| intro a b hab | |
| have h := tupleType_project S S f e u.symm.toEmbedding a b hab | |
| obtain β¨g,hgβ© := hh _ _ h | |
| exact β¨g,fun j => by simpa using hg (u j)β© | |
| variable (eplus : (V Γ Fin s) β Fin s βͺ I) | |
| variable (hAutA : β (g : G) r a b, S.rel r (g β’ a) (g β’ b) β S.rel r a b) | |
| variable (hAutB : β (g : H) r a b, T.rel r (g β’ a) (g β’ b) β T.rel r a b) | |
| include eplus e3 e4 hAutA hAutB in | |
| theorem represented_extension (hs : 0 < s) | |
| (hHomA2 : β a b : Fin s β Fin s β A, | |
| tupleType S e2 a = tupleType S e2 b β β g : G, β i, g β’ a i = b i) | |
| (hHomB2 : β a b : Fin s β Fin s β B, | |
| tupleType T e2 a = tupleType T e2 b β β g : H, β i, g β’ a i = b i) | |
| (hHomA : β a b : V Γ Fin s β A, | |
| tupleType S ef a = tupleType S ef b β β g : G, β i, g β’ a i = b i) | |
| (hHomB : β a b : V Γ Fin s β B, | |
| tupleType T ef a = tupleType T ef b β β g : H, β i, g β’ a i = b i) | |
| (v : V β Domain (A := A) G s) (w : V β Domain (A := B) H s) | |
| (h : Represented S T ef e2 v w) (i : V) : | |
| β f : Domain (A := A) G s β Domain (A := B) H s, | |
| β x, Represented S T ef e2 (Function.update v i x) (Function.update w i (f x)) := by | |
| obtain β¨Ο,a,b,ha,hb,htβ© := h | |
| let P := {j : V // j β i} Γ Fin s | |
| let u : P β Fin s β V Γ Fin s := splitBlock i | |
| let ep := u.toEmbedding.trans ef | |
| let epp := (Equiv.sumCongr u (Equiv.refl (Fin s))).toEmbedding.trans eplus | |
| let e0 := Function.Embedding.inl.trans ep | |
| let keep : P βͺ V Γ Fin s := Function.Embedding.inl.trans u.toEmbedding | |
| let p : P β A := a β keep | |
| let q : P β B := b β keep | |
| have hp : tupleType S e0 p = tupleType T e0 q := | |
| tupleType_project S T ef e0 keep a b ht | |
| have homA := homogeneity_reindex S ef ep u hHomA | |
| have homB := homogeneity_reindex T ef ep u hHomB | |
| obtain β¨f,hfβ© := supported_domain_bijection S T ep epp e2 e3 e4 | |
| hAutA hAutB hs e0 hHomA2 hHomB2 homA homB p q hp | |
| refine β¨f,fun x => ?_β© | |
| obtain β¨Ο,c,d,hc,hd,hcdβ© := hf x | |
| let a' := Sum.elim p c β u.symm | |
| let b' := Sum.elim q d β u.symm | |
| refine β¨Function.update Ο i Ο,a',b',?_,?_,?_β© | |
| Β· intro j | |
| by_cases hj : j = i | |
| Β· subst j | |
| simpa [a',u,Function.comp_def,splitBlock] using hc | |
| Β· simpa [a',u,p,keep,Function.comp_def,splitBlock_symm_old i j hj, | |
| Function.update_of_ne hj,splitBlock,hj] using ha j | |
| Β· intro j | |
| by_cases hj : j = i | |
| Β· subst j | |
| simpa [b',u,Function.comp_def,splitBlock] using hd | |
| Β· simpa [b',u,q,keep,Function.comp_def,splitBlock_symm_old i j hj, | |
| Function.update_of_ne hj,splitBlock,hj] using hb j | |
| Β· exact tupleType_project S T ep ef u.symm.toEmbedding _ _ hcd | |
| include eplus e3 e4 hAutA hAutB in | |
| theorem supported_eval_transfer (hs : 0 < s) | |
| (hHomA2 : β a b : Fin s β Fin s β A, | |
| tupleType S e2 a = tupleType S e2 b β β g : G, β i, g β’ a i = b i) | |
| (hHomB2 : β a b : Fin s β Fin s β B, | |
| tupleType T e2 a = tupleType T e2 b β β g : H, β i, g β’ a i = b i) | |
| (hHomA : β a b : V Γ Fin s β A, | |
| tupleType S ef a = tupleType S ef b β β g : G, β i, g β’ a i = b i) | |
| (hHomB : β a b : V Γ Fin s β B, | |
| tupleType T ef a = tupleType T ef b β β g : H, β i, g β’ a i = b i) | |
| (Ο : Formula (HFRelation R) V) | |
| (v : V β Domain (A := A) G s) (w : V β Domain (A := B) H s) | |
| (h : Represented S T ef e2 v w) : | |
| Ο.eval (hfStructure S) v β Ο.eval (hfStructure T) w := by | |
| apply Formula.eval_of_bijectionSystem (hfStructure S) (hfStructure T) | |
| (Represented S T ef e2) _ _ _ Ο v w h | |
| Β· exact represented_equal S T ef e2 e3 e4 | |
| Β· intro v w h r i j | |
| cases r with | |
| | mem => exact represented_mem S T ef e2 e3 e4 v w h i j | |
| | atom => exact represented_atom S T ef e2 v w h i | |
| | base r => exact represented_base S T ef e2 v w h r i j | |
| Β· exact represented_extension S T ef e2 e3 e4 eplus hAutA hAutB hs | |
| hHomA2 hHomB2 hHomA hHomB | |
| include eplus e3 e4 hAutA hAutB in | |
| theorem supported_sentences_transfer (hs : 0 < s) | |
| (hHomA2 : β a b : Fin s β Fin s β A, | |
| tupleType S e2 a = tupleType S e2 b β β g : G, β i, g β’ a i = b i) | |
| (hHomB2 : β a b : Fin s β Fin s β B, | |
| tupleType T e2 a = tupleType T e2 b β β g : H, β i, g β’ a i = b i) | |
| (hHomA : β a b : V Γ Fin s β A, | |
| tupleType S ef a = tupleType S ef b β β g : G, β i, g β’ a i = b i) | |
| (hHomB : β a b : V Γ Fin s β B, | |
| tupleType T ef a = tupleType T ef b β β g : H, β i, g β’ a i = b i) | |
| (hbase : tupleType S (Function.Embedding.ofIsEmpty : Empty βͺ I) Empty.elim = | |
| tupleType T (Function.Embedding.ofIsEmpty : Empty βͺ I) Empty.elim) | |
| (Ο : Formula (HFRelation R) V) (hΟ : Ο.free = β ) | |
| (v : V β Domain (A := A) G s) (w : V β Domain (A := B) H s) : | |
| Ο.eval (hfStructure S) v β Ο.eval (hfStructure T) w := by | |
| let a : V Γ Fin s β A := fun _ => Classical.choice inferInstance | |
| have he : tupleType S (Function.Embedding.ofIsEmpty : Empty βͺ I) | |
| (a β (Function.Embedding.ofIsEmpty : Empty βͺ V Γ Fin s)) = | |
| tupleType T (Function.Embedding.ofIsEmpty : Empty βͺ I) Empty.elim := by | |
| convert hbase using 1 | |
| congr 1; funext x; exact x.elim | |
| obtain β¨b,_,habβ© := tupleType_extend S T | |
| (Function.Embedding.ofIsEmpty : Empty βͺ I) ef | |
| (Function.Embedding.ofIsEmpty : Empty βͺ V Γ Fin s) a Empty.elim he | |
| let emptyForm : Form (Fin s) (Set (Formula R I)) := .set 0 Fin.elim0 Fin.elim0 | |
| let v' : V β Domain (A := A) G s := fun i => | |
| β¨Form.value S e2 emptyForm (fun j => a (i,j)), | |
| value_hereditarily_supported S e2 hAutA emptyForm _β© | |
| let w' : V β Domain (A := B) H s := fun i => | |
| β¨Form.value T e2 emptyForm (fun j => b (i,j)), | |
| value_hereditarily_supported T e2 hAutB emptyForm _β© | |
| have hr : Represented S T ef e2 v' w' := | |
| β¨(fun _ => emptyForm),a,b,(fun _ => rfl),(fun _ => rfl),habβ© | |
| have hh := supported_eval_transfer S T ef e2 e3 e4 eplus hAutA hAutB hs | |
| hHomA2 hHomB2 hHomA hHomB Ο v' w' hr | |
| exact (Formula.eval_congr _ Ο (fun i hi => by simp [hΟ] at hi)).trans | |
| (hh.trans (Formula.eval_congr _ Ο (fun i hi => by simp [hΟ] at hi))) | |
| def namesOfCard {J : Type*} [Fintype J] {M : β} (h : Fintype.card J β€ M) : J βͺ Fin M := | |
| (Fintype.equivFin J).toEmbedding.trans (Fin.castLEEmb h) | |
| def HomogeneousThrough (S : Structure R A) (G : Type*) [Group G] [MulAction G A] | |
| (M r : β) : Prop := | |
| β k β€ r, β e : Fin k βͺ Fin M, β a b : Fin k β A, | |
| tupleType S e a = tupleType S e b β β g : G, β j, g β’ a j = b j | |
| omit [Fintype A] in | |
| private theorem homogeneous_tuple {J : Type*} [Fintype J] {M r : β} | |
| (S : Structure R A) (G : Type*) [Group G] [MulAction G A] | |
| (h : HomogeneousThrough S G M r) (e : J βͺ Fin M) | |
| (hc : Fintype.card J β€ r) : | |
| β a b : J β A, tupleType S e a = tupleType S e b β β g : G, β j, g β’ a j = b j := by | |
| exact homogeneity_reindex S ((Fintype.equivFin J).symm.toEmbedding.trans e) e | |
| (Fintype.equivFin J) (h _ hc _) | |
| theorem hf_transfer {m M : β} (hs : 0 < s) (_hm : 0 < m) (hM : 0 < M) | |
| (hwidth : max 4 (m+1) * s β€ M) | |
| (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 : HomogeneousThrough S G M (max 2 m * s)) | |
| (hHomB : HomogeneousThrough T H M (max 2 m * s)) | |
| (hbase : tupleType S (Function.Embedding.ofIsEmpty : Empty βͺ Fin M) Empty.elim = | |
| tupleType T (Function.Embedding.ofIsEmpty : Empty βͺ Fin M) Empty.elim) | |
| (Ο : Formula (HFRelation R) (Fin m)) (hΟ : Ο.free = β ) | |
| (v : Fin m β Domain (A := A) G s) (w : Fin m β Domain (A := B) H s) : | |
| Ο.eval (hfStructure S) v β Ο.eval (hfStructure T) w := by | |
| have h4 : 4*s β€ M := (Nat.mul_le_mul_right s (le_max_left _ _)).trans hwidth | |
| have hp : (m+1)*s β€ M := (Nat.mul_le_mul_right s (le_max_right _ _)).trans hwidth | |
| have h2 : Fintype.card (Fin s β Fin s) β€ M := by simp only [Fintype.card_sum,Fintype.card_fin]; omega | |
| have h3 : Fintype.card ((Fin s β Fin s) β Fin s) β€ M := by simp only [Fintype.card_sum,Fintype.card_fin]; omega | |
| have h4' : Fintype.card (((Fin s β Fin s) β Fin s) β Fin s) β€ M := by simp only [Fintype.card_sum,Fintype.card_fin]; omega | |
| have hpf : Fintype.card ((Fin m Γ Fin s) β Fin s) β€ M := by simpa [Nat.add_mul] using hp | |
| have hfull : Fintype.card (Fin m Γ Fin s) β€ M := by simp only [Fintype.card_prod,Fintype.card_fin]; nlinarith | |
| have hom2 : Fintype.card (Fin s β Fin s) β€ max 2 m*s := by | |
| simpa [two_mul] using Nat.mul_le_mul_right s (le_max_left 2 m) | |
| have homf : Fintype.card (Fin m Γ Fin s) β€ max 2 m*s := by | |
| simpa using Nat.mul_le_mul_right s (le_max_right 2 m) | |
| exact supported_sentences_transfer S T (namesOfCard hfull) (namesOfCard h2) | |
| (namesOfCard h3) (namesOfCard h4') (namesOfCard hpf) hAutA hAutB hs | |
| (homogeneous_tuple S G hHomA _ hom2) (homogeneous_tuple T H hHomB _ hom2) | |
| (homogeneous_tuple S G hHomA _ homf) (homogeneous_tuple T H hHomB _ homf) | |
| hbase Ο hΟ v w | |
| end | |
| end WitnessedSeparation.Forms | |
| namespace WitnessedSeparation.Hereditary | |
| noncomputable section | |
| variable {A G : Type*} [Group G] [MulAction G A] | |
| theorem supports_pad {k s : β} (hks : k β€ s) (aβ : A) (alpha : Fin k β A) | |
| {x : HF A} (h : Supports (G := G) alpha x) : Supported (G := G) s x := by | |
| classical | |
| let beta (i : Fin s) : A := if hi : i.val < k then alpha β¨i.val,hiβ© else aβ | |
| refine β¨beta,?_β© | |
| intro g hg | |
| apply h g | |
| intro i | |
| have hi := hg (i.castLE hks) | |
| simpa only [beta, Fin.val_castLE, dite_eq_left i.isLt] using hi | |
| end | |
| end WitnessedSeparation.Hereditary | |
| namespace WitnessedSeparation.Grid | |
| open Support Hereditary | |
| noncomputable section | |
| variable {n : β} {b : Vertex n β Scalar} | |
| @[simp] theorem central_smul_HF (k : CentralGroup n) (x : HF (Atom b)) : | |
| k β’ x = centralHom k β’ x := rfl | |
| theorem small_orbit_supported (hn : 1 β€ n) (x : HF (Atom b)) | |
| (N : β) (hN : 0 < N) (q : β) (hq : 0 β€ q) | |
| (horbit : (Nat.card (MulAction.orbit (BoxGroup n) x) : β) β€ (N : β)^q) : | |
| Supported (G := CentralGroup n) β2 * (n+1 : β) * (q * Real.logb 3 N)^2ββ x := by | |
| classical | |
| obtain β¨T,hT,hfixβ© := small_orbit_support_edges x N hN q hq horbit | |
| obtain β¨alpha,haβ© := edge_support_tuple (b := b) T x hfix | |
| have hsupport : Supports (G := CentralGroup n) alpha x := by | |
| intro k hk | |
| exact ha k hk | |
| have hlen : T.card β€ β2 * (n+1 : β) * (q * Real.logb 3 N)^2ββ := by | |
| exact_mod_cast le_trans hT (Nat.le_ceil _) | |
| let aβ : Atom b := zeroEdgeAtom b (ex β¨0,by omegaβ© 0 0) | |
| exact supports_pad hlen aβ alpha hsupport | |
| theorem orbit_card_le_invariant_family (F : Finset (HF (Atom b))) | |
| (hF : β g : BoxGroup n, β x β F, g β’ x β F) {x : HF (Atom b)} (hx : x β F) : | |
| Nat.card (MulAction.orbit (BoxGroup n) x) β€ F.card := by | |
| classical | |
| let f : MulAction.orbit (BoxGroup n) x β {y // y β F} := fun y => | |
| β¨y.val,by obtain β¨g,hgβ© := y.property; rw [β hg]; exact hF g x hxβ© | |
| have hf : Function.Injective f := by | |
| intro a c h | |
| exact Subtype.ext (congrArg (fun z : {y // y β F} => z.val) h) | |
| have hn := Nat.card_le_card_of_injective f hf | |
| simpa only [Nat.card_eq_fintype_card, Fintype.card_coe] using hn | |
| theorem invariant_family_hereditarily_supported (hn : 1 β€ n) | |
| (F : Finset (HF (Atom b))) | |
| (hF : β g : BoxGroup n, β x β F, g β’ x β F) | |
| (htrans : β x β F, β y, y β x β y β F) | |
| (N : β) (hN : 0 < N) (q : β) (hq : 0 β€ q) | |
| (hsize : (F.card : β) β€ (N : β)^q) : | |
| β x β F, HereditarilySupported (G := CentralGroup n) | |
| β2 * (n+1 : β) * (q * Real.logb 3 N)^2ββ x := by | |
| intro x hx y hy | |
| have hymem : y β F := by | |
| induction hy with | |
| | refl => exact hx | |
| | @tail z w hpath hmem ih => exact ih (htrans w hx z hmem) | |
| apply small_orbit_supported hn y N hN q hq | |
| exact le_trans (by exact_mod_cast orbit_card_le_invariant_family F hF hymem) hsize | |
| end | |
| end WitnessedSeparation.Grid | |
| namespace WitnessedSeparation.Grid | |
| noncomputable section | |
| open Classical Finset | |
| variable {n M m s : β} {b : Vertex n β Scalar} | |
| theorem atom_nonempty (hn : 1 β€ n) (b : Vertex n β Scalar) : Nonempty (Atom b) := | |
| β¨.inr β¨(0,0,0),someConfiguration hn b (0,0,0)β©β© | |
| instance atom_nonempty_succ (b : Vertex (n+1) β Scalar) : Nonempty (Atom b) := atom_nonempty (by omega) b | |
| theorem central_analysis_isomorphism (k : CentralGroup n) (r : AnalysisSymbol) (x y : Atom b) : | |
| (analysisStructure b).rel r (k β’ x) (k β’ y) β (analysisStructure b).rel r x y := | |
| ((central_atomShift k x).analysisRelation (central_atomShift k y) r).symm | |
| theorem homogeneous_through_numeric (hn : 1 β€ n) [Nonempty (Atom b)] (R : β) | |
| (hw : (7*R:β)+7*((6*R:β)/boxConstant)^((3:β)/2)+1 β€ M) : | |
| Forms.HomogeneousThrough (analysisStructure b) (CentralGroup n) M R := by | |
| intro k hk names a a' ht | |
| apply quantitative_homogeneity hn names a a' _ ht | |
| simp only [Fintype.card_fin] | |
| have hkr : (k:β) β€ R := by exact_mod_cast hk | |
| have hp : ((6*k:β)/boxConstant)^((3:β)/2) β€ ((6*R:β)/boxConstant)^((3:β)/2) := by | |
| apply Real.rpow_le_rpow (div_nonneg (by positivity) boxConstant_pos.le) _ (by norm_num) | |
| exact div_le_div_of_nonneg_right (by linarith) boxConstant_pos.le | |
| linarith | |
| theorem base_empty_type (hn : 1 β€ n) (hbound : GiantBound n M) (vstar : Vertex n) | |
| [Nonempty (Atom (0 : Vertex n β Scalar))] [Nonempty (Atom (Pi.single vstar 1))] : | |
| Counting.tupleType (analysisStructure (0 : Vertex n β Scalar)) | |
| (Function.Embedding.ofIsEmpty : Empty βͺ Fin M) Empty.elim = | |
| Counting.tupleType (analysisStructure (Pi.single vstar 1)) | |
| (Function.Embedding.ofIsEmpty : Empty βͺ Fin M) Empty.elim := by | |
| apply (Counting.typeOf_eq_iff _ _ _ _ _).mpr | |
| intro Ο hΟ | |
| have he : Ο.free = β := by | |
| apply subset_empty.mp | |
| simpa only [Counting.tupleNames,Finset.univ_eq_empty,Finset.map_empty] using hΟ | |
| exact base_equivalence_numeric hn hbound vstar Ο he _ _ | |
| theorem grid_hf_transfer (hn : 1 β€ n) (hs : 0 < s) (hm : 0 < m) | |
| (vstar : Vertex n) [Nonempty (Atom (0 : Vertex n β Scalar))] | |
| [Nonempty (Atom (Pi.single vstar 1))] | |
| (hwidth : max 4 (m+1)*s β€ M) | |
| (hhom : (7*(max 2 m*s):β)+7*((6*(max 2 m*s):β)/boxConstant)^((3:β)/2)+1 β€ M) | |
| (hgiant : GiantBound n M) | |
| (Ο : Counting.Formula (Forms.HFRelation AnalysisSymbol) (Fin m)) (hΟ : Ο.free = β ) | |
| (v : Fin m β Forms.Domain (A := Atom (0 : Vertex n β Scalar)) (CentralGroup n) s) | |
| (w : Fin m β Forms.Domain (A := Atom (Pi.single vstar 1)) (CentralGroup n) s) : | |
| Ο.eval (Forms.hfStructure (analysisStructure (0 : Vertex n β Scalar))) v β | |
| Ο.eval (Forms.hfStructure (analysisStructure (Pi.single vstar 1))) w := by | |
| have hM : 0 < M := lt_of_lt_of_le (Nat.mul_pos (by omega) hs) hwidth | |
| exact Forms.hf_transfer _ _ hs hm hM hwidth | |
| (fun g r a b => central_analysis_isomorphism g r a b) | |
| (fun g r a b => central_analysis_isomorphism g r a b) | |
| (homogeneous_through_numeric hn _ (by simpa only [Nat.cast_mul] using hhom)) | |
| (homogeneous_through_numeric hn _ (by simpa only [Nat.cast_mul] using hhom)) | |
| (base_empty_type hn hgiant vstar) Ο hΟ v w | |
| end | |
| end WitnessedSeparation.Grid | |
| namespace WitnessedSeparation.Interpretations | |
| structure Structure (R : Type) where | |
| Carrier : Type | |
| finite : Fintype Carrier | |
| rel : R β Carrier β Carrier β Bool | |
| attribute [instance] Structure.finite | |
| inductive Formula (R : Type) : β β Type | |
| | falsum {n} : Formula R n | |
| | eq {n} (x y : Fin n) : Formula R n | |
| | rel {n} (r : R) (x y : Fin n) : Formula R n | |
| | neg {n} : Formula R n β Formula R n | |
| | and {n} : Formula R n β Formula R n β Formula R n | |
| | ex {n} : Formula R (n+1) β Formula R n | |
| | hartig {n} : Formula R (n+1) β Formula R (n+1) β Formula R n | |
| noncomputable def Formula.eval {R : Type} (A : Structure R) : | |
| {n : β} β Formula R n β (Fin n β A.Carrier) β Prop | |
| | _, .falsum, _ => False | |
| | _, .eq x y, v => v x = v y | |
| | _, .rel r x y, v => A.rel r (v x) (v y) = true | |
| | _, .neg Ο, v => Β¬ Ο.eval A v | |
| | _, .and Ο Ο, v => Ο.eval A v β§ Ο.eval A v | |
| | _, .ex Ο, v => β a, Ο.eval A (Fin.cons a v) | |
| | _, .hartig Ο Ο, v => | |
| Nat.card {a : A.Carrier // Ο.eval A (Fin.cons a v)} = | |
| Nat.card {a : A.Carrier // Ο.eval A (Fin.cons a v)} | |
| def Formula.holds {R : Type} (Ο : Formula R 0) (A : Structure R) : Prop := | |
| Ο.eval A Fin.elim0 | |
| structure Interpretation (R T : Type) where | |
| domain : Formula R 2 | |
| identify : Formula R 4 | |
| relation : T β Formula R 4 | |
| namespace Interpretation | |
| variable {R T : Type} (I : Interpretation R T) (A : Structure R) | |
| abbrev Domain := {a : A.Carrier Γ A.Carrier // I.domain.eval A ![a.1,a.2]} | |
| def link (a b : I.Domain A) : Prop := | |
| I.identify.eval A ![a.val.1,a.val.2,b.val.1,b.val.2] | |
| def classSetoid : Setoid (I.Domain A) := | |
| Relation.EqvGen.setoid (I.link A) | |
| abbrev Vertex := Quotient (I.classSetoid A) | |
| noncomputable def apply : Structure T := by | |
| classical | |
| letI : Fintype (I.Domain A) := Fintype.ofFinite _ | |
| letI : Fintype (I.Vertex A) := Fintype.ofFinite _ | |
| exact { | |
| Carrier := I.Vertex A | |
| finite := inferInstance | |
| rel := fun r x y => decide (β a b : I.Domain A, | |
| Quotient.mk (I.classSetoid A) a = x β§ | |
| Quotient.mk (I.classSetoid A) b = y β§ | |
| (I.relation r).eval A ![a.val.1,a.val.2,b.val.1,b.val.2]) } | |
| end Interpretation | |
| structure Program (InputSymbols : Type) where | |
| StateSymbols : Type | |
| stateFinite : Fintype StateSymbols | |
| init : Interpretation InputSymbols StateSymbols | |
| step : Interpretation StateSymbols StateSymbols | |
| halt : Formula StateSymbols 0 | |
| output : Formula StateSymbols 0 | |
| namespace Program | |
| variable {R : Type} (P : Program R) | |
| noncomputable def state (A : Structure R) : β β Structure P.StateSymbols | |
| | 0 => P.init.apply A | |
| | j+1 => P.step.apply (state A j) | |
| def haltsAt (A : Structure R) (j : β) : Prop := | |
| P.halt.holds (P.state A j) β§ β k < j, Β¬ P.halt.holds (P.state A k) | |
| noncomputable def cost (A : Structure R) (j : β) : β := | |
| (j+1) + β k β Finset.range (j+1), Fintype.card (P.state A k).Carrier | |
| def accepts (A : Structure R) : Prop := | |
| β j, P.haltsAt A j β§ P.output.holds (P.state A j) | |
| def polynomiallyBounded : Prop := | |
| β c d : β, β A : Structure R, β j, | |
| P.haltsAt A j β§ P.cost A j β€ c * (Fintype.card A.Carrier + 1)^d | |
| def decides (Q : Structure R β Prop) : Prop := | |
| P.polynomiallyBounded β§ β A, P.accepts A β Q A | |
| end Program | |
| def NondefinableByInterpretations {R : Type} (Q : Structure R β Prop) : Prop := | |
| Β¬ β P : Program R, P.decides Q | |
| end WitnessedSeparation.Interpretations | |
| namespace WitnessedSeparation.Interpretations | |
| noncomputable section | |
| open Classical Finset Hereditary | |
| variable {R T A : Type} (I : Interpretation R T) (S : Structure R) | |
| def payload (e : S.Carrier β HF A) (C : I.Vertex S) : HF A := | |
| ofFinset ((univ.filter (fun p : I.Domain S => Quotient.mk (I.classSetoid S) p = C)).image | |
| (fun p => pair (e p.val.1) (e p.val.2))) | |
| theorem mem_payload (e : S.Carrier β HF A) (C : I.Vertex S) (x : HF A) : | |
| x β payload I S e C β β p : I.Domain S, | |
| Quotient.mk (I.classSetoid S) p = C β§ x = pair (e p.val.1) (e p.val.2) := by | |
| simp only [payload,mem_ofFinset,mem_image,mem_filter,mem_univ,true_and] | |
| exact exists_congr (fun p => and_congr_right (fun _ => eq_comm)) | |
| theorem payload_injective (e : S.Carrier β HF A) (he : Function.Injective e) : | |
| Function.Injective (payload I S e) := by | |
| intro C D h | |
| obtain β¨p,rflβ© := Quotient.exists_rep C | |
| have hm : pair (e p.val.1) (e p.val.2) β payload I S e (Quotient.mk _ p) := | |
| (mem_payload I S e _ _).mpr β¨p,rfl,rflβ© | |
| rw [h] at hm | |
| obtain β¨q,hq,hpqβ© := (mem_payload I S e D _).mp hm | |
| have hh := pair_injective hpq | |
| have heq : p = q := Subtype.ext (Prod.ext (he hh.1) (he hh.2)) | |
| rw [heq] | |
| exact hq | |
| def vertexCode (e : S.Carrier β HF A) (j : β) (C : I.Vertex S) : HF A := | |
| pair (ordinal j) (payload I S e C) | |
| theorem vertexCode_injective (e : S.Carrier β HF A) (he : Function.Injective e) (j : β) : | |
| Function.Injective (vertexCode I S e j) := by | |
| intro C D h | |
| exact payload_injective I S e he (pair_injective h).2 | |
| def pairFamily (e : S.Carrier β HF A) : Finset (HF A) := | |
| univ.biUnion (fun p : I.Domain S => wrappers (e p.val.1) (e p.val.2)) | |
| def classFamily (e : S.Carrier β HF A) (j : β) : Finset (HF A) := | |
| univ.biUnion (fun C : I.Vertex S => insert (payload I S e C) | |
| (wrappers (ordinal j) (payload I S e C))) | |
| theorem pairFamily_card_le (e : S.Carrier β HF A) : | |
| (pairFamily I S e).card β€ 3*Fintype.card S.Carrier^2 := by | |
| calc | |
| (pairFamily I S e).card β€ β p : I.Domain S, (wrappers (e p.val.1) (e p.val.2)).card := | |
| card_biUnion_le | |
| _ β€ β _p : I.Domain S, 3 := sum_le_sum (fun p _ => wrappers_card_le _ _) | |
| _ = 3*Fintype.card (I.Domain S) := by simp [mul_comm] | |
| _ β€ 3*Fintype.card S.Carrier^2 := by | |
| apply Nat.mul_le_mul_left | |
| have h := Fintype.card_subtype_le (fun p : S.Carrier Γ S.Carrier => I.domain.eval S ![p.1,p.2]) | |
| simpa only [Fintype.card_prod,pow_two] using h | |
| theorem classFamily_card_le (e : S.Carrier β HF A) (j : β) : | |
| (classFamily I S e j).card β€ 4*Fintype.card (I.Vertex S) := by | |
| calc | |
| (classFamily I S e j).card β€ β C : I.Vertex S, | |
| (insert (payload I S e C) (wrappers (ordinal j) (payload I S e C))).card := card_biUnion_le | |
| _ β€ β _C : I.Vertex S, 4 := by | |
| apply sum_le_sum | |
| intro C _ | |
| exact (card_insert_le _ _).trans (by have := wrappers_card_le (ordinal (A := A) j) (payload I S e C); omega) | |
| _ = 4*Fintype.card (I.Vertex S) := by simp [mul_comm] | |
| theorem stage_family_transitive (e : S.Carrier β HF A) (j : β) (F : Finset (HF A)) | |
| (hF : β x β F, β y, y β x β y β F) | |
| (he : β a, e a β F) (hj : ordinal j β F) : | |
| β x β F βͺ pairFamily I S e βͺ classFamily I S e j, | |
| β y, y β x β y β F βͺ pairFamily I S e βͺ classFamily I S e j := by | |
| intro x hx y hy | |
| have incF : F β F βͺ pairFamily I S e βͺ classFamily I S e j := | |
| fun z hz => mem_union_left _ (mem_union_left _ hz) | |
| have incP : pairFamily I S e β F βͺ pairFamily I S e βͺ classFamily I S e j := | |
| fun z hz => mem_union_left _ (mem_union_right _ hz) | |
| have incC : classFamily I S e j β F βͺ pairFamily I S e βͺ classFamily I S e j := | |
| fun z hz => mem_union_right _ hz | |
| rcases mem_union.mp hx with hx|hx | |
| Β· rcases mem_union.mp hx with hx|hx | |
| Β· exact incF (hF x hx y hy) | |
| Β· obtain β¨p,_,hpβ© := mem_biUnion.mp hx | |
| rcases wrappers_trans hp hy with h|h|h | |
| Β· rw [h]; exact incF (he _) | |
| Β· rw [h]; exact incF (he _) | |
| Β· exact incP (mem_biUnion.mpr β¨p,mem_univ _,hβ©) | |
| Β· obtain β¨C,_,hCβ© := mem_biUnion.mp hx | |
| rcases mem_insert.mp hC with rfl|hC | |
| Β· obtain β¨p,hp,hypβ© := (mem_payload I S e C y).mp hy | |
| apply incP | |
| apply mem_biUnion.mpr | |
| exact β¨p,mem_univ _,by simp [hyp,wrappers]β© | |
| Β· rcases wrappers_trans hC hy with h|h|h | |
| Β· rw [h]; exact incF hj | |
| Β· rw [h]; exact incC (mem_biUnion.mpr β¨C,mem_univ _,mem_insert_self _ _β©) | |
| Β· exact incC (mem_biUnion.mpr β¨C,mem_univ _,mem_insert_of_mem hβ©) | |
| end | |
| end WitnessedSeparation.Interpretations | |
| namespace WitnessedSeparation.Counting | |
| noncomputable section | |
| open Classical Finset | |
| variable {R D : Type*} (S : Structure R D) {m n k : β} | |
| def Definable (m n : β) (P : (Fin n β D) β Prop) : Prop := | |
| β args : Fin n β Fin m, β Ο : Formula R (Fin m), | |
| Ο.free β univ.image args β§ β v, Ο.eval S v β P (v β args) | |
| namespace Definable | |
| variable {S} {P Q : (Fin n β D) β Prop} | |
| theorem congr (h : Definable S m n P) (heq : β v, P v β Q v) : Definable S m n Q := by | |
| intro args | |
| obtain β¨Ο,hΟ,heβ© := h args | |
| exact β¨Ο,hΟ,fun v => (he v).trans (heq _)β© | |
| theorem reindex (h : Definable S m n P) (f : Fin n β Fin k) : | |
| Definable S m k (fun v => P (v β f)) := by | |
| intro args | |
| obtain β¨Ο,hΟ,heβ© := h (args β f) | |
| refine β¨Ο,?_,fun v => he vβ© | |
| intro i hi | |
| obtain β¨j,_,rflβ© := mem_image.mp (hΟ hi) | |
| exact mem_image.mpr β¨f j,mem_univ _,rflβ© | |
| theorem falsum : Definable S m n (fun _ => False) := by | |
| intro args | |
| exact β¨.falsum,by simp [Formula.free],fun _ => Iff.rflβ© | |
| theorem neg (h : Definable S m n P) : Definable S m n (fun v => Β¬ P v) := by | |
| intro args | |
| obtain β¨Ο,hΟ,heβ© := h args | |
| exact β¨.neg Ο,hΟ,fun v => not_congr (he v)β© | |
| theorem and (h : Definable S m n P) (h' : Definable S m n Q) : | |
| Definable S m n (fun v => P v β§ Q v) := by | |
| intro args | |
| obtain β¨Ο,hΟ,heβ© := h args | |
| obtain β¨Ο,hΟ,he'β© := h' args | |
| exact β¨.and Ο Ο,union_subset hΟ hΟ,fun v => and_congr (he v) (he' v)β© | |
| theorem or (h : Definable S m n P) (h' : Definable S m n Q) : | |
| Definable S m n (fun v => P v β¨ Q v) := | |
| (h.neg.and h'.neg).neg.congr (fun _ => by tauto) | |
| theorem imp (h : Definable S m n P) (h' : Definable S m n Q) : | |
| Definable S m n (fun v => P v β Q v) := | |
| (h.neg.or h').congr (fun _ => by tauto) | |
| theorem iff (h : Definable S m n P) (h' : Definable S m n Q) : | |
| Definable S m n (fun v => P v β Q v) := | |
| ((h.imp h').and (h'.imp h)).congr (fun _ => by tauto) | |
| theorem equal (i j : Fin n) : Definable S m n (fun v => v i = v j) := by | |
| intro args | |
| refine β¨.equal (args i) (args j),?_,fun _ => Iff.rflβ© | |
| simp only [Formula.free,insert_subset_iff,singleton_subset_iff] | |
| exact β¨mem_image.mpr β¨i,mem_univ _,rflβ©,mem_image.mpr β¨j,mem_univ _,rflβ©β© | |
| theorem relation (r : R) (i j : Fin n) : Definable S m n (fun v => S.rel r (v i) (v j)) := by | |
| intro args | |
| refine β¨.relation r (args i) (args j),?_,fun _ => Iff.rflβ© | |
| simp only [Formula.free,insert_subset_iff,singleton_subset_iff] | |
| exact β¨mem_image.mpr β¨i,mem_univ _,rflβ©,mem_image.mpr β¨j,mem_univ _,rflβ©β© | |
| private theorem fresh (args : Fin n β Fin m) (hn : n < m) : β i, β j, args j β i := by | |
| have hns : Β¬ Function.Surjective args := by | |
| intro hs | |
| have h := Fintype.card_le_of_surjective args hs | |
| simp only [Fintype.card_fin] at h | |
| omega | |
| simp only [Function.Surjective] at hns | |
| push Not at hns | |
| exact hns | |
| private theorem updated_args (args : Fin n β Fin m) (i : Fin m) | |
| (hi : β j, args j β i) (v : Fin m β D) (x : D) : | |
| Function.update v i x β Fin.cons i args = Fin.cons x (v β args) := by | |
| funext j | |
| refine Fin.cases ?_ (fun j => ?_) j | |
| Β· simp | |
| Β· simp [hi j] | |
| private theorem free_binder {args : Fin n β Fin m} {i : Fin m} {Ο : Formula R (Fin m)} | |
| (hΟ : Ο.free β univ.image (Fin.cons i args)) : Ο.free.erase i β univ.image args := by | |
| intro j hj | |
| obtain β¨k,_,hkβ© := mem_image.mp (hΟ (mem_erase.mp hj).2) | |
| cases k using Fin.cases with | |
| | zero => | |
| simp only [Fin.cons_zero] at hk | |
| exact False.elim ((mem_erase.mp hj).1 hk.symm) | |
| | succ k => exact mem_image.mpr β¨k,mem_univ _,hkβ© | |
| theorem ex {P : (Fin (n+1) β D) β Prop} (h : Definable S m (n+1) P) (hn : n < m) : | |
| Definable S m n (fun v => β x, P (Fin.cons x v)) := by | |
| intro args | |
| obtain β¨i,hiβ© := fresh args hn | |
| obtain β¨Ο,hΟ,heβ© := h (Fin.cons i args) | |
| refine β¨.ex i Ο,free_binder hΟ,?_β© | |
| intro v | |
| apply exists_congr | |
| intro x | |
| simpa only [updated_args args i hi] using he (Function.update v i x) | |
| theorem all {P : (Fin (n+1) β D) β Prop} (h : Definable S m (n+1) P) (hn : n < m) : | |
| Definable S m n (fun v => β x, P (Fin.cons x v)) := | |
| (h.neg.ex hn).neg.congr (fun _ => by simp) | |
| theorem exact {P : (Fin (n+1) β D) β Prop} (h : Definable S m (n+1) P) (hn : n < m) (k : β) : | |
| Definable S m n (fun v => Nonempty ({x : D // P (Fin.cons x v)} β Fin k)) := by | |
| intro args | |
| obtain β¨i,hiβ© := fresh args hn | |
| obtain β¨Ο,hΟ,heβ© := h (Fin.cons i args) | |
| refine β¨.exact i k Ο,free_binder hΟ,?_β© | |
| intro v | |
| let e : {x : D // Ο.eval S (Function.update v i x)} β {x : D // P (Fin.cons x (v β args))} := | |
| Equiv.subtypeEquivRight (fun x => by simpa only [updated_args args i hi] using he (Function.update v i x)) | |
| exact β¨fun β¨fβ© => β¨e.symm.trans fβ©,fun β¨fβ© => β¨e.trans fβ©β© | |
| theorem exists_finset {ΞΉ : Type*} {P : ΞΉ β (Fin n β D) β Prop} (t : Finset ΞΉ) | |
| (h : β i β t, Definable S m n (P i)) : Definable S m n (fun v => β i β t, P i v) := by | |
| induction t using Finset.induction_on with | |
| | empty => exact (falsum (S := S)).congr (fun _ => by simp) | |
| | @insert i t hi ih => | |
| exact ((h i (mem_insert_self _ _)).or (ih (fun j hj => h j (mem_insert_of_mem hj)))).congr | |
| (fun v => by simp only [mem_insert,exists_eq_or_imp]) | |
| theorem bounded_hartig {P Q : (Fin (n+1) β D) β Prop} | |
| (hP : Definable S m (n+1) P) (hQ : Definable S m (n+1) Q) (hn : n < m) (B : β) : | |
| Definable S m n (fun v => β k β€ B, | |
| Nonempty ({x : D // P (Fin.cons x v)} β Fin k) β§ | |
| Nonempty ({x : D // Q (Fin.cons x v)} β Fin k)) := by | |
| apply (exists_finset (range (B+1)) (fun k _ => (hP.exact hn k).and (hQ.exact hn k))).congr | |
| intro v | |
| simp only [mem_range,Nat.lt_succ_iff] | |
| end Definable | |
| end | |
| end WitnessedSeparation.Counting | |
| end OAI | |