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 ExprRange, IndexedVar, Variable, a, b, m
from proveit.logic import Equals, Forall
from proveit.numbers import Add, NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(a, sub_expr1)
sub_expr3 = Add(m, one)
sub_expr4 = IndexedVar(b, sub_expr1)
sub_expr5 = ExprRange(sub_expr1, sub_expr2, one, sub_expr3)
sub_expr6 = ExprRange(sub_expr1, sub_expr4, one, sub_expr3)
sub_expr7 = Equals(sub_expr2, sub_expr4)
sub_expr8 = ExprRange(sub_expr1, sub_expr2, one, m)
sub_expr9 = ExprRange(sub_expr1, sub_expr4, one, m)
expr = Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [sub_expr5, sub_expr6], instance_expr = Equals([sub_expr5], [sub_expr6]), condition = ExprRange(sub_expr1, sub_expr7, one, sub_expr3)), domain = NaturalPos, condition = Forall(instance_param_or_params = [sub_expr8, sub_expr9], instance_expr = Equals([sub_expr8], [sub_expr9]), condition = ExprRange(sub_expr1, sub_expr7, one, m)))
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_{m \in \mathbb{N}^+~|~\forall_{a_{1}, a_{2}, \ldots, a_{m}, b_{1}, b_{2}, \ldots, b_{m}~|~\left(a_{1} = b_{1}\right), \left(a_{2} = b_{2}\right), \ldots, \left(a_{m} = b_{m}\right)}~\left(\left(a_{1}, a_{2}, \ldots, a_{m}\right) = \left(b_{1}, b_{2}, \ldots, b_{m}\right)\right)}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{m + 1}, b_{1}, b_{2}, \ldots, b_{m + 1}~|~\left(a_{1} = b_{1}\right), \left(a_{2} = b_{2}\right), \ldots, \left(a_{m + 1} = b_{m + 1}\right)}~\left(\left(a_{1}, a_{2}, \ldots, a_{m + 1}\right) = \left(b_{1}, b_{2}, \ldots, b_{m + 1}\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: 16
operand: 2
1ExprTuple2
2Lambdaparameter: 48
body: 4
3ExprTuple48
4Conditionalvalue: 5
condition: 6
5Operationoperator: 16
operand: 9
6Operationoperator: 34
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operand: 21
12ExprTuple31, 32
13Conditionalvalue: 18
condition: 19
14Literal
15ExprTuple48, 20
16Literal
17ExprTuple21
18Operationoperator: 50
operands: 22
19Operationoperator: 34
operands: 23
20Literal
21Lambdaparameters: 24
body: 25
22ExprTuple26, 27
23ExprTuple28
24ExprTuple42, 43
25Conditionalvalue: 29
condition: 30
26ExprTuple31
27ExprTuple32
28ExprRangelambda_map: 44
start_index: 47
end_index: 36
29Operationoperator: 50
operands: 33
30Operationoperator: 34
operands: 35
31ExprRangelambda_map: 45
start_index: 47
end_index: 36
32ExprRangelambda_map: 46
start_index: 47
end_index: 36
33ExprTuple37, 38
34Literal
35ExprTuple39
36Operationoperator: 40
operands: 41
37ExprTuple42
38ExprTuple43
39ExprRangelambda_map: 44
start_index: 47
end_index: 48
40Literal
41ExprTuple48, 47
42ExprRangelambda_map: 45
start_index: 47
end_index: 48
43ExprRangelambda_map: 46
start_index: 47
end_index: 48
44Lambdaparameter: 57
body: 49
45Lambdaparameter: 57
body: 52
46Lambdaparameter: 57
body: 53
47Literal
48Variable
49Operationoperator: 50
operands: 51
50Literal
51ExprTuple52, 53
52IndexedVarvariable: 54
index: 57
53IndexedVarvariable: 55
index: 57
54Variable
55Variable
56ExprTuple57
57Variable