# 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.
# import Expression classes needed to build the expression
from proveit import Conditional, ExprTuple, Lambda, U, n
from proveit.linear_algebra import Unitary
from proveit.logic import CartExp, Forall, InSet
from proveit.numbers import Complex, NaturalPos
from proveit.physics.quantum import Qmult, var_ket_psi

In [2]:
# build up the expression from sub-expressions
sub_expr1 = CartExp(Complex, n)
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [U], instance_expr = Forall(instance_param_or_params = [var_ket_psi], instance_expr = InSet(Qmult(U, var_ket_psi), sub_expr1), domain = sub_expr1), 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(n \mapsto \left\{\forall_{U \in \textrm{U}\left(n\right)}~\left[\forall_{\lvert \psi \rangle \in \mathbb{C}^{n}}~\left(\left(U \thinspace \lvert \psi \rangle\right) \in \mathbb{C}^{n}\right)\right] \textrm{ if } n \in \mathbb{N}^+\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: 36
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 13
operand: 7
4Operationoperator: 25
operands: 6
5ExprTuple7
6ExprTuple36, 8
7Lambdaparameter: 33
body: 10
8Literal
9ExprTuple33
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operand: 16
12Operationoperator: 25
operands: 15
13Literal
14ExprTuple16
15ExprTuple33, 17
16Lambdaparameter: 34
body: 19
17Operationoperator: 20
operand: 36
18ExprTuple34
19Conditionalvalue: 22
condition: 23
20Literal
21ExprTuple36
22Operationoperator: 25
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple27, 28
25Literal
26ExprTuple34, 28
27Operationoperator: 29
operands: 30
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Variable
34Variable
35Literal
36Variable