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 And, Forall, InClass, InSet
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [A, B], instance_expr = InClass(Qmult(A, B), QmultCodomain), conditions = [InSet(Qmult(A), LinMap(X, Y)), InSet(Qmult(B), LinMap(Hspace, X))]), And(InClass(Hspace, HilbertSpaces), InClass(X, HilbertSpaces), InClass(Y, HilbertSpaces)))
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, B~|~\left[A\right] \in \mathcal{L}\left(X, Y\right), \left[B\right] \in \mathcal{L}\left(\mathcal{H}, X\right)}~\left(\left(A \thinspace B\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right) \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  X \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  Y \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\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: 19
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8, 9
6Lambdaparameters: 25
body: 10
7Operationoperator: 17
operands: 11
8Operationoperator: 17
operands: 12
9Operationoperator: 17
operands: 13
10Conditionalvalue: 14
condition: 15
11ExprTuple42, 16
12ExprTuple43, 16
13ExprTuple40, 16
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16Literal
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24
21Operationoperator: 35
operands: 25
22Literal
23Operationoperator: 27
operands: 26
24Operationoperator: 27
operands: 28
25ExprTuple39, 41
26ExprTuple29, 30
27Literal
28ExprTuple31, 32
29Operationoperator: 35
operand: 39
30Operationoperator: 37
operands: 34
31Operationoperator: 35
operand: 41
32Operationoperator: 37
operands: 38
33ExprTuple39
34ExprTuple43, 40
35Literal
36ExprTuple41
37Literal
38ExprTuple42, 43
39Variable
40Variable
41Variable
42Variable
43Variable