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 Conditional, ExprTuple, l
from proveit.logic import And, InSet, TRUE
from proveit.numbers import Abs, Exp, two
from proveit.physics.quantum.QPE import _pos_domain, _rel_indexed_alpha
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(Abs(_rel_indexed_alpha), two)
sub_expr2 = InSet(l, _pos_domain)
expr = ExprTuple(Conditional(sub_expr1, And(sub_expr2, TRUE)), Conditional(sub_expr1, sub_expr2))
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|\alpha_{b_{\textit{f}} \oplus l}\right|^{2} \textrm{ if } l \in \{e + 1~\ldotp \ldotp~2^{t - 1}\} ,  \top, \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2} \textrm{ if } l \in \{e + 1~\ldotp \ldotp~2^{t - 1}\}\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
1Conditionalvalue: 4
condition: 3
2Conditionalvalue: 4
condition: 8
3Operationoperator: 5
operands: 6
4Operationoperator: 25
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple10, 30
8Operationoperator: 11
operands: 12
9Literal
10Operationoperator: 13
operand: 16
11Literal
12ExprTuple33, 15
13Literal
14ExprTuple16
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operand: 23
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23
21Operationoperator: 34
operands: 24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24ExprTuple29, 40
25Literal
26ExprTuple30, 31
27Literal
28ExprTuple32, 33
29Variable
30Literal
31Operationoperator: 34
operands: 35
32Literal
33Variable
34Literal
35ExprTuple36, 37
36Literal
37Operationoperator: 38
operand: 40
38Literal
39ExprTuple40
40Literal