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, b, l, n
from proveit.core_expr_types import A_1_to_l, C_1_to_n
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, Natural
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [b], instance_expr = Forall(instance_param_or_params = [A_1_to_l, C_1_to_n], instance_expr = Equals(Qmult(A_1_to_l, b, C_1_to_n), Qmult(b, A_1_to_l, C_1_to_n)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l, C_1_to_n), QmultCodomain)), domain = Complex), And(InSet(l, Natural), InSet(n, Natural)))
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_{b \in \mathbb{C}}~\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\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(b\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)\right] \textrm{ if } l \in \mathbb{N} ,  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: 16
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8
6Lambdaparameter: 37
body: 10
7Operationoperator: 18
operands: 11
8Operationoperator: 18
operands: 12
9ExprTuple37
10Conditionalvalue: 13
condition: 14
11ExprTuple41, 15
12ExprTuple44, 15
13Operationoperator: 16
operand: 20
14Operationoperator: 18
operands: 19
15Literal
16Literal
17ExprTuple20
18Literal
19ExprTuple37, 21
20Lambdaparameters: 36
body: 22
21Literal
22Conditionalvalue: 23
condition: 24
23Operationoperator: 25
operands: 26
24Operationoperator: 27
operands: 28
25Literal
26ExprTuple29, 30
27Literal
28ExprTuple31, 32
29Operationoperator: 35
operands: 33
30Operationoperator: 35
operands: 34
31Operationoperator: 35
operands: 36
32Literal
33ExprTuple38, 37, 39
34ExprTuple37, 38, 39
35Literal
36ExprTuple38, 39
37Variable
38ExprRangelambda_map: 40
start_index: 43
end_index: 41
39ExprRangelambda_map: 42
start_index: 43
end_index: 44
40Lambdaparameter: 50
body: 45
41Variable
42Lambdaparameter: 50
body: 46
43Literal
44Variable
45IndexedVarvariable: 47
index: 50
46IndexedVarvariable: 48
index: 50
47Variable
48Variable
49ExprTuple50
50Variable