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