QSP Conventions¶
qsp_proc.conventions
¶
QSP convention definitions (Angle, Symmetric, Laurent, Generalized).
AngleQSP
¶
Angle-QSP polynomial validator based on Lemma 1.
The checks are sampled numerical versions of the four constraints:
1) parity n mod 2,
2) |P(x)| <= 1 for x in [-1, 1],
3) |P(x)| >= 1 for x in (-inf,-1] U [1,inf),
4) when n is even, P(i x) P*(i x) >= 1 for all real x.
Source code in src\qsp_proc\conventions\angle_qsp.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
__init__(target_degree=None, *, interior_samples=2049, exterior_samples=2049, imaginary_axis_samples=2049, exterior_bound=8.0, imaginary_axis_bound=8.0, tol=1e-12)
¶
Initialize numerical validation settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_degree
|
int | None
|
Optional Lemma-1 degree |
None
|
interior_samples
|
int
|
Number of samples on |
2049
|
exterior_samples
|
int
|
Number of samples on each exterior interval. |
2049
|
imaginary_axis_samples
|
int
|
Number of samples on imaginary-axis grid. |
2049
|
exterior_bound
|
float
|
Finite proxy for |
8.0
|
imaginary_axis_bound
|
float
|
Sample range for condition 4. |
8.0
|
tol
|
float
|
Numerical tolerance used in inequality checks. |
1e-12
|
Source code in src\qsp_proc\conventions\angle_qsp.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
condition_1_parity(poly)
¶
Check Lemma-1 condition 1: parity equals n mod 2.
If target_degree is provided, this also enforces deg(P) < n.
Source code in src\qsp_proc\conventions\angle_qsp.py
78 79 80 81 82 83 84 85 86 87 88 89 90 | |
condition_2_unit_interval(poly)
¶
Check Lemma-1 condition 2 on sampled [-1, 1].
Source code in src\qsp_proc\conventions\angle_qsp.py
92 93 94 95 96 | |
condition_3_exterior(poly)
¶
Check Lemma-1 condition 3 on sampled exterior intervals.
Source code in src\qsp_proc\conventions\angle_qsp.py
98 99 100 101 102 103 104 105 106 | |
condition_4_imaginary_axis(poly)
¶
Check Lemma-1 condition 4 when n is even.
Source code in src\qsp_proc\conventions\angle_qsp.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
validate_polynomial(poly)
¶
Check all Lemma-1 conditions for an Angle-QSP polynomial.
Source code in src\qsp_proc\conventions\angle_qsp.py
123 124 125 126 127 128 129 130 131 | |
completion_problem(poly)
¶
Return completion residual for |Q|^2 = 1 - |P|^2.
Source code in src\qsp_proc\conventions\angle_qsp.py
133 134 135 136 137 138 139 140 141 | |
circuit_cost(degree)
¶
Return coarse Angle-QSP gate counts from Sec. 3.3.2.
This returns convention-level symbolic counts rather than hardware specific gate costs.
Source code in src\qsp_proc\conventions\angle_qsp.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
GeneralizedQSP
¶
Generalized-QSP validator based on Lemma 4.
Lemma 4 requires exactly the unit-circle boundedness condition:
|P(z)|^2 <= 1 for all z in U(1).
Source code in src\qsp_proc\conventions\generalized_qsp.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
__init__(*, unit_circle_samples=4096, tol=1e-12)
¶
Initialize numerical validation settings.
Source code in src\qsp_proc\conventions\generalized_qsp.py
31 32 33 34 | |
condition_1_unit_circle_bound(poly)
¶
Check Lemma-4 bound |P(z)|^2 <= 1 on sampled U(1).
Source code in src\qsp_proc\conventions\generalized_qsp.py
43 44 45 46 47 48 | |
validate_polynomial(poly)
¶
Validate a polynomial against the Lemma-4 condition.
Source code in src\qsp_proc\conventions\generalized_qsp.py
50 51 52 | |
completion_problem(poly)
¶
Return completion residual 1 - |P(z)|^2.
Source code in src\qsp_proc\conventions\generalized_qsp.py
54 55 56 57 58 59 60 61 62 | |
circuit_cost(degree)
¶
Return coarse G-QSP gate counts from Sec. 3.3.1.
Source code in src\qsp_proc\conventions\generalized_qsp.py
64 65 66 67 68 69 70 71 72 73 | |
LaurentQSP
¶
Laurent-QSP polynomial validator based on Lemma 3.
Conditions checked numerically:
1) A and B are real-on-circle,
2) A and B are pure (reciprocal or anti-reciprocal),
3) A(e^{i theta})^2 + B(e^{i theta})^2 <= 1 on sampled unit-circle points.
Source code in src\qsp_proc\conventions\laurent_qsp.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
__init__(*, unit_circle_samples=4096, tol=1e-12)
¶
Initialize numerical validation settings.
Source code in src\qsp_proc\conventions\laurent_qsp.py
34 35 36 37 | |
condition_1_real_on_circle(a, b)
¶
Check Lemma-3 real-on-circle requirement for A and B.
Source code in src\qsp_proc\conventions\laurent_qsp.py
46 47 48 49 50 51 52 53 54 55 56 57 | |
condition_2_pure(a, b)
¶
Check Lemma-3 purity (reciprocal or anti-reciprocal).
Source code in src\qsp_proc\conventions\laurent_qsp.py
59 60 61 62 63 64 65 | |
condition_3_bounded_sum(a, b)
¶
Check Lemma-3 bound A^2 + B^2 <= 1 on U(1).
Source code in src\qsp_proc\conventions\laurent_qsp.py
67 68 69 70 71 72 73 74 | |
validate_polynomial(polys)
¶
Validate a pair (A, B) against Lemma-3 constraints.
Source code in src\qsp_proc\conventions\laurent_qsp.py
76 77 78 79 80 81 82 83 | |
completion_problem(polys)
¶
Return completion residual 1 - A^2 - B^2 on the unit circle.
Source code in src\qsp_proc\conventions\laurent_qsp.py
85 86 87 88 89 90 91 92 93 94 | |
circuit_cost(degree)
¶
Return coarse Laurent-QSP gate counts from Sec. 3.3.3.
Source code in src\qsp_proc\conventions\laurent_qsp.py
96 97 98 99 100 101 102 103 104 105 106 107 | |
SymmetricQSP
¶
Symmetric-QSP validator based on Lemma 2.
Conditions checked numerically:
1) deg(P)=n and deg(Q)=n-1,
2) parity of P is n mod 2 and parity of Q is (n-1) mod 2,
3) |P(x)|^2 + (1-x^2)|Q(x)|^2 = 1 on [-1,1],
4) |P(x)| >= 1 on (-inf,-1] U [1,inf),
5) if n is odd, leading coefficient of Q is positive.
Source code in src\qsp_proc\conventions\sym_qsp.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
__init__(target_degree=None, *, interior_samples=2049, exterior_samples=2049, exterior_bound=8.0, tol=1e-12)
¶
Initialize numerical validation settings.
Source code in src\qsp_proc\conventions\sym_qsp.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
condition_1_degree(p, q)
¶
Check Lemma-2 condition 1 on degrees.
Source code in src\qsp_proc\conventions\sym_qsp.py
63 64 65 66 67 68 69 70 71 72 | |
condition_2_parity(p, q)
¶
Check Lemma-2 condition 2 on parity.
Source code in src\qsp_proc\conventions\sym_qsp.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
condition_3_unit_interval_identity(p, q)
¶
Check Lemma-2 condition 3 on [-1,1].
Source code in src\qsp_proc\conventions\sym_qsp.py
89 90 91 92 93 94 95 96 97 98 99 | |
condition_4_exterior(p)
¶
Check Lemma-2 condition 4 on sampled exterior intervals.
Source code in src\qsp_proc\conventions\sym_qsp.py
101 102 103 104 105 106 107 108 109 | |
condition_5_leading_q(p, q)
¶
Check Lemma-2 condition 5 when n is odd.
Source code in src\qsp_proc\conventions\sym_qsp.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
validate_polynomial(polys)
¶
Validate a pair (P, Q) against all Lemma-2 conditions.
Source code in src\qsp_proc\conventions\sym_qsp.py
128 129 130 131 132 133 134 135 136 137 138 139 140 | |
completion_problem(p)
¶
Return the symmetric completion target for |Q|^2.
Source code in src\qsp_proc\conventions\sym_qsp.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
circuit_cost(degree)
¶
Return coarse symmetric-QSP gate counts.
Source code in src\qsp_proc\conventions\sym_qsp.py
160 161 162 163 164 165 166 167 168 169 170 171 | |
qsp_proc.conventions.angle_qsp
¶
Lemma 1: Angle-QSP convention checks and helpers.
CompletionProblem
dataclass
¶
Container for the Angle-QSP completion relation.
This encodes the Lemma 1 completion target
|Q(x)|^2 = 1 - |P(x)|^2.
Source code in src\qsp_proc\conventions\angle_qsp.py
13 14 15 16 17 18 19 20 21 22 23 | |
AngleQSP
¶
Angle-QSP polynomial validator based on Lemma 1.
The checks are sampled numerical versions of the four constraints:
1) parity n mod 2,
2) |P(x)| <= 1 for x in [-1, 1],
3) |P(x)| >= 1 for x in (-inf,-1] U [1,inf),
4) when n is even, P(i x) P*(i x) >= 1 for all real x.
Source code in src\qsp_proc\conventions\angle_qsp.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
__init__(target_degree=None, *, interior_samples=2049, exterior_samples=2049, imaginary_axis_samples=2049, exterior_bound=8.0, imaginary_axis_bound=8.0, tol=1e-12)
¶
Initialize numerical validation settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_degree
|
int | None
|
Optional Lemma-1 degree |
None
|
interior_samples
|
int
|
Number of samples on |
2049
|
exterior_samples
|
int
|
Number of samples on each exterior interval. |
2049
|
imaginary_axis_samples
|
int
|
Number of samples on imaginary-axis grid. |
2049
|
exterior_bound
|
float
|
Finite proxy for |
8.0
|
imaginary_axis_bound
|
float
|
Sample range for condition 4. |
8.0
|
tol
|
float
|
Numerical tolerance used in inequality checks. |
1e-12
|
Source code in src\qsp_proc\conventions\angle_qsp.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
condition_1_parity(poly)
¶
Check Lemma-1 condition 1: parity equals n mod 2.
If target_degree is provided, this also enforces deg(P) < n.
Source code in src\qsp_proc\conventions\angle_qsp.py
78 79 80 81 82 83 84 85 86 87 88 89 90 | |
condition_2_unit_interval(poly)
¶
Check Lemma-1 condition 2 on sampled [-1, 1].
Source code in src\qsp_proc\conventions\angle_qsp.py
92 93 94 95 96 | |
condition_3_exterior(poly)
¶
Check Lemma-1 condition 3 on sampled exterior intervals.
Source code in src\qsp_proc\conventions\angle_qsp.py
98 99 100 101 102 103 104 105 106 | |
condition_4_imaginary_axis(poly)
¶
Check Lemma-1 condition 4 when n is even.
Source code in src\qsp_proc\conventions\angle_qsp.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
validate_polynomial(poly)
¶
Check all Lemma-1 conditions for an Angle-QSP polynomial.
Source code in src\qsp_proc\conventions\angle_qsp.py
123 124 125 126 127 128 129 130 131 | |
completion_problem(poly)
¶
Return completion residual for |Q|^2 = 1 - |P|^2.
Source code in src\qsp_proc\conventions\angle_qsp.py
133 134 135 136 137 138 139 140 141 | |
circuit_cost(degree)
¶
Return coarse Angle-QSP gate counts from Sec. 3.3.2.
This returns convention-level symbolic counts rather than hardware specific gate costs.
Source code in src\qsp_proc\conventions\angle_qsp.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
qsp_proc.conventions.laurent_qsp
¶
Lemma 3: Laurent-QSP convention checks and helpers.
LaurentCompletionProblem
dataclass
¶
Container for the Laurent completion relation.
For Laurent-QSP we solve for complementary terms from
A(z)^2 + B(z)^2 + C(z)^2 + D(z)^2 = 1 on z in U(1).
Source code in src\qsp_proc\conventions\laurent_qsp.py
13 14 15 16 17 18 19 20 21 22 | |
LaurentQSP
¶
Laurent-QSP polynomial validator based on Lemma 3.
Conditions checked numerically:
1) A and B are real-on-circle,
2) A and B are pure (reciprocal or anti-reciprocal),
3) A(e^{i theta})^2 + B(e^{i theta})^2 <= 1 on sampled unit-circle points.
Source code in src\qsp_proc\conventions\laurent_qsp.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
__init__(*, unit_circle_samples=4096, tol=1e-12)
¶
Initialize numerical validation settings.
Source code in src\qsp_proc\conventions\laurent_qsp.py
34 35 36 37 | |
condition_1_real_on_circle(a, b)
¶
Check Lemma-3 real-on-circle requirement for A and B.
Source code in src\qsp_proc\conventions\laurent_qsp.py
46 47 48 49 50 51 52 53 54 55 56 57 | |
condition_2_pure(a, b)
¶
Check Lemma-3 purity (reciprocal or anti-reciprocal).
Source code in src\qsp_proc\conventions\laurent_qsp.py
59 60 61 62 63 64 65 | |
condition_3_bounded_sum(a, b)
¶
Check Lemma-3 bound A^2 + B^2 <= 1 on U(1).
Source code in src\qsp_proc\conventions\laurent_qsp.py
67 68 69 70 71 72 73 74 | |
validate_polynomial(polys)
¶
Validate a pair (A, B) against Lemma-3 constraints.
Source code in src\qsp_proc\conventions\laurent_qsp.py
76 77 78 79 80 81 82 83 | |
completion_problem(polys)
¶
Return completion residual 1 - A^2 - B^2 on the unit circle.
Source code in src\qsp_proc\conventions\laurent_qsp.py
85 86 87 88 89 90 91 92 93 94 | |
circuit_cost(degree)
¶
Return coarse Laurent-QSP gate counts from Sec. 3.3.3.
Source code in src\qsp_proc\conventions\laurent_qsp.py
96 97 98 99 100 101 102 103 104 105 106 107 | |
qsp_proc.conventions.generalized_qsp
¶
Lemma 4: Generalized-QSP convention checks and helpers.
GeneralizedCompletionProblem
dataclass
¶
Container for generalized-QSP completion relation.
In G-QSP, completion enforces |Q(z)|^2 = 1 - |P(z)|^2 on z in U(1).
Source code in src\qsp_proc\conventions\generalized_qsp.py
13 14 15 16 17 18 19 20 21 | |
GeneralizedQSP
¶
Generalized-QSP validator based on Lemma 4.
Lemma 4 requires exactly the unit-circle boundedness condition:
|P(z)|^2 <= 1 for all z in U(1).
Source code in src\qsp_proc\conventions\generalized_qsp.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
__init__(*, unit_circle_samples=4096, tol=1e-12)
¶
Initialize numerical validation settings.
Source code in src\qsp_proc\conventions\generalized_qsp.py
31 32 33 34 | |
condition_1_unit_circle_bound(poly)
¶
Check Lemma-4 bound |P(z)|^2 <= 1 on sampled U(1).
Source code in src\qsp_proc\conventions\generalized_qsp.py
43 44 45 46 47 48 | |
validate_polynomial(poly)
¶
Validate a polynomial against the Lemma-4 condition.
Source code in src\qsp_proc\conventions\generalized_qsp.py
50 51 52 | |
completion_problem(poly)
¶
Return completion residual 1 - |P(z)|^2.
Source code in src\qsp_proc\conventions\generalized_qsp.py
54 55 56 57 58 59 60 61 62 | |
circuit_cost(degree)
¶
Return coarse G-QSP gate counts from Sec. 3.3.1.
Source code in src\qsp_proc\conventions\generalized_qsp.py
64 65 66 67 68 69 70 71 72 73 | |
qsp_proc.conventions.sym_qsp
¶
Lemma 2: Symmetric-QSP convention checks and helpers.
SymmetricCompletionProblem
dataclass
¶
Container for the symmetric completion relation.
In the standard symmetric-QSP form this is
|Q(x)|^2 = (1 - |P(x)|^2) / (1 - x^2) for x in (-1, 1).
Source code in src\qsp_proc\conventions\sym_qsp.py
13 14 15 16 17 18 19 20 21 22 | |
SymmetricQSP
¶
Symmetric-QSP validator based on Lemma 2.
Conditions checked numerically:
1) deg(P)=n and deg(Q)=n-1,
2) parity of P is n mod 2 and parity of Q is (n-1) mod 2,
3) |P(x)|^2 + (1-x^2)|Q(x)|^2 = 1 on [-1,1],
4) |P(x)| >= 1 on (-inf,-1] U [1,inf),
5) if n is odd, leading coefficient of Q is positive.
Source code in src\qsp_proc\conventions\sym_qsp.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
__init__(target_degree=None, *, interior_samples=2049, exterior_samples=2049, exterior_bound=8.0, tol=1e-12)
¶
Initialize numerical validation settings.
Source code in src\qsp_proc\conventions\sym_qsp.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
condition_1_degree(p, q)
¶
Check Lemma-2 condition 1 on degrees.
Source code in src\qsp_proc\conventions\sym_qsp.py
63 64 65 66 67 68 69 70 71 72 | |
condition_2_parity(p, q)
¶
Check Lemma-2 condition 2 on parity.
Source code in src\qsp_proc\conventions\sym_qsp.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
condition_3_unit_interval_identity(p, q)
¶
Check Lemma-2 condition 3 on [-1,1].
Source code in src\qsp_proc\conventions\sym_qsp.py
89 90 91 92 93 94 95 96 97 98 99 | |
condition_4_exterior(p)
¶
Check Lemma-2 condition 4 on sampled exterior intervals.
Source code in src\qsp_proc\conventions\sym_qsp.py
101 102 103 104 105 106 107 108 109 | |
condition_5_leading_q(p, q)
¶
Check Lemma-2 condition 5 when n is odd.
Source code in src\qsp_proc\conventions\sym_qsp.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
validate_polynomial(polys)
¶
Validate a pair (P, Q) against all Lemma-2 conditions.
Source code in src\qsp_proc\conventions\sym_qsp.py
128 129 130 131 132 133 134 135 136 137 138 139 140 | |
completion_problem(p)
¶
Return the symmetric completion target for |Q|^2.
Source code in src\qsp_proc\conventions\sym_qsp.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
circuit_cost(degree)
¶
Return coarse symmetric-QSP gate counts.
Source code in src\qsp_proc\conventions\sym_qsp.py
160 161 162 163 164 165 166 167 168 169 170 171 | |