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, Function, Lambda, U, Variable, s, t
from proveit.logic import And, Forall, InSet
from proveit.physics.quantum import normalized_var_ket_u, var_ket_u
from proveit.physics.quantum.QPE import phase, s_ket_domain
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(var_ket_u, Conditional(Forall(instance_param_or_params = [phase], instance_expr = Function(Variable("_b", latex_format = r"{_{-}b}"), [s, t, U, var_ket_u, phase])), And(InSet(var_ket_u, s_ket_domain), normalized_var_ket_u))))
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(\lvert u \rangle \mapsto \left\{\forall_{\varphi}~{_{-}b}\left(s, t, U, \lvert u \rangle, \varphi\right) \textrm{ if } \lvert u \rangle \in \mathbb{C}^{2^{s}} ,  \left \|\lvert u \rangle\right \| = 1\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 32
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 25
body: 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operands: 17
12ExprTuple25
13Operationoperator: 18
operands: 19
14Literal
15ExprTuple32, 20
16Literal
17ExprTuple21, 22
18Variable
19ExprTuple36, 23, 24, 32, 25
20Operationoperator: 26
operands: 27
21Operationoperator: 28
operand: 32
22Literal
23Variable
24Variable
25Variable
26Literal
27ExprTuple30, 31
28Literal
29ExprTuple32
30Literal
31Operationoperator: 33
operands: 34
32Variable
33Literal
34ExprTuple35, 36
35Literal
36Variable