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
from proveit.linear_algebra import Hspace
from proveit.logic import Forall, InClass, InSet
from proveit.physics.quantum import Qmult, QmultCodomain, bra_varphi, ket_varphi, var_ket_psi, varphi
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [Hspace, X], instance_expr = Forall(instance_param_or_params = [var_ket_psi], instance_expr = Forall(instance_param_or_params = [varphi], instance_expr = InClass(Qmult(var_ket_psi, bra_varphi), QmultCodomain), condition = InSet(ket_varphi, X)), domain = Hspace))
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_{\mathcal{H}, X}~\left[\forall_{\lvert \psi \rangle \in \mathcal{H}}~\left[\forall_{\varphi~|~\lvert \varphi \rangle \in X}~\left(\left(\lvert \psi \rangle \thinspace \langle \varphi \rvert\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\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: 11
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple15, 26
4Operationoperator: 11
operand: 6
5ExprTuple6
6Lambdaparameter: 30
body: 8
7ExprTuple30
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 14
10Operationoperator: 21
operands: 13
11Literal
12ExprTuple14
13ExprTuple30, 15
14Lambdaparameter: 34
body: 16
15Variable
16Conditionalvalue: 17
condition: 18
17Operationoperator: 19
operands: 20
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26
23Operationoperator: 27
operands: 28
24Literal
25Operationoperator: 29
operand: 34
26Variable
27Literal
28ExprTuple30, 31
29Literal
30Variable
31Operationoperator: 32
operand: 34
32Literal
33ExprTuple34
34Variable