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, i, j, n
from proveit.core_expr_types import v_1_to_n, v_i, v_j
from proveit.linear_algebra import Adj, MatrixSpace, OrthoNormBases, Unitary
from proveit.logic import CartExp, Equals, Forall, Implies, InSet, Set
from proveit.numbers import Complex, Interval, KroneckerDelta, NaturalPos, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [U], instance_expr = Forall(instance_param_or_params = [v_1_to_n], instance_expr = Implies(Forall(instance_param_or_params = [i, j], instance_expr = Equals(Qmult(Bra(v_i), Adj(U), U, Ket(v_j)), KroneckerDelta(i, j)), domain = Interval(one, n)), InSet(U, Unitary(n))), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(CartExp(Complex, n)))).with_wrapping(), domain = MatrixSpace(field = Complex, rows = n, columns = 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 \mathbb{C}^{n \times n}}~\left[\begin{array}{l}\forall_{v_{1}, v_{2}, \ldots, v_{n}~|~\left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right)}~\\
\left(\left[\forall_{i, j \in \{1~\ldotp \ldotp~n\}}~\left(\left(\langle v_{i} \rvert \thinspace U^{\dagger} \thinspace U \thinspace \lvert v_{j} \rangle\right) = \delta_{i, j}\right)\right] \Rightarrow \left(U \in \textrm{U}\left(n\right)\right)\right)\end{array}\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: 29
operand: 5
2Operationoperator: 65
operands: 4
3ExprTuple5
4ExprTuple86, 6
5Lambdaparameter: 83
body: 7
6Literal
7Conditionalvalue: 8
condition: 9
8Operationoperator: 29
operand: 12
9Operationoperator: 65
operands: 11
10ExprTuple12
11ExprTuple83, 13
12Lambdaparameters: 14
body: 15
13Operationoperator: 16
operands: 17
14ExprTuple18
15Conditionalvalue: 19
condition: 20
16Literal
17NamedExprsfield: 49
rows: 86
columns: 86
18ExprRangelambda_map: 21
start_index: 85
end_index: 86
19Operationoperator: 22
operands: 23
20Operationoperator: 65
operands: 24
21Lambdaparameter: 87
body: 72
22Literal
23ExprTuple25, 26
24ExprTuple27, 28
25Operationoperator: 29
operand: 35
26Operationoperator: 65
operands: 31
27Operationoperator: 42
operand: 37
28Operationoperator: 33
operand: 38
29Literal
30ExprTuple35
31ExprTuple83, 36
32ExprTuple37
33Literal
34ExprTuple38
35Lambdaparameters: 63
body: 39
36Operationoperator: 40
operand: 86
37Operationoperator: 42
operands: 43
38Operationoperator: 44
operands: 45
39Conditionalvalue: 46
condition: 47
40Literal
41ExprTuple86
42Literal
43ExprTuple48
44Literal
45ExprTuple49, 86
46Operationoperator: 50
operands: 51
47Operationoperator: 52
operands: 53
48ExprRangelambda_map: 54
start_index: 85
end_index: 86
49Literal
50Literal
51ExprTuple55, 56
52Literal
53ExprTuple57, 58
54Lambdaparameter: 87
body: 59
55Operationoperator: 60
operands: 61
56Operationoperator: 62
operands: 63
57Operationoperator: 65
operands: 64
58Operationoperator: 65
operands: 66
59Operationoperator: 77
operand: 72
60Literal
61ExprTuple68, 69, 83, 70
62Literal
63ExprTuple91, 92
64ExprTuple91, 71
65Literal
66ExprTuple92, 71
67ExprTuple72
68Operationoperator: 73
operand: 82
69Operationoperator: 75
operand: 83
70Operationoperator: 77
operand: 84
71Operationoperator: 79
operands: 80
72IndexedVarvariable: 89
index: 87
73Literal
74ExprTuple82
75Literal
76ExprTuple83
77Literal
78ExprTuple84
79Literal
80ExprTuple85, 86
81ExprTuple87
82IndexedVarvariable: 89
index: 91
83Variable
84IndexedVarvariable: 89
index: 92
85Literal
86Variable
87Variable
88ExprTuple91
89Variable
90ExprTuple92
91Variable
92Variable