O a Algorith for Isoorphis-Free Geeratios of Cobiatorial Objects Krasiir Yordzhev Faculty of Matheatics ad Natural Scieces South-West Uiversity, Blagoevgrad, Bulgaria yordzhev@swubg Abstract: I the wor are defied the cocepts seicaoical ad caoical biary atrix What is described is a algorith solvig the cobiatorial proble for fidig the sei-caoical atrices i the set Λ cosistig of all biary atrices havig exactly s i every row ad every colu without perabulatig all eleets I the described algorith bitwise operatios are substatially used I this way it becoes easier to fid the solutio to the proble for receivig oe represetative fro every equivalece class regardig the itroduced i the article equivalece relatio i the set Λ The last proble is equivalet to the proble for fidig all caoical atrices i Λ Keywords: biary atrix, equivalece relatio, bitwise operatios, C++ prograig laguage, isoorphis-free geeratios INTRODUCTION A big class of prograig probles has the followig geeral forulatio: Proble The set is give Copose a coputer progra receivig the set δ ( ) fro all eleets of possessig give properties It is desirable to do this without perabulatig all eleets of the set Variatio of the proble above ca be forulated i the followig way: Proble 2 2The set is give ad a equivalece relatio is defied i Copose a coputer progra receivig exactly oe represetative of every equivalece class regardig, ie costruct the factorset / Moreover without the ecessity to perabulate all eleets of It is very ofte ecessary to solve probles which solve siultaeously probles ad 2, ie to fid the itersectio δ ( ) / of two sets, the first of which solves proble, ad the secod proble 2 We presue that there is a procedure which with a give eleet of aswers i the affirative or i the egative whether this eleet belogs or respectively does ot belog to δ ( ) / The solutio to such a proble i real tie is coplicated if the set is too big, ie if its cardiality is a expoetial fuctio of oe or ore paraeters I this case the tie ecessary to perabulate all eleets of the set ad to chec for every eleet whether it possesses the ecessary properties is iefficietly large durig the growth of the paraeters Oe solutio to the probles described above, which sigificatly icreases the efficiecy of the coputer progra, is to fid a set, such that < δ ( ), ad the proble for ad / fidig is algorithically a easily solved proble The we will chec whether they possess the give properties ot for all eleets of, but oly for the eleets of The ideal case is whe = δ ( ) Ufortuately this is ot always a / easy proble fro a algorithic poit of view Oe criterio for efficiecy ay be the fractio, where the efficiecy is iversely proportioal to the value of this fractio I the curret wor we will use this approach The algoriths solvig the forulated proble are ow as algoriths for isoorphis-free geeratios of cobiatorial objects Differet approaches to creatig such algoriths are discussed i [2] The ai of the preset article is to use the bitwise operatios [6]-[8] i order to solve a proble fro this class The wor is a cotiuatio ad additio to [7] 2 SEMI-CANONICAL AND CANONICAL BINARY MATRICES Biary (or boolea, or (0,)-atrix) is called a atrix whose eleets belog to the set = 0, Let ad be positive itegers With we will deote the set of all biary atrices, while with = we will deote the set of all square biary atrices
Defiitio 3Let With r( A) we will A deote the ordered -tuple,,,, x x2 x where 0 x i 2, i =,2, ad x i is the iteger writte i biary otatio with the help of the i -th row of A Siilarly with ca ( ) we will deote the ordered - tuple y, y2,, y, where 0 y j 2, j =,2, ad y j is the iteger writte i biary otatio with the help of the j -th colu of A ad We cosider the sets: x x2 x x i =,,, 0 2, =,2, i r A A = ( ) y y2 y y j =,,, 0 2, =,2, = ( ) j ca A With ''<'' we will deote the lexicographic orders i ad i It is easy to see that i defiitio two appigs are described: ad r : :, c which are bijective ad therefore I [3] it is prove that the represetatio of the eleets of usig ordered -tuples of atural ubers leads to the creatio of faster ad eory-savig algoriths Defiitio 2 4Let A, r( A)= x, x,, x, ca y y2 y ( )=,,, We will call the atrix A sei-caoical, if ad x x x y y y 2 Propositio 5Let A=[ a ij ] be a seicaoical atrix The there exist itegers i, j, such that i, j ad a = a = = a = 0, a = a = = a =, () 2 j j+ j+ 2 a = a = = a = 0, a = a = = a = (2) ad i i+ i+ 2 Proof Let r A x x x ( )=, 2, ca y y y ( )=, 2, We assue that there exist itegers p ad q, such that p < q, a = ad a =0 But i this case y p p q > y, which cotradicts the coditio for seicaoicity of the atrix A We have prove () Siilarly we prove (2) as well Let be a positive iteger With q = we will deote the set of all perutatio atrices, ie the set of all biary atrices havig exactly oe i every row ad every colu The isoorphis, is true, where with we have deoted the syetric group, ie the group of all oe-to-oe appigs of the set [ ] =,2, i itself As it is well ow [4], [5], the ultiplicatio of a arbitrary real or coplex atrix A fro the left with a perutatio atrix (if the ultiplicatio is possible) leads to dislocatio of the rows of the atrix A The ultiplicatio of A fro the right with a perutatio atrix leads to the dislocatio of the colus of A AB atrices A ad B are equivalet ad we will write Defiitio 3 6Let, We will say that the if there exist perutatio atrices such that A B, (3) X ad Y, A = XBY (4) I other words A B if A is received fro B after dislocatio of soe of the rows ad the colus of B Obviously the itroduced relatio is a equivalece relatio
With we deote the set of all traspositios i, ie the set of all perutatio atrices, which ultiplyig fro the left a arbitrary atrix swaps the places of exactly two rows, while ultiplyig fro the right a arbitrary atrix swaps the places of exactly two colus Theore 7Let A be a arbitrary atrix fro The: a) If are such that X, X2,, Xs r( X X X A)< r( X X X A)< < r( X A)< r( A), the s 2 3 s s b) If are such that cxx ( XA) < ca ( ) Y, Y2,, Yt cyy ( YA)< cyy ( YA)< < c( X A)< r( A), the t 2 3 t t r( YY Y A) < r( A) t Proof a) Iductio by s Let s = ad let X be a traspositio which ultiplyig a arbitrary atrix A=[ a ij ] fro the left swaps the places of the rows of A with ubers u ad v ( u < v ), while the reaiig rows stay i their places I other words if the a a a a a a a a a a a a A = a a a a a a a a s 2 r 22 2r 2 u u2 ur u v v2 vr v r a a2 a r a a2 a22 a2r a 2 av av2 avr av XA =, au au 2 aur au a a2 ar a a, i, j where ij 0, Let The r( A)= x, x,, x,, x,, x u v r( XA)= x, x,, x,, x,, x v u Sice r( XA)< r( A ) the accordig to the properties x x Accordig to of the lexicographic order v < u defiitio the represetatio of x u ad x v i biary otatio with a evetual additio if ecessary with uessetial zeroes i the begiig is respectively as follows: x = a a a, u u u2 u x = a a a v v v2 v Sice xv < x u, the there exists a iteger r,2,,, such that auj = a vj whe j < r, a = ad a =0 ur ad Let vr ca y y y ( )=, 2,, c( XA)= z, z,, z The y j = z j whe j < r, while the represetatio of yr ad z r i biary otatio with a evetual additio if ecessary with uessetial zeroes i the begiig is respectively as follows: y = a a a a a a, r r 2r u r ur vr r z = a a a a a a r r 2r u r vr ur r Sice a ur =, a vr =0, the zr < follows that cxa ( )< ca ( ) y, whece it r
We assue that for every s -tuple of traspositios X, X2,, Xs ad for every atrix A fro r( X X X A)< r( X X A)< < r( X A)< r( A) s 2 s s it follows that cxx ( XA)< ca ( ) ad let X s + be such that r( X X X X A)< r( X X A)< < r( X A)< r( A) s s+ s+ s+ Accordig to the iductio assuptio We put cx ( A)< ca ( ) s s+ A X A = s + Accordig to the iductio assuptio fro r( X X X A)< r( X X A)< < r( X A)< r( A) s s s it follows that cxx ( XX A)= cxx ( XA)< ca ( )= s s+ s = cx ( A)< ca ( ), s+ with which we have prove a) b) is prove siilarly to a) Corollary 8Let A The r( A ) is a iial eleet about the lexicographic order i the set rb ( ) B A if ad oly if ca ( ) is a iial eleet about the lexicographic order i the set cb ( ) B A Corollary gives us grouds to forulate the followig defiitio: Defiitio 4 We will call the atrix A caoical atrix, if r( A ) is a iial eleet about the lexicographic order i the set rb ( ) B A, ad therefore ca ( ) is a iial eleet about the lexicographic order i the set cb ( ) B A Fro defiitio 4 follows that i every equivalece class about the relatio " " (defiitio 3) there exists oly oe caoical atrix If a atrix A B is a caoical atrix, the it is easy to see that A is a sei-caoical atrix, but as we will see i the ext exaple the opposite stateet is ot always true Exaple 9We cosider the atrices: 0 0 0 A = 0 0 0 ad 0 0 0 0 B = 0 0 It is ot difficult to see that A B Furtherore r( A ) = 7,9,0,4, ca ( ) = 7,9,,2, rb ( ) = 3,5,3,4, cb ( ) = 3,7,9,9 Therefore A ad B are two equivalet to each other sei-caoical atrices Fro exaple follows that i a equivalece class it is possible to exist ore tha oe sei-caoical eleet Let be a arbitrary subset of, such that if A ad B A, the B The obviously there exists oly oe caoical atrix i every equivalece class i the factor-set / Therefore the uber of the caoical atrices will give us the cardiality of the factor-set / 3 FORMULATION OF THE PROBLEM Defiitio 5 0The square biary atrices i every row ad every colu o which there exist exactly s we will call Λ -atrices, where with Λ we will also deote the set of these atrices Let ad be positive itegers We cosider the sets: - the set of all square biary atrices; Λ - the set of all square biary atrices havig exactly s i every row ad every colu; = A r( A)= x, x2,, x, x x2 x ; = A ca ( )= y, y2,, y, y y2 y = i ; Λ - the set of all sei-caoical atrices Λ Let us cosider the followig proble: Proble 3 Describe ad ipleet a algorith receivig the set
By solvig proble 3 we will facilitate to a iiu µ (, )= Λ, the solutio to the proble for fidig / ie the uber of the equivalece classes accordig to defiitio 3 relatio The proble for fidig the uber µ (, ) of the equivalece classes for every ad is a ope scietific proble We will solve proble 3 by substatially usig the properties of the bitwise operatios with the ai of icreasig the efficiecy of the algorith created by us 4 Descriptio ad ipleetatio of the algorith by usig bitwise operatios I the descriptio of algoriths we will use the C++ prograig laguage As it is well ow, there are exactly 2 oegative itegers, which are preseted with o ore tha digits i biary otatio We eed to select all of the, which have exactly 's i biary otatio Their uber is << 2 We will describe a algorith that directly receives the ecessary eleets without checig whether ay iteger [0, 2 ] satisfies the coditios We will reeber the result i the array p[] of size c = Moreover, the obtaied array will be sorted i ascedig order ad there are o duplicate eleets The algorith is based o the fact that the set of all ordered -tuples = b, b,, b b = 0,, i =,2,,, =,2,,, is partitioed ito two disjoit subsets where ad = M M, M M = i, M = b, b,, b b = 0 M = b, b,, b b = 2 The described below recursive algorith will use the bitwise operatios void DataNub(it p[], usiged it, it, it& c) if (<=0) c = ; p[0] = 0; else if (==) c = ; p[0] = (<<)-; // p[0]= 2 else it p[0000], p2[0000]; it c, c2; DataNub(p, -,, c); DataNub(p2, -, -, c2); c = c+c2; for (it i=0; i<c; i++) p[i] = p[i]; for (it i=0; i<c2; i++) p[c+i] = p2[i] <<(-); We will also use bitwise operatios i costructig the ext two fuctios The fuctio it _tuple(it[], it, it, it) gets all + t = (cobiatios with repetitios) ordered -tuples x, x,, x, where 0 x x x < 2 c, ad for each i =,2,,, x i are eleets of sorted array p[] of size c As a result, the fuctio returs the uber of sei-caoical eleets I her wor, she will refer to fuctio bool chec(it[], it) This fuctio refers to the use of each received -tuple It exaies whether this is a sei-caoical eleet ad prits it if the aswer is yes bool chec(it x[], it, it ) it yj; // the iteger represetig colu (-j) it y0=0; // the iteger precedig colu j it b; for (it j=-; j>=0; j--) yj=0; for (it i=0; i<; i++) b = <<j & x[i]? : 0; yj = b << (--i); if (yj<y0 (NubOf_(yj)!= )) retur false; y0 = yj; // We have received a caoical eleet Prit it: for (it i=0; i<; i++) cout<<x[i]<<" "; cout<<'\'; retur true; it _tuple(it p[], it, it, it c) it t=0; it a[], x[];
it idx = -; for (it i=0; i<; i++) a[i]=0; while (idx >= 0) for (it i=idx+; i<; i++) a[i] = a[idx]; for (it i=0; i<; i++) x[i] = p[a[i]]; if(chec(x,,)) t++; idx = -; a[idx]++; while (idx>=0 && a[idx]==c) idx--; a[idx]++; retur t; Here we will oit the descriptio of the fuctio ai() 5 Coclusio soe results fro the wor of the algorith Let ad be atural ubers Let us deote with (, ) ν the uber of all sei-caoical atrices i Λ, ie ν (, )= = Λ Here for = 2,3,4 ad 5 we will idicate the ν for soe ot (, ) begiig of the sequeces = big values of the paraeter With the help of the coputer progra described i sectio 4, the followig results have bee obtaied: ν (, 2) =,, 2,5,3, 42,55, 636, 2889,432, 76834, 44357, =2 ν (,3) =,,3, 25, 272, 4070,7922,90650, =3 (5) (6) Refereces [] The O-Lie Ecyclopedia of Iteger Sequeces (OEIS) http://oeisorg/ [2] I Bouyuliev, About Algoriths for Isoorphis- Free Geeratios of Cobiatorial Objects, Matheatics ad educatio i atheatics, (38), pp 5-60, 2009 [3] [3] H Kostadiova, K Yordzhev A Represetatio of Biary Matrices, Matheatics ad educatio i atheatics, (39), pp 98-206, 200 [4] [4] V N Sachov, V E Taraaov, Cobiatorics of Noegative Matrices of Noegative Matrices, Aer Math Soc, 975 [5] [5] V E Taraaov, Cobiatorial probles ad (0,)-atrices Moscow, Naua, 985 (i Russia) [6] [6] K Yordzhev, A exaple for the use of bitwise operatios i prograig, Matheatics ad educatio i atheatics, (38), pp 96-202, 2009 [7] [7] K Yordzhev, Bitwise Operatios Related to a Cobiatorial Proble o Biary Matrices, I J Moder Educatio ad Coputer Sciece, (4), pp 9-24, 203 [8] [8] K Yordzhev, The Bitwise Operatios Related to a Fast Sortig Algorith Iteratioal Joural of Advaced Coputer Sciece ad Applicatios (IJACSA), Vol 4, No 9, 203, pp 03-07 [9] [9] K Yordzhev, Fiboacci sequece related to a cobiatorial proble o biary atrices, preprit, arxiv:3056790, 203 AUTHOR Associate professor Dr Krasiir Yordzhev is a lecturer i coputer sciece, prograig ad discrete atheatics at the Departet of Coputer Sciece, Faculty of Matheatics ad Natural Scieces, South- West Uiversity, Blagoevgrad, Bulgaria Dr Yordzhev received his PhD degree i the Faculty of Cyberetics, Kiev State Uiversity, Uraie He is the author of ore tha 70 scietific publicatios i the field of discrete atheatics, cobiatorics, cobiatorial algoriths ad prograig ν (, 4) =,,5,6, 7776, 626649, =4 ν (,5) =,,8,2, 2873, =5 (7) (8) The iteger sequeces (5), (6), (7) ad (8) are idicated i the Ecyclopedia of Iteger Sequeces [], respectively uder the ubers A2296, A22962, A22963 ad A22964 All of the are preseted by N J A Sloae, who cites the wor [9] The sequece (5) is coeted by Breda McKay ad is suppleeted by R H Hardi with the eleets ν (2,2) = 76 834 ad ν (3, 2) = 44357 I the sequece (6) the eleet ν (0,3) = 906 50 is added by R H Hardi