Skip to content

Commit cc932ab

Browse files
authored
Merge pull request #60 from f64u/error-correction
Error correction
2 parents 321dfe1 + 38e5fc5 commit cc932ab

File tree

5 files changed

+1705
-0
lines changed

5 files changed

+1705
-0
lines changed

_CoqProject

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-R _build/default/SQIR SQIR
22
-R _build/default/examples/examples Examples
33
-R _build/default/examples/shor Shor
4+
-R _build/default/examples/error-correction ErrorCorrection
45
-R _build/default/VOQC VOQC

examples/error-correction/Common.v

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
Require Export SQIR.UnitaryOps.
2+
3+
Module Common.
4+
5+
Local Open Scope ucom.
6+
7+
(** A toffoli gate but controlled on the first qubit
8+
being zero. *)
9+
Definition ZCCX {dim} (a b c : nat) : base_ucom dim :=
10+
X a;
11+
CCX a b c;
12+
X a.
13+
14+
Lemma zero_3_f_to_vec :
15+
∣0,0,0⟩ = f_to_vec 3 (fun _ => false).
16+
Proof.
17+
lma'. simpl. auto with wf_db.
18+
Qed.
19+
20+
Lemma one_3_f_to_vec :
21+
∣1,0,0⟩ = f_to_vec 3 (fun n => n =? 0).
22+
Proof.
23+
lma'. simpl. auto with wf_db.
24+
Qed.
25+
26+
Lemma two_3_f_to_vec :
27+
∣0,1,0⟩ = f_to_vec 3 (fun n => n =? 1).
28+
Proof.
29+
lma'. simpl. auto with wf_db.
30+
Qed.
31+
32+
Lemma three_3_f_to_vec :
33+
∣1,1,0⟩ = f_to_vec 3 (fun n => orb (n =? 0) (n =? 1)).
34+
Proof.
35+
lma'. simpl. auto with wf_db.
36+
Qed.
37+
38+
Lemma four_3_f_to_vec :
39+
∣0,0,1⟩ = f_to_vec 3 (fun n => n =? 2).
40+
Proof.
41+
lma'. simpl. auto with wf_db.
42+
Qed.
43+
44+
Lemma five_3_f_to_vec :
45+
∣1,0,1⟩ = f_to_vec 3 (fun n => orb (n =? 0) (n =? 2)).
46+
Proof.
47+
lma'. simpl. auto with wf_db.
48+
Qed.
49+
50+
Lemma six_3_f_to_vec :
51+
∣0,1,1⟩ = f_to_vec 3 (fun n => orb (n =? 1) (n =? 2)).
52+
Proof.
53+
lma'. simpl. auto with wf_db.
54+
Qed.
55+
56+
Lemma seven_3_f_to_vec :
57+
∣1,1,1⟩ = f_to_vec 3 (fun _ => true).
58+
Proof.
59+
lma'. simpl. auto with wf_db.
60+
Qed.
61+
62+
#[export] Hint Rewrite
63+
zero_3_f_to_vec
64+
one_3_f_to_vec
65+
two_3_f_to_vec
66+
three_3_f_to_vec
67+
four_3_f_to_vec
68+
five_3_f_to_vec
69+
six_3_f_to_vec
70+
seven_3_f_to_vec
71+
: f_to_vec_3_db.
72+
73+
74+
Ltac f_to_vec_simpl_light :=
75+
first
76+
[ rewrite f_to_vec_H
77+
| rewrite f_to_vec_X
78+
| rewrite f_to_vec_CCX
79+
| rewrite f_to_vec_CNOT
80+
];
81+
try lia;
82+
simpl update;
83+
do 2 (
84+
repeat rewrite Mmult_plus_distr_l;
85+
repeat rewrite Mscale_mult_dist_r
86+
).
87+
88+
End Common.

0 commit comments

Comments
 (0)