Skip to content

Commit

Permalink
Public release
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum-mob committed Jul 31, 2023
1 parent c6521ab commit c411a86
Show file tree
Hide file tree
Showing 42 changed files with 21,522 additions and 20,014 deletions.
Binary file modified Q3/Documentation/English/Index/_0.cfs
Binary file not shown.
Binary file modified Q3/Documentation/English/Index/segments_3
Binary file not shown.
373 changes: 215 additions & 158 deletions Q3/Documentation/English/ReferencePages/Symbols/BinarySymplecticGroup.nb

Large diffs are not rendered by default.

591 changes: 328 additions & 263 deletions Q3/Documentation/English/ReferencePages/Symbols/CZ.nb

Large diffs are not rendered by default.

435 changes: 232 additions & 203 deletions Q3/Documentation/English/ReferencePages/Symbols/CliffordGroup.nb

Large diffs are not rendered by default.

1,192 changes: 754 additions & 438 deletions Q3/Documentation/English/ReferencePages/Symbols/ControlledGate.nb

Large diffs are not rendered by default.

10,959 changes: 4,446 additions & 6,513 deletions Q3/Documentation/English/ReferencePages/Symbols/FromGottesmanMatrix.nb

Large diffs are not rendered by default.

505 changes: 259 additions & 246 deletions Q3/Documentation/English/ReferencePages/Symbols/FromGottesmanVector.nb

Large diffs are not rendered by default.

439 changes: 233 additions & 206 deletions Q3/Documentation/English/ReferencePages/Symbols/FullCliffordGroup.nb

Large diffs are not rendered by default.

427 changes: 288 additions & 139 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanBasis.nb

Large diffs are not rendered by default.

476 changes: 331 additions & 145 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanInner.nb

Large diffs are not rendered by default.

396 changes: 222 additions & 174 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanInverse.nb

Large diffs are not rendered by default.

7,298 changes: 3,270 additions & 4,028 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanMatrix.nb

Large diffs are not rendered by default.

311 changes: 172 additions & 139 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanMatrixQ.nb

Large diffs are not rendered by default.

387 changes: 218 additions & 169 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanMerge.nb

Large diffs are not rendered by default.

392 changes: 223 additions & 169 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanSolve.nb

Large diffs are not rendered by default.

387 changes: 218 additions & 169 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanSplit.nb

Large diffs are not rendered by default.

813 changes: 413 additions & 400 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanStandard.nb

Large diffs are not rendered by default.

505 changes: 259 additions & 246 deletions Q3/Documentation/English/ReferencePages/Symbols/GottesmanVector.nb

Large diffs are not rendered by default.

11,241 changes: 6,622 additions & 4,619 deletions Q3/Documentation/English/ReferencePages/Symbols/GraphState.nb

Large diffs are not rendered by default.

1,753 changes: 980 additions & 773 deletions Q3/Documentation/English/ReferencePages/Symbols/ModMultiply.nb

Large diffs are not rendered by default.

373 changes: 189 additions & 184 deletions Q3/Documentation/English/ReferencePages/Symbols/SWAP.nb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

363 changes: 183 additions & 180 deletions Q3/Documentation/English/ReferencePages/Symbols/StabilizerStateQ.nb

Large diffs are not rendered by default.

Binary file modified Q3/Documentation/English/SearchIndex/5/_0.cfe
Binary file not shown.
Binary file modified Q3/Documentation/English/SearchIndex/5/_0.cfs
Binary file not shown.
Binary file modified Q3/Documentation/English/SearchIndex/5/_0.si
Binary file not shown.
9 changes: 4 additions & 5 deletions Q3/Documentation/English/SearchIndex/5/indexMetadata.wl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<|"IndexedPaths" -> None, "Driver" -> "Lucene",
"CreationDate" -> DateObject[{2023, 7, 26, 15, 29,
28.097825`8.201247684806715}, "Instant", "Gregorian", 9.],
"Version" -> 5, "Synonyms" -> None, "Method" -> "BM25",
"Language" -> "English", "ContentFieldOptions" ->
<|"Title" -> <|"Stored" -> True, "Weight" -> 2|>,
"CreationDate" -> DateObject[{2023, 7, 29, 23, 31,
51.8458`8.467288555440298}, "Instant", "Gregorian", 9.], "Version" -> 5,
"Synonyms" -> None, "Method" -> "BM25", "Language" -> "English",
"ContentFieldOptions" -> <|"Title" -> <|"Stored" -> True, "Weight" -> 2|>,
"ExactTitle" -> <|"Stored" -> True, "Tokenized" -> False,
"LengthWeighted" -> False|>, "NormalizedTitle" ->
<|"Tokenized" -> False, "LengthWeighted" -> False|>,
Expand Down
Binary file modified Q3/Documentation/English/SearchIndex/5/segments_2
Binary file not shown.
Binary file modified Q3/Documentation/English/SpellIndex/_2b.cfs
Binary file not shown.
Binary file modified Q3/Documentation/English/SpellIndex/segments_4p
Binary file not shown.
137 changes: 80 additions & 57 deletions Q3/Documentation/English/Tutorials/CliffordDecomposition.nb

Large diffs are not rendered by default.

566 changes: 284 additions & 282 deletions Q3/Documentation/English/Tutorials/PauliAndCliffordGroups.nb

Large diffs are not rendered by default.

40 changes: 24 additions & 16 deletions Q3/Kernel/Abel.wl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ BeginPackage["Q3`"]

`Abel`$Version = StringJoin[
$Input, " v",
StringSplit["$Revision: 3.46 $"][[2]], " (",
StringSplit["$Date: 2023-07-23 11:17:49+09 $"][[2]], ") ",
StringSplit["$Revision: 3.53 $"][[2]], " (",
StringSplit["$Date: 2023-07-28 22:30:12+09 $"][[2]], ") ",
"Mahn-Soo Choi"
];

Expand Down Expand Up @@ -1341,25 +1341,33 @@ MultiplyDot[a_?ArrayQ, b_?ArrayQ] := Inner[Multiply, a, b]

(**** <Garner> ****)

Garner::usage = "Garner[expr] collects together terms involving the same species objects (operators, Kets, Bras, etc.) and simplifies the coefficients by using Simplify.\nGarner[expr, function] uses function instead of Simplify."

FullGarner::usage = "FullGarner[expr] collects together terms involving the same species objects (operators, Kets, Bras, etc.) and simplifies the coefficients by using FullSimplify."

SetAttributes[Garner, Listable]

SetAttributes[FullGarner, Listable]

FullGarner[expr_] := Garner[expr, FullSimplify]


Garner::usage = "Garner[expr] collects together terms involving the same species objects (operators, Kets, Bras, etc.) and simplifies the coefficients by using Simplify.\nGarner[expr, function] uses function instead of Simplify."

SetAttributes[Garner, Listable]

Garner[expr_, tool_:Simplify] := Module[
{ bb = $GarnerPatterns["Heads"],
tt = $GarnerPatterns["Tests"],
qq },
bb = Union @ Cases[expr, bb, Infinity];
qq = expr /. {_Multiply -> 0};
qq = Union @ Cases[qq, tt, Infinity];
Collect[KetRegulate @ expr, Join[qq, bb], tool]
{ pp = Alternatives @@ Values[$GarnerPatterns],
gg = expr /. {op:$GarnerPatterns["Heads"]->Hold[op]} },
gg = theGarner[Expand @ gg];
gg = Union @ Cases[ReleaseHold @ gg, pp];
Collect[KetRegulate @ expr, gg, tool]
]

FullGarner[expr_] := Garner[expr, FullSimplify]

theGarner::usage = "Breaks into elementary parts."

theGarner[expr_Plus] := Flatten @ Map[theGarner, List @@ expr]

theGarner[expr_Times] := List @@ expr

theGarner[any_] := {any}


AddGarnerPatterns::usage = "AddGarnerPatterns[pattern$1,pattern$2,\[Ellipsis]] adds patterns to be handled by Garner."
Expand Down Expand Up @@ -1424,7 +1432,7 @@ $ElaborationPatterns = Association[

DistributableQ::usage = "DistributableQ[x, y, \[Ellipsis]] returns True if any of the arguments x, y, \[Ellipsis] has head of Plus."

DistributableQ[args__] := Not @ MissingQ @ FirstCase[ {args}, _Plus ]
DistributableQ[args__] := Not @ MissingQ @ FirstCase[{args}, _Plus]


MultiplyGenus::usage = "MultiplyGenus[op] returns the Genus of op, which may be a Species or related function.\nMultiplyGenus is a category class of Species and functions for Multiply that ranks above MultiplyKind. It affects how Multiply rearranges the non-commutative elements.\nMultiplyGenus is intended for internal use."
Expand Down Expand Up @@ -1475,7 +1483,7 @@ NonCommutativeMultiply[a___] := Multiply[a]

Multiply[] = 1 (* See also Times[]. *)

Multiply[c_] := c
Multiply[c_] = c

(* Associativity *)

Expand Down
76 changes: 46 additions & 30 deletions Q3/Kernel/Gottesman.wl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ BeginPackage["Q3`"]

`Gottesman`$Version = StringJoin[
$Input, " v",
StringSplit["$Revision: 2.57 $"][[2]], " (",
StringSplit["$Date: 2023-07-19 23:48:01+09 $"][[2]], ") ",
StringSplit["$Revision: 2.70 $"][[2]], " (",
StringSplit["$Date: 2023-07-28 07:28:00+09 $"][[2]], ") ",
"Mahn-Soo Choi"
];

Expand All @@ -21,7 +21,7 @@ BeginPackage["Q3`"]

{ CliffordDecompose };

{ Stabilizer, StabilizerStateQ };
{ Stabilizer, StabilizerStateQ, StabilizerStateCount };

{ BinarySymplecticGroup,
BinarySymplecticGroupElements };
Expand Down Expand Up @@ -481,29 +481,34 @@ GottesmanInner[v_?VectorQ, w_?VectorQ] := (
Message[GottesmanInner::incon, v, w];
0 ) /; Not @ ArrayQ @ {v, w}


GottesmanBasis::usage = "GottesmanBasis[{v1, v2, \[Ellipsis]}] returns a symplectic basis of the vector space spanned by {v1, v2, \[Ellipsis]}.\nGottesmanBasis[v] returns a symplectic basis {v, \[Ellipsis]} spanning the Gottesman vector space containing v.\nGottesmanBasis[n] returns the standard basis of the n-qubit (2n-dimensional) Gottesman vector space, which happens to be a symplectic basis with respect to GottesmanInner."

GottesmanBasis[bs:{__?VectorQ}] := Module[
(* See: Koenig and Smolin (2021) *)

GottesmanBasis[{}] = {} (* fallback *)

GottesmanBasis[bs_?MatrixQ] := Module[
{ v = First @ bs,
w, new },
If[ContainsOnly[v, {0}], Return @ GottesmanBasis @ Rest @ bs];

w = Select[bs, GottesmanInner[v, #]==1&];
If[ Length[w] == 0,
Return[bs],
w = First[w]
];
If[Length[w] == 0, Return[bs], w = First[w]];

new = Map[
Mod[# + w * GottesmanInner[v, #] + v * GottesmanInner[w, #], 2]&,
DeleteCases[Rest @ bs, w]
];
Join[{v, w}, new]
] /; ArrayQ @ bs
Join[{v, w}, GottesmanBasis @ DeleteCases[new, Table[0, Length @ v]]]
]

GottesmanBasis[v_?VectorQ] := One[Length @ v] /;
GottesmanBasis[v_?VectorQ] := IdentityMatrix[Length @ v] /;
v == UnitVector[Length @ v, 1]

GottesmanBasis[v_?VectorQ] := With[
{ id = IdentityMatrix[Length @ v] },
GottesmanBasis @ Join[{v}, Rest @ id]
GottesmanBasis @ Join[{v}, id]
]

GottesmanBasis[n_Integer] := One[2*n] /; n > 0
Expand Down Expand Up @@ -631,6 +636,16 @@ StabilizerStateQ[expr_] := StabilizerStateQ[Matrix @ expr]

StabilizerStateQ[expr_, ss:{__?QubitQ}] := StabilizerStateQ[Matrix @ expr]


StabilizerStateCount::usage = "StabilizerStateCount[n] returns the number of stabilizer states on an n-qubit system.\nStabilizerStateCount[{s1,s2,\[Ellipsis],sn}] is equivalent to StabilizerStateCount[n] for qubits s1, s2, \[Ellipsis], sn."
(* See: Aaronson and Gottesman (2004). *)

StabilizerStateCount[n_Integer] :=
Power[2, n] * Product[Power[2, k] + 1, {k, n}]

StabilizerStateCount[ss:{___?QubitQ}] :=
StabilizerStateCount[Length @ ss]

(**** </Stabilizer> ****)


Expand Down Expand Up @@ -810,7 +825,7 @@ GottesmanMatrixQ[mat_?MatrixQ] := Module[

GottesmanMatrix::usage = "GottesmanMatrix[mat] returns the binary symplectic matrix corresponding to the Clifford operator represented with matrix representation mat.\nGottesmanMatrix[op, {s$1,s$2,$$}] returns the binary symplectic matrix corresponding to Clifford operator op."

GottesmanMatrix::dimen = "`` has wrong dimensions and is not a valid matrix representation of a Clifford operator."
GottesmanMatrix::dim = "`` has wrong dimensions and is not a valid matrix representation of a Clifford operator."

GottesmanMatrix[op_, S_?QubitQ] := GottesmanMatrix[op, {FlavorNone @ S}]

Expand Down Expand Up @@ -839,7 +854,7 @@ GottesmanMatrix[mat_?MatrixQ] := Module[
{ n = Log[2, First @ Dimensions @ mat],
xz },
If[ Not @ IntegerQ[n],
Message[GottesmanMatrix::dimen, MatrixForm @ mat];
Message[GottesmanMatrix::dim, MatrixForm @ mat];
Return[{{}}]
];
xz = ThePauli @@@ Riffle[
Expand All @@ -852,7 +867,7 @@ GottesmanMatrix[mat_?MatrixQ] := Module[

FromGottesmanMatrix::usage = "FromGottesmanMatrix[mat, {s$1,s$2,$$}] returns the Clifford operator corresponding to binary symplectic matrix mat."

FromGottesmanMatrix::badmat = "`` is not a valid binary symplectic matrix."
FromGottesmanMatrix::spmat = "`` is not a valid binary symplectic matrix."

FromGottesmanMatrix[mat_?MatrixQ, ss:{_?QubitQ, __?QubitQ}] := Module[
{ n = Length @ ss,
Expand All @@ -863,12 +878,13 @@ FromGottesmanMatrix[mat_?MatrixQ, ss:{_?QubitQ, __?QubitQ}] := Module[
ff = Transpose[Partition[#, 2]& /@ Take[mat, 2]];
kk = FirstPosition[GottesmanInner @@@ ff, 1];

If[ MissingQ[kk],
Message[FromGottesmanMatrix::badmat, MatrixForm @ mat];
Return[1]
If[ MissingQ[kk],
Message[FromGottesmanMatrix::spmat, MatrixForm @ mat];
Return[1],
kk = First[kk]
];

If[ (kk = First[kk]) != 1,
If[ kk != 1,
cyc = CircleTimes[
PermutationMatrix[Cycles @ {{1, kk}}, n],
One[2]
Expand Down Expand Up @@ -1002,27 +1018,27 @@ GottesmanStandard[mat_?MatrixQ, off_?MatrixQ] := (
GottesmanStandard[mat_?MatrixQ, off_?MatrixQ] := Module[
{ vv = off,
xx, zz, rx, rz,
prm, new, m, n },
cx, cz, new, m, n },
{xx, zz} = GottesmanSplit[mat];
{m, n} = Dimensions[xx];

(* Gaussian elimitation of the X-part *)

new = RowReduce[ArrayFlatten @ {{xx, zz, vv}}, Modulus->2];
xx = new[[;;, ;;n]];
zz = new[[;;, n+1;;2n]];
vv = new[[;;, 2n+1;;]];

rx = MatrixRank[xx, Modulus->2];
prm = columnPivoting[new, 0, Range @ rx];
cx = columnPivoting[xx, 0, Range @ rx];

xx = Transpose @ Permute[Transpose @ xx, prm];
zz = Transpose @ Permute[Transpose @ zz, prm];
xx = Transpose @ Permute[Transpose @ xx, cx];
zz = Transpose @ Permute[Transpose @ zz, cx];

If[rx == m, Return @ {xx, zz, vv, prm}];
If[rx == m, Return @ {xx, zz, vv, cx}];

(* Gaussian elimitation of the Z-part *)

new = RotateLeft[#, n+rx]& /@ ArrayFlatten @ {{xx, zz, vv}};
new = Join[ new[[;;rx]], RowReduce[new[[rx+1;;]], Modulus->2] ];
new = RotateRight[#, n+rx]& /@ new;
Expand All @@ -1031,12 +1047,12 @@ GottesmanStandard[mat_?MatrixQ, off_?MatrixQ] := Module[
vv = new[[;;, 2n+1;;]];

rz = MatrixRank[zz[[rx+1;;, rx+1;;]], Modulus->2];
prm = columnPivoting[new, rx, Range @ rz];
cz = columnPivoting[zz, rx, Range @ rz];

xx = Transpose @ Permute[Transpose @ xx, prm];
zz = Transpose @ Permute[Transpose @ zz, prm];
xx = Transpose @ Permute[Transpose @ xx, cz];
zz = Transpose @ Permute[Transpose @ zz, cz];

Return @ {xx, zz, vv, prm}
Return @ {xx, zz, vv, PermutationProduct[cx, cz]}
]


Expand Down
6 changes: 3 additions & 3 deletions Q3/Kernel/Gray.wl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ BeginPackage["Q3`"]

`Gray`$Version = StringJoin[
$Input, " v",
StringSplit["$Revision: 1.88 $"][[2]], " (",
StringSplit["$Date: 2023-07-23 12:10:11+09 $"][[2]], ") ",
StringSplit["$Revision: 1.89 $"][[2]], " (",
StringSplit["$Date: 2023-07-28 00:03:42+09 $"][[2]], ") ",
"Mahn-Soo Choi"
];

Expand Down Expand Up @@ -79,7 +79,7 @@ Elaborate @ GrayTransform[ss:{__?QubitQ}] :=
Elaborate @ ExpressionFor[TheGrayTransform[Length @ ss], ss]

GrayTransform /:
Elaborate @ GrayTransform[n_Integer] := TheGrayTransform[n]
Elaborate @ GrayTransform[n_Integer] :=
Elaborate @ ExpressionFor[TheGrayTransform[n]]


Expand Down
12 changes: 10 additions & 2 deletions Q3/Kernel/Pauli.wl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ BeginPackage["Q3`"]

`Pauli`$Version = StringJoin[
$Input, " v",
StringSplit["$Revision: 6.4 $"][[2]], " (",
StringSplit["$Date: 2023-07-22 19:37:14+09 $"][[2]], ") ",
StringSplit["$Revision: 6.5 $"][[2]], " (",
StringSplit["$Date: 2023-07-30 10:41:31+09 $"][[2]], ") ",
"Mahn-Soo Choi"
];

Expand Down Expand Up @@ -2703,6 +2703,14 @@ Rotation[a:{_, {_, _, _}}, b:{_, {_, _, _}}..] :=

Rotation::axis = "The axis in `` is not proper."

Format[ op:Rotation[phi_, v:{_, _, _}, S:(_?SpinQ|_?QubitQ), rest___] ] :=
Interpretation[
DisplayForm @ RowBox @ { Exp,
RowBox @ {"(", -I * (phi/2) * Dot[S @ All, Normalize @ v], ")"}
},
op ]


Options[Rotation] = { "Label" -> Automatic }

Rotation[phi_, S:(_?SpinQ|_?QubitQ), opts___?OptionQ] := (
Expand Down
Loading

0 comments on commit c411a86

Please sign in to comment.