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, j, l
from proveit.core_expr_types import A_1_to_l, b_1_to_j
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, Mult, Natural, NaturalPos
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [b_1_to_j], instance_expr = Forall(instance_param_or_params = [A_1_to_l], instance_expr = Equals(Qmult(b_1_to_j, A_1_to_l), Qmult(Mult(b_1_to_j), A_1_to_l)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l), QmultCodomain)), domain = Complex), And(InSet(j, NaturalPos), InSet(l, 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_{1}, b_{2}, \ldots, b_{j} \in \mathbb{C}}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{l}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\left(\begin{array}{c} \begin{array}{l} \left(b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) =  \\ \left(\left(b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right)\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \end{array} \end{array}\right)\right] \textrm{ if } j \in \mathbb{N}^+ ,  l \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: 15
operand: 5
2Operationoperator: 17
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 44
body: 8
6Operationoperator: 30
operands: 9
7Operationoperator: 30
operands: 10
8Conditionalvalue: 11
condition: 12
9ExprTuple51, 13
10ExprTuple46, 14
11Operationoperator: 15
operand: 19
12Operationoperator: 17
operands: 18
13Literal
14Literal
15Literal
16ExprTuple19
17Literal
18ExprTuple20
19Lambdaparameters: 40
body: 21
20ExprRangelambda_map: 22
start_index: 50
end_index: 51
21Conditionalvalue: 23
condition: 24
22Lambdaparameter: 56
body: 25
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26Literal
27ExprTuple32, 33
28Literal
29ExprTuple34, 35
30Literal
31ExprTuple53, 36
32Operationoperator: 39
operands: 37
33Operationoperator: 39
operands: 38
34Operationoperator: 39
operands: 40
35Literal
36Literal
37ExprTuple47, 42
38ExprTuple41, 42
39Literal
40ExprTuple42
41Operationoperator: 43
operands: 44
42ExprRangelambda_map: 45
start_index: 50
end_index: 46
43Literal
44ExprTuple47
45Lambdaparameter: 56
body: 48
46Variable
47ExprRangelambda_map: 49
start_index: 50
end_index: 51
48IndexedVarvariable: 52
index: 56
49Lambdaparameter: 56
body: 53
50Literal
51Variable
52Variable
53IndexedVarvariable: 54
index: 56
54Variable
55ExprTuple56
56Variable