logo

Expression of type Forall

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, X, Y
from proveit.linear_algebra import HilbertSpaces, Hspace, LinMap
from proveit.logic import Exists, Forall, 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 = Forall(instance_param_or_params = [A, B], instance_expr = 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), condition = 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())
\forall_{A, B~|~\left(A \thinspace B\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\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)\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 14
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 32
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 48
10Lambdaparameters: 12
body: 13
11Operationoperator: 35
operands: 14
12ExprTuple55, 56, 54
13Conditionalvalue: 15
condition: 16
14ExprTuple43, 44
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24, 25
21ExprTuple26, 27
22Operationoperator: 28
operands: 29
23Operationoperator: 32
operands: 30
24Operationoperator: 32
operands: 31
25Operationoperator: 32
operands: 33
26Operationoperator: 35
operand: 43
27Operationoperator: 35
operand: 44
28Literal
29ExprTuple37, 38, 39, 40, 41
30ExprTuple55, 42
31ExprTuple56, 42
32Literal
33ExprTuple54, 42
34ExprTuple43
35Literal
36ExprTuple44
37ExprTuple47, 55
38ExprTuple56, 45
39ExprTuple46, 47
40ExprTuple53, 48
41ExprTuple48, 53
42Literal
43Variable
44Variable
45Operationoperator: 51
operands: 49
46Operationoperator: 51
operands: 50
47Operationoperator: 51
operands: 52
48Literal
49ExprTuple55, 53
50ExprTuple56, 54
51Literal
52ExprTuple55, 56
53Literal
54Variable
55Variable
56Variable