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, x
from proveit.core_expr_types import Pk_a1_to_an, a_1_to_n
from proveit.logic import And, Forall, Set
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [P], instance_expr = And(Pk_a1_to_an), condition = Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n))))
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_{a_{1}, a_{2}, \ldots, a_{n}}~\left[\forall_{P~|~\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)}~\left(P\left(a_{1}\right) \land  P\left(a_{2}\right) \land  \ldots \land  P\left(a_{n}\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: 12
operand: 2
1ExprTuple2
2Lambdaparameters: 29
body: 3
3Operationoperator: 12
operand: 5
4ExprTuple5
5Lambdaparameter: 22
body: 7
6ExprTuple22
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operand: 15
10Literal
11ExprTuple14
12Literal
13ExprTuple15
14ExprRangelambda_map: 16
start_index: 32
end_index: 33
15Lambdaparameter: 26
body: 17
16Lambdaparameter: 37
body: 18
17Conditionalvalue: 19
condition: 20
18Operationoperator: 22
operand: 34
19Operationoperator: 22
operand: 26
20Operationoperator: 24
operands: 25
21ExprTuple34
22Variable
23ExprTuple26
24Literal
25ExprTuple26, 27
26Variable
27Operationoperator: 28
operands: 29
28Literal
29ExprTuple30
30ExprRangelambda_map: 31
start_index: 32
end_index: 33
31Lambdaparameter: 37
body: 34
32Literal
33Variable
34IndexedVarvariable: 35
index: 37
35Variable
36ExprTuple37
37Variable