logo

Expression of type ExprTuple

from the theory of proveit.logic.booleans.quantification.existence

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, P, Q, R, n
from proveit.logic import Forall, Implies, InSet
from proveit.logic.booleans.quantification import general_exists_Py_st_Qy, general_exists_Rz_st_Qz, general_forall_st_Qx__Px_implies_Rx
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [P, Q, R], instance_expr = Implies(general_forall_st_Qx__Px_implies_Rx, Implies(general_exists_Py_st_Qy, general_exists_Rz_st_Qz).with_wrapping_at(2)).with_wrapping_at(2)), InSet(n, 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())
\left(n \mapsto \left\{\forall_{P, Q, R}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x_{1}, x_{2}, \ldots, x_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~\left(P\left(x_{1}, x_{2}, \ldots, x_{n}\right) \Rightarrow R\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left[\exists_{y_{1}, y_{2}, \ldots, y_{n}~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right] \Rightarrow  \\ \left[\exists_{z_{1}, z_{2}, \ldots, z_{n}~|~Q\left(z_{1}, z_{2}, \ldots, z_{n}\right)}~R\left(z_{1}, z_{2}, \ldots, z_{n}\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\right) \textrm{ if } 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
1Lambdaparameter: 53
body: 3
2ExprTuple53
3Conditionalvalue: 4
condition: 5
4Operationoperator: 16
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple53, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple41, 44, 43
12Operationoperator: 30
operands: 13
13ExprTuple14, 15
14Operationoperator: 16
operand: 19
15Operationoperator: 30
operands: 18
16Literal
17ExprTuple19
18ExprTuple20, 21
19Lambdaparameters: 40
body: 22
20Operationoperator: 24
operand: 28
21Operationoperator: 24
operand: 29
22Conditionalvalue: 26
condition: 27
23ExprTuple28
24Literal
25ExprTuple29
26Operationoperator: 30
operands: 31
27Operationoperator: 44
operands: 40
28Lambdaparameters: 42
body: 32
29Lambdaparameters: 45
body: 33
30Literal
31ExprTuple34, 35
32Conditionalvalue: 36
condition: 37
33Conditionalvalue: 38
condition: 39
34Operationoperator: 41
operands: 40
35Operationoperator: 43
operands: 40
36Operationoperator: 41
operands: 42
37Operationoperator: 44
operands: 42
38Operationoperator: 43
operands: 45
39Operationoperator: 44
operands: 45
40ExprTuple46
41Variable
42ExprTuple47
43Variable
44Variable
45ExprTuple48
46ExprRangelambda_map: 49
start_index: 52
end_index: 53
47ExprRangelambda_map: 50
start_index: 52
end_index: 53
48ExprRangelambda_map: 51
start_index: 52
end_index: 53
49Lambdaparameter: 61
body: 54
50Lambdaparameter: 61
body: 55
51Lambdaparameter: 61
body: 56
52Literal
53Variable
54IndexedVarvariable: 57
index: 61
55IndexedVarvariable: 58
index: 61
56IndexedVarvariable: 59
index: 61
57Variable
58Variable
59Variable
60ExprTuple61
61Variable