logo

Expression of type Forall

from the theory of proveit.physics.quantum.algebra

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 U, alpha, n
from proveit.linear_algebra import Norm, Unitary
from proveit.logic import CartExp, Equals, Forall
from proveit.numbers import Complex, RealNonNeg
from proveit.physics.quantum import Qmult, var_ket_psi
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [U], instance_expr = Forall(instance_param_or_params = [alpha], instance_expr = Forall(instance_param_or_params = [var_ket_psi], instance_expr = Equals(Norm(Qmult(U, var_ket_psi)), alpha), domain = CartExp(Complex, n), condition = Equals(Norm(var_ket_psi), alpha)), domain = RealNonNeg), domain = Unitary(n))
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_{U \in \textrm{U}\left(n\right)}~\left[\forall_{\alpha \in \mathbb{R}^{\ge 0}}~\left[\forall_{\lvert \psi \rangle \in \mathbb{C}^{n}~|~\left \|\lvert \psi \rangle\right \| = \alpha}~\left(\left \|U \thinspace \lvert \psi \rangle\right \| = \alpha\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: 17
operand: 2
1ExprTuple2
2Lambdaparameter: 46
body: 4
3ExprTuple46
4Conditionalvalue: 5
condition: 6
5Operationoperator: 17
operand: 9
6Operationoperator: 32
operands: 8
7ExprTuple9
8ExprTuple46, 10
9Lambdaparameter: 39
body: 12
10Operationoperator: 13
operand: 48
11ExprTuple39
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple48
15Operationoperator: 17
operand: 20
16Operationoperator: 32
operands: 19
17Literal
18ExprTuple20
19ExprTuple39, 21
20Lambdaparameter: 49
body: 22
21Literal
22Conditionalvalue: 23
condition: 24
23Operationoperator: 34
operands: 25
24Operationoperator: 26
operands: 27
25ExprTuple28, 39
26Literal
27ExprTuple29, 30
28Operationoperator: 44
operand: 36
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 35
31ExprTuple36
32Literal
33ExprTuple49, 37
34Literal
35ExprTuple38, 39
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operands: 43
38Operationoperator: 44
operand: 49
39Variable
40Literal
41ExprTuple46, 49
42Literal
43ExprTuple47, 48
44Literal
45ExprTuple49
46Variable
47Literal
48Variable
49Variable