logo
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, 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 = 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\{\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..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 23
operand: 5
2Operationoperator: 17
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 8
body: 9
6Operationoperator: 11
operands: 10
7Operationoperator: 11
operands: 12
8ExprTuple41, 36
9Operationoperator: 34
operands: 13
10ExprTuple48, 14
11Literal
12ExprTuple39, 15
13ExprTuple16, 39
14Literal
15Literal
16Operationoperator: 17
operands: 18
17Literal
18ExprTuple19, 20
19Operationoperator: 21
operand: 25
20Operationoperator: 23
operand: 26
21Literal
22ExprTuple25
23Literal
24ExprTuple26
25Lambdaparameters: 33
body: 27
26Lambdaparameters: 42
body: 28
27Conditionalvalue: 29
condition: 30
28Conditionalvalue: 31
condition: 32
29Operationoperator: 41
operands: 33
30Operationoperator: 36
operands: 33
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 42
33ExprTuple37
34Literal
35ExprTuple38, 39
36Variable
37ExprRangelambda_map: 40
start_index: 47
end_index: 48
38Operationoperator: 41
operands: 42
39Variable
40Lambdaparameter: 52
body: 43
41Variable
42ExprTuple44
43IndexedVarvariable: 45
index: 52
44ExprRangelambda_map: 46
start_index: 47
end_index: 48
45Variable
46Lambdaparameter: 52
body: 49
47Literal
48Variable
49IndexedVarvariable: 50
index: 52
50Variable
51ExprTuple52
52Variable