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 TensorProd
from proveit.logic import Equals, Forall
from proveit.numbers import Add, NaturalPos, one
from proveit.physics.quantum import NumKet, ket0
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 = Equals(NumKet(k, Add(n, one)), TensorProd(ket0, NumKet(k, n))), 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(\lvert k \rangle_{n + 1} = \left(\lvert 0 \rangle {\otimes} \lvert k \rangle_{n}\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: 48
body: 4
3ExprTuple48
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 18
operands: 9
7Literal
8ExprTuple10
9ExprTuple48, 11
10Lambdaparameter: 40
body: 13
11Literal
12ExprTuple40
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operands: 17
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple40, 22
20Operationoperator: 35
operands: 23
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23ExprTuple40, 28
24Literal
25ExprTuple29, 30
26Literal
27ExprTuple39, 31
28Operationoperator: 37
operands: 32
29Operationoperator: 33
operand: 39
30Operationoperator: 35
operands: 36
31Operationoperator: 37
operands: 38
32ExprTuple48, 49
33Literal
34ExprTuple39
35Literal
36ExprTuple40, 48
37Literal
38ExprTuple41, 42
39Literal
40Variable
41Operationoperator: 43
operands: 44
42Operationoperator: 45
operand: 49
43Literal
44ExprTuple47, 48
45Literal
46ExprTuple49
47Literal
48Variable
49Literal