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 f, g, 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 = [f, g], instance_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_{f, g}~\left[\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)\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: 18
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple44, 45
4Operationoperator: 18
operand: 6
5ExprTuple6
6Lambdaparameters: 48
body: 7
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Operationoperator: 18
operand: 23
15Operationoperator: 34
operands: 20
16Operationoperator: 36
operands: 21
17Operationoperator: 36
operands: 22
18Literal
19ExprTuple23
20ExprTuple24, 25
21ExprTuple51, 26
22ExprTuple52, 26
23Lambdaparameter: 50
body: 27
24ExprTuple28
25ExprTuple29
26Literal
27Conditionalvalue: 30
condition: 31
28ExprRangelambda_map: 32
start_index: 51
end_index: 52
29ExprRangelambda_map: 33
start_index: 51
end_index: 52
30Operationoperator: 34
operands: 35
31Operationoperator: 36
operands: 37
32Lambdaparameter: 49
body: 38
33Lambdaparameter: 49
body: 39
34Literal
35ExprTuple40, 41
36Literal
37ExprTuple50, 42
38Operationoperator: 44
operand: 49
39Operationoperator: 45
operand: 49
40Operationoperator: 44
operand: 50
41Operationoperator: 45
operand: 50
42Operationoperator: 47
operands: 48
43ExprTuple49
44Variable
45Variable
46ExprTuple50
47Literal
48ExprTuple51, 52
49Variable
50Variable
51Variable
52Variable