logo

Expression of type Forall

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 Function, U, Variable, s, t
from proveit.linear_algebra import Unitary
from proveit.logic import Forall
from proveit.numbers import NaturalPos
from proveit.physics.quantum import normalized_var_ket_u, var_ket_u
from proveit.physics.quantum.QPE import phase, s_ket_domain, two_pow_s
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [s, t], instance_expr = Forall(instance_param_or_params = [U], instance_expr = Forall(instance_param_or_params = [var_ket_u], instance_expr = Forall(instance_param_or_params = [phase], instance_expr = Function(Variable("_b", latex_format = r"{_{-}b}"), [s, t, U, var_ket_u, phase])), domain = s_ket_domain, condition = normalized_var_ket_u), domain = Unitary(two_pow_s)), domain = NaturalPos)
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())
\forall_{s, t \in \mathbb{N}^+}~\left[\forall_{U \in \textrm{U}\left(2^{s}\right)}~\left[\forall_{\lvert u \rangle \in \mathbb{C}^{2^{s}}~|~\left \|\lvert u \rangle\right \| = 1}~\left[\forall_{\varphi}~{_{-}b}\left(s, t, U, \lvert u \rangle, \varphi\right)\right]\right]\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 28
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple59, 46
4Conditionalvalue: 5
condition: 6
5Operationoperator: 28
operand: 9
6Operationoperator: 30
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameter: 47
body: 13
10Operationoperator: 37
operands: 14
11Operationoperator: 37
operands: 15
12ExprTuple47
13Conditionalvalue: 16
condition: 17
14ExprTuple59, 18
15ExprTuple46, 18
16Operationoperator: 28
operand: 21
17Operationoperator: 37
operands: 20
18Literal
19ExprTuple21
20ExprTuple47, 22
21Lambdaparameter: 55
body: 23
22Operationoperator: 24
operand: 54
23Conditionalvalue: 26
condition: 27
24Literal
25ExprTuple54
26Operationoperator: 28
operand: 32
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32
30Literal
31ExprTuple33, 34
32Lambdaparameter: 48
body: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operands: 40
35ExprTuple48
36Operationoperator: 41
operands: 42
37Literal
38ExprTuple55, 43
39Literal
40ExprTuple44, 45
41Variable
42ExprTuple59, 46, 47, 55, 48
43Operationoperator: 49
operands: 50
44Operationoperator: 51
operand: 55
45Literal
46Variable
47Variable
48Variable
49Literal
50ExprTuple53, 54
51Literal
52ExprTuple55
53Literal
54Operationoperator: 56
operands: 57
55Variable
56Literal
57ExprTuple58, 59
58Literal
59Variable