#OK to post homework #Natalya Ter-Saakov, Feb 4, 2024, Assignment 5 read "C5.txt": #from Robert, a faster GRC GRCrdb:=proc(q,n,d) local S,A,v,sp,sphere: A:=MutableSet(Fqn(q,n)): S:={}: sphere := SP(q, [0 $ n], d - 1): while not empty(A) do v:=A[1]: S:=S union {v}: sp := map(x -> (x + v) mod q, sphere): A &minus MutableSet(sp): od: S: end: #Problem 1 #2.1 #(6,2,6): {(0,0,0,0,0,0),(1,1,1,1,1,1)} #(3,8,1): all of {0,1}^3 #(4,8,2): all of {0,1}^3 with a final parity bit #(5,3,4): Impossible! There are 6 code words at distance at least 4 from (0,0,0,0,0) and all of them are within distance 2 of each other. #(8,30,3): Impossible! To have a code of distance 3, every word must have a sphere of radius 1 surrounding it. Those spheres have 9 elements in them, so there must be at least 30*9 = 270 possible words on length 8. However, there are only 2^8=256 words. #2.2 #For a (n,M,d) code, consider the last element over all the words. WLOG assume there are more 1s than 0s. Take all the words that end in 1 and remove the last element. These will be words of length n and min distance d and there will be at least M/2 of them. #Thus A_2(n-1,d)<=2A_2(n,d). #2.3 #Let us first demonstrate that a code of q^2 words exists. Consider all words that sum to 0 mod q. There are q^2 of them. The better way to think about this is to imagine them as elements of F_q^2 with a last bit that makes the sum work out. As below, we know that two such words cannot be distance 1 apart because then one of the sums cannot be 0. #Now we must show that there cannot be a larger code. Consider a maximal code and two words that disagree in the last bit (if no words disagree in the last bit, then we already have no more than q^2 words). Deleting the last bit from every word cannot create a collision since the minimum distance is 2. Thus, we get at most q^2 distinct words, so the maximal code is at most q^2 words. #2.4 #Let E_n be the set of all vectors in F_2^n with even weight. This is a set of 2^(n-1) vectors. Note that adding a parity bit to the end of a vector in F_2^(n-1) ensures even weight. Thus, since this makes all 2^(n-1) vectors, that is what E_n is. #All that remains is to show that the vectors have distance at least 2. Suppose not. These vectors cannot differ in the last bit as the parity of the remainder would be the same. They also cannot differ in an earlier bit as the parity would then be different. #Problem 3 #[seq(nops(GRCrdb(2,n,3)),n=5..20)]; #[4, 8, 16, 16, 32, 64, 128, 256, 512, 1024, 2048, 2048, 4096, 8192, 16384, 32768] #Sphere Bounds: #[5, 9, 16, 28, 51, 93, 170, 315, 585, 1092, 2048, 3855, 7281, 13797, 26214, 49932] #[seq(nops(GRCrdb(2,n,5)),n=5..20)]; #[2, 2, 2, 4, 4, 8, 16, 16, 32, 64, 128, 256, 512, 512, 1024, 2048] #Sphere Bounds: #[2, 2, 4, 6, 11, 18, 30, 51, 89, 154, 270, 478, 851, 1524, 2744, 4969] #[seq(nops(GRCrdb(2,n,7)),n=5..20)]; #[1, 1, 2, 2, 2, 2, 4, 4, 8, 16, 32, 32, 64, 128, 256, 512] #Sphere Bounds: #[1, 1, 2, 2, 3, 5, 8, 13, 21, 34, 56, 94, 157, 265, 451, 776] #Problem 4 #[seq(nops(GRCrdb(3,n,3)),n=5..10)]; #[9, 24, 72, 198, 519, 1390] #Sphere Bounds: #[22, 56, 145, 385, 1035, 2811] #[seq(nops(GRCrdb(3,n,5)),n=5..10)]; #[3, 3, 8, 18, 39, 83] #Sphere Bounds: #[4, 9, 22, 50, 120, 293] #[seq(nops(GRCrdb(3,n,7)),n=5..10)]; #[1, 1, 3, 3, 3, 9] #Sphere Bounds: #[1, 3, 5, 11, 23, 50] #Problem 5 #[seq(nops(GRCrdb(5,n,3)),n=5..7)]; #[74, 265, 1113] #Sphere Bounds: #[148, 625, 2693] #[seq(nops(GRCrdb(5,n,5)),n=5..7)] #[5, 13, 39] #Sphere Bounds: #[17, 58, 214] #[seq(nops(GRCrdb(5,n,7)),n=5..7)] #[1, 1, 5] #Sphere Bounds: #[3, 10, 29] #Problem 6 #ParaBD(BD,v), that inputs a potential block design with v varieties (or points) (i.e. the universal set is {1, ..., v}) and checks whether it is indeed a block design (if it is not it should return FAIL). If it is the output should be the 5-tuple [b,v,r,k,lambda]. ParaBD:=proc(BD,v) local b,r,k,lambda,block,i,j, rI,lambdaIJ: b:=nops(BD): k:=nops(BD[1]): r:=0: lambda:=0: for block in BD do if not nops(block)=k then return FAIL: fi: if 1 in block then r+=1: if 2 in block then lambda+=1: fi: fi: od: for i from 1 to v do rI:=0: for block in BD do if i in block then rI+=1 fi: od: if not rI=r then return FAIL: fi: for j from 1 to v do if not j=i then lambdaIJ:=0: for block in BD do if i in block and j in block then lambdaIJ+=1: fi: od: if not lambdaIJ=lambda then return FAIL: fi: fi: od: od: [b,v,r,k,lambda]: end: #Problem 7 PlotkinBound:=proc(n,d) if evalb(0=d mod 2) then if n<2*d then return min(4*d,2*floor(d/(2*d-n))): fi: return 4*d: fi: if n<2*d+1 then return min(4*d+4,2*floor((d+1)/(2*d+1-n))): fi: return 4*d+4: end: ComparePlotkinSphere:=proc(n,d) local P,S: P:=PlotkinBound(n,d): #Note that the sphere packing bound does not work for even d. As such, we will just use the d one bigger. if evalb(0=d mod 2) then S:=SPB(2,n,d/2): else S:=SPB(2,n,(d-1)/2): fi: if P