logo

Expression of type ExprTuple

from the theory of proveit.core_expr_types.conditionals

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, a, m, n
from proveit.core_expr_types import Q_1_to_m, R_1_to_n
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([m, n], Conditional(Forall(instance_param_or_params = [a, Q_1_to_m, R_1_to_n], instance_expr = Equals(Conditional(a, And(And(Q_1_to_m), And(R_1_to_n))), Conditional(a, And(Q_1_to_m, R_1_to_n))).with_wrapping_at(1)), And(InSet(m, Natural), InSet(n, Natural)))))
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(m, n\right) \mapsto \left\{\forall_{a, Q_{1}, Q_{2}, \ldots, Q_{m}, R_{1}, R_{2}, \ldots, R_{n}}~\left(\begin{array}{c} \begin{array}{l} \left\{a \textrm{ if } Q_{1} \land  Q_{2} \land  \ldots \land  Q_{m} ,  R_{1} \land  R_{2} \land  \ldots \land  R_{n}\right.. \\  = \left\{a \textrm{ if } Q_{1} ,  Q_{2} ,  \ldots ,  Q_{m}, R_{1} ,  R_{2} ,  \ldots ,  R_{n}\right.. \end{array} \end{array}\right) \textrm{ if } m \in \mathbb{N} ,  n \in \mathbb{N}\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
2ExprTuple35, 38
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 30
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple23, 32, 33
13Operationoperator: 17
operands: 18
14ExprTuple35, 19
15Literal
16ExprTuple38, 19
17Literal
18ExprTuple20, 21
19Literal
20Conditionalvalue: 23
condition: 22
21Conditionalvalue: 23
condition: 24
22Operationoperator: 30
operands: 25
23Variable
24Operationoperator: 30
operands: 26
25ExprTuple27, 28
26ExprTuple32, 33
27Operationoperator: 30
operands: 29
28Operationoperator: 30
operands: 31
29ExprTuple32
30Literal
31ExprTuple33
32ExprRangelambda_map: 34
start_index: 37
end_index: 35
33ExprRangelambda_map: 36
start_index: 37
end_index: 38
34Lambdaparameter: 44
body: 39
35Variable
36Lambdaparameter: 44
body: 40
37Literal
38Variable
39IndexedVarvariable: 41
index: 44
40IndexedVarvariable: 42
index: 44
41Variable
42Variable
43ExprTuple44
44Variable