# from the theory of proveit.logic.booleans.quantification.universality¶

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.
# import Expression classes needed to build the expression
from proveit import P, Q, R, m, n
from proveit.logic import Forall, Implies
from proveit.logic.booleans.quantification import general_bundled_forall_Pxy_if_Qx, general_nested_forall_Pxy_if_Qx
from proveit.numbers import NaturalPos

In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [m, n], instance_expr = Forall(instance_param_or_params = [P, Q, R], instance_expr = Implies(general_nested_forall_Pxy_if_Qx, general_bundled_forall_Pxy_if_Qx).with_wrapping_at(1)), domain = 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())

\forall_{m, n \in \mathbb{N}^+}~\left[\forall_{P, Q, R}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x_{1}, x_{2}, \ldots, x_{m}~|~Q\left(x_{1}, x_{2}, \ldots, x_{m}\right)}~\left[\forall_{y_{1}, y_{2}, \ldots, y_{n}~|~R\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)\right]\right] \\  \Rightarrow \left[\forall_{x_{1}, x_{2}, \ldots, x_{m}, y_{1}, y_{2}, \ldots, y_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{m}\right), R\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)\right] \end{array} \end{array}\right)\right]

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Operationoperator: 30
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple48, 51
4Conditionalvalue: 5
condition: 6
5Operationoperator: 30
operand: 9
6Operationoperator: 32
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 12
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple42, 38, 43
13Operationoperator: 17
operands: 18
14ExprTuple48, 19
15Literal
16ExprTuple51, 19
17Literal
18ExprTuple20, 21
19Literal
20Operationoperator: 30
operand: 24
21Operationoperator: 30
operand: 25
22ExprTuple24
23ExprTuple25
24Lambdaparameters: 39
body: 26
25Lambdaparameters: 44
body: 27
26Conditionalvalue: 28
condition: 35
27Conditionalvalue: 40
condition: 29
28Operationoperator: 30
operand: 34
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple34
32Literal
33ExprTuple35, 41
34Lambdaparameters: 36
body: 37
35Operationoperator: 38
operands: 39
36ExprTuple46
37Conditionalvalue: 40
condition: 41
38Variable
39ExprTuple45
40Operationoperator: 42
operands: 44
41Operationoperator: 43
operands: 44
42Variable
43Variable
44ExprTuple45, 46
45ExprRangelambda_map: 47
start_index: 50
end_index: 48
46ExprRangelambda_map: 49
start_index: 50
end_index: 51
47Lambdaparameter: 57
body: 52
48Variable
49Lambdaparameter: 57
body: 53
50Literal
51Variable
52IndexedVarvariable: 54
index: 57
53IndexedVarvariable: 55
index: 57
54Variable
55Variable
56ExprTuple57
57Variable