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, alpha, n
from proveit.core_expr_types import P__x_1_to_n, Q__x_1_to_n, x_1_to_n
from proveit.logic import And, Forall, Implies, InSet
from proveit.logic.booleans.quantification import general_exists_Py_st_Qy
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, alpha], instance_expr = Implies(And(general_exists_Py_st_Qy, Forall(instance_param_or_params = [x_1_to_n], instance_expr = Implies(P__x_1_to_n, alpha), condition = Q__x_1_to_n)), alpha)), 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, \alpha}~\left(\left(\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] \land \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 \alpha\right)\right]\right) \Rightarrow \alpha\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: 46
body: 3
2ExprTuple46
3Conditionalvalue: 4
condition: 5
4Operationoperator: 21
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple46, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple39, 34, 37
12Operationoperator: 32
operands: 13
13ExprTuple14, 37
14Operationoperator: 15
operands: 16
15Literal
16ExprTuple17, 18
17Operationoperator: 19
operand: 23
18Operationoperator: 21
operand: 24
19Literal
20ExprTuple23
21Literal
22ExprTuple24
23Lambdaparameters: 31
body: 25
24Lambdaparameters: 40
body: 26
25Conditionalvalue: 27
condition: 28
26Conditionalvalue: 29
condition: 30
27Operationoperator: 39
operands: 31
28Operationoperator: 34
operands: 31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 40
31ExprTuple35
32Literal
33ExprTuple36, 37
34Variable
35ExprRangelambda_map: 38
start_index: 45
end_index: 46
36Operationoperator: 39
operands: 40
37Variable
38Lambdaparameter: 50
body: 41
39Variable
40ExprTuple42
41IndexedVarvariable: 43
index: 50
42ExprRangelambda_map: 44
start_index: 45
end_index: 46
43Variable
44Lambdaparameter: 50
body: 47
45Literal
46Variable
47IndexedVarvariable: 48
index: 50
48Variable
49ExprTuple50
50Variable