logo

Expression of type ExprTuple

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, ExprTuple, Variable, t
from proveit.linear_algebra import MatrixExp, Unitary
from proveit.logic import And, Forall, InSet
from proveit.numbers import Add, Exp, Interval, Neg, one, two, zero
from proveit.physics.quantum.QPE import _U, _s
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Add(Neg(t), one)
sub_expr3 = InSet(MatrixExp(_U, Exp(two, Neg(sub_expr1))), Unitary(Exp(two, _s)))
expr = ExprTuple(Forall(instance_param_or_params = [sub_expr1], instance_expr = sub_expr3, domain = Interval(sub_expr2, zero)), And(ExprRange(sub_expr1, sub_expr3, sub_expr2, 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(\forall_{{_{-}a} \in \{-t + 1~\ldotp \ldotp~0\}}~\left(U^{2^{-{_{-}a}}} \in \textrm{U}\left(2^{s}\right)\right), \left(U^{2^{-\left(-t + 1\right)}} \in \textrm{U}\left(2^{s}\right)\right) \land  \left(U^{2^{-\left(-t + 2\right)}} \in \textrm{U}\left(2^{s}\right)\right) \land  \ldots \land  \left(U^{2^{-0}} \in \textrm{U}\left(2^{s}\right)\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8
7Lambdaparameter: 44
body: 9
8ExprRangelambda_map: 10
start_index: 25
end_index: 26
9Conditionalvalue: 12
condition: 11
10Lambdaparameter: 44
body: 12
11Operationoperator: 14
operands: 13
12Operationoperator: 14
operands: 15
13ExprTuple44, 16
14Literal
15ExprTuple17, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operand: 29
19Literal
20ExprTuple25, 26
21Literal
22ExprTuple27, 28
23Literal
24ExprTuple29
25Operationoperator: 30
operands: 31
26Literal
27Literal
28Operationoperator: 33
operands: 32
29Operationoperator: 33
operands: 34
30Literal
31ExprTuple35, 36
32ExprTuple38, 37
33Literal
34ExprTuple38, 39
35Operationoperator: 41
operand: 43
36Literal
37Operationoperator: 41
operand: 44
38Literal
39Literal
40ExprTuple43
41Literal
42ExprTuple44
43Variable
44Variable