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, ExprRange, IndexedVar, Variable, b, j
from proveit.core_expr_types import A_1_to_l, C_1_to_n, b_1_to_j
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, one
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Forall(instance_param_or_params = [A_1_to_l, C_1_to_n], instance_expr = Equals(Qmult(A_1_to_l, b_1_to_j, C_1_to_n), Qmult(b_1_to_j, A_1_to_l, C_1_to_n)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l, C_1_to_n), QmultCodomain)), And(ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), one, j)))
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_{A_{1}, A_{2}, \ldots, A_{l}, C_{1}, C_{2}, \ldots, C_{n}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\left(\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \end{array} \end{array}\right) \textrm{ if } \left(b_{1} \in \mathbb{C}\right) \land  \left(b_{2} \in \mathbb{C}\right) \land  \ldots \land  \left(b_{j} \in \mathbb{C}\right)\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: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8
7Lambdaparameters: 28
body: 9
8ExprRangelambda_map: 10
start_index: 37
end_index: 33
9Conditionalvalue: 11
condition: 12
10Lambdaparameter: 46
body: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Literal
15ExprTuple20, 21
16Literal
17ExprTuple22, 23
18Literal
19ExprTuple39, 24
20Operationoperator: 27
operands: 25
21Operationoperator: 27
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24Literal
25ExprTuple30, 29, 31
26ExprTuple29, 30, 31
27Literal
28ExprTuple30, 31
29ExprRangelambda_map: 32
start_index: 37
end_index: 33
30ExprRangelambda_map: 34
start_index: 37
end_index: 35
31ExprRangelambda_map: 36
start_index: 37
end_index: 38
32Lambdaparameter: 46
body: 39
33Variable
34Lambdaparameter: 46
body: 40
35Variable
36Lambdaparameter: 46
body: 41
37Literal
38Variable
39IndexedVarvariable: 42
index: 46
40IndexedVarvariable: 43
index: 46
41IndexedVarvariable: 44
index: 46
42Variable
43Variable
44Variable
45ExprTuple46
46Variable