# 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, 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 = 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\{\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..

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: 11
operand: 5
2Operationoperator: 23
operands: 4
3ExprTuple5
4ExprTuple34, 6
5Lambdaparameter: 31
body: 8
6Literal
7ExprTuple31
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 14
10Operationoperator: 23
operands: 13
11Literal
12ExprTuple14
13ExprTuple31, 15
14Lambdaparameter: 32
body: 17
15Operationoperator: 18
operand: 34
16ExprTuple32
17Conditionalvalue: 20
condition: 21
18Literal
19ExprTuple34
20Operationoperator: 23
operands: 22
21Operationoperator: 23
operands: 24
22ExprTuple25, 26
23Literal
24ExprTuple32, 26
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Variable
32Variable
33Literal
34Variable