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, 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 = [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(), InSet(U, MatrixSpace(field = Complex, rows = n, columns = 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\{\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} \textrm{ if } U \in \mathbb{C}^{n \times 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: 22
operand: 5
2Operationoperator: 58
operands: 4
3ExprTuple5
4ExprTuple76, 6
5Lambdaparameters: 7
body: 8
6Operationoperator: 9
operands: 10
7ExprTuple11
8Conditionalvalue: 12
condition: 13
9Literal
10NamedExprsfield: 42
rows: 79
columns: 79
11ExprRangelambda_map: 14
start_index: 78
end_index: 79
12Operationoperator: 15
operands: 16
13Operationoperator: 58
operands: 17
14Lambdaparameter: 80
body: 65
15Literal
16ExprTuple18, 19
17ExprTuple20, 21
18Operationoperator: 22
operand: 28
19Operationoperator: 58
operands: 24
20Operationoperator: 35
operand: 30
21Operationoperator: 26
operand: 31
22Literal
23ExprTuple28
24ExprTuple76, 29
25ExprTuple30
26Literal
27ExprTuple31
28Lambdaparameters: 56
body: 32
29Operationoperator: 33
operand: 79
30Operationoperator: 35
operands: 36
31Operationoperator: 37
operands: 38
32Conditionalvalue: 39
condition: 40
33Literal
34ExprTuple79
35Literal
36ExprTuple41
37Literal
38ExprTuple42, 79
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operands: 46
41ExprRangelambda_map: 47
start_index: 78
end_index: 79
42Literal
43Literal
44ExprTuple48, 49
45Literal
46ExprTuple50, 51
47Lambdaparameter: 80
body: 52
48Operationoperator: 53
operands: 54
49Operationoperator: 55
operands: 56
50Operationoperator: 58
operands: 57
51Operationoperator: 58
operands: 59
52Operationoperator: 70
operand: 65
53Literal
54ExprTuple61, 62, 76, 63
55Literal
56ExprTuple84, 85
57ExprTuple84, 64
58Literal
59ExprTuple85, 64
60ExprTuple65
61Operationoperator: 66
operand: 75
62Operationoperator: 68
operand: 76
63Operationoperator: 70
operand: 77
64Operationoperator: 72
operands: 73
65IndexedVarvariable: 82
index: 80
66Literal
67ExprTuple75
68Literal
69ExprTuple76
70Literal
71ExprTuple77
72Literal
73ExprTuple78, 79
74ExprTuple80
75IndexedVarvariable: 82
index: 84
76Variable
77IndexedVarvariable: 82
index: 85
78Literal
79Variable
80Variable
81ExprTuple84
82Variable
83ExprTuple85
84Variable
85Variable