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, NaturalPos, 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 = [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)), InSet(n, 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())
\left\{\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] \textrm{ if } n \in \mathbb{N}^+\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: 21
operand: 5
2Operationoperator: 36
operands: 4
3ExprTuple5
4ExprTuple52, 6
5Lambdaparameter: 50
body: 8
6Literal
7ExprTuple50
8Conditionalvalue: 9
condition: 10
9Operationoperator: 21
operand: 13
10Operationoperator: 36
operands: 12
11ExprTuple13
12ExprTuple50, 14
13Lambdaparameter: 43
body: 16
14Operationoperator: 17
operand: 52
15ExprTuple43
16Conditionalvalue: 19
condition: 20
17Literal
18ExprTuple52
19Operationoperator: 21
operand: 24
20Operationoperator: 36
operands: 23
21Literal
22ExprTuple24
23ExprTuple43, 25
24Lambdaparameter: 53
body: 26
25Literal
26Conditionalvalue: 27
condition: 28
27Operationoperator: 38
operands: 29
28Operationoperator: 30
operands: 31
29ExprTuple32, 43
30Literal
31ExprTuple33, 34
32Operationoperator: 48
operand: 40
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35ExprTuple40
36Literal
37ExprTuple53, 41
38Literal
39ExprTuple42, 43
40Operationoperator: 44
operands: 45
41Operationoperator: 46
operands: 47
42Operationoperator: 48
operand: 53
43Variable
44Literal
45ExprTuple50, 53
46Literal
47ExprTuple51, 52
48Literal
49ExprTuple53
50Variable
51Literal
52Variable
53Variable