Download data/lean/OAI/Computability/WLIdentification/BijectionGames.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.49 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/WLIdentification/BijectionGames.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/WLIdentification/BijectionGames.lean
-
curl -L -o BijectionGames.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/WLIdentification/BijectionGames.lean
8.49 kB
| import OAI.Computability.WLIdentification.CycleSums | |
| namespace OAI | |
| namespace WLIdentification | |
| /-- A finite-slot bijective extension system. The extra slot is genuine: | |
| a k-tuple is extended before any one of its slots is discarded. -/ | |
| structure BijectionSystem (G H : Graph) (K : β) where | |
| relates : (m : β) β (Fin m β Fin G.order) β (Fin m β Fin H.order) β Prop | |
| empty : β v w, relates 0 v w | |
| restrict : β {m n} {v w}, relates m v w β β f : Fin n β Fin m, | |
| relates n (v β f) (w β f) | |
| atomic : β {m v w}, relates m v w β | |
| (β i j, v i = v j β w i = w j) β§ | |
| (β i j, G.edge (v i) (v j) = H.edge (w i) (w j)) | |
| extend : β {m}, m < K β β {v w}, relates m v w β | |
| β e : Fin G.order β Fin H.order, β z, | |
| relates (m + 1) (Fin.snoc v z) (Fin.snoc w (e z)) | |
| namespace BijectionSystem | |
| /-- Deleting a slot after an extension simultaneously preserves every possible | |
| replacement, as required by the joint (not independent-marginal) WL update. -/ | |
| theorem replace {G H : Graph} {K m : β} (S : BijectionSystem G H K) | |
| {v : Fin m β Fin G.order} {w : Fin m β Fin H.order} | |
| {z : Fin G.order} {z' : Fin H.order} | |
| (h : S.relates (m + 1) (Fin.snoc v z) (Fin.snoc w z')) (i : Fin m) : | |
| S.relates m (Function.update v i z) (Function.update w i z') := by | |
| let f (j : Fin m) : Fin (m + 1) := if j = i then Fin.last m else j.castSucc | |
| have hv : Fin.snoc v z β f = Function.update v i z := by | |
| funext j | |
| by_cases hj : j = i | |
| Β· subst j; simp [f] | |
| Β· simp [f, hj] | |
| have hw : Fin.snoc w z' β f = Function.update w i z' := by | |
| funext j | |
| by_cases hj : j = i | |
| Β· subst j; simp [f] | |
| Β· simp [f, hj] | |
| simpa only [hv, hw] using S.restrict h f | |
| /-- Every maintained tuple has equal colors at every actual finite joint round. -/ | |
| theorem tupleColor_eq {G H : Graph} {K k : β} (S : BijectionSystem G H K) | |
| (hk : k < K) {v : Fin k β Fin G.order} {w : Fin k β Fin H.order} | |
| (h : S.relates k v w) (round : β) : tupleColor G k round v = tupleColor H k round w := by | |
| induction round generalizing v w with | |
| | zero => | |
| apply Prod.ext | |
| Β· funext i j | |
| exact decide_eq_decide.mpr ((S.atomic h).1 i j) | |
| Β· funext i j | |
| exact (S.atomic h).2 i j | |
| | succ r ih => | |
| obtain β¨e, heβ© := S.extend hk h | |
| apply Prod.ext | |
| Β· exact ih h | |
| Β· apply histogram_eq_of_equiv e | |
| intro z | |
| funext i | |
| exact ih (S.replace (he z) i) | |
| def tupleSnocEquiv (V : Type) (m : β) : ((Fin m β V) Γ V) β (Fin (m + 1) β V) where | |
| toFun p := Fin.snoc p.1 p.2 | |
| invFun v := (Fin.init v, v (Fin.last m)) | |
| left_inv _ := by simp | |
| right_inv _ := Fin.snoc_init_self _ | |
| /-- Sequentially chosen vertex bijections give a bijection of all ordered tuples; | |
| there is no unsupported inference from mere existence of a mate for each tuple. -/ | |
| theorem tupleBijection {G H : Graph} {K : β} (S : BijectionSystem G H K) | |
| (m : β) (hm : m β€ K) : | |
| β E : (Fin m β Fin G.order) β (Fin m β Fin H.order), β v, S.relates m v (E v) := by | |
| induction m with | |
| | zero => exact β¨Equiv.ofUnique _ _, fun v => S.empty v _β© | |
| | succ m ih => | |
| obtain β¨E, hEβ© := ih (by omega) | |
| have hext (v : Fin m β Fin G.order) : | |
| β e : Fin G.order β Fin H.order, β z, | |
| S.relates (m + 1) (Fin.snoc v z) (Fin.snoc (E v) (e z)) := | |
| S.extend (by omega) (hE v) | |
| choose e he using hext | |
| let P := (Equiv.prodCongrRight e).trans (Equiv.prodCongr E (Equiv.refl _)) | |
| let E' := (tupleSnocEquiv (Fin G.order) m).symm.trans | |
| (P.trans (tupleSnocEquiv (Fin H.order) m)) | |
| refine β¨E', ?_β© | |
| intro v | |
| change S.relates (m + 1) v (Fin.snoc (E (Fin.init v)) (e (Fin.init v) (v (Fin.last m)))) | |
| simpa only [Fin.snoc_init_self] using he (Fin.init v) (v (Fin.last m)) | |
| /-- A genuine k+1-slot system proves equivalence for the literal joint k-WL colors. -/ | |
| theorem equivalent {G H : Graph} {K k : β} (S : BijectionSystem G H K) | |
| (hk : 2 β€ k) (hkK : k < K) : Equivalent k G H := by | |
| rw [Equivalent, ite_eq_right (by omega : k β 1)] | |
| intro round | |
| obtain β¨E, hEβ© := S.tupleBijection k (by omega) | |
| exact histogram_eq_of_equiv E _ _ (fun v => S.tupleColor_eq hkK (hE v) round) | |
| end BijectionSystem | |
| /-- Finite descending choice, used only for actual finite vertex/tuple bijections. -/ | |
| theorem finite_descending_choice {A : Type} [Fintype A] | |
| (P : β β A β Prop) (hm : β n a, P (n + 1) a β P n a) | |
| (he : β n, β a, P n a) : β a, β n, P n a := by | |
| classical | |
| by_contra h | |
| have hn : β a : A, β n, Β¬ P n a := by simpa only [not_exists, not_forall] using h | |
| choose n hn using hn | |
| let N : β := β a : A, n a | |
| obtain β¨a, haβ© := he N | |
| have hle : n a β€ N := Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finset.mem_univ a) | |
| have hdown : β j l, j β€ l β P l a β P j a := by | |
| intro j l hj | |
| induction l, hj using Nat.le_induction with | |
| | base => exact id | |
| | succ l _ ih => exact fun hp => ih (hm l a hp) | |
| exact hn a (hdown (n a) N hle ha) | |
| def StableTuple {G H : Graph} (k : β) (v : Fin k β Fin G.order) (w : Fin k β Fin H.order) : Prop := | |
| β round, tupleColor G k round v = tupleColor H k round w | |
| theorem stableTuple_exists {G H : Graph} {k : β} (hk : k β 1) | |
| (h : Equivalent k G H) (v : Fin k β Fin G.order) : | |
| β w : Fin k β Fin H.order, StableTuple k v w := by | |
| rw [Equivalent, ite_eq_right hk] at h | |
| apply finite_descending_choice (fun r w => tupleColor G k r v = tupleColor H k r w) | |
| Β· intro r w hh | |
| exact congrArg Prod.fst hh | |
| Β· intro r | |
| obtain β¨E, hEβ© := tupleRound_bijection (h r) | |
| exact β¨E v, hE vβ© | |
| /-- Stable joint colors supply one permanent finite vertex bijection for all | |
| replacement coordinates and all refinement rounds, not a separate round choice. -/ | |
| theorem stableTuple_extension {G H : Graph} {k : β} | |
| {v : Fin k β Fin G.order} {w : Fin k β Fin H.order} (h : StableTuple k v w) : | |
| β e : Fin G.order β Fin H.order, β z i, | |
| StableTuple k (Function.update v i z) (Function.update w i (e z)) := by | |
| classical | |
| let P (r : β) (e : Fin G.order β Fin H.order) : Prop := β z i, | |
| tupleColor G k r (Function.update v i z) = tupleColor H k r (Function.update w i (e z)) | |
| have hmono (r : β) (e : Fin G.order β Fin H.order) (he : P (r + 1) e) : P r e := by | |
| intro z i | |
| exact congrArg Prod.fst (he z i) | |
| have hn (r : β) : β e, P r e := by | |
| have hh := congrArg Prod.snd (h (r + 1)) | |
| change Finset.univ.val.map (fun z => fun i => tupleColor G k r (Function.update v i z)) = | |
| Finset.univ.val.map (fun z => fun i => tupleColor H k r (Function.update w i z)) at hh | |
| obtain β¨e, heβ© := exists_colorEquiv _ _ hh | |
| exact β¨e, fun z i => congrFun (he z) iβ© | |
| obtain β¨e, heβ© := finite_descending_choice P hmono hn | |
| exact β¨e, fun z i r => he r z iβ© | |
| /-- Such an extension fixes all currently paired vertices and preserves adjacency | |
| to every current slot, as can be tested in a different replacement coordinate. -/ | |
| theorem stableTuple_extension_local {G H : Graph} {k : β} (hk : 2 β€ k) | |
| {v : Fin k β Fin G.order} {w : Fin k β Fin H.order} (h : StableTuple k v w) : | |
| β e : Fin G.order β Fin H.order, | |
| (β z i, StableTuple k (Function.update v i z) (Function.update w i (e z))) β§ | |
| (β i, e (v i) = w i) β§ | |
| (β z i, G.edge (v i) z = H.edge (w i) (e z)) β§ | |
| (β z, degree G z = degree H (e z)) := by | |
| obtain β¨e, heβ© := stableTuple_extension h | |
| have hdif (i : Fin k) : β j : Fin k, i β j := by | |
| let a : Fin k := β¨0, by omegaβ© | |
| let b : Fin k := β¨1, by omegaβ© | |
| by_cases hia : i = a | |
| Β· refine β¨b, ?_β© | |
| subst i | |
| intro hh | |
| have := congrArg Fin.val hh | |
| simp [a, b] at this | |
| Β· exact β¨a, hiaβ© | |
| refine β¨e, he, ?_, ?_, ?_β© | |
| Β· intro i | |
| obtain β¨j, hijβ© := hdif i | |
| have hh := (round_one_local hk (he (v i) j 1)).1 i j | |
| have hh' : w i = e (v i) := by | |
| simpa only [Function.update_of_ne hij, Function.update_self] using hh.mp (by simp only [Function.update_of_ne hij, Function.update_self]) | |
| exact hh'.symm | |
| Β· intro z i | |
| obtain β¨j, hijβ© := hdif i | |
| have hh := (round_one_local hk (he z j 1)).2.1 i j | |
| simpa only [Function.update_of_ne hij, Function.update_self] using hh | |
| Β· intro z | |
| let i : Fin k := β¨0, by omegaβ© | |
| simpa only [Function.update_self] using (round_one_local hk (he z i 1)).2.2 i | |
| end WLIdentification | |
| end OAI | |