Professional Documents
Culture Documents
Designing A Quantum Hamming Code Generator Detector and Error Corrector Using IBM Quantum Experience
Designing A Quantum Hamming Code Generator Detector and Error Corrector Using IBM Quantum Experience
net/publication/338411309
CITATION READS
1 189
3 authors:
Prasanta K. Panigrahi
Indian Institute of Science Education and Research Kolkata
617 PUBLICATIONS 5,323 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
Experimental Demonstration of Delta, Scattering and Interaction Potentials in IBM Quantum Experience View project
All content following this page was uploaded by Bikash K. Behera on 06 January 2020.
B S B+ Remark
0 0 0 Non corrupt 0 bit
0 1 1 Corrupt 0 bit
1 0 1 Non corrupt 1 bit
1 1 0 Corrupt 0 bit
TABLE IV. Table showing the registers used for making the
detector/corrector. Number in parentheses indicate the size
FIG. 2. The result of input 1000 in the Hamming code gen- of the register.
erator with 1024 shots.
B. Implementation
from Hamming code generator should be 1001011, since
all three parity bits are 1. Clearly, this matches with the
output shown in Fig. 2 and hence we can say that our Since the detector/corrector is more complicated we
Hamming code generator works correctly. have programmed it using QISKit. We have Table IV
showing registers used for the same. We have given
1011011 as input assuming D5 to be corrupted.
The python code for the same is:
IV. DETECTOR AND CORRECTOR 1
2 %m a t p l o t l i b i n l i n e
A. Theory 3 # I m p o r t i n g s t a n d a r d Q i s k i t l i b r a r i e s and
c o n f i g u r i n g account
4 from q i s k i t im po rt QuantumCircuit , e x e c u t e , Aer ,
The detector first generates a checker bit correspond- IBMQ, QuantumRegister , C l a s s i c a l R e g i s t e r
ing to each parity bit. In Eq. (2), we XORed the data 5 from q i s k i t . c o m p i l e r im por t t r a n s p i l e , a s s e m b l e
6 from q i s k i t . t o o l s . j u p y t e r i mp ort ∗
bits, now we will XOR the parity bits as well. The 7 from q i s k i t . v i s u a l i z a t i o n im por t ∗
checker bits are given by the following equations : 8
9 # Loading IBM Q a c c o u n t
10 p r o v i d e r = IBMQ. l o a d a c c o u n t ( )
11
C1 = P 1 ⊕ D3 ⊕ D5 ⊕ D7 12 #G e t t i n g s i m u l a t o r
13 s i m u l a t o r=Aer . g e t b a c k e n d ( ’ q a s m s i m u l a t o r ’ )
C2 = P 2 ⊕ D3 ⊕ D6 ⊕ D7 14
C4 = P 4 ⊕ D5 ⊕ D6 ⊕ D7 (3) 15 ’’’
16 There a r e 6 quantum r e g i s t e r s and 1 c l a s s i c a l
r e g i s t e r used i n t h i s c i r c u i t .
Assuming that no bit is corrupt, we can safely expect 17 qp QuantumRegister i s composed o f p a r i t y i n p u t
all the checker bits to be 0 indicating no bit has to be lines
18 qd QuantumRegister i s composed o f data i n p u t
corrected. However, if one or more checker bits are non- lines
zero it indicates there is some corrupted bit. To identify 19 qch QuantumRegister i s composed o f c h e c k e r l i n e s
and correct it, we first find its position. The position 20 qb , qe QuantumRegisters a r e composed o f b u f f e r
is given by C4 C2 C1 . To find this bit, we use a 3 × 8 l i n e s which a r e used f o r i n t e r m e d i a t e
calculations
decoder17 . After decoding, for each bit we have Table
21 qx QuantumRegister i s composed o f i n v e r t e d i n p u t
III. lines for calculations
We can clearly see that this is also a XOR operation. 22 qo QuantumRegister i s composed o f ou tp ut l i n e s
4
which d i s p l a y s t h e o ut pu t 91 #Using a 3 t o 8 d e c o d e r
23 c C l a s s i c a l R e g i s t e r i s used f o r m e a u s r i n g qo 92
24 c i r c u i t i s t h e QuantumCircuit composed o f t h e 93 f o r i in range ( 0 , 3 ) :
above t h e r e g i s t e r 94 c i r c u i t . cx ( qch [ i ] , qxc [ i ] )
25 ’’’ 95 c i r c u i t . x ( qxc [ i ] )
26 96
27 qp=QuantumRegister ( 3 ) 97 or3 ( c i r c u i t , qxc [ 0 ] , qxc [ 1 ] , qxc [ 2 ] , qb [ 0 ] , qe [ 7 ] )
28 qd=QuantumRegister ( 4 ) 98 or3 ( c i r c u i t , qch [ 0 ] , qxc [ 1 ] , qxc [ 2 ] , qb [ 0 ] , qe [ 6 ] )
29 qch=QuantumRegister ( 3 ) 99 or3 ( c i r c u i t , qxc [ 0 ] , qch [ 1 ] , qxc [ 2 ] , qb [ 0 ] , qe [ 5 ] )
30 qb=QuantumRegister ( 1 ) 100 or3 ( c i r c u i t , qch [ 0 ] , qch [ 1 ] , qxc [ 2 ] , qb [ 0 ] , qe [ 4 ] )
31 qe=QuantumRegister ( 8 ) 101 or3 ( c i r c u i t , qxc [ 0 ] , qxc [ 1 ] , qch [ 2 ] , qb [ 0 ] , qe [ 3 ] )
32 qxc=QuantumRegister ( 3 ) 102 or3 ( c i r c u i t , qch [ 0 ] , qxc [ 1 ] , qch [ 2 ] , qb [ 0 ] , qe [ 2 ] )
33 c=C l a s s i c a l R e g i s t e r ( 7 ) 103 or3 ( c i r c u i t , qxc [ 0 ] , qch [ 1 ] , qch [ 2 ] , qb [ 0 ] , qe [ 1 ] )
34 104 or3 ( c i r c u i t , qch [ 0 ] , qch [ 1 ] , qch [ 2 ] , qb [ 0 ] , qe [ 0 ] )
35 c i r c u i t=QuantumCircuit ( qp , qd , qch , qb , qe , qxc , c ) 105
36 106 f o r i in range ( 0 , 8 ) :
37 #F u n c t i o n s a r e d e f i n e d below 107 c i r c u i t . x ( qe [ i ] )
38 108
39 d e f f u n o r ( qc , q0 , q1 , q2 ) : 109 #Using a s i m p l e XOR g a t e , with ou tp ut g e t t i n g
40 qc . x ( q0 ) stored in bit 1
41 qc . x ( q1 ) 110
42 qc . c c x ( q0 , q1 , q2 ) 111 mod xor ( c i r c u i t , qp [ 0 ] , qe [ 1 ] , qb [ 0 ] )
43 qc . x ( q2 ) 112 mod xor ( c i r c u i t , qp [ 1 ] , qe [ 2 ] , qb [ 0 ] )
44 qc . x ( q1 ) 113 mod xor ( c i r c u i t , qd [ 0 ] , qe [ 3 ] , qb [ 0 ] )
45 qc . x ( q0 ) 114 mod xor ( c i r c u i t , qp [ 2 ] , qe [ 4 ] , qb [ 0 ] )
46 115 mod xor ( c i r c u i t , qd [ 1 ] , qe [ 5 ] , qb [ 0 ] )
47 d e f o r 3 ( qc , q0 , q1 , q2 , b , q3 ) : 116 mod xor ( c i r c u i t , qd [ 2 ] , qe [ 6 ] , qb [ 0 ] )
48 f u n o r ( qc , q0 , q1 , b ) 117 mod xor ( c i r c u i t , qd [ 3 ] , qe [ 7 ] , qb [ 0 ] )
49 f u n o r ( qc , b , q2 , q3 ) 118
50 qc . r e s e t ( b ) 119 #Measurements
51 120
52 121 circuit . measure ( qp [ 0 ] , c [0])
53 d e f o r 4 ( qc , q0 , q1 , q2 , q3 , b1 , b2 , q4 ) : 122 circuit . measure ( qp [ 1 ] , c [1])
54 o r 3 ( qc , q0 , q1 , q2 , b1 , b2 ) 123 circuit . measure ( qd [ 0 ] , c [2])
55 f u n o r ( qc , b2 , q3 , q4 ) 124 circuit . measure ( qp [ 2 ] , c [3])
56 qc . r e s e t ( b1 ) 125 circuit . measure ( qd [ 1 ] , c [4])
57 qc . r e s e t ( b2 ) 126 circuit . measure ( qd [ 2 ] , c [5])
58 127 circuit . measure ( qd [ 3 ] , c [6])
59 d e f x o r 4 ( qc , q0 , q1 , q2 , q3 , q4 ) : 128
60 qc . cx ( q0 , q4 ) 129 #E x e c u t i o n o f t h e c i r c u i t
61 qc . cx ( q1 , q4 ) 130
62 qc . cx ( q2 , q4 ) 131 j o b = e x e c u t e ( c i r c u i t , s i m u l a t o r , s h o t s =1)
63 qc . cx ( q3 , q4 ) 132 r e s u l t=j o b . r e s u l t ( )
64 133 counts = r e s u l t . get counts ( c i r c u i t )
65 d e f mod xor ( qc , q1 , q2 , qb ) : 134
66 c i r c u i t . cx ( q1 , qb ) 135 #Output
67 c i r c u i t . cx ( q2 , qb ) 136
68 c i r c u i t . r e s e t ( q1 ) 137 print ( counts )
69 c i r c u i t . cx ( qb , q1 ) 138 c i r c u i t . draw ( )
70 c i r c u i t . r e s e t ( qb ) 139 plot histogram ( counts )
71
72
73 #I n p u t Below
74
C. Results
75 #1011011
76
77 circuit . x ( qd [ 3 ] ) The resulting circuit is given in Fig. 4. The histogram
78 circuit . x ( qd [ 1 ] ) is given in Fig. 3.
79 circuit . x ( qp [ 2 ] )
80 circuit . x ( qp [ 1 ] )
The output is 1001011 which is the same as the input
81 circuit . x ( qp [ 0 ] ) as in Fig. 2. Clearly, the original message has been recov-
82 ered and the corrupted bit has been corrected. Therefore,
83 #I n p u t Above our detector/corrector works correctly.
84
85 #G e n e r a t i n g Checker B i t s
86
87 x o r 4 ( c i r c u i t , qp [ 0 ] , qd [ 0 ] , qd [ 1 ] , qd [ 3 ] , qch [ 0 ] ) V. CONCLUSION
88 x o r 4 ( c i r c u i t , qp [ 1 ] , qd [ 0 ] , qd [ 2 ] , qd [ 3 ] , qch [ 1 ] )
89 x o r 4 ( c i r c u i t , qp [ 2 ] , qd [ 2 ] , qd [ 1 ] , qd [ 3 ] , qch [ 2 ] )
90
To summarize, we have designed and implemented
quantum circuits for Hamming code (7,4) generator and
5
ACKNOWLEDGEMENTS
Appendices
The quantum circuit for the detector/corrector is given
in Figs. 4. Here, q83 lines are parity lines, q84 lines are
data lines, q85 are check lines, q18 is the output line,
q86 is buffer line, q87 is extra buffer, q88 is the inverted
check bit line and c12 is the classical register.
∗
hrideynarula74@gmail.com Sci. Direct, 40, 681 (2007).
† 12
bikash@bikashsquantum.com K. Furutani, K. Arimoto, H. Miyamoto, T. Kobayashi, K.
‡
pprasanta@iiserkol.ac.in Yasuda and K. Mashiko, A built-in Hamming code ECC
1
M. A. Nielsen and I. L. Chuang, Quantum computation circuit for DRAMs, IEEE J. of Solid-State Circuits, 24,
and Quantum Information, 10th ed. Cambridge, U.K.: 50-56 (1989).
13
Cambridge Univ. Press (2010). R. Hentschke, F. Marques, F. Lima, L. Carro, A. Susin
2
P. Kaye, R. Laflamme, and M. Mosca, An introduction to and R. Reis, Analyzing area and performance penalty of
quantum computing, Oxford University Press (2007). protecting different digital modules with Hamming code
3
H.-K. Lo, Quantum Cryptology, Introduction to Quantum and triple modular redundancy, Proceedings. 15th Symp.
Computation and Information, 77, 76-119 (1998). on Int. Circuits and Systems Design, 95-100 (2002).
4 14
C. P. Williams, Quantum computing and quantum com- J. E. Whitesitt, Boolean Algebra and Its Applications,
munications, in Proc. 1st NASA Int. Conf. QCQC 1509, Dover Books on C.Sc. (2010).
15
Palm Springs, CA, USA, 200-217 (1998). D. R. Choudhury and K. Podder, Design of Hamming Code
5
R. P. Feynman, Simulating physics with computers, Int. J. Encoding and Decoding Circuit Using Transmission Gate
Theor. Phys. 21(6/7), 467-488 (1982). Logic, IRJET 2, (2015).
6 16
P. W. Shor, Algorithms for quantum computation: dis- K. Anand, B. K. Behera and P. K. Panigrahi, Experimen-
crete logarithms and factoring, Proceedings 35th Annual tal Realization of NEQR and Encryption Algorithm us-
Symposium on Foundations of C.Sc.,pp. 124-134 (1994). ing Generalized Affine Transform and Logistic Map, DOI:
7
Digital Principles and Applications, Leach, Malvino and 10.13140/RG.2.2.12533.32485 (2019).
Saha. McGraw Hill Education , 8th edition (2014). 17
H. Narula, B. K. Behera and P. K. Panigrahi, Designing a
8
R.W. Hamming, Error Detecting and Error Correcting Simple Quantum Morse Encoder and Decoder Using IBM
Codes, Bell Labs Tech. J. 29, 147 (1950). Quantum Experience, DOI: 10.13140/RG.2.2.18770.71366
9
https://en.wikipedia.org/wiki/Hamming code (2019).
10
https://en.wikipedia.org/wiki/Parity bit
11
C.-. Chan, and C.-C. Chang, An efficient image authen-
tication method based on Hamming code, Pattern Recog.