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
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
In [2]:
# build up the expression from sub-expressions
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))
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, 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)
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: 9
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple33, 34, 27
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8
7Operationoperator: 9
operand: 12
8Operationoperator: 24
operands: 11
9Literal
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 35
body: 15
13Lambdaparameters: 26
body: 16
14Lambdaparameters: 28
body: 17
15Conditionalvalue: 18
condition: 19
16Conditionalvalue: 20
condition: 21
17Conditionalvalue: 22
condition: 23
18Operationoperator: 24
operands: 25
19Operationoperator: 27
operands: 35
20Operationoperator: 33
operands: 26
21Operationoperator: 27
operands: 26
22Operationoperator: 34
operands: 28
23Operationoperator: 27
operands: 28
24Literal
25ExprTuple29, 30
26ExprTuple31
27Variable
28ExprTuple32
29Operationoperator: 33
operands: 35
30Operationoperator: 34
operands: 35
31ExprRangelambda_map: 36
start_index: 42
end_index: 43
32ExprRangelambda_map: 37
start_index: 42
end_index: 43
33Variable
34Variable
35ExprTuple38
36Lambdaparameter: 49
body: 39
37Lambdaparameter: 49
body: 40
38ExprRangelambda_map: 41
start_index: 42
end_index: 43
39IndexedVarvariable: 44
index: 49
40IndexedVarvariable: 45
index: 49
41Lambdaparameter: 49
body: 46
42Literal
43Variable
44Variable
45Variable
46IndexedVarvariable: 47
index: 49
47Variable
48ExprTuple49
49Variable