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, i, n
from proveit.core_expr_types import v_1_to_n, v_i, w_1_to_n, w_i
from proveit.linear_algebra import OrthoNormBases, Unitary, VecSum
from proveit.logic import CartExp, Forall, InSet, Set
from proveit.numbers import Complex, Interval, NaturalPos, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets, w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = OrthoNormBases(CartExp(Complex, n))
expr = Conditional(Forall(instance_param_or_params = [v_1_to_n, w_1_to_n], instance_expr = InSet(VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n)), Unitary(n)), conditions = [InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), sub_expr1)]).with_wrapping(), 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\{\begin{array}{l}\forall_{v_{1}, v_{2}, \ldots, v_{n}, w_{1}, w_{2}, \ldots, w_{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\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right)}~\\
\left(\left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right) \in \textrm{U}\left(n\right)\right)\end{array} \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: 3
operand: 6
2Operationoperator: 45
operands: 5
3Literal
4ExprTuple6
5ExprTuple68, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple10, 11
9Conditionalvalue: 12
condition: 13
10ExprRangelambda_map: 14
start_index: 67
end_index: 68
11ExprRangelambda_map: 15
start_index: 67
end_index: 68
12Operationoperator: 45
operands: 16
13Operationoperator: 17
operands: 18
14Lambdaparameter: 81
body: 76
15Lambdaparameter: 81
body: 77
16ExprTuple19, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 23
operand: 29
20Operationoperator: 25
operand: 68
21Operationoperator: 45
operands: 27
22Operationoperator: 45
operands: 28
23Literal
24ExprTuple29
25Literal
26ExprTuple68
27ExprTuple30, 32
28ExprTuple31, 32
29Lambdaparameter: 75
body: 33
30Operationoperator: 48
operand: 40
31Operationoperator: 48
operand: 41
32Operationoperator: 36
operand: 42
33Conditionalvalue: 38
condition: 39
34ExprTuple40
35ExprTuple41
36Literal
37ExprTuple42
38Operationoperator: 43
operands: 44
39Operationoperator: 45
operands: 46
40Operationoperator: 48
operands: 47
41Operationoperator: 48
operands: 49
42Operationoperator: 50
operands: 51
43Literal
44ExprTuple52, 53
45Literal
46ExprTuple75, 54
47ExprTuple55
48Literal
49ExprTuple56
50Literal
51ExprTuple57, 68
52Operationoperator: 73
operand: 65
53Operationoperator: 59
operand: 66
54Operationoperator: 61
operands: 62
55ExprRangelambda_map: 63
start_index: 67
end_index: 68
56ExprRangelambda_map: 64
start_index: 67
end_index: 68
57Literal
58ExprTuple65
59Literal
60ExprTuple66
61Literal
62ExprTuple67, 68
63Lambdaparameter: 81
body: 69
64Lambdaparameter: 81
body: 70
65IndexedVarvariable: 78
index: 75
66IndexedVarvariable: 79
index: 75
67Literal
68Variable
69Operationoperator: 73
operand: 76
70Operationoperator: 73
operand: 77
71ExprTuple75
72ExprTuple76
73Literal
74ExprTuple77
75Variable
76IndexedVarvariable: 78
index: 81
77IndexedVarvariable: 79
index: 81
78Variable
79Variable
80ExprTuple81
81Variable