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 X, x
from proveit.linear_algebra import HilbertSpaces, Hspace, LinMap
from proveit.logic import Equals, Exists, Forall, InClass, InSet, Or
from proveit.physics.quantum import QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [x], instance_expr = Equals(InClass(x, QmultCodomain), Or(Exists(instance_param_or_params = [Hspace], instance_expr = InSet(x, Hspace), domain = HilbertSpaces), Exists(instance_param_or_params = [Hspace, X], instance_expr = InSet(x, LinMap(Hspace, X)), domain = HilbertSpaces)).with_wrapping_at(2)))
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_{x}~\left(\left(x \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right) = \left(\begin{array}{c} \left[\exists_{\mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}}~\left(x \in \mathcal{H}\right)\right] \lor  \\ \left[\exists_{\mathcal{H}, X \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}}~\left(x \in \mathcal{L}\left(\mathcal{H}, X\right)\right)\right] \end{array}\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
3Lambdaparameter: 32
body: 5
4ExprTuple32
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Operationoperator: 39
operands: 10
9Operationoperator: 11
operands: 12
10ExprTuple32, 13
11Literal
12ExprTuple14, 15
13Literal
14Operationoperator: 17
operand: 19
15Operationoperator: 17
operand: 20
16ExprTuple19
17Literal
18ExprTuple20
19Lambdaparameter: 41
body: 22
20Lambdaparameters: 37
body: 23
21ExprTuple41
22Conditionalvalue: 24
condition: 34
23Conditionalvalue: 25
condition: 26
24Operationoperator: 28
operands: 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple32, 41
28Literal
29ExprTuple32, 33
30Literal
31ExprTuple34, 35
32Variable
33Operationoperator: 36
operands: 37
34Operationoperator: 39
operands: 38
35Operationoperator: 39
operands: 40
36Literal
37ExprTuple41, 42
38ExprTuple41, 43
39Literal
40ExprTuple42, 43
41Variable
42Variable
43Literal