Download data/lean/OAI/Computability/DepthThree/HashBool.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.13 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/DepthThree/HashBool.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/DepthThree/HashBool.lean
-
curl -L -o HashBool.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/DepthThree/HashBool.lean
5.13 kB
| import OAI.Computability.DepthThree.HashAffine | |
| namespace OAI | |
| namespace DepthThreeLowerBound.BinaryHash | |
| open BinaryAlgebra | |
| variable {d r : β} | |
| theorem hashBool_eq_iff (u : Fin (d + r - 1) β Bool) | |
| (x : Fin d β Bool) (a : Fin r β Bool) : | |
| hashBool u x = a β | |
| hashF2 (bitsEquivF2 (Fin (d + r - 1)) u) (bitsEquivF2 (Fin d) x) = | |
| bitsEquivF2 (Fin r) a := by | |
| rw [β bitsEquivF2_hashBool] | |
| exact (bitsEquivF2 (Fin r)).injective.eq_iff.symm | |
| theorem hashBool_collision_iff (u : Fin (d + r - 1) β Bool) | |
| (x y : Fin d β Bool) : | |
| hashBool u x = hashBool u y β | |
| hashF2 (bitsEquivF2 (Fin (d + r - 1)) u) (bitsEquivF2 (Fin d) x) = | |
| hashF2 (bitsEquivF2 (Fin (d + r - 1)) u) (bitsEquivF2 (Fin d) y) := by | |
| rw [β bitsEquivF2_hashBool, β bitsEquivF2_hashBool] | |
| exact (bitsEquivF2 (Fin r)).injective.eq_iff.symm | |
| def hashBool_fiberEquiv (x : Fin d β Bool) (a : Fin r β Bool) : | |
| {u : Fin (d + r - 1) β Bool // hashBool u x = a} β | |
| {u : Seed d r // hashF2 u (bitsEquivF2 (Fin d) x) = | |
| bitsEquivF2 (Fin r) a} := | |
| Equiv.subtypeEquiv (bitsEquivF2 (Fin (d + r - 1))) | |
| (fun u => hashBool_eq_iff u x a) | |
| theorem hashBool_fiber_card (x : Fin d β Bool) (hx : x β fun _ => false) | |
| (a : Fin r β Bool) : | |
| Fintype.card {u : Fin (d + r - 1) β Bool // hashBool u x = a} = 2 ^ (d - 1) := by | |
| classical | |
| have hnonzero : bitsEquivF2 (Fin d) x β 0 := by | |
| intro h | |
| apply hx | |
| funext i | |
| apply bitValue_injective | |
| simpa using congrFun h i | |
| exact (Fintype.card_congr (hashBool_fiberEquiv x a)).trans | |
| (hashF2_fiber_card (bitsEquivF2 (Fin d) x) hnonzero (bitsEquivF2 (Fin r) a)) | |
| def hashBool_collisionEquiv (x y : Fin d β Bool) : | |
| {u : Fin (d + r - 1) β Bool // hashBool u x = hashBool u y} β | |
| {u : Seed d r // hashF2 u (bitsEquivF2 (Fin d) x) = | |
| hashF2 u (bitsEquivF2 (Fin d) y)} := | |
| Equiv.subtypeEquiv (bitsEquivF2 (Fin (d + r - 1))) | |
| (fun u => hashBool_collision_iff u x y) | |
| theorem hashBool_collision_card (x y : Fin d β Bool) (hxy : x β y) : | |
| Fintype.card {u : Fin (d + r - 1) β Bool // hashBool u x = hashBool u y} = | |
| 2 ^ (d - 1) := by | |
| classical | |
| exact (Fintype.card_congr (hashBool_collisionEquiv (r := r) x y)).trans | |
| (hashF2_collision_card (bitsEquivF2 (Fin d) x) (bitsEquivF2 (Fin d) y) | |
| (fun h => hxy ((bitsEquivF2 (Fin d)).injective h))) | |
| def boolCoordinateCube (T : Finset (Fin d)) (rho : {i : Fin d // i β T} β Bool) : | |
| Set (Fin d β Bool) := | |
| {x | β i (hi : i β T), x i = rho β¨i, hiβ©} | |
| theorem mem_boolCoordinateCube_iff (T : Finset (Fin d)) | |
| (rho : {i : Fin d // i β T} β Bool) (x : Fin d β Bool) : | |
| x β boolCoordinateCube T rho β | |
| bitsEquivF2 (Fin d) x β coordinateCube T (fun i => bitValue (rho i)) := by | |
| constructor | |
| Β· intro hx i hi | |
| change bitValue (x i) = bitValue (rho β¨i, hiβ©) | |
| exact congrArg bitValue (hx i hi) | |
| Β· intro hx i hi | |
| exact bitValue_injective (hx i hi) | |
| theorem injOn_hashBool_iff (u : Fin (d + r - 1) β Bool) | |
| (T : Finset (Fin d)) (rho : {i : Fin d // i β T} β Bool) : | |
| Set.InjOn (hashBool u) (boolCoordinateCube T rho) β | |
| Set.InjOn (hashF2 (bitsEquivF2 (Fin (d + r - 1)) u)) | |
| (coordinateCube T (fun i => bitValue (rho i))) := by | |
| constructor | |
| Β· intro hinj x hx y hy hxy | |
| obtain β¨a, rflβ© := (bitsEquivF2 (Fin d)).surjective x | |
| obtain β¨b, rflβ© := (bitsEquivF2 (Fin d)).surjective y | |
| have hab := hinj ((mem_boolCoordinateCube_iff T rho a).mpr hx) | |
| ((mem_boolCoordinateCube_iff T rho b).mpr hy) | |
| ((hashBool_collision_iff u a b).mpr hxy) | |
| exact congrArg (bitsEquivF2 (Fin d)) hab | |
| Β· intro hinj x hx y hy hxy | |
| apply (bitsEquivF2 (Fin d)).injective | |
| exact hinj ((mem_boolCoordinateCube_iff T rho x).mp hx) | |
| ((mem_boolCoordinateCube_iff T rho y).mp hy) | |
| ((hashBool_collision_iff u x y).mp hxy) | |
| def hashBool_badSeedEquiv (T : Finset (Fin d)) | |
| (rho : {i : Fin d // i β T} β Bool) : | |
| {u : Fin (d + r - 1) β Bool // Β¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)} β | |
| {u : Seed d r // Β¬ Set.InjOn (hashF2 u) | |
| (coordinateCube T (fun i => bitValue (rho i)))} := | |
| Equiv.subtypeEquiv (bitsEquivF2 (Fin (d + r - 1))) | |
| (fun u => not_congr (injOn_hashBool_iff u T rho)) | |
| open scoped Classical in | |
| theorem hashBool_badSeed_card_le (T : Finset (Fin d)) | |
| (rho : {i : Fin d // i β T} β Bool) : | |
| Fintype.card | |
| {u : Fin (d + r - 1) β Bool // Β¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)} β€ | |
| (2 ^ T.card - 1) * 2 ^ (d - 1) := by | |
| classical | |
| calc | |
| Fintype.card | |
| {u : Fin (d + r - 1) β Bool // Β¬ Set.InjOn (hashBool u) (boolCoordinateCube T rho)} = | |
| Fintype.card {u : Seed d r // Β¬ Set.InjOn (hashF2 u) | |
| (coordinateCube T (fun i => bitValue (rho i)))} := | |
| Fintype.card_congr (hashBool_badSeedEquiv (r := r) T rho) | |
| _ = (badSeeds (r := r) T (fun i => bitValue (rho i))).card := by | |
| simp only [badSeeds, Fintype.card_subtype] | |
| _ β€ (2 ^ T.card - 1) * 2 ^ (d - 1) := badSeeds_card_le T _ | |
| end DepthThreeLowerBound.BinaryHash | |
| end OAI | |