logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.QPE

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 ExprRange, ExprTuple, Variable, t
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Interval, Neg, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Add(Add(sub_expr1, Add(Neg(t), one)), Neg(one), t)
expr = ExprTuple(Forall(instance_param_or_params = [sub_expr1], instance_expr = Equals(sub_expr2, sub_expr1), domain = Interval(one, t)), Equals([ExprRange(sub_expr1, sub_expr2, one, t)], [ExprRange(sub_expr1, sub_expr1, one, t)]))
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())
\left(\forall_{{_{-}a} \in \{1~\ldotp \ldotp~t\}}~\left(\left(\left({_{-}a} + \left(-t + 1\right)\right) - 1 + t\right) = {_{-}a}\right), \left(\left(\left(1 + \left(-t + 1\right)\right) - 1 + t\right), \left(\left(2 + \left(-t + 1\right)\right) - 1 + t\right), \ldots, \left(\left(t + \left(-t + 1\right)\right) - 1 + t\right)\right) = \left(1, 2, \ldots, t\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operand: 6
2Operationoperator: 16
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 30
body: 9
7ExprTuple10
8ExprTuple11
9Conditionalvalue: 12
condition: 13
10ExprRangelambda_map: 14
start_index: 35
end_index: 38
11ExprRangelambda_map: 15
start_index: 35
end_index: 38
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Lambdaparameter: 30
body: 21
15Lambdaparameter: 30
body: 30
16Literal
17ExprTuple21, 30
18Literal
19ExprTuple30, 22
20ExprTuple30
21Operationoperator: 32
operands: 23
22Operationoperator: 24
operands: 25
23ExprTuple26, 27, 38
24Literal
25ExprTuple35, 38
26Operationoperator: 32
operands: 28
27Operationoperator: 36
operand: 35
28ExprTuple30, 31
29ExprTuple35
30Variable
31Operationoperator: 32
operands: 33
32Literal
33ExprTuple34, 35
34Operationoperator: 36
operand: 38
35Literal
36Literal
37ExprTuple38
38Variable