Analysis of Quantum Artificial Intelligence Algorithms Grover Search and Natural Language Processing With Quantum Communication
Analysis of Quantum Artificial Intelligence Algorithms Grover Search and Natural Language Processing With Quantum Communication
BAHCESEHIR UNIVERSITY
Master’s Thesis
ISTANBUL, 2021
THE REPUBLIC OF TURKEY
BAHCESEHIR UNIVERSITY
GRADUATE SCHOOL
ELECTRICAL AND ELECTRONICS ENGINEERING MASTER’
PROGRAM
Master’s Thesis
ISTANBUL, 2021
T.C.
BAHCESEHIR UNIVERSITY
GRADUATE SCHOOL
04/08/2021
This thesis has been approved by the Graduate School which has fulfilled the necessary
conditions as Master thesis.
This thesis was read by us, quality and content as a Master's thesis has been seen and
accepted as sufficient.
Title/Name Signature
I would like to thank my thesis advisor Prof. Şeref KALEM, who is a very precious
scientist in Quantum Computing. Also, special thanks to my mother for her assistance.
They always motivate and support me while I was writing this thesis which is about such
an excellent subject.
I want to dedicate this thesis in memory of my father Mahir ALTUN and Quantum
Research Scientist Dr. Peter WITTEK.
The Search Algorithms and Natural Language Processing are the trends in development
of the Artificial Intelligence based electronics & computer projects. With new Quantum
revolution, the scientists began to research and develop AI algorithms in Quantum
domain. We can also say that the quantum based algorithms support AI in different
computation domains both classical and quantum. One of the first algorithm of the
Quantum AI is the Grover algorithm which solves the problem of unstructured search.
Grover is a quantum algorithm that finds with high probability the unique input to a black
box function that produces a particular output value, using just o(√n) evaluations of the
function, where is the size of the function’s domain. Another important branch of the AI
is the Natural Language Processing (NLP) which is mostly used in human language
recognition, classification, verification tasks. Today, the scientists work on the
development phase of QNLP.
In this thesis, we especially focused on analysing the Search and NLP related problems
with Quantum based Grover Search Algorithm, Classical NLP, QNLP and Cryptographic
Communication (QKD). These research topics were considered with contributions of the
live example of an Artificial Intelligence based algorithms such as classical search and
NLP on classical & quantum computing domain. Grover Algorithm is tried to be
investigated and simulated in a classical computer and detailed knowledge of the Grover
algorithm, pseudocode of the simulation experiment and hands-on problem solution of
Sudoku with Grover Algorithm was mentioned. Also, detailed knowledge of the NLP
was investigated and some of the hands-on experiments evaulated.
This thesis consists of literature survey, applied methods, the experiments and conclusion-
discussion. We worked with Grover and used DFS as benchmark model for comparison
of the Quantum and Classical Search Algorithms, also with Qiskit and Q# in the
experiments. Kaggle and some of other NLP datasets with various classification models
are used in the experiments.
Also, we worked to build a hybrid system-architecture model with using classical NLP
classification algorithms and Quantum Key Distribution with Superdense Coding
iv
protocol, in order to illustrate a hybrid model which consists of NLP and secure
communication. Lastly, Quantum Natural Language Processing was analized with
comparison to Classical NLP and further future reasearch determined and noted. The
main contribution of this thesis is the evaulation, design, tuning, implementation,
revealing the differences between Classical & Quantum Grover Search, Classical &
Quantum NLP with Cryptographic Communication. Also, Quantum-like simulation
project for the individuals who newly begin the Grover algorithm, which provides a better
understanding the algorithm in a classical way of calculations in fewer steps.
The reason for investigating this topic is related with concern on artificial intelligence
based quantum consideration. AI’s newest technological development motivates us for
working and searching on this subject. The challenges of examining the research topics
is to consider and manage to reveal the differences on the ideas which are applied in AI
based Classical & Quantum Computer Projects, it needs extra research effort on both of
the side.
v
ÖZET
Arama Algoritmaları ve Doğal Dil İşleme, Yapay Zeka tabanlı elektronik ve bilgisayar
projelerinin gelişimindeki eğilimlerdir. Yeni Kuantum devrimi ile bilim adamları,
Kuantum alanında yapay zeka algoritmaları araştırmaya ve geliştirmeye başladı. Ayrıca
kuantum tabanlı algoritmaların hem klasik hem de kuantum hesaplama alanlarında yapay
zekayı desteklediğini söyleyebiliriz. Quantum AI'nın ilk algoritmalarından biri,
yapılandırılmamış arama sorununu çözen Grover algoritmasıdır. Grover, işlevin etki
alanının boyutu olan işlevin yalnızca değerlendirmelerini kullanarak belirli bir çıktı
değeri üreten bir kara kutu işlevinin benzersiz girdisini yüksek olasılıkla bulan bir
kuantum algoritmasıdır. Yapay zekanın bir diğer önemli dalı, çoğunlukla insan dili
tanıma, sınıflandırma, doğrulama görevlerinde kullanılan Doğal Dil İşleme (NLP) 'dir.
Bugün bilim adamları QNLP'nin geliştirme aşamasında çalışıyorlar.
Bu tezde özellikle Kuantum tabanlı Grover Arama Algoritması, Klasik NLP, QNLP ve
Kriptografik İletişim (QKD) ile Arama ve NLP ile ilgili problemleri analiz etmeye
odaklandık. Bu araştırma konuları, klasik ve kuantum hesaplama alanında klasik arama
ve NLP gibi Yapay Zeka tabanlı algoritmaların canlı örneğinin katkılarıyla
değerlendirildi. Grover Algoritması klasik bir bilgisayarda araştırılıp simüle edilmeye
çalışılmış ve Grover algoritmasının detaylı bilgisi, simülasyon deneyinin sözde kodu ve
Grover Algoritması ile Sudoku'nun uygulamalı problem çözümünden bahsedilmiştir.
Ayrıca, NLP ayrıntılı olarak ele alındı ve bazı uygulamalı deneylerle üzerinde çalışıldı.
Bu tez, literatür taraması, uygulanan yöntemler, deneyler ve sonuç-tartışmadan oluşur.
Grover ile çalışıp, DFS'yi, Kuantum ve Klasik Arama Algoritmalarının deneylerinde,
Qiskit ve Q# ile karşılaştırmak için karşılaştırma modeli olarak kullandık.
Deneylerde Kaggle ve çeşitli sınıflandırma modellerine sahip diğer bazı NLP dasetleri
kullanılmıştır.
Ayrıca, NLP ve güvenli iletişimden oluşan hibrit bir modeli göstermek için klasik NLP
sınıflandırma algoritmaları ve Superdense Coding protokolü ile Kuantum Anahtar
vi
daha fazla ileri araştırma konusu belirlendi ve not edildi. Bu tezin ana katkısı,
Kriptografik İletişim ile Klasik ve Kuantum Arama, Klasik ve Kuantum NLP arasındaki
farkların ortaya çıkarılması, değerlendirilmesi, tasarımı, düzeltilmesi, uygulanmasıdır.
Ayrıca, algoritmaya yeni başlayan bireyler için, daha az adımda klasik bir hesaplama
yöntemiyle iyi anlamaya destek sağlayan Kuantum benzeri simülasyon projesi üzerinde
çalışıldı.
vii
CONTENTS
TABLES ........................................................................................................................... x
FIGURES ........................................................................................................................ xi
ABBREVIATIONS ...................................................................................................... xiii
1. INTRODUCTION ....................................................................................................... 1
2. RELEVANT LITERATURE ..................................................................................... 6
2.1 LITERATURE SURVEY ON QUANTUM COMPUTING ............................. 6
2.1.1 The Qubits …….……………………………………………………………7
2.1.2 Superposition, Entanglement, Interference ............................................... 8
2.1.3 Quantum Gates and Computing Environment ......................................... 8
2.1.4 Measuring A Qubit ..................................................................................... 13
2.1.5 Creating Quantum Circuits ....................................................................... 14
2.2 QUANTUM-AI: GROVER’S SEARCH ALGORITHM ............................... 14
2.2.1 Grover Algorithm Background And Literature Survey ......................... 14
2.2.2 Problem Definition & Application Areas ................................................ 16
2.2.3 Unstructed Search ...................................................................................... 17
2.2.4 Oracle…… ................................................................................................... 18
2.2.5 Amplitude Amplification ........................................................................... 19
2.2.6 Proposed Method For Grover Search Algorithm .................................... 21
2.2.7 Grover Example .......................................................................................... 23
2.3 CLASSICAL COMPUTING: DEPTH-FIRST SEARCH ALGORITHM ... 24
2.4 LITERATURE SURVEY ON NLP, QKD, QUANTUM
COMMUNICATION ......................................................................................... 25
2.4.1 Natural Language Processing .................................................................... 25
2.4.2 AI -ML Classification Methods &Algorithms ......................................... 28
2.4.3 Quantum Key Distribution (BB84) .......................................................... 31
2.4.4 Quantum Natural Language Processing .................................................. 33
2.4.5 Classical Communication - TCP-IP & Socket Programming ................ 39
2.4.6 Quantum Communication – Teleportation, Superdense Coding Protocol
viii
& QKD….. ................................................................................................... 41
3. ANALYSIS OF GROVER SEARCH ALGORITHM .......................................... 46
3.1 GROVER-LIKE MODEL ON CLASSICAL COMPUTER &
COMPARISON .................................................................................................. 46
3.2 GROVER ALGORITHM EXPERIMENTS …. ............................................. 53
3.2.1 Sudoku Solving With Microsoft’s Quantum Grover Search and
Classical DFS............................................................................................... 53
3.2.2 The Sudoku Experiment Results Classical vs Quantum Solution
Comparison ................................................................................................. 54
3.3 GROVER ALGORITHM RESULTS .............................................................. 58
4. APPLIED METHODS ON NLP & COMMUNICATION EXPERIMENT..…...59
4.1 CHAT ROOM APPLICATION........................................................................ 59
4.2 SECURITY PROBLEMS IN CONVENTIONAL COMMUNICATION
METHODS (UNSECURITY) .......................................................................... 59
4.3 CREATING THE DATASET ........................................................................... 59
4.4 NLP USAGE ....................................................................................................... 60
4.5 QUANTUM KEY DISTRIBUTION (BB84) .................................................. 66
4.6 SUPERDENSE CODING PROTOCOL INTEGRATION TO NLP............. 70
4.7 QNLP EXPERIMENT ....................................................................................... 73
4.8 EXPERIMENTAL RESULTS .......................................................................... 78
4.9 A HYBRID WORKFLOW MODEL ................................................................ 78
4.10 COMPARISON OF CLASSICAL CRYPTOGRAPHY & QUANTUM
CRYPTOGRAPHY ......................................................................................... 82
4.11 COMPARISON OF CLASSICAL NLP & QNLP ........................................ 83
5. DISCUSSION AND CONCLUSION ...................................................................... 86
REFERENCES ............................................................................................................. 90
ix
TABLES
x
FIGURES
Figure 2.1: The comparison of quantum bit and classical bit states……………………. 7
Figure 2.2: The qubit form representation……………………………………………… 8
Figure 2.3: Measurement representation of a quantum circuit………………………… 13
Figure 2.4: Poker card example………………………………………………………... 15
Figure 2.5: Grover algorithm steps……………………………………………………. 16
Figure 2.6: Amplitude amplification, oracle and additional reflection……………….. 20
Figure 2.7: Grover run and searched value……………………………………………. 24
Figure 2.8: DFS-Searching path………………………………………………………. 25
Figure 2.9: The publication count of nlp ın literature………………………………… 26
Figure 2.10: Words of sentences……………………………………………………… 27
Figure 2.11: Bag of words…………………………………………………………….. 28
Figure 2.12: Gaussian distribution(normal distribution) across x and f(x) …………… 30
Figure 2.13: Message encoding and sharing random secret key in qkd………………. 32
Figure 2.14: Applying qkd via polarization…………………………………………… 33
Figure 2.15: Word bindings in quantum nlp…………………………………………… 34
Figure 2.16: States and measurements on words……………………………………… 35
Figure 2.17: Quantum circuit of a sentence…………………………………………… 35
Figure 2.18: CQC experiment on wikipedia and ibm quantum computer……………. 36
Figure 2.19: Brief steps of qnlp……………………………………………………….. 36
Figure 2.20: The error detection and correction repetition phase……………………… 38
Figure 2.21: Client-Server socket functions and establishing communication……….. 41
Figure 2.22: Bell pair circuit creation using hadamard and cnot gate…………………. 42
Figure 2.23: Entire teleportation circuit……………………………………………….. 42
Figure 2.24: Actual quantum teleportation circuit prepared on ibm qiskit……………. 43
Figure 2.25: Entire circuit of superdense coding protocol…………………………….. 44
Figure 3.1: Grover classical computing ımplementation attemp-steps……………….. 49
Figure 3.2: Grover classical computing ımplementation attemp-time………………... 49
Figure 3.3: Screenshot of used ibm qc and runned grover algorithm job…………….. 50
Figure 3.4: Entire circuit of superdense coding protocol……………………………... 51
xi
Figure 3.5: Classical sudoku game missing numbers should be filled by player……… 53
Figure 4.1: Incompatibility of data and gnb classification algorithm…………………. 64
Figure 4.2: Word cloud as custom mask “africa map” ……………………………….. 66
Figure 4.3: Keys, rotation strings, encrypted and decrypted message……………….... 68
Figure 4.4: Illustration of intercepting, rotation & probability of detecting eve……… 69
Figure 4.5: Superdense coding circuit of ‘11’………………………………………… 71
Figure 4.6: SCP measurement result of “11” in qasm simulator……………………… 71
Figure 4.7: A network drawing for qnlp………………………………………………. 75
Figure 4.8: DisCoCat diagram of sentence…………………………………………….. 75
Figure 4.9: GHZ state circuit for “who” and word binding state………………………. 76
Figure 4.10: Circuit functor for whole sentence……………………………………….. 76
Figure 4.11: QNLP circuit…………………………………………………………….. 77
Figure 4.12: QNLP result details……………………………………………………… 77
Figure 4.13: Hybrid workflow model illustration…………………………………….. 81
xii
ABBREVIATIONS
AI : Artificial Intelligence
ML : Machine Learning
NL : Natural Language
OF : Optical Fiber
OS : Operating System
QC : Quantum Computing/Computer
QG : Quantum Gate
xiii
QOC : Quantum Optical Communications
xiv
1. INTRODUCTION
In today’s changing world, the scientists makes contributions on every technology. These
technologies can be developed and maintained by the researchers and many others who
deal with newest technologies. Today, one of the most important things is getting the
information about any discipline that affects everyting on the earth. We can solve each
problem by the science, and the science can be grown by the information science.
Therefore, the country or company who gets the superior technology can lead the rest of
the world and its economies. For example, most of us are using computers and its
applications, the computer science and its applicaitions becomes growing fast. We also
use smart applications called Artificial Intelligence based programmes for our scientific
and daily needings, they ease our jobs and total efforts in every situations we use them.
In the beginning of the 1900 ‘s the new era is born, which is called “Quantum Mechanics”
which deals with atomic and photonic particules of the matter. Quantum mechanics and
theories about quantum universe and quantum science are grown so fast by the researches
of scientists. So now, we are in the phase of designing new technologies and developing
computing machines by using these atomic and photonic domain laws. Recently,
quantum technologies and artificial intelligence algorithms are important research areas
concerning big data, information security, computing supremacy for governments and
companies.
Here, we can benefit from classical computing AI algorithms and can try to convert these
algorithms into quantum domain if it is convertable, otherwise, we need to create a new
algorithm to solve the particular problem. Therefore, right here, the ways of quantum
information science and AI intersects and we need to solve the problems using AI aided
quantum computing. When “machine learning” and “making inference” features of AI
meet quantum computing supremacy (information processing), an excellent advances can
take place in the future, especially in the fields; data mining, big data & processing,
communication network security, cryptology, computer vision, neural networks, block
chain, deep fake, molecular communication & neuroscience, etc. So quantum technology
has a significant future in the research field of physic and technology which relies on the
principles of quantum physics.
2
Schrondinger throw an idea called entanglement and tried to prove this idea by a cat in
closed box. Schrondinger did an experiment about putting a cat in a closed box and he
made some inferences. The experiment is about If we put a cat in this box and we wait
for a long time, the cat can be dead or alive until he opened up the box. The quantum
entanglement principle explains most of the behavior of the quantum particles. If we
divide quantum revolution in three part, we can say that beginning of the theory reveals
Quantum 1.0, building quantum algorithms to solve problems according to these theories
can be called Quantum 2.0 and today, we can talk about quantum information, computers
or sensors we can say we are in the third stage “Quantum 3.0” of quantum revolution.
Most of problems can be solved by classical computers, but when we need and research
different kind of computing methods for scientific and efficiency reasons, especially for
accurate solution in a much practical and fastest way, like we use quantum technologies
for certain problems and duities such as optimizations, cryptography or big data mining.
If we think diverse kind of smart searching and heuristic problems, we can solve these
by traditional (classical) computing, but when the complex questions which classical
computers cannot become sufficient to solve, we need to develop and use the quantum
computing algortihms for its high central processing efficiency which comes from
quantum nature (hardware).
Recently, the scientists have reached the quantum supremacy and proved some of the
quantum theories like teleportation and entanglement. They proved that the quantum
computing is exponentially fast and efficient from classical computing counterparts.
Thus, the scientists can investigate 4 main topics by researching the quantum information
science, first, physics-the secrets of the matter, second, the much efficient computing
method, as third quantum hardware (computer, sensor etc.) and as fourth, building Q-
algorithms which can be solution for particular scientific researches and AI problems.
The training process is getting harder and demanding with using from these complex
3
datasets. So, this process causes to train complex models with long times even we cannot
get clear generalization risk. This risk can be minimalized with improving training
algorithms of models and computer power coming from hardware. Since the classical
AI-ML models was developed, the scientists wanted to reseach the hardware based
solutions to improve AI-ML models and algorithms. The Quantum information science
is emerged to handle the data with using new perspective, thus we are expecting to solve
particular problems faster than classical AI. The quantum computing also brings new
potential to improve AI-Algorithms’s power and efficiency. The QML offers new
algorithms and solutions with using quantum computers’ special capabilities. We can
choose working in quantum computers in order to improve the accuracy of models.
Because, the quatum computers has exponentially higher-dimensional feature spaces and
that’s why, they are planned to be used instead of super computers in the future.
The search algorithms are the fundamental agents of AI which solve the search problem
by finding a specific value within a given data structure. These algorithms teach
computers how to act rationally. Thus, by using searching algorithms, AI has the
capability to solve a given problem. For example, path finding, game theory, factoring
in cryptography, constraint satisfaction, combinatorial optimization-routing, etc. That’s
why, most of AI aided systems are based on search algorithms, mathematical
calculations and have probablistic approach on their background steps. The quantum-
search algorithm researches propose to handle the search problems in very efficient way,
such as Grover algorithm, it guarantees to find the solution with sqrt(N) steps.
Another important branch of AI is NLP which deals with the interactions between
computers and human language, namely, NLP’s main topic is about how to teach the
computers to analyze, process, interpret and manipulate big amounts of natural language
datasets.
4
Today, as we think most of writings and opinions about a subject has a documented on
the web by natural language, NLP is very famous and common analyzing technology in
daily-life technology. The use case of NLP such as sentiment analysis, Siri like apps,
Google, translate applications, verification, classification, customer related special
programs, speech to text and vice versa, etc.
There are many research about Grover search algorithm and NLP in the literature. On the
other hand, these researches are not sufficient for understanding the complex algorithm
like Grover for the beginners and comparison classical search and quantum counterpart.
Also, there are limited numbers of research about NLP, QKD, Superdense Coding and
QNLP.
So, we still need further research about the Grover, NLP and communication topics. The
quantum computing based AI algorithms and quantum communication systems are the
main topics of this thesis. We want to demonstrate Grover quantum algorithm in classical
computers as a simulation programmes for a better understanding of complex steps of
Quantum Algorithms. This thesis includes the definiton part of the Quantum Computing,
Quantum Algorithms, AI, NLP, Quantum Communication. We try to explain and develop
some of the quantum AI based algorithms and consistency of quantum communication
protocols. We used classical & quantum computing algorithms and computers in order to
demonstrate the working mechanisms. Firstly, we explain the Quantum Computing &
Algorithms with Grover Simulation, Classical AI Algorithms basics with hands on
example and then we mention NLP and Quantum Key Distribution (BB84 protocol) with
QNLP. We also discuss about there is any development consistency with Quantum AI,
Quantum communication systems ? and it will be in the future ?
5
2. RELEVANT LITERATURE
Quantum Computing has a major role among the Information and Computing Science.
Quantum Computer and devices use atomic and photonic laws of the universe. The
devices which are worked using Quantum Mechanic’s laws called Quantum Computers,
sensors, etc. We can use bits as ‘0’ or ‘1’ in classical computing while we are using
Quantum bits named qubits which take bit values 0, 1 and both of them 0 and 1 at the
same time, this is called Quantum Superposition. Quantum computing differs from
conventional computing in that applying quantum mechanics laws for computing tasks,
Quantum devices can works using photons, ions. It is very new research area and still in
the development phase. We can use this technology in a very limited branches. Quantum
Computers handle computing tasks using very diffent types of process. The scientists
show and proof that Quantum Computers and Quantum based devices (i.e sensors, radars,
etc) has significant advantages for certain problems when comparing with their
counterparts in classical computing. Quantum Computing has several features which can
differ it from classical computing, these features are to work with quantum bits (qubits),
works with quantum parallelism-superposition entanglement.
We have a long way to reach the quantum supremacy. In this way, many scientists
contribute the Quantum Theory, we need to memorialize the scientists who made
significant contributions to Quantum Science, Max Planck, Erwin Schrödinger, Niels
Bohr, Albert Einstein, Peter Shor, Lov Grover and many others. Today, we have
Universal Quantum Computing: “gate model” superconducting qubits, topological qubits,
quantum dots and Non Universal Quantum Computing : such as quantum annealing
superconducting qubits, ion trap technology.
6
Figure 2.1: The comparison of quantum bit and classical bit states
The qubits or quantum bits are the fundamental information base of quantum computing,
it represents quantum state. We use kets and vectors notations for qubits.
(2.1)
(2.2)
We can also do some matthematical operations on qubits such as multiplying the qubits.
7
(2.3)
The superposition stands for the quantum feature that produces a state which can exist in
multiple states, places at the same time. The entanglement is a quantum effect which
describes correlation that exists between quantum particles. The entanglement is a
magical attribute which is special for Quantum world. It explains the quantum particles
are inextricably connected with harmony, even if separated by great distances in universe.
The superposition stands for the quantum feature that produces a state which can exist
Vector Qubit-0 state and vice versa matrix for qubit-1 state
8
The superposisition is one of the unnique property of Quantum computing that represents
a state which has both of the states ∣0⟩’s and ∣1⟩’s .
For example, 0.9∣0⟩+0.4∣1⟩ is a superposition of ∣0⟩ and ∣1⟩. Amplitude of ∣0⟩ is 0.9 and
for ∣1⟩ is 0.4. We have also normalization constraint,
(2.4)
If Identity Matrix can be formulated from U’s below operation, then we can call U as
unitary matrix.
(2.5)
Now, we can focus on quantum logic gates that is similar to ttansistor based classical
logic gates in conventional computing. The quantum gates are the fundamental building
blocks of quantum computation. A quantum logic gate is a technique of processing
quantum information, refer to the quantum states of qubits. Some of the similar gates with
classical computers are such as the OR, NOT, AND gate. Most of quantum gates are
based on close to classical logic gates. The differences specify the power of quantum
computations.
The Hadamard gate produces quantum effects into quantum computing. We can provide
the superposition state using hadamard gate in quantum circuits.
9
(2.6)
(2.7)
Hadamart gate circuit representation and matrix form are shown below
(2.8)
If we apply Hadamard gate twice, we can just get quantum wire and no effect.
(2.9)
The letter ψ is used to denote an arbitrary quantum state into the quantum state. When we
input an optional quantum state ∣ψ⟩ to the circuit, output should be HH ∣ψ⟩. For example,
the result of applying two H matrices to ∣ψ⟩. But if you just compute the matrix
product HH it changes to be the 2×2 identity matrix, HH = I, therefore the output from
the circuit must be the same as the input, HH ∣ψ⟩ = I∣ψ⟩ = ∣ψ⟩, like above.
10
The Quantum NOT gate:
The quantum not gate converts the quantum states, ∣0⟩ state to ∣1⟩, and vice versa:
(2.10)
(2.11)
We can get initial condition by applying X gate twice. Martix form of it:
(2.12)
11
The CNOT gate (CX gate):
The CNOT gate flips the second qubit (target quantum bit) when the first qubit (the
control qubit) is ∣1⟩, it doesn’t make any changes in other situations . The CNOT (CX
gate) gate operates on a quantum register involves 2 qubits. CX is one of the most used
gate in circuits.
(2.13)
The Pauli Y gate makes a rotation around the Y-axis of the block sphere by π radians.
Pauli Y gate charts ∣0⟩ to i ∣1⟩ and ∣1⟩ to -i∣0⟩. The Pauli Z gate makes a rotation around
the Z-axis of the Block sphere by π radians, phase flip. The Pauli Z gate works on single
qubit. It leaves the basis state ∣0⟩ unchanged, maps ∣1⟩ to - ∣1⟩.
(2.14)
12
Table 2.2: Other quantum gates and matrix representations
The measurement of a qubit, can get the value "0" and "1", such as a classical bit or
binary digit. The state of a qubit according to quantum mechanics can be a coherent
superposition of both, the measurement of a classical bit would not disturb its state, a
measurement of a qubit would destroy its coherence we can lose the quantum effect on
qubit, it breaks the superposition state and it not recoverable. There something to fully
encode one bit in one qubit, but, a qubit can hold more information,for example, two bits
with using 1 qubit in superdense coding.
13
2.1.5 Creating Quantum Circuits
We have qubits and quantum gates, now we can create quantum circuits with using qubits
and gates. The quantum circuit uses coherent quantum operations on quantum bits.
We can use IBM Qiskit, Microsoft Q# python packages or Quantum Computing machines
like Rigetti, D-Wave, Cirq, CQC, Xanadu, Honeywell or any other open quantum
environment. IBM offers public quantum computers for scientists and students. IBM’s
Qiskit is an open source python package. We can create and simulate quantum circuits
using Qiskit.
AI and Quantum-computing paths intersects on the point where Quantum Computing and
Artificial Intelligence solve the complex, fast processing & efficiency needed problems,
for example, the big data for human oriented research and inventions (chemistry, path
finding, encyrption, etc).
AI and Quantum Computing paths are integrated each other swhere quantum search
algorithms such as Grover algorithm which is invented by Lov Grover in 1996. The
Grover search algorithm is a quantum algorithm which uses quantum mechanics laws to
solve the complex search problems in fewer steps than classical search algorithms.
It is a probalistic search algorithms like most of the AI based search algortihms and
searching value is calculated by the the highest probable matched value of the input's
field. Grover Algorithm works very well with quantum computer and offers O(√N) run
time and takes O(√N) operations.
14
This is a quadratic speed up when we compare from its classical counterpart.
For instance, Suppose you play a card game and you wonder something about a particular
card “ this card is drawn from an ace of hearts pack or not”. This particular item stands
for the marked input. We can use Grover search algorithm in order to find the specific
item by doing a searching job in a list. The classical algorithms succeed on the search in
fewer steps than the total number of items in the list. Quantum version has a searching
mechanism that any of the classical algorithms can do. We can use this algorithm
especially in extreme lists which contains billions of items, it offers such an important
advantage when dealing with big data.
We can see it closer, Grover algorithm asks if the particular item in a list is the one we
are searching for. It does this by constructing a quantum superposition of the indexes of
the list with each coefficient, or probability amplitude. It calculates and represents the
probability of that specific index being the one you are looking for. The highest
probability gives the closest result for the particular search.
At the heart of the algorithm are two steps that incrementally boost the coefficient of the
index that we are looking for, until the probability of the amplitude in that coefficient
approaches very close to one. The number of incremental augmentation is fewer than the
number of items in the list, therefore, Grover search algorithm offers the search in fewer
steps than any classical algorithm.
15
Figure 2.5: Grover algorithm steps
For example, a set of N elements given and it forms a set X = {x1, x2…xN} in an
unstructured search problem. We have also given a boolean function f : X {0,1}.
Our aim is to acquire an element X* in X such that f(X*) = 1 using Grover algorithm.
The proccess searches a list for an element and aimed to find the probability of that
element can be considered in the project.
If we have a database that consists of N surnames and we want to find the location of a
specific surname in the database. We don’t know how the database is ordered, thus, we
can say that the searching process is “unstructured”. For example, when we have a sorted
database, we can also use binary search, it finds the solution in logarithmic time.
Grover algorithm is used extensively in quantum cryptography and to solve problems
such as the Transcendental Logarithm Problem, Polynomial Root Finding Problem,
16
numerical optimization problems. It has speed advantage when comparing to brute-force
search.
(2.15)
We need an oracle function, in classical computing, oracle function can need an N core
computer with complexity O(N), while the oracle function computes f(x) simultaneously
in quantum computing.
When we want an Oracle for function f, this process is limited in quantum computing.
We can also use a tricky method that we can succeed, by providing the loading wanted
superposition in polynomial time. The important thing is the creating a practical Oracle
function and using special techniques for particular problems.
We can analyze Grover Search Algorithm processing methods in a closer look.
Suppose you are given a large list of N items. Among these items there is one item with
a unique property that we wish to locate; we will call this one the winner ω. Think of each
item in the list as a box of a particular color. Say all items in the list are blue except the
winner ω, which is RED.
17
I I I I I I
1 2 3 … w (item) N= 2nX
To find the red box, using classical computation, one would have to check on average N/2
of these boxes and in the worst case all N of them. On a quantum computer, however,
Grover's amplitude amplification trick reduces this complexity to in
approximately √N steps. A quadratic speedup is indeed a substantial time-saver for
finding marked items in long lists. Additionally, the algorithm does not use the list's
internal structure, which makes it generic; this is why it immediately provides a quadratic
quantum speed-up for many classical problems.
2.2.4 Oracle
How will the list items be provided to the quantum computer? A common way to encode
such a list is in terms of a function f which returns f(x)=0 for all unmarked
items x and f(w)=1 for the winner. To use a quantum computer for this problem, we must
provide the items in superposition to this function, so we encode the function into a
unitary matrix called an oracle.
We see that if x is an unmarked item, the oracle does nothing to the state. However, when
we apply the oracle to the basis state |w⟩, it maps Uf|w⟩=−|w⟩. Geometrically, this unitary
matrix corresponds to a reflection about the origin for the marked item in an N =
2n dimensional vector space.
18
2.2.5 Amplitude Amplification
So how does the algorithm work? Before looking at the list of items, we have no idea
where the marked item is. Therefore, any guess of its location is as good as any other,
which can be expressed in terms of a uniform superposition:
(2.16)
If at this point we were to measure in the standard basis {|x⟩}, this superposition would
collapse, according to the fifth quantum law, to any one of the basis states with the same
Enter the procedure called amplitude amplification, which is how a quantum computer
significantly enhances this probability. This procedure stretches out (amplifies) the
amplitude of the marked item, which shrinks the other items' amplitude, so that measuring
the final state will return the right item with near-certainty.
This algorithm has a nice geometrical interpretation in terms of two reflections, which
generate a rotation in a two-dimensional plane. The only two special states we need to
consider are the winner |w⟩ and the uniform superposition |s⟩. These two vectors span a
two-dimensional plane in the vector space . They are not quite perpendicular
because |w⟩ occurs in the superposition with amplitude N-1/2 as well.
We can, however, introduce an additional state | s′⟩ that is in the span of these two vectors,
which is perpendicular to |w⟩ and is obtained from |s⟩ by removing |w⟩ and rescaling.
19
Figure 2.6: Amplitude amplification, oracle and additional reflection
20
Source: qiskit.org/textbook [2020]
Grover's algorithm begins with a quantum register of n qubits, where n is the number of
qubits necessary to represent the search space of , all initialized to |0⟩ :
(2.17)
The first step is to put the system into an equal superposition of states, achieved by
applying the Hadamard transform :
21
(2.18)
The next series of transformations is often referred to as the Grover Iteration and it will
The next part of the iteration is referred as the diffusion transform which
performs inversion about the average, transforming the amplitude of each state. The
diffusion transform consist of another application of the Hadamard transform H⊗n,
followed by a conditional phase shift that shifts every state except |0⟩ by -1, follower by
another Hadamard transform.
Given the entire diffusion transform, using the notation ψ from equation 2:
(2.19)
22
2.2.7 Grover Example
Suppose we have binary function : n binary items. One of it should have the value as 1
and we want to find the input value for f(x) = 1 .
f(x1, x2 , x3) = x1 & x2 & x3
This function has the marked input as wanted item that has the value as 1 in one of
the 8 variant, because 23=8.
x1 = x2 = x3 =1 while f(x1, x2 , x3) = 1 .
Source: codeproject.com
Now that we have the oracle, let's calculate the diffusion matrix ;
23
(2.20)
After running Grover's Algorithm 1 million times, the next chart is obtained:
We can observe that the correct answer |111> was obtained in almost 350000 of 1 million
runs.
The Depth-First Search Algorithm is an Artificial Intelligence based algorithm that can
be used to find a solution for search problems. It can be used in almost every search and
path finding problems in classical AI experiments.
The DFS algorithm is recursive search algorithm and it uses the idea of backtracking. The
DFS can be applied using stacks technique. DFS consists of comprehensive searches of
all the nodes, it tries to go ahead, otherwise it uses backtracking. The backtracking stands
for the operation for returning the another open node, when there aren’t any nodes on
24
current path, the algorithm goes backwards on the same path to find another nodes to
traverse.
25
We can do many difficult tasks in an eaiser way using NLP, such as text classification,
emotion analysis, manipulation awareness, word clouding, fake knowledge detection,
inference, etc. The aim of natural language procesing is to create a computer skilled
medium of grasping every token of documents or articles. The main concerning topics of
NLP is NL generation, NL understanding, Speech recognition, speech to text or vice
versa.
We can say that NLP’s biggest advantages is to make the computers capable of reading,
understanding, interfering, in other words, derive meaning from human language, thanks
to Artificial Intelligence. NLP can be used in almost every science discipline, for instance,
Amazon Comprehend Medical figure out extract disease conditions and it uses NLP ,
medications and treatment outcomes from patient notes, clinical trial reports and other
electronic health records or we can give as an example of the companies which want to
observe what customers are thinking about a service or product by identifying and
extracting information in sources like social media. Also, NLP ease the difficult tasks such
as fake news or spam detection, Apple’s talking assistant Siri and Amazon’s Alexa is a
good examples of Speech recognition. There are hundreds of NLP hands on use cases in
the industry.
So, individual or special techniques can be used in particular NLP tasks as well as
algorithms.
26
Firstly, NLP begins with computer interaction of words, in other words, all the
documents’ tokens should be transformed into numbers, to make the computer handle
with them, thanks to mathematics. All the documents or text should be handled into
singular forms that make them more uniform and commentateble. When we want to
convert the words into numbers, we should apply some of the preprocess operations, such
as text should be purged from punctuation and special characters.
NLP’s most widely used algorithms consist of some kind of operations like tokenization,
bag of words, stop words removal, stemming, lemmatization, topic modelling, etc.
Tokenization is handling the task of seperating words as individual parts. It divides the
text into small amaount of data that is called token, also it is used for the cleaning process,
special and punctuation characters.
27
Figure 2.11: Bag of words
Stop words removal process is the operation of removing common words that we don’t
need them anymore in processing. It involves widespread pronouns, prepositions, names
in particular language words like “of”, “with”, “at”, “the”.
Stemming is the process which aims of removing affixes by seperating and saving
beginning or end of words.We can also remove duplication rows to ensure preprocessing
operations.
Classification is a supervised learning technique that we send an input to the system and
the programmed learning algorithm learns from the input data and then uses this learning
to classify new investigation and marking, in other words they learn from samples.
Classifier can predict a class of an input variable. Classification algorithms specifies the
class of dataset elements, it has very good results when the output has discrete and finite
values. Mostly used use cases of classification are recognizing of customer segments, an
e-mail is fake, spam or real, recommendation, financial trading, marketing
personalization. There are diffent types of classification methods in AI. The types of
Classification methods are binomial, multi class, Multi-Label, Imbalanced.
Many dfifferent classification methods can be used in NLP according to technique and
problem relation.
28
Table 2.4: Types of classification algorithms that can be used in nlp
Naïve Bayes methods are the types of supervised learning algorithms, classification
technique is based on the Bayes theorem application, which is a probabilistic non-linear
ML model that’s used for classification task. It provides probability of an event to be
calculated based on the knowledge of factors that can affect the event. The classification
supposes acceptance of independency of each pair item in the dataset,so we call it
“Naive”. It shows the relationship between conditional probabilities and marginal
probabilities.
We can give examples of use cases as, real time estimation, multi class prediction, analyze
emotion (idea) based on customer comments,classifying emails as spam based on
classifier.
(2.21)
29
2.4.2.2 Gaussian naïve bayes classification
If our properties (features, predictors) are not discrete and get continuous value,as well as
the classifier assumes it. We assume that these values are illustrated (sampled) from a
normal distribution, in other words gaussian distribution.
The figur shows Gaussian distribution formula parameters as “features values” ’s mean
and the variance corresponding conditional probability.
(2.22)
Multinomial Naïve Bayes classification can be used when we need discrete counts. The
classifier uses predictors, features which are calculated as frequency of the words in
dataset. We can say, If we have several categories, we can use Multinomial Naïve Bayes
classification method for multi class categories.For example, we can say for use cases as
categories of subjects (e.g subject of science of an document or subject of finance).
30
2.4.2.4 Bernoulli naïve bayes classification
(2.23)
Support Vector Classifier is a supervised leaning model which is used for classification
in data analysis, regression analysis, outliers detection. SVMs are effective algorithms for
working with high dimensional spaces.
C-Support Vector Classification differs from SVM. The implementation of SVC
algorithm is based on SVM algorithm library.
The C value stands for the process, how we want to fit and classify. SVC can be used
with linear kernel. It is good to used it when we have larger datasets.
Quantum Key Distribution is a secure, quantum based communication method which uses
quantum mechanics’ laws and applies quantum cryptography. Quantum Key Distribution
(QKD) is one of the widespread example of quantum cryptography (QC) methods and
brings a solution method consist of encryption and decryption process for message (data)
delivery. QKD provides two node to produce a secret key which is known by only these
two parties. This secret key is used to encrypt and decrypt the message. Today, we use
mostly classical computing based cryptography methods to provide and protect
operations for secure communication methods and applications for banking, trading,
private chats, file transferring, etc. The cryptography algorithm OTP is a classical
algorithm and it is similar to QKD method when it used with a secret and random key.
31
QKD is known as one of the most powerful cryptography method ever, as well as, if we
use QKD we can also detect the eavesdroppers who trying to obtain any knowledge of
the key. This is the oe of the most important and special feature of the QKD. If an
eavesdropper tries to make measurement on the key, it produces some kind of anomalies,
because as we know from Quantum mechanics’ , the measurement operation attempt on
a quantum system or state causes failures so we can detect presence of an eavesdropper.
Different variety of secure communication protocols can be implemented using Quantum
mechanics’ extraordinary features like superposition, delivering information with using
states, entanglement, etc. This features can makes QC methods different from Classical
Cryptography methods such as public key cryptography.
Today, BB84 and E91 are the famous QKD based protocols. Most of QKD algorithms
require an authentication method using classical channel, this can be a drawback for
QKD.
Figure 2.13: Message encoding and sharing random secret key in QKD
32
Figure 2.14: Applying QKD via polarization
Quantum Natural Language Processing (QNLP) is a very new research and development
area which focuses on natural language readability and interpretability of quantum
computers. Today, QNLP research and development phase is done by University of
Oxford & Cambridge Quantum Computing department. The idea is seen first in science
magazine in 2010.
33
In classical computing, we handle the sentences using “bag of words” shape which
includes meanings of individual words. In this quantum model, the sentence is not just
like a shape of “bag of words”, they are perceived as networks. A word interacts with
other words using a specific model. This model brings a new kind of perspective and
solution for quantum computing when we try to create a NLP example on a actual
quantum computer.
The network between the words can be defined by drawings, but in the year 2016, some
of the scientists proposed that QRAM is needed for “meanings of words” encoding
process in QNLP. Now, meanings of words are learnt by quantum states and processes
from data (text). These drawings (graphics) can provide us to analyzing how the word
meanings come together and compose the meaning of whole sentence, after, the meaning
of grammatical sentences is encoded on quantum hardware by launching quantum states.
Thus, we can ask questions to quantum computer about a subject, if we provide trainings
to Quantum Computer which is about the vocabulary and grammar learning. If we do it,
we can get answer from quantum computer. We can build a relation between quantum
computing and natural language when thinking about quantum theory which is quite
similar to networks.
The box and wire model describes an easy and sample of the model. The boxes refers to
word meanings, and wires are for the communication channels and stands for the
meanings of words can be sent.
Source: CQC
QNLP can be considered by diving it into two parts. First, it creates a relation, the
meanings of words form quantum states. Second, grammatical structures of sentence and
34
quantum measurements.
Source: CQC
A QNLP experiment simulation is done in the year 2019 and researchers investigate
IBM’s NISQ devices for a reliable experiment. They applied “quantum circuit” shape into
“word network” to acquire an understandable model by IBM’s quantum computer.
Thus, the researchers proved that QNLP can be applied on NISQ devices and works so
fine with it, also they uses ZX language for drawing quantum circuits by CQC.
QNLP works together with processing grammar and meaning, while the classical NLP
doesn’t use grammatical structure of a sentence. The main difference between Classical
NLP and QNLP is Classical NLP applies ML using neural networks and manages to learn
patterns from data, on the other side, QNLP applies quantum circuits in quantum ML.
Source: CQC
35
Figure 2.18: CQC experiment on wikipedia and IBM quantum computer
Source: CQC
The researchers need to create an architecture of the experiment for determining the
overview, first they observe a mathematical form which is used for the grammar diagram
(network) generation to provide encoding “the word and meaning” information.
A quantum circuit named QCirc(θ) is lauched according to this diagram ( network). They
can achieve to encode “meaning of the words” part using quantum circuits as QCirc(θ).
The figure shows G represents the grammar category, QCirc(θ) is quantum circuit
category.
Source: CQC
36
All of grammatical quantum circuits are a family spanned by θ, thus, the researchers can
create the one dimensional semantic space based on “meanings of the words”, it manage
to encode whole sentences.The researchers interpret the grammar diagrams, because a
number shows the truth value of the sentence .
Each word is processed by text data, after, we can ask question and get answers about the
text data. In the sentence example, ‘Alice hates Bob’, “Alice” is the subject, “Bob” is the
object and “hates” is the verb, which should be parameterized by θ in quantum circuit, as
seen in the figure above, named “the quantum circuit of a sentence”.
subj(θ₀)=Alice verb(θ₁)=hates obj(θ₂)=Bob
Vocabulary samples = {Alice, Bob, loves, hates, rich, cute}
If we have vocabulary set consists of the words like above, we should handle and create
all of the grammatical sentences from their combinations, and it needs to be built all of
their represented parameterised circuits.
Truth Value of the sentence is acquired by calculating |C(θ)|² , where C(θ) represents
quantum circuit related sentence.
As we know from previous section (Classical ML-NLP ), we can get and interpret the
value |C(θ)|², by looking to interval 0<|C(θ)|²<1. If the value closes to 1, we can know it
as “true”, and vie versa, closing 0 means “false”.
It seems just like Classical NLP, and we get database like this :
Processed as dataset consists of collection of sentences with “truth universe”, (dataset
with labels).
K={(Alice loves Bob, false), (Bob is cute, true), (Alice is rich, true), …}
Then, the researchers divides “the dataset with labels” as Training set and Test set, which
are R for traing and E-estimation for inferred truth labels’ consistency of new sentences.
Training set R is used for training, and same like classical NLP, By using traing set R,
supervised quantum machine learning is applied for learning the parameters that result in
the correct measurement of the truth labels .The sum of both sets equals to dataset which
37
is K = R + E .
The meaning states for adjectives, nouns, verbs and others are created by the parameters
for the circuits. Thus, {Alice, Bob, Eve }, adjectives {rich, cute, angry}, verbs {are, is,
loves, hates, wonders} are learned.
The researchers also creates a control and correction method for quantum circuit on
quantum computer, and they use classical computer for this purpose. |C(θ)|² value is
calculated by quantum computer and then it is checked “desired truth label of the
sentence” by classical computer. In this process, truth labels are renewed for the sentences
in the training set. Thus system test of the experiment is done, if there is any unexpected
match according to the system, the quantum computer updates the previously created
circuit. This procedure is repeated until the parameters converge, and reaches the
optimum desire (optimal sequence of updates).
Source: CQC
Thus, the scientist can ask questions to quantum computer provided that previously
learned sentences. They use {who}, and moleded it as CNOT gates + Hadamard. “Does
Bob who is cute love Alice who is rich?” Estimating the value of the circuit produces the
truth label, we know from |C(θ)|². The quantum circuit needs to be compiled before run it
on quantum computer.
38
For giving a use case of QNLP, the researchers needs good compiling and optimation,
for this pupose, they use CQC’s quantum software development platform named t|ket>.
Usage of this framework (t|ket>) maps requirements and solves the quantum processor’s
connectivity problems and device-native operations.
39
Table 2.6: OSI 7 model and some of the protocols working in different layers
Sockets usage begins with ARPANET in 1971 and later became Application
Programming Interface (API) in 1983. Network programming applications, client-server
based applications, routers and switch devices are programmed using sockets, they are
also real backbone parts of web browsing. Python and C programming languages are
mostly used to build reliable and state-of-the-art communication applications. We can
illustrate the working mechanism of the sockets, Socket (e.g at Server Node) listens on
related (special) IP port, the another (e.g at client node) socket sends a connection request,
after 3 handshake way, connection occurs.
40
Figure 2.21: Client-Server socket programming functions and establishing
communication
Encryption research area is one of the most important branch of the communication
science, because the communication process is tied with many aspects of the reliability
of the used encryption method. History of the encryption methods is too old. People
believed that the first encryption method begins with urban colonization of the humans.
In Roman civilization, the government used encyrption methods for the security of the
top secret information when they deliver it. One of the first known primitive encyption
method is known as very weak encryption method called Ceaser Cipher, it is such a easy
way of encrypt and decrypt a message.
Quantum teleportation is one the most exciting phenomena in Quantum Computing and
Quantum Mechanics. The exciting and fascinating part comes true from Quantum
physic’s natural laws (particul behaviours).
41
We don’t use reliable & continuous data communication method or protocol in quantum
computing for now, it is very limited and not fault tolerance, but now, it is research and
development phase. We know that we can teleport a qubit by using quantum teleportation
across the universe. The magical story lives behind the quantum theory, quantum
superposition and quantum entanglement by using Bell Pair.
Figure 2.22: Bell pair circuit creation using hadamard and cnot gate
Source: qiskit.org/textbook
(2.25)
42
(2.26)
(2.27)
For now, we see the Bell pair and analyze the fundamental parts of quantum teleportation,
teleportating a quantum information ‘1 qubit’. It is experimented by the scientist and
observed that this event is independent of distance. The results of experiment show the
proof of teleportation which is the breakthrough event for science and information theory.
If we return our project, we can use teleportation protocol to send quantum information,
of course, but it is useless and it has limitations for us.
Instead of transmit 1 qubit, using 2 classical bits in teleportation, we can use Superdense
coding protocol to transmit 2 classical bits, using one qubit. It is more useful for the data
communication in our project.
Superdense coding protocol can be used to transmit two classical bits to another party
with using a qubit. Alice and Bob have shared an entangled Bell pair previously.
43
Figure 2.25: Entire circuit of superdense coding protocol
Preparation (Step 1)
Quantum Entangled state is prepared by protocol. The hadamart and CNOT gate applied
to create the Bell pair.
Bell pair quantum circuit (entangled 2 qubit state)
44
Table 2.8: Messages, operations and bell states
45
3. ANALYSIS OF GROVER SEARCH ALGORITHM
We aimed to analyze Grover Algorithm and consider the comparison from its classical
counterparts, such as DFS classical search algorithm. The simulation acts like a Grover-
like searching process, while Grover Algorithm returns the highest probability for an
element in quantum computer. Moreover, the difference between classical based search
and quantum based Grover search is investigated and clarified well.
We start with investigating the sample classical Grover implementation in the literature
and develop with new features. The algorithm is O(2n) complexity, otherwise, when
trying to iterate O(√2n) times it gives wrong results. Beacuse of the absence of quantum
mechanical features, it compels to evaluate the algorithm in a different kind of way which
is more likely close to Grover steps.
46
convenient for beginners to use the algorithm.
Question : How can we achieve to implement an algorithm to search and find that item
by using 2n times “O(2n)” in a classical way ?
One of the first classical Grover Search Algorithm attempt is based on finding the
probability of the searched value (Lee-Dang et al. 2019). Brief steps as follows, the
command prompt terminal asks user to enter the number of qubits and the value searched
for, Number of Qubits (n) stands for the list space and the searching value that wanted to
be found in the unstructed list. The value should be entered as a decimal number and
between 0 to N =2n (search space).
The goal is to find an element from a list in O(2n) iteration and to write an algorithm
which has a “Grover like search” mechanism to illustrate the working principles and ideas
of the Grover Algorithm in a classical computer. Beside this, there are many algorithms
to do this job with O(nlogn) or N/2(search space) iterations.
After that array list iteration begins, we determine the borders of search space and fill this
array list. After creating the instance, we execute some of the methods to obtain the
backend Grover Search Algorithm calculations and operations. We initialize the bra-kets
for the search space and value, the next, running the main part of the search algorithm
and calculate vector form. After these operations, we can begin the iteration with running
Phase Inversion and Inversion Mean number of qubit times.
The next step, we can print the final vector, probability of finding, the run time of
algorithm as milliseconds for searching and how many steps needed to find the searched
value. Additionaly, amplitude, braket forms and get braket notations of Qubit Search
Space are calculated and vital stages of algorithm is declared (for readability-simulation
purpose).
47
Table 3.1: Average results of grover algorithm ın classical computer ımplementation
attempt
21 1 5
22 2 5
23 2 6
24 4 6
25 5 7
26 8 8
27 11 9
28 16 12
29 22 18
210 32 26
211 45 36
212 64 59
213 90 108
48
Figure 3.1: Grover classical computing implementation attemp-steps (Size=N=2 n)
150 128
90
Steps
100
64
45
50 32
16 22
4 5 8 11
1 2 2
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Size
Grover Java
600
Time
400 321
200 108
18 26 36 59
5 5 6 6 7 8 9 12
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Size
49
Figure 3.3: Results of grover running on a real quantum computer
50
Figure 3.4: Screenshot of used IBM quantum computer and runned grover
algorithm job
The more we run algorithm, the more we close to find the value and get close probability
value to 1.
51
Table 3.2: Success probability of finding searched value in quantum computer and
grover algorithm efficiency over classical algorithms
52
3.2 GROVER ALGORITHM EXPERIMENTS
In this section, we analyzed the Sudoku solving problem with comparing DFS algorithm.
3.2.1 Sudoku Solving With Microsoft’s Quantum Grover Search and Classical
DFS
Figure 3.5: Classical sudoku game missing numbers should be filled by player
Each row and column which compose the grid must contain all of the digits from 1 to 9
and each nine (3x3) subgrids composing the grid must contain all of the digits from 1 to
9.
53
Figure 3.6: Expected Q# sudoku quantum grover solution of 4x4 with 4 missing
number
We got the results different than as we thought that we expect the Quantum simulation
was faster and much efficient than Classical DFS algorithm. First, The solution gives the
correct answers on both of the mediums.
The classical depth first search algorithm solves the puzzle very fast, that’s why we called
the advantage of interpreted and compiled java code. On the other hand, The Microsoft’s
Q# Sudoku solver can solves the puzzle using Quantum Simulator without any errors and
always gives the correct answer.
We calculate running time of the algorithms for both of the Classical-DFS and Q#-
Quantum Grover Simulation Sudoku Solver.
54
Figure 3.7: Q# sudoku experiment result of 4x4-4 solution
“dotnet run 4x4-4” command on the terminal runs the Quantum solution for a 4x4 puzzle
with 4 missing numbers.
55
Table 3.4: Microsoft’s classical computing solution results of sudoku
Q# Classical Computing
Specifications 4x4 9x9-1 9x9-64
Bits Per Color - - -
Estimated 1 1 1
#of Iter. needed
Size_of 4X4 9X9 9X9
sudoku grid
Search with # of iter. 1 1 1
Q# Quantum Computing
Specifications
4x4-1 4x4-3 4x4-4 9x9-1 9x9-2 9x9-64
Bits Per Color
2 2 2 4 4 4
Estimated #of iter.
needed 1 6 12 3 12 12
Size_of
sudoku grid 4X4 4X4 4X4 9X9 9X9 9X9
Search with
#of iter. 1 2 8 1 6 7
Solved or
not solved solved solved solved solved solved solved
Time
for solving 203 ms 359 ms 921677 221 ~900 Very
ms ms ms long
56
The DFS algorithm is a state-of-the-art searching algorithm in classical computing that
fits well for solving Sudoku puzzle. We also try and observe the results of the DFS
algorithm which is available and prepared as DFS Sudoku solving experiment. It
implements the DFS algorithm in classical computing for 9x9 Sudoku solving.
We observe that Classical DFS algorithm finds the solution in a efficient way and faster
than Q# Grover Simulation. In fact we can expect the Grover Solution would be faster
57
than DFS, because as we see from the experiments Grover algorithm complexity is 0(sqrt
(n)), but here, the sudoku Grover solution in the Q# example wasn’t built for efficiency,
it is just a simulation and is not runned on a acutual quantum computer, also it needs
iteration (shots), to find a probabilistic quantum solution.
The Q# quantum simulator solution loses so much time which existing iteration process.
If we prepare the Sudoku Solver quantum circuit and runned in a actual Quantum
Computer, we could get a faster solution than Classical DFS algorithm.
We get the results as we expect using a classical implementation for this algorithm.
Making a simulation for a quantum algorithm in java is one of the best way to understand
a quantum algorithm with an easier way through classical computer, running Grover
Algorithm on a real quantum computer has many advantages like amplitude amplification
trick and superposition features so, we cannot benefit these features in a classical
computer.
58
4. APPLIED METHODS ON NLP & COMMUNICATION EXPERIMENT
We aimed to use NLP as “fake or spam, real” mail detection to prevent unwanted
manipulation of the dirty information cleaning. To do this idea, We tried to prove that
providing a convenient medium of communication counterpart by using NLP . We begin
with establishing a tiny classical communication chat app with using TCP-IP protocol &
socket and log the e-mails of the chat app users.
The data security affects every branch in today’s technology. The security of digital data
has a major principle of conventional computing. If we don’t provide a secure
communication or computing model to clients or servers, we cannot gurantee safety,
maintainability and operability of any created system.
The TCP/IP and HTTP protocols can be used to create and ensure online chatting,
Transmission Control Protocol supports the guarantees the data-packet delivery for the
communication peers, but HTTP and TCP/IP encounter some security attacks like
eavesdropping, connection hijacking, denial of service, reset attack, TCP veto, etc.
We prepare blended datasets by gathering 2 dataset and mixing them. One of the dataset
belongs to Kaggle which is one of the famous ML datasets creating website. Other one
belongs to NLPTK dataset. Comma Separated Value (.csv) data type is the best choice
59
for the natural language processing for the dataset. If we have a big dataset like this
experiment, we can’t ensure the correctness of the dataset when we want to prepare it by
editing, therefore we have two chance to apply, first one, we can use a professionally
prepared datasets like Kaggle’s or as second, we should test the dataset’s data frame, and
shape.
CSV dataset is not working properly with all editors like Notepad, Notepad++ or MS
Word. MS Excel is one of the best editors for CSV Files for editing operations, Chat
Room App e-mails can be saved as csv files according to rows and columns, as we show
a small example of it in the project. We use the MS Excel’s “from text to csv” import
feature, but, we face some of the problems, like there can be some of unwanted problems
(e.g null type import or encoding) to do it, for the convenince of the data frame, we test
convenience of my self-prepared private dataset using tools such as Notepad++ and
Windows Powershell and MS Excel.
After showing the idea of the saving the e-mails as e-mails.csv, we have succeed classical
communication part and having our self-prepared dataset. Instead of doing and
creating e-mail.csv by our chat- app chatting messages, we use available e-mails from
Kaggles’ we site, as we mentioned above , and we create e-mails.csv files.
After these steps, We can begin to apply main NLP jobs to dataset. As first a step, we can
illustrate the dataset that we have, as second we can begin NLP operations like extraction,
tokenizaiton, vectorization, etc.
NLP usage becomes popular in AI and Data science, If we want to handle difficult text,
speech and complex big data problems, we can use NLP algorithms to solve these tasks.
We know the computers “Quantum or conventional computers”, cannot handle or
understand the words or sentences directly. We need some of the transforms and
processing operations to make computer understands the text words (data) when they
compute with natural language.
60
We want to analyze and classify the e-mail texts by its owner, text subject, content and
‘fake or spam’ feature. We also add some of the features like sentiment analysis for
observing the subjectivity-objectivity and polarity ( negative or positive) for each of the
particular sentences.
After importing some of the necessary libraries such as numpy, matplotlib.pyplot, regex,
PIL, wordcloud, python NLP library as sklearn. We are ready to handle the text operations
for natural languge processing. First, We gave an examle of the fundamental parts of NLP
(NLP working mechanism). After starting the CountVectorizer class and produce an
object from that class, we need this to process the operations like seperating the words
from sentences as tokens, transfer words into vectors which represent the words.
We encode (transform words to vectors) the words, thus, each word can be represented
by a number. Next, these numbers are converted to arrays which we get encoded vector
matrix.
Next part is about to deal with a real data ( e-mail.csv) files, we logged all the
conversations into comma seperated files, including sender, e-mail text, and classification
as “fake or spam, real”. We should also configure the encoding type for the data
processing with a well known one, if we don’t do that, we can face some of the problems
in the future, especially when including different encoded datas from somewhere, so
encoding type is important. We can set it as “latin” or “utf-8” (Unicode transformation
format) in order to prevent other language encoding data operations.
We can use python’s standart functions from numpy and panda’s to analyze the
dataframe’s (text) elements such as owner of the e-mails, subbranch of the
dataframe,”fake or spam, real” count, repeated lines and dropping out them etc. We can
export these data parts and print them as attributes of the e-mails.
61
Table 4.1: The dataframe of experiment
We should get pure text, without any special, punctuation or tag-digit characters. Fistly,
all the text data is converted into lower characters to succeed uniform operability,
because, we cannot process words and apply ML algorithms if we don’t do these
operations. Then we assign the cleaned dataframe into new dataframe which we have not
any unwanted special character in it.
We import necessary “natural language tool kit “ and “TextBlob” libraries for giving
example of sentiment analysis and new dataframe in the csv file.
TextBlob is built by python to analyze and classify the sentiment feature of a sentence
(i.g e-mails), Textblob uses some of the algorithms in background to classify a sentence
structure according the feature of subjectivity-objectivity and polarity “positive or
negative” . Subjectivity shows the sentiment feaute of a sentence (e-mail), it has value
between 0 to 1 , closing to 0 shows the much objective sentence and polarity shows the
polarity of a sentence, it has the value between 1 to -1 closing -1 shows the much negative
sentence and vice versa.
Thanks to TextBlob sentiment “emotion” anlaysis. This analysis gives us the flexibility
of understanding each of the particular e-mail by using computers. So, it is very beneficial
technique to understand the e-mails by computer and use this information to handle
classification tasks.
62
Table 4.2: Dataframe after operations
Now we are ready to handle one of the exciting part of NLP using SciKit-learn “Sklearn”
python library.
We can create ML models with Sklearn which has a lot of learning algorithms such as
regression, classification, clustering. It is compatible with NumPy and SciPy. After
importing some of the necessary class libraries such as Count Vectorizer, Tfidf
Transformer, we can hande the operations on dataframe. Applying count vector
transformation on text data, we can get text vector. Then we can split the dataframe as
“train” and “test”, finally training and testing data sum gives the total data. We can choose
text vector, data frame part as “fake or spam, real”, test size, random state and shuffle
properties.
We split the data using sklearn train_test_split and configuring X-y train and test part
using :
Here, X_train consists of all independent variables, values which are used to train the
particular model, we configure the test size as 0.45, in other words, 45% of the complete
data is used to test the model, 55% of the complete data is used to train/fit the model.
X_test is the chosen portion (%45) from the data which is used to make predictions to test
the accuracy of the used model.
y_train stands for the dependent variable, it needs to be predicted by the particular model.
63
The category labels, opposite our independent variables, we express our dependent
variable while training (fitting) the model and lastly, we use y_test which has category
labels for our test data, these labels are used to test the accuracy between the actual and
predicted categories, thus we fit a model on the particular data .
After completing these steps, we can apply the classification part of NLP, and we are
ready to apply classification algorithms for NLP. SVC Algorithm is one of the type of
SVM algorithms, it uses C value and linear kernel. The X train and y train data is fitted
on the same object, then prediction is made on X test data, thus we can get classification
report using on y test and x test predictions. Also accuracy score can be calculated using
x test prediction and y test.
Here we can observe the prediction accuracy is 0.89 and the y test has 826 ‘fake or spam’
and 2190 real e-mail counts. Confusion matrix also shown .
We also tried to use Gaussian Naive Bayes Classifier for the classification problem, but
We got some kind of errors due to structure of the data. We researched this issiue on some
of ML internet forums and saw that it causes from some of the vectorization case which
is not compatible with Gaussian Naïve Bayes Classification Algorithm.
64
Although it is not consistent with GNB classifier, I observe the data is suited well with
GNB types such as Bernoulli Naive Bayes Classifier. The classifier gets and variable
named alpha which has value either “1” or “0”, 1 is for smoothing, 0 means no smoothing.
I applied same method x test , y test, predictions to acquire classification report, accuracy
and confusion matrix as i show above.
The figure below shows Bernoulli Naïve Bayes Classification method can also be applied
for classification task using the methods above, x test and ytest.
The figure shows Multinomial Naïve Bayes Classification method can also be applied for
classification task using the methods above, x test and ytest.
After we applied different classification algorithms, we can also create an word cloud
image (visual) which shows the frequency of most used words in ‘fake or spam’ e-mails
and ‘real’ e-mails or in total data frame (all e-mails).
65
The common words such as “I ,the, are, is” should not be processed, so we import
prepared ENGLISH_STOP_WORDS into the project and drop the common words out.
We choose the data frame “real” or “fake or spam” and set the parameters colour, font,
background and resolution specifications, etc. We can also select custom_mask for the
creation of wanted shape of word cloud such as Africa or Turkey map. The most used
words are bigger and bold while less used words are small and not bold on word cloud
image. We can create and plot word clouds with different type of variety. This brings a
feature, observing the most used words in particular e-mails, such as ’fake or spam, real’.
First, we need a key to encrypt the message, after QKD, receiver will use this key to
decrypt the message ad can safely read it. Qasm simulator is used in the implementation
66
(Qiskit-BB84 Rasmusson-Barney et al. 2018). The aim is to create and share a secure
one-time-pad encryption key.
Quantum and Classical registers are set for the quantum circuit. After quantum circuit
and environment preparation completed, we need purely generated random key which is
generated by Alice. A random key can be generated using by the quantum states of qubits
and it is a pure random key which provided by nature of quantum physics. Because a
qubit can be “1” by %50 probability and “0” by %50 probability. Also, the random key
is generated by using quantum states without any algorithm dependancy, thus a random
key is a pure key when it is generated. This makes the key nearly impossible to be
generated or forecast as the same. Also possible eavesdroppers can easily be detected
very fast by the comparison of the key between sender and receiver, thus the information
cannot be intercepted by the eavesdroppers.
First, as we mention above, Alice generates a random key to transmit it to Bob. Then
Alice converts these string bits comes up to qubits. For the “0” bits will prepare a qubit
on the negative z axis and for “1” bits prepares a qubit on the positive z axis.
After that, 2 random strings are created by randomStringGen function which uses
quantum superposition to make purely random rotation strings, the rotation strings will
be used seperately for the rotation process by Alice and Bob. After the conversion of key
bits to qubits by Alice, she changes these qubit states and randomly rotate some of them
into superposition. She applies Hadamard gate to her key qubit, when she has 1 in her
rotate string. Bob receives the qubits and randomly rotates some of them in the opposite
direction, when he has 1 in his rotate string, he rotates the string into opposite direction
with Hadamart gate. After these operations Bob can calculate the result and save it.
After these steps, they share their rotation strings and compare the results. When Alice’s
rotation bits is the same with Bob’s coreesponding bits, Alice tells him to save that bit,
thus, they produce a new quantum encryption key for secure communication. They use
this key to encrypt and decrypt the message.
67
Figure 4.3: Keys, rotation strings, encrypted and decrypted message
68
and Bob, we can benefit the quantum mesurement principle to detect eavesdropper. Eve
intercepts the transmission between Alice and Bob. For the avoidance of doubt, Eve
should send the intercepted transmission and deceives Bob, otherwise Bob cannot receive
the transmission. Eve doesn’t know which qubit is rotated by Alice in her transmission
string. Also Eve cannot measure the qubit, because if she tries to measure, she destroys
the quantum state and cannot send the same qubit to Bob.
Eve just measures 0’s and 1’s and doesn’t know when she needs a rotation on the key
bits, thus, she cannot recreate the Alice original key bits. If there is anomaly in the key
comparison between Alice and Bob, they can easily detect Eve as eavesdropper.
If we use longer key, the probability of intercepting mismatch by Eve can increase
exponentially. The probability follows as the function 1 - (3/4)n
n represents the nuber of comparison bits by Alice and Bob in spot check.
69
Table 4.7: QKD-BB84 operations and process with an eavesdropper (Alice-Bob-
Eve)
Now we can use Superdense Coding protocol to transmit 2 classical bits of this super
secret message. We use IBM’s Qiskit which offers a frame work on python that we can
use quantum computers and similators. We build Superdense Coding Protocol on
quantum circuit.
The brief steps for creating the SCP begins with configuring quantum registers and a
classical register.
70
First, we need to put Hadamard gate followed by CX which generates a Bell pair. We
should use bell pair in order to generate the entangled pair between Bob and Alice. Alice
is sender for this scenario, so the next, we need to encode the state in the circuit which is
regarding to Alice’s demand. Namely, Alice here encodes the bits. The next, Alice send
them and Bob decodes these bits and then measures to get classical bits, thus Bob receives
the information from Alice in an efficient way.
After we got meaningful inference regarding messages by using NLP in the experiment,
we want to send first 2-bits from the information of this meaningful sentence using SCP.
As we observe from SCP that we use 1 qubit to send 2 bits of classical information, then
Bob successfully recover the message. Our whole message bits from the NLP inference
as follows below:
71
The string after binary conversion :
1100001010101010110000111000100111000010100000001100001010100010110000111001000111000011100001001100001 . . .
For further future work, If we basically create a statement to read these classical bits from
an array or stack using python, we can send whole classical bits using individual quantum
circuit. We have 4 possibility for the 2 bit string information, they are “ 11, 10, 01, 00 ”.
After read these classical 2-bits pair, we can parse it and create individual circuits and can
send them using SCP.
We have already created the quantum circuit for “11” so need 3 circuits more.
The new method parses the encoded message into classical bits and the next, by looking
these bits, it sends the 2-bit pairs to its particular quantum circuit to run, thus all the
classical bits can be sent over SCP.
We have 848 classical bits in our example above. If we want to use SCP, we need 848/2
= 424 qubits and to send 2 bits pair over SCP.
Here is the brief arhitecture of the idea for further future work like If-statements:
The method above should be configured on both sides, Alice and Bob. This above model
stands for sender, there should be a correspondance as a receiver part, such as sharing
encoded bit pairs in an classical way, so Bob could know when to use which particular
circuit, otherwise he can also use a trigger for the recover part of each circuit. After he
got whole 2 bit pairs, he save them and integrate each other, finally he gets whole encoded
message using SCP. The next, he can decode these encoded message using BB84 secret
key.
Thus, they can use SCP that is a secure quantum communication method. If someone
72
like Eve wants to intercept the qubits from Alice transmission, the qubit cannot give a
hint about the information, because of the entangled state. So Eve always needs Bob’s
qubits. Also, If Eve attemps to measure that qubits, the process collapses the qubit state
and Alice and Bob would be aware of failure of something.
QNLP is a very new kind of processing method for natural language. It is used for
processing the language using different kind of quantum mechanical properties. We can
also use grammatical structure of a sentence by creating a meaningful semantics for
natural language processing in order to ease the processing tasks that is such a beneficial
technique on quantum domain.
QNLP needs a conversion cycle to handle the classical data, it encodes classical data to
quantum states in order to understand and process the classical data. To work with QNLP,
we need quantum data or we made some arrangements on classical data that convert it
into encoded quantum states.
The natural language is structured as quantum circuit in QNLP. QNLP uses “network like
model” to draw the relation of words that interacts each other which is called “sentences
as networks” and “language is quantum native”. The quantum circuit of the sentence can
be drawn according to these network structured pictures. Next, these circuits processed
and converted to quantum assembly language.
Namely, each word meaning corresponds to a quantum state and grammatical structures
and measurements. Also, as we observe from the QNLP experiment, one insteresting
point different from classical NLP is that we don’t need to encode each of the word
meaning, instead of doing this, a framework can learn their meanings from text using
quantum states and processes. The meaning of each word is encoded previously in the
framework, thus we can create quantum circuits and encode the meaning on quantum
computer, the next, quantum computer learns by using the framework and can return an
answer when a question asked regarding particular learned words and grammar. This is a
supervised learning method in quantum domain. Thus, we can work with both grammar
and meaning. In order to make inference and learn the patterns from data, quantum
73
circuits are used in QNLP. QNLP makes parameterization between circuits by Qcirc(θ)
to create a whole semantics in a sentence and also needs a confirmation which is done by
a classical computer for the faults and mismatches, thus, if there is fault, the circuit can
be updated.
Oxford Quantum Group scientists created a toolbox called DisCoPy which computes NL
meaning in pictures. We can write an example sentence for example “Alice hates Eve” to
use discopy and we can express types of the nouns or subjects using discopy as box shape.
Then we can bind these boxes with wire which we can call it as communication channel
and draw our picture according to our particular sentence.
After these steps we can also define a model using discopy with object, array, etc. Lastly,
we can achieve to compute the meaning. Moreover, Discopy has a capability to handle
the grammatical structure of a given sentence, in order to achieve this, it draws the
grammatical structure of NL sentences encoded as reductions in a pregroup grammar,
Lambek, “From Word to Sentence” et al. (2008).
We can also use discopy with other additional useful libraries such as numpy for
computing matrix-valued functors or pytket for creating real quantum circuits which a
python module for interfacing with CQC tket using set of toolbox for quantum
programming, Seyon Sivarajah et al (2021).
Thus we can express sentences as networks with these tools and can create a quantum
circuits from these pictures with IBM-Qiskit and compile it to OpenQASM and thus
quantum hardware can evaulate the expected results. We use super conducting qubit
processor of IBM’s quantum computer which is a NISQ device and differs from trapped
ion and photonic processor based quantum computers.
74
Figure 4.7: A network drawing for qnlp
With the absence of QRAM, we can encode each word as quantum states and can create
the quantum circuit to handle the meaning of whole sentence as a quantum circuit. The
interactions between the box-shaped words can be handled with quantum gates such as
C-NOT, GHZ, etc.
We try the sentence “Eve who listens chat is eavesdropper” as QNLP experiment on
remote quantum computer at Melbourne. We got the result as we expect, as following
stages.
75
For the encoding process we need bindings and quantum states, we can use CQC’s
encoding semantics to handle both of grammar and word meanings.
Figure 4.9: GHZ state circuit for “who” and word binding state
So now, we are ready to get quantum qiskit circuit using DisCoCat or we can use CQC’s
library for circuit generation method that does the same thing.
76
Figure 4.11: QNLP circuit
We send the quantum estimations to classical computer in order to handle the refinements
and fixing mismatches on calculations, the next refinements we can get the exact solution
as below :
Is Eve who listens chat eavesdropper?
Job Status: job has successfully run
Yes, she is.
The refinement process can take some time on classical computer, also we have to wait
to run the jobs on scheduled before on quantum computer.
77
4.8 EXPERIMENTAL RESULTS
The experiements are applied on classical, quantum computers and quantum simulators.
We used latest Compiler & Software Environment For Classical Computing Experiments
with Intel i7-6820 HQ 2.7GHz Processor, 32 GB Memory. Operating system is Windows
10, Eclipse 2018 version with Java 8 (JRE & JDK is open AZUL Zulu), Python 3
Anaconda, Jupyter Notebook, Scikit Learn library 0.23.1.
We used Quantum computers and simulators for Quantum Computing such as IBM
Qiskit, Microsoft Q#, t|ket>, DisCoPy, DisCoCat from CQC.
Quantum computing simulation programs from IBM, Microsoft, CQC, remote online
IBM Q Quantum computer and Qiskit are also used. All of the results is noted on related
sections.
In previous chapters, we mentioned Classical NLP, QKD, Superdense Coding and QNLP.
As we know, we use words and sentences in our daily life for communication purposes
or every point on the technology.
We wanted to create a hybrid model for two reason, first one is about showing the relation
between communication networks and NLP. Today, current technology ignores this
relation and not take advantage of this together usage (NLP & Communication
Networks), such as usage on communication methods or protocols or just text messages
or e-mails.
In classical NLP, words and sentences are just represented by digits and have no
individual meanings in classical NLP, for the reason bag of words and non-grammatical
model (unstructed model). They cannot interact each other directly without a usage of
neural network and classical NLP model.
Whereas words, sentences and networks have strong native relation. They are composed
78
by human and each word and sentence has a meaning in human language. In fact as we
think the words as nodes, we routes this nodes to each other which we want (when we
need to express the particular situation and thus sentences are created by us ) Thus,
network-like sentences are created.
Moreover, if we closely look it, we can see that each sentence looks like networks, some
of the sentences have close meaning or even continuation section of each other, that’s
why we can call the sentences as networks. For example, when we want to handle with
text of an essay, we easily recognize that each sentences (networks) also interacts with
each other (previous or next sentences) in the text. Namely, this assesment is a very
efficient way when we create a model and relation between networks and sentences, also
when we compute the NLP tasks.
Now, we can say that we represent the sentences as networks and human language is
quantum native. More likely, we can use network model, because a model that the
quantum mechanics is structured as pictures which evaulated in very similar to network-
like langauge, Coecke et al. (2005). So, thanks to Quantum Mechanics and QNLP.
In contrast to classical NLP, we can also handle with the grammatical structures of each
sentences in QNLP. We can compute the tasks according to grammatical structures, this
is very important advantage in comparison to classical NLP counterparts.
As second reason, on the point why we want to create a hybrid model is about building
a compatible model with using classical NLP or QNLP with QKD-SCP, for a super secret
NLP problem solution, more likely an architecture. We analyze the differences and create
a more stable model with blended usage. Thus we can present a model, on the point
handling big NL data texts and make interference from this NL data (which is about a
critical subject and top-secret) and send a super secret message through QKD-SCP.
We also illustrate the strong relation of NLP and communication methods which are very
close to each other. Because NL is human language and we communicate with each other
using NL. Thus NLP is directly affects the ordinary communication methods and
architectures and go forward to a new period when we deal with meaningful network
model on communication methods.
79
We could have 4 kind of parts in hybrid workflow model:
a. Classical NLP
b. QNLP
c. QKD-BB84 or AES-RSA
d. SCP or TCP/IP
We can begin to use hybrid workflow model from the part which we need to make
inference by the data which corresponds to classical NLP or QNLP. We can prefer
classical NLP over QNLP for the convenient usage big texts.
So hybrid workflow model can be the model below, which offers more reliable and
robust usage.
80
Figure 4.13: Hybrid workflow model illustration
According to our classical NLP and QKD-BB84 experiment, we want to analyze big e-
mails or chat texts between the parties and make meaningful inferences, these inferences
shows the truth value of the e-mails and text messages. We aim to got an ouput from big
text which is wanted to use as a communication message after inference process with
NLP. By the way, this inference can point out about intentions such as manupilation of
something or fake news. Namely, they are used as a part of the communication cycle by
81
classical NLP. This shows us classical NLP or QNLP has directly affects the
communication methods by using NL, they can be integrated to each other and used in
AI-QAI.
We assume from the experiements that NLP has strong relations with networks by its
nature and QNLP takes this advantage to one step beyond by grammatical workflow. And
NLP and QNLP can also be used as network modeled categories and can be integrated to
automate to make inference from NL. The new communication methods and
architectures can be developed and used by NLP and QNLP, thus the people don’t need
to comeback to read and make inference from big texts such as e-mail or archieve of news
for the critical inference works which can directly affects communication message from
big texts. This is one of the most important aspects of hybrid workflow model, thus,
people don’t need to decide and have false beliefs about uncertain and controversial
subjects.
A hybrid workflow model that is illustrated above directly affects whole communication
system by early alerts against fake & spam e-mails and false news. This model can also
send notification message automatically to other fair users or even prevent them directly
such kind of messages at the beginning of the communication such as human conversation
and news publishment.
Consequently, we can say that usage of the classical NLP is more likely is a vey efficent
way and good choice when we want to build such a NLP architecture which is integrated
to a communication method strengthened by cryptographic algorithm like QKD in our
experiment. On the other hand, QNLP puts in hand the advantages of computing with
grammatical structures. It can be very fast in the future. QKD is a very useful when
detecting the eavesdroppers easily.
82
such as, we use OTP in BB84 which provides a private key for the purpose that unique
key creation for only one time established conversation. OTP also widely used some of
the classical encryption algorithms.
The more or less QKD is a sophisticated and based on physics laws of quantum
mechanics, its digital signature is absent too, while classical ones have the digital
signature. Also, we can observe from the recent researches that QKD is a expensive
method and restricted with max. 250 KM at the speed of 16 bps, which is not possible for
a daily usage, the quantum hardware & infrastructure is absent too which depends on
communication medium such as ion-traps, superconducting qubits or photonic
polarization methods, in contrast classical cryptography is indepented from
communication medium. Moreover, while classical computing has 2n n-bit string, QKD-
BB84 has 1 n-bit string.
Today, QKD is mostly used on big quantum computers and similators for research
purposes, while classical counterparts used in national security, banking process or
communication applications, etc.
One of the standout features of QKD is a well designed method to create an ubreakable
encryption method, because the quantum states measurement principle perfectly suits to
this phenomena, the encoded data in quantum states cannot be copied. We can easliy
detect anyone who try to listen our communication in QKD, so communication can be
aborted by the users. Therefore, we can call it as unhackable method.
As we know from the previoous sections, we have 2 kind of NLP methods in classical
computing, one of is classical NLP method and other one is deep learning technique
applied on NLP with using supervised, unsupervised, etc. Classical NLP is based on
mathematical calculations and algorithms and works in the style of “bag of words” and
they are widely used as state-of-the-art in many branches and commercial industry
applications.
The classical NLP begins with language detection, pre-processing, modeling and output
83
which can be used in various application to handle human language, such as voice2text,
text2voice, voice2voice, error detection, fake news detection, speech recognition,
sentiment and hand writing analysis, etc. Various classification algorithms can also be
used for particular processing job. NLP understands words and each characters of the
alphabet as a number and it makes a vectorization method to handle the data and make
meaningful inference from the text. It encodes each word as vector and next the
classification part is evaulated by algorithms, thus training process can be made.
In order to make inference and learn the patterns from data, neural networks are used in
classical NLP. But, most of methods ignores grammatical structures and loses handling
with this advantage. The data space is K = R+E, here R indicates the training size and E
represents the test size of the data space of U.
The QNLP is based on pysical laws of quantum mechanics and in its initial steps for now.
It has some big advantages in comparison to classical NLP. Today, CQC researchers
experimentally proofed first QNLP example on a (NISQ) quantum computer that we also
have an advantage to handle with grammatical structure of a sentence, which is different
from Classical NLP.
Table 4.8: Differences between classical nlp and qnlp-pros and cons
84
algorithms
Can be done on every Proofed and experimented on just
classical computing machines Superconducting qubit processors
(classical computers) (NISQ) not Trapped ion or
Photonic polarization processors
Handles meanings Handles meanings + grammar
Uses RAM Not use QRAM (absent)
Uses NL toolkits Uses QNLP toolkits and
quantum frameworks for circuit
and mapping
Works with big text or voice files Works with only individual
sentences for now, with big text
files in the near future
Preprocessing and other Preprocessing or other
advanced operations regarding advanced operations regarding
NLP can be made NLP can be made using
classical computer
Based on processing Based on probabilistic
with exact calculations and results calculations and results by
number of runs-shots and
quantum theory
Supervised learning and Just supervised learning model
other learning methods can be can be applied for now
applied
Runs on economical and Runs on expensive and
limited computer CPU’s powerful quantum processor
except supercomputers support on QC’s
(16 & 65 qubits QC)
We will handle text documents for NL processing with QNLP after some open points
completed regarding QNLP. For example, hardware related QRAM and QPU and also
QNLP algorithm based solutions.
We can see that it is early to use QNLP instead of classical NLP. But QNLP experiment
shows that we are getting much closer to NL processing operations by quantum native
NL. Also the framework of CQC’s quantum software development platform t|ket> is very
85
useful at all.
5. DISCUSSION AND CONCLUSION
In this thesis, Grover search algorithm, NLP, QKD, QNLP topics have been intensely
studied. We have worked on state-of-the-art AI and ML applications which consist of
newest trend topics especially in quantum domain. We have compared both classical and
quantum computing domains which are related about searching algorithms, natural
language processing and communication protocols.
We have applied Grover simulation method with several problem solving and also
suggested a usage of traditional NLP with QKD-SCP together as a hybrid model. We
have used 9K natural language sentences, most of them belong to Kaggle dataset and rest
of it belong to other NLP dataset source. We have used and considered Microsoft Q# and
DFS Sudoku problem examples and we calculate the required time for finding the solution
that we need to solve the particular problem on the both sides; classical and quantum
domains.
This algorithm is well suited for quantum computation, because the data type and
processing way is much relavent with quantum computing, but it is a good thing to deal
with this algorithm to understand its complex mathematical operations and calculation in
an easier way in classical computer. Therefore, we develop a simulation for better
understanding the algorithm steps. For searching the item, algorithm is iterated square
root of 2n in classical computing.
86
We can experience that Grover algorithm is working much better on quantum
computer, because we cannot do the amplitude amplification trick by absence of qubits
in superposition. The results we get classical computing Grover algorithm is interesting
and system capacity begins to hardened and close to be failure, if we increase the
number_of_qubits value, because the search space of algorithm is increased
exponentially.
In NLP experiment, some of the NL sentences are used for training and rest of them for
testing. We used 9K sentences for traing and testing puposes. In our experiments,
different classifiers are used and compared to each others, such as Bernoulli N.B,
Multinominal N.B and SVM. We used 4 classifiers to classify the objects in the large
dataset. QNLP publication by CQC is also worked and compared to classical NLP. In
the beginning of the NLP research, we wanted to use QML for processing the dataset,
but there is a potential handicap regarding the QRAM that we need to load the datasets
into classical computer and properly use classical NLP, that’s why, we lose QML’s
quantum supremacy over classical ML. Therefore we don’t use Quantum Support
Vector Machines (QSVM) for classification task.
We use quantum computing simulations from IBM Qiskit and CQC t|ket> which works
and give solutions like real quantum computer. We plan to work with our hybrid
architecture developing with BB84 and superdense coding protocol. We use SCP in
order to prove that the sending secret cryptographic information (QKD-BB84) with
SCP.
We can only send first 2 classical bits using 1 qubit in SCP, therefore, for further
research, we need to develop an automated-protocol (using SCP) to send whole
encrypted message which needs to be divided into 2 bits frames and can be send using
SCP with QKD. We can also build a framework like CQC’s QNLP experiment to
handle the NLP in quantum domain datasets, maybe with QRAM and NISQ devices in
the future. Thus, we can totally achieve a long term hybrid architecture in NLP using
both computing domains.
87
We could have the chance for making comparison on both of the domains; classical
and quantum computing. Thus, moreover, we can show the usage and applicability of
classical and quantum computing domains in a hybrid model for particular and critical
tasks, especially high severity tasks regarding big datasets for perfect processing and
also concerning the high-end, top-security with QKD. This hybrid model takes its
power
from both sides, state-of-the-art NLP from classical computing and unbreakable
cryptographic communication method from quantum computing. We could also use
AES, RSA, TLS classical encryption algorithms but, the key point here is that QKD is
a very powerful and useful method against eavesdroppers with its unique features that
consist of special quantum mechanics laws and makes random strings and rotations.
In addition to this, we design a architecture model using SCP for sending the classical
information using quantum bits after classical NLP process is completed. This iteration
model, we can get the processed message by classical NLP application and start the
SCP handling stage for every classical message bytes, finally send the top secret
message by SCP iteration model. We showed this SCP iteration model theoritically
possible, well-suited into a hybrid model like ours and can be implemented in the
future. Thus we could achieve the hybrid architecture with using classical NLP, QKD,
SCP and also QNLP together.
In future works, QSVM can be used for the classification task for NLP. We can also
try to transform the classical data into quantum data and apply QML. Thus, the data
becomes the suitable format for QML. We can use “words as networks” model and
design quantum states as NL networks. We can also use the Grover algorithm for QNLP
tasks for finding the specific sentences in a very efficient way, because it is well-suited
with quantum data and quantum processing method.
As a consequence, we can observe that quantum computers give best solutions and time
efficiency for complex problems through this experiment projects. They are special for
particular jobs. We forecast the quantum algorithms and communication protocol
solutions becomes growing very fast in the future.
We also assume that together hybrid usage of classical and quantum computing
88
algorithms and solutions can open the closed doors of the both technology from different
point of view and perspectives. Thus, it can be used in every domains such as quantum
physics, chemistry, quantum sensors and quantum communication models. Quantum
computing will also help AI by handling and the developing the algorithms all over and
communication methods too.
89
REFERENCES
Other Publications
90
tossing.” International Conference on Computer System and Signal
Processing,IEEE (1984).
Cambridge Quantum Computing Web Sources, cambridge.org/pqp,
youtube.com/channel/UCD5Pa5pKMRrkUSKGwjBxrSQ/videos,
github.com/oxford-quantum-group, discopy.readthedocs.io/en/main/.
Dr Iain Styles, Lecture 8: Grover’s Quantum Search Algorithm.
Camilo Z.,Xiao Y. “The Grover’s Algorithm”, ETHzurich, 2016.
DK Lee, D. Dang, “Grover-Algorithm”, github.com/dqdang/grover-algorithm/.
E. Farhi and H. Neven, “Classification with Quantum Neural Networks on Near Term
Processors”, arXiv:1802.06002v2 [quant-ph] 30 Aug 2018.
E. Strubell, “An Introduction to Quantum Algorithms”, COS498 – Chawathe Spring,
2011.
erickleppen.medium.com/the-ultimate-guide-to-erics-articles-d32df8241353.
geeksforgeeks.org/difference-between-cryptography-and-cryptology/?ref=rp.
Eleanor Rieffel, Wolfgang Polak, “An Introduction to Quantum Computing for Non-
Physicists”, arxiv.org/abs/quant-ph/9809016v2, 2000.
Fabian K., “Quantum teleportation in a nutshell”, Technische Universität München and
MPQ, 2013.
Github Source Code Portal,
github.com/melphi/fakenews-analysis,
github.com/microsoft/Quantum,medium.com/towards-artificial-intelligence/solving-
sudoku-with-ai-or-quantum-3421f5af7b54,tensorflow.google.cn/quantum/,
github.com/krishnakumarsekar/awesome-quantum-machine-
learning,github.com/Qiskit/qiskit/blob/master/docs/,
github.com/PennyLaneAI/pennylane/blob/master/doc/introduction/,
github.com/microsoft/Quantum/tree/main/samples/algorithms/sudoku-grover,
github.com/XanaduAI/quantum-transfer-learning,
github.com/desireevl/awesome-quantum-computing,
Gidney, Craig. “Logical Ingredients of a Quantum Computer.”Algorithmic Assertions -
Craig Gidney's Computer Science Blog, algassert.com/quantum-
computing/2014/07/29/Logical-Ingredients-of-a-Quantum-Computer.html.
Grover, Lov K.: From Schrdinger’s Equation to the Quantum Search Algorithm. 2001. –
91
URL http://www.citebase.org/abstract?id=oai:arXiv.org:quant-ph/0109116.
IBM Staff. Quantum information science kit. https://qiskit.org/aqua.
IBM Qiskit, qiskit.org/textbook/preface.html, qiskit-community-tutorials_QISKIT for
quantum machine learning, qiskit.org/textbook/.
I. Chuang & M. Nielsen, "Quantum Computation and Quantum Information",
Cambridge: Cambridge University Press, 2000.
J. Brownlee, “Deep Learning for Natural Language Processing Develop Deep Learning
Models for Natural Language in Python”.
J. Wallnofer, Alexey A. Melnikov, Wolfgang Dur, Hans J. Briegel, “Machine learning
for long-distance quantum communication”, arXiv:1904.10797v2 [quant-ph] 17
Sep 2020.
K. Meichanetzidis, G. De Felice, A. Toumi and B. Coecke Cambridge Quantum
Computing, “Quantum Natural Language Processing on Near-Term Quantum
Computers”, arxiv.org/abs/2005.04147v1, 2020.
K. Ali, “Analysis of Grover’s Algorithm and Quantum Computation” California State
Polytechnic University, Pomona Thesis, 2019.
K.Meichanetzidis, “Quantum Natural Language Processing”,
https://medium.com/cambridge-quantum-computing/, 2020.
Kimble H. J., “The quantum internet,” Nature, vol. 453, no. 7198, pp. 1023–1030, 2008.
L. K. Grover (1996), "A fast quantum mechanical algorithm for database search",
Proceedings of the 28th Annual ACM Symposium on the Theory of Computing
(STOC 1996), doi:10.1145/237814.237866, arXiv:quant-ph/9605043.
“Measuring Quantum Information without Destroying It.” Phys.org -News and
Articles on Science and Technology, Phys.org, phys.org/news/2009-01-
quantum.html.
Maggie Li, “Grover’s Search Algorithm”, medium.com/@ziyu.lili.maggie, 2020.
Mario Mastriani, “Simplified Protocol of Quantum Teleportation” Scientific Research
Publishing, Journal of Quantum Information Science, 2018, 8, 107-120.
NLP Conference, cambridgequantum.com/quantum-natural-language-processing-2019/.
Pennylane AI, pennylane.ai/qml/demos/.
P Shor, J Preskill, ”Simple proof of security of the BB84 quantum key distribution
protocol.” Physical review letters 85.2 (2000): 441.
92
Peter Wittek, University of Borås Sweden, “Quantum Machine Learning What Quantum
Computing Means to Data Mining”, Academic Press, Elsevier, 2014.
R.Anand, “BuildingYour Own Quantum Circuits in Python”, 2019.
Schrödinger, E. (1935) Die Gegenwaertige Situation in der Quantenmechanik. Die
Naturwissenschaften, 23, 807-812. https://doi.org/10.1007/BF01491891.
0Samson Abramsky & Bob Coecke (2004): A categorical semantics of quantum
protocols. In: Logic in Computer Science, 2004. Proceedings of the 19th Annual
IEEE Symposium on, IEEE, pp. 415–425, doi:10.1109/LICS.2004.1319636.
W. Zeng & B. Coecke, “Quantum Algorithms for Compositional Natural Language
Processing”, Rigetti Computing and University of Oxford.
93