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 k, n
from proveit.linear_algebra import LinMap
from proveit.logic import CartExp, Forall, InSet
from proveit.numbers import Complex, Exp, NaturalPos, two
from proveit.physics.quantum import NumBra
from proveit.physics.quantum.algebra import n_bit_interval
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [k], instance_expr = InSet(NumBra(k, n), LinMap(CartExp(Complex, Exp(two, n)), Complex)), domain = n_bit_interval), domain = NaturalPos)
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_{n \in \mathbb{N}^+}~\left[\forall_{k \in \{0~\ldotp \ldotp~2^{n} - 1\}}~\left({_{n}}\langle k \rvert \in \mathcal{L}\left(\mathbb{C}^{2^{n}}, \mathbb{C}\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: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 44
body: 4
3ExprTuple44
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 17
operands: 9
7Literal
8ExprTuple10
9ExprTuple44, 11
10Lambdaparameter: 28
body: 13
11Literal
12ExprTuple28
13Conditionalvalue: 14
condition: 15
14Operationoperator: 17
operands: 16
15Operationoperator: 17
operands: 18
16ExprTuple19, 20
17Literal
18ExprTuple28, 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23ExprTuple28, 44
24Literal
25ExprTuple29, 36
26Literal
27ExprTuple30, 31
28Variable
29Operationoperator: 32
operands: 33
30Literal
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36, 37
34Literal
35ExprTuple37, 38
36Literal
37Operationoperator: 39
operands: 40
38Operationoperator: 41
operand: 45
39Literal
40ExprTuple43, 44
41Literal
42ExprTuple45
43Literal
44Variable
45Literal