logo

Expression of type Forall

from the theory of proveit.core_expr_types.tuples

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 i, j, k
from proveit.core_expr_types import f_i_to_j, fk, g_i_to_j, gk
from proveit.logic import Equals, Forall, Implies
from proveit.numbers import Integer, Interval
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [i, j], instance_expr = Implies(Forall(instance_param_or_params = [k], instance_expr = Equals(fk, gk), domain = Interval(i, j)), Equals([f_i_to_j], [g_i_to_j])), 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_{i, j \in \mathbb{Z}}~\left(\left[\forall_{k \in \{i~\ldotp \ldotp~j\}}~\left(f\left(k\right) = g\left(k\right)\right)\right] \Rightarrow \left(\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) = \left(g\left(i\right), g\left(i + 1\right), \ldots, g\left(j\right)\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: 14
operand: 2
1ExprTuple2
2Lambdaparameters: 44
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 14
operand: 19
11Operationoperator: 30
operands: 16
12Operationoperator: 32
operands: 17
13Operationoperator: 32
operands: 18
14Literal
15ExprTuple19
16ExprTuple20, 21
17ExprTuple47, 22
18ExprTuple48, 22
19Lambdaparameter: 46
body: 23
20ExprTuple24
21ExprTuple25
22Literal
23Conditionalvalue: 26
condition: 27
24ExprRangelambda_map: 28
start_index: 47
end_index: 48
25ExprRangelambda_map: 29
start_index: 47
end_index: 48
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28Lambdaparameter: 45
body: 34
29Lambdaparameter: 45
body: 35
30Literal
31ExprTuple36, 37
32Literal
33ExprTuple46, 38
34Operationoperator: 40
operand: 45
35Operationoperator: 41
operand: 45
36Operationoperator: 40
operand: 46
37Operationoperator: 41
operand: 46
38Operationoperator: 43
operands: 44
39ExprTuple45
40Variable
41Variable
42ExprTuple46
43Literal
44ExprTuple47, 48
45Variable
46Variable
47Variable
48Variable