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 A, B, Conditional, X, Y
from proveit.linear_algebra import HilbertSpaces, Hspace, LinMap
from proveit.logic import Exists, InClass, InSet, Set
from proveit.numbers import Complex
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = LinMap(Hspace, X)
expr = Conditional(Exists(instance_param_or_params = [Hspace, X, Y], instance_expr = InSet([Qmult(A), Qmult(B)], Set([sub_expr1, Hspace], [X, LinMap(Hspace, Complex)], [LinMap(X, Y), sub_expr1], [Complex, QmultCodomain], [QmultCodomain, Complex])), domain = HilbertSpaces), InClass(Qmult(A, B), QmultCodomain))
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\{\exists_{\mathcal{H}, X, Y \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}}~\left(\left(\left[A\right], \left[B\right]\right) \in \left\{\left(\mathcal{L}\left(\mathcal{H}, X\right), \mathcal{H}\right), \left(X, \mathcal{L}\left(\mathcal{H}, \mathbb{C}\right)\right), \left(\mathcal{L}\left(X, Y\right), \mathcal{L}\left(\mathcal{H}, X\right)\right), \left(\mathbb{C}, \mathcal{Q^*}\right), \left(\mathcal{Q^*}, \mathbb{C}\right)\right\}\right) \textrm{ if } \left(A \thinspace B\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\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: 28
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 44
6Lambdaparameters: 8
body: 9
7Operationoperator: 31
operands: 10
8ExprTuple51, 52, 50
9Conditionalvalue: 11
condition: 12
10ExprTuple39, 40
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18
15Literal
16ExprTuple19, 20, 21
17ExprTuple22, 23
18Operationoperator: 24
operands: 25
19Operationoperator: 28
operands: 26
20Operationoperator: 28
operands: 27
21Operationoperator: 28
operands: 29
22Operationoperator: 31
operand: 39
23Operationoperator: 31
operand: 40
24Literal
25ExprTuple33, 34, 35, 36, 37
26ExprTuple51, 38
27ExprTuple52, 38
28Literal
29ExprTuple50, 38
30ExprTuple39
31Literal
32ExprTuple40
33ExprTuple43, 51
34ExprTuple52, 41
35ExprTuple42, 43
36ExprTuple49, 44
37ExprTuple44, 49
38Literal
39Variable
40Variable
41Operationoperator: 47
operands: 45
42Operationoperator: 47
operands: 46
43Operationoperator: 47
operands: 48
44Literal
45ExprTuple51, 49
46ExprTuple52, 50
47Literal
48ExprTuple51, 52
49Literal
50Variable
51Variable
52Variable