logo

Expression of type Forall

from the theory of proveit.numbers.summation

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 Function, a, b, f, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Integer, Interval, Neg, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [a, b], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = Function(f, [Neg(x)]), domain = Interval(Neg(b), Neg(a)))), domain = Integer)
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_{a, b \in \mathbb{Z}}~\left(\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\sum_{x = -b}^{-a} f\left(-x\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 37
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 14
11Operationoperator: 16
operand: 20
12Operationoperator: 16
operand: 21
13Operationoperator: 32
operands: 18
14Operationoperator: 32
operands: 19
15ExprTuple20
16Literal
17ExprTuple21
18ExprTuple48, 22
19ExprTuple47, 22
20Lambdaparameter: 41
body: 23
21Lambdaparameter: 41
body: 24
22Literal
23Conditionalvalue: 25
condition: 26
24Conditionalvalue: 27
condition: 28
25Operationoperator: 30
operand: 41
26Operationoperator: 32
operands: 29
27Operationoperator: 30
operand: 35
28Operationoperator: 32
operands: 33
29ExprTuple41, 34
30Variable
31ExprTuple35
32Literal
33ExprTuple41, 36
34Operationoperator: 39
operands: 37
35Operationoperator: 45
operand: 41
36Operationoperator: 39
operands: 40
37ExprTuple48, 47
38ExprTuple41
39Literal
40ExprTuple42, 43
41Variable
42Operationoperator: 45
operand: 47
43Operationoperator: 45
operand: 48
44ExprTuple47
45Literal
46ExprTuple48
47Variable
48Variable