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, Boolean, 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, alpha], Conditional(Forall(instance_param_or_params = [P, Q], 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)), And(InSet(n, NaturalPos), InSet(alpha, Boolean)))))
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(n, \alpha\right) \mapsto \left\{\forall_{P, Q}~\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}^+ ,  \alpha \in \mathbb{B}\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
2ExprTuple51, 42
3Conditionalvalue: 4
condition: 5
4Operationoperator: 26
operand: 8
5Operationoperator: 20
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple44, 39
12Operationoperator: 37
operands: 16
13ExprTuple51, 17
14Literal
15ExprTuple42, 18
16ExprTuple19, 42
17Literal
18Literal
19Operationoperator: 20
operands: 21
20Literal
21ExprTuple22, 23
22Operationoperator: 24
operand: 28
23Operationoperator: 26
operand: 29
24Literal
25ExprTuple28
26Literal
27ExprTuple29
28Lambdaparameters: 36
body: 30
29Lambdaparameters: 45
body: 31
30Conditionalvalue: 32
condition: 33
31Conditionalvalue: 34
condition: 35
32Operationoperator: 44
operands: 36
33Operationoperator: 39
operands: 36
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 45
36ExprTuple40
37Literal
38ExprTuple41, 42
39Variable
40ExprRangelambda_map: 43
start_index: 50
end_index: 51
41Operationoperator: 44
operands: 45
42Variable
43Lambdaparameter: 55
body: 46
44Variable
45ExprTuple47
46IndexedVarvariable: 48
index: 55
47ExprRangelambda_map: 49
start_index: 50
end_index: 51
48Variable
49Lambdaparameter: 55
body: 52
50Literal
51Variable
52IndexedVarvariable: 53
index: 55
53Variable
54ExprTuple55
55Variable