logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(Lambda([f, g, Q], 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())
\left(\left(f, g, Q\right) \mapsto \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()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple32, 33, 26
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 8
operand: 11
7Operationoperator: 23
operands: 10
8Literal
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameters: 34
body: 14
12Lambdaparameters: 25
body: 15
13Lambdaparameters: 27
body: 16
14Conditionalvalue: 17
condition: 18
15Conditionalvalue: 19
condition: 20
16Conditionalvalue: 21
condition: 22
17Operationoperator: 23
operands: 24
18Operationoperator: 26
operands: 34
19Operationoperator: 32
operands: 25
20Operationoperator: 26
operands: 25
21Operationoperator: 33
operands: 27
22Operationoperator: 26
operands: 27
23Literal
24ExprTuple28, 29
25ExprTuple30
26Variable
27ExprTuple31
28Operationoperator: 32
operands: 34
29Operationoperator: 33
operands: 34
30ExprRangelambda_map: 35
start_index: 41
end_index: 42
31ExprRangelambda_map: 36
start_index: 41
end_index: 42
32Variable
33Variable
34ExprTuple37
35Lambdaparameter: 48
body: 38
36Lambdaparameter: 48
body: 39
37ExprRangelambda_map: 40
start_index: 41
end_index: 42
38IndexedVarvariable: 43
index: 48
39IndexedVarvariable: 44
index: 48
40Lambdaparameter: 48
body: 45
41Literal
42Variable
43Variable
44Variable
45IndexedVarvariable: 46
index: 48
46Variable
47ExprTuple48
48Variable