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, TRUE
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(Q_1_to_m, TRUE, 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} ,  Q_{2} ,  \ldots ,  Q_{m} ,  \top, R_{1} ,  R_{2} ,  \ldots ,  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
2ExprTuple32, 35
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 26
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple23, 29, 30
13Operationoperator: 17
operands: 18
14ExprTuple32, 19
15Literal
16ExprTuple35, 19
17Literal
18ExprTuple20, 21
19Literal
20Conditionalvalue: 23
condition: 22
21Conditionalvalue: 23
condition: 24
22Operationoperator: 26
operands: 25
23Variable
24Operationoperator: 26
operands: 27
25ExprTuple29, 28, 30
26Literal
27ExprTuple29, 30
28Literal
29ExprRangelambda_map: 31
start_index: 34
end_index: 32
30ExprRangelambda_map: 33
start_index: 34
end_index: 35
31Lambdaparameter: 41
body: 36
32Variable
33Lambdaparameter: 41
body: 37
34Literal
35Variable
36IndexedVarvariable: 38
index: 41
37IndexedVarvariable: 39
index: 41
38Variable
39Variable
40ExprTuple41
41Variable