logo

Expression of type Conditional

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 Conditional, U, alpha, n
from proveit.linear_algebra import Norm, Unitary
from proveit.logic import CartExp, Equals, Forall, InSet
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 = Conditional(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), InSet(U, 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())
\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] \textrm{ if } U \in \textrm{U}\left(n\right)\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 13
operand: 5
2Operationoperator: 28
operands: 4
3ExprTuple5
4ExprTuple42, 6
5Lambdaparameter: 35
body: 8
6Operationoperator: 9
operand: 44
7ExprTuple35
8Conditionalvalue: 11
condition: 12
9Literal
10ExprTuple44
11Operationoperator: 13
operand: 16
12Operationoperator: 28
operands: 15
13Literal
14ExprTuple16
15ExprTuple35, 17
16Lambdaparameter: 45
body: 18
17Literal
18Conditionalvalue: 19
condition: 20
19Operationoperator: 30
operands: 21
20Operationoperator: 22
operands: 23
21ExprTuple24, 35
22Literal
23ExprTuple25, 26
24Operationoperator: 40
operand: 32
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple32
28Literal
29ExprTuple45, 33
30Literal
31ExprTuple34, 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operands: 39
34Operationoperator: 40
operand: 45
35Variable
36Literal
37ExprTuple42, 45
38Literal
39ExprTuple43, 44
40Literal
41ExprTuple45
42Variable
43Literal
44Variable
45Variable