logo

Expression of type And

from the theory of proveit.physics.quantum.QPE

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import ExprRange, Variable, t
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.logic import And, CartExp, InSet
from proveit.numbers import Add, Complex, Exp, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = And(ExprRange(sub_expr1, InSet(ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), CartExp(Complex, Exp(two, one))), Add(Neg(t), two), zero))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-\left(-t + 2\right)} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) \in \mathbb{C}^{2^{1}}\right) \land  \left(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-\left(-t + 3\right)} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) \in \mathbb{C}^{2^{1}}\right) \land  \ldots \land  \left(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-0} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) \in \mathbb{C}^{2^{1}}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3
3ExprRangelambda_map: 4
start_index: 5
end_index: 35
4Lambdaparameter: 58
body: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 54
9Literal
10ExprTuple12, 13
11Operationoperator: 56
operand: 18
12Operationoperator: 32
operands: 15
13Operationoperator: 16
operands: 17
14ExprTuple18
15ExprTuple19, 20
16Literal
17ExprTuple21, 22
18Variable
19Operationoperator: 38
operands: 23
20Operationoperator: 24
operands: 25
21Literal
22Operationoperator: 52
operands: 26
23ExprTuple45, 27
24Literal
25ExprTuple28, 29
26ExprTuple54, 45
27Operationoperator: 52
operands: 30
28Operationoperator: 41
operand: 35
29Operationoperator: 32
operands: 33
30ExprTuple54, 34
31ExprTuple35
32Literal
33ExprTuple36, 37
34Operationoperator: 38
operands: 39
35Literal
36Operationoperator: 52
operands: 40
37Operationoperator: 41
operand: 45
38Literal
39ExprTuple45, 54
40ExprTuple43, 44
41Literal
42ExprTuple45
43Literal
44Operationoperator: 46
operands: 47
45Literal
46Literal
47ExprTuple54, 48, 49, 50, 51
48Literal
49Literal
50Operationoperator: 52
operands: 53
51Literal
52Literal
53ExprTuple54, 55
54Literal
55Operationoperator: 56
operand: 58
56Literal
57ExprTuple58
58Variable