logo

Expression of type Forall

from the theory of proveit.numbers.addition

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 b, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import Forall
from proveit.numbers import Add, Less, Natural, Real, RealNeg, greater, zero
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [i, j], instance_expr = Forall(instance_param_or_params = [a_1_to_i, c_1_to_j], instance_expr = Forall(instance_param_or_params = [b], instance_expr = Less(Add(a_1_to_i, b, c_1_to_j), b), domain = Real), domain = RealNeg), domain = Natural, condition = greater(Add(i, j), zero))
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_{i, j \in \mathbb{N}~|~\left(i + j\right) > 0}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{j} \in \mathbb{R}^-}~\left[\forall_{b \in \mathbb{R}}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) < b\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: 22
operand: 2
1ExprTuple2
2Lambdaparameters: 26
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 22
operand: 8
5Operationoperator: 24
operands: 7
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 12
body: 13
9Operationoperator: 42
operands: 14
10Operationoperator: 42
operands: 15
11Operationoperator: 38
operands: 16
12ExprTuple49, 51
13Conditionalvalue: 17
condition: 18
14ExprTuple53, 19
15ExprTuple56, 19
16ExprTuple20, 21
17Operationoperator: 22
operand: 27
18Operationoperator: 24
operands: 25
19Literal
20Literal
21Operationoperator: 47
operands: 26
22Literal
23ExprTuple27
24Literal
25ExprTuple28, 29
26ExprTuple53, 56
27Lambdaparameter: 50
body: 31
28ExprRangelambda_map: 32
start_index: 55
end_index: 53
29ExprRangelambda_map: 33
start_index: 55
end_index: 56
30ExprTuple50
31Conditionalvalue: 34
condition: 35
32Lambdaparameter: 62
body: 36
33Lambdaparameter: 62
body: 37
34Operationoperator: 38
operands: 39
35Operationoperator: 42
operands: 40
36Operationoperator: 42
operands: 41
37Operationoperator: 42
operands: 43
38Literal
39ExprTuple44, 50
40ExprTuple50, 45
41ExprTuple57, 46
42Literal
43ExprTuple58, 46
44Operationoperator: 47
operands: 48
45Literal
46Literal
47Literal
48ExprTuple49, 50, 51
49ExprRangelambda_map: 52
start_index: 55
end_index: 53
50Variable
51ExprRangelambda_map: 54
start_index: 55
end_index: 56
52Lambdaparameter: 62
body: 57
53Variable
54Lambdaparameter: 62
body: 58
55Literal
56Variable
57IndexedVarvariable: 59
index: 62
58IndexedVarvariable: 60
index: 62
59Variable
60Variable
61ExprTuple62
62Variable