Add DM6,DM7.typ

This commit is contained in:
augustin64 2024-11-30 10:27:09 +01:00
parent 7e70fb58ae
commit e104689ff1
2 changed files with 113 additions and 0 deletions

66
DM6.typ Normal file
View File

@ -0,0 +1,66 @@
#import "qcs.typ": *
#set page(
paper: "a4",
header: align(center)[
QCS - DM6 : Decide satisfiability - Augustin LUCAS
],
)
#question("Assignment Q1", [
Using Grover's algorithm, design a quantum circuit deciding with probability $>= 2/3$ SATISFIABILITY,
having size $O(2^(n/2) "poly"(abs(phi)))$, where $n$ is the number of variables of $phi$.
SATISFIABILITY:
- INPUT: Boolean formula $phi$
- OUTPUT: 1 if $exists sigma : {x_1, dots, x_n} -> {0, dots, 1}$ satisfying $phi$; 0 otherwise
])
Let $f : x in {0, 1}^n |-> phi(x) in {0, 1}$.
Let $Z_f$ be a circuit of size $"poly"(abs(phi))$ such that $Z_f ket(x) = (-1)^(f(x)) ket(x)$
Applying Grover's algorithm with $Z_f$ consists of the following circuit :
#{
import "@preview/quill:0.5.0": *
quantum-circuit(
setwire(0), lstick(align(center)[$n$ qubits], n: 4, pad: 10.5pt),
lstick($|0〉$), setwire(1), $H$, mqgate($G$, n:4), mqgate($G$, n:4), mqgate($G$, n:4),
midstick($ dots $), mqgate($G$, n:4), 1, meter(), setwire(2), 1, [\ ],
setwire(0), 1, lstick($|0〉$), setwire(1), $H$, 3, midstick($ dots $), 2, meter(), setwire(2), 1, [\ ],
setwire(0), 1, lstick($|0〉$), setwire(1), $H$, 3, midstick($ dots $), 2, meter(), setwire(2), 1, [\ ],
setwire(0), 1, lstick($|0〉$), setwire(1), $H$, 3, midstick($ dots $), 2, meter(), setwire(2), 1,
)
}
Let $y$ be the final measurement. After that, we check if it is a solution to $f$. If it is a solution
to $f$, it it a solution to $phi$ too, and $phi$ is satisfiable.
As we need to apply the $G$ gate $O(2^(n/2))$ times, there are $O(2^(n/2))$ uses of $Z_f$ in this circuit. Then,
the complexity of the circuit is $O(2^(n/2) "poly"(abs(phi)))$.
We now need to design a circuit $Z_f$, such that $Z_f ket(x) = (-1)^(f(x)) ket(x)$.
We may need the following gates:
- $Z_1 ket(x_1 x_2 y) = ket(x_1 x_2 ((x_1 and x_2) xor y))$
- $Z_2 ket(x_1 x_2 y) = ket(x_1 x_2 ((x_1 or x_2) xor y))$
- $Z_3 ket(x y) = ket(x (not x xor y))$
Using these gates, we can build $Y_phi$ such that $Y_phi ket(x_1 dots x_n) ket(0^p) ket(b) = ket(x_1 dots x_n (b xor phi(x_1, dots, x_n)))$, using $p$ ancilla qubits.
We then restore these $p$ ancilla qubits to their original state by applying the operations in reverse order.
#question("Bonus Question", [
There is a box with 2 possibilities:
- There is no bomb, the box replicates identity
- There is a bomb, if we measure in basis ${ket(0), ket(1)}$:
+ outcome $ket(0)$ : it outputs $ket(0)$
+ outcome $ket(1)$ : EXPLOSION
For any $epsilon > 0$, determine if there is a bomb without getting an explosion.
You are allowed for an error or an explosion with probability $<= epsilon$
])

47
DM7.typ Normal file
View File

@ -0,0 +1,47 @@
#import "qcs.typ": *
#set page(
paper: "a4",
header: align(center)[
QCS - DM7 : Decide satisfiability - Augustin LUCAS
],
)
#v(10%)
#question("Assignment Q1", [
#align(center, {
import "@preview/quill:0.5.0": *
quantum-circuit(
lstick($"input:" psi = alpha ket(0)+beta ket(1)$), 2, slice(label: $ket(phi_0)$), targ(),
slice(label: $ket(phi_1)$), 2, rstick("output"), [\ ],
lstick(ket(0)), $H$, 1, ctrl(-1), 2, rstick($X$)
)
})
Compute Kraus representation of map input $->$ output.
])
#v(2%)
$ket(phi_0) &= (alpha ket(0)+beta ket(1)) times.circle (ket(0)+ket(1))/sqrt(2) \
&= alpha/sqrt(2) ket(00) + alpha/sqrt(2) ket(01) + beta/sqrt(2) ket(11) + beta/sqrt(2) ket(10)$
$ket(phi_1) = (alpha ket(0) +beta ket(1))/sqrt(2) times.circle ket(0)
+ (alpha ket(1) +beta ket(0))/sqrt(2) times.circle ket(1)$
This corresponds on the first qubit to the circuit "do a bit flip with probability $1/2$",
which Kraus representation is: $Phi(psi) = (1/sqrt(2) I) psi (1/sqrt(2) I) + (1/sqrt(2) X) psi (1/sqrt(2) X)$
#v(10%)
#question("Assignment Q2", [
Let $M=mat(a,b;c,d)$, $a,b,c,d in bb(C)$.
Compute $Phi(M)$ where $Phi$ phase flips with probability $1/2$.
])
#v(2%)
#align(center, $Phi(M) &= (1-1/2)M + 1/2 Z M Z \
&= 1/2mat(a,b;c,d)+1/2 mat(1,0;0,-1) mat(a,b;c,d) mat(1,0;0,-1) \
&= 1/2 (mat(a,b;c,d)+mat(a,b;-c,-d) mat(1,0;0,-1)) \
&= 1/2 (mat(a,b;c,d)+mat(a,-b;-c,d)) \
&= mat(a,0;0,d)$
)