logo

Expression of type Forall

from the theory of proveit.logic.sets.enumeration

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 P, Px, n, x
from proveit.core_expr_types import Pk_a1_to_an, a_1_to_n
from proveit.logic import Forall, Set
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [P], instance_expr = Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n)), condition = Pk_a1_to_an)), domain = Natural)
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_{n \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{n}}~\left[\forall_{P~|~P\left(a_{1}\right), P\left(a_{2}\right), \ldots, P\left(a_{n}\right)}~\left[\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)\right]\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: 18
operand: 2
1ExprTuple2
2Lambdaparameter: 41
body: 4
3ExprTuple41
4Conditionalvalue: 5
condition: 6
5Operationoperator: 18
operand: 9
6Operationoperator: 30
operands: 8
7ExprTuple9
8ExprTuple41, 10
9Lambdaparameters: 37
body: 11
10Literal
11Operationoperator: 18
operand: 13
12ExprTuple13
13Lambdaparameter: 32
body: 15
14ExprTuple32
15Conditionalvalue: 16
condition: 17
16Operationoperator: 18
operand: 22
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple23
22Lambdaparameter: 34
body: 24
23ExprRangelambda_map: 25
start_index: 40
end_index: 41
24Conditionalvalue: 26
condition: 27
25Lambdaparameter: 45
body: 28
26Operationoperator: 32
operand: 34
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operand: 42
29ExprTuple34
30Literal
31ExprTuple34, 35
32Variable
33ExprTuple42
34Variable
35Operationoperator: 36
operands: 37
36Literal
37ExprTuple38
38ExprRangelambda_map: 39
start_index: 40
end_index: 41
39Lambdaparameter: 45
body: 42
40Literal
41Variable
42IndexedVarvariable: 43
index: 45
43Variable
44ExprTuple45
45Variable