logo

Expression of type Forall

from the theory of proveit.core_expr_types.lambda_maps

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 Conditional, Lambda, Q, f, g, i
from proveit.core_expr_types import Q__a_1_to_i, Q__b_1_to_i, Q__c_1_to_i, a_1_to_i, b_1_to_i, c_1_to_i, f__a_1_to_i, f__b_1_to_i, g__a_1_to_i, g__c_1_to_i
from proveit.logic import Equals, Forall, Implies
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [i], instance_expr = Forall(instance_param_or_params = [f, g, Q], instance_expr = Implies(Forall(instance_param_or_params = [a_1_to_i], instance_expr = Equals(f__a_1_to_i, g__a_1_to_i), condition = Q__a_1_to_i), Equals(Lambda([b_1_to_i], Conditional(f__b_1_to_i, Q__b_1_to_i)), Lambda([c_1_to_i], Conditional(g__c_1_to_i, Q__c_1_to_i))).with_wrapping_at(2)).with_wrapping_at(2)), domain = NaturalPos)
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 \in \mathbb{N}^+}~\left[\forall_{f, g, Q}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{a_{1}, a_{2}, \ldots, a_{i}~|~Q\left(a_{1}, a_{2}, \ldots, a_{i}\right)}~\left(f\left(a_{1}, a_{2}, \ldots, a_{i}\right) = g\left(a_{1}, a_{2}, \ldots, a_{i}\right)\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\left(b_{1}, b_{2}, \ldots, b_{i}\right) \mapsto \left\{f\left(b_{1}, b_{2}, \ldots, b_{i}\right) \textrm{ if } Q\left(b_{1}, b_{2}, \ldots, b_{i}\right)\right..\right] =  \\ \left[\left(c_{1}, c_{2}, \ldots, c_{i}\right) \mapsto \left\{g\left(c_{1}, c_{2}, \ldots, c_{i}\right) \textrm{ if } Q\left(c_{1}, c_{2}, \ldots, c_{i}\right)\right..\right] \end{array} \end{array}\right) \end{array} \end{array}\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
2Lambdaparameter: 52
body: 4
3ExprTuple52
4Conditionalvalue: 5
condition: 6
5Operationoperator: 18
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple52, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple42, 43, 36
13Operationoperator: 14
operands: 15
14Literal
15ExprTuple16, 17
16Operationoperator: 18
operand: 21
17Operationoperator: 33
operands: 20
18Literal
19ExprTuple21
20ExprTuple22, 23
21Lambdaparameters: 44
body: 24
22Lambdaparameters: 35
body: 25
23Lambdaparameters: 37
body: 26
24Conditionalvalue: 27
condition: 28
25Conditionalvalue: 29
condition: 30
26Conditionalvalue: 31
condition: 32
27Operationoperator: 33
operands: 34
28Operationoperator: 36
operands: 44
29Operationoperator: 42
operands: 35
30Operationoperator: 36
operands: 35
31Operationoperator: 43
operands: 37
32Operationoperator: 36
operands: 37
33Literal
34ExprTuple38, 39
35ExprTuple40
36Variable
37ExprTuple41
38Operationoperator: 42
operands: 44
39Operationoperator: 43
operands: 44
40ExprRangelambda_map: 45
start_index: 51
end_index: 52
41ExprRangelambda_map: 46
start_index: 51
end_index: 52
42Variable
43Variable
44ExprTuple47
45Lambdaparameter: 58
body: 48
46Lambdaparameter: 58
body: 49
47ExprRangelambda_map: 50
start_index: 51
end_index: 52
48IndexedVarvariable: 53
index: 58
49IndexedVarvariable: 54
index: 58
50Lambdaparameter: 58
body: 55
51Literal
52Variable
53Variable
54Variable
55IndexedVarvariable: 56
index: 58
56Variable
57ExprTuple58
58Variable