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, Equals, 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 = Equals(And(Pk_a1_to_an), 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}~\left(\left(P\left(a_{1}\right) \land  P\left(a_{2}\right) \land  \ldots \land  P\left(a_{n}\right)\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: 14
operand: 2
1ExprTuple2
2Lambdaparameters: 31
body: 3
3Operationoperator: 14
operand: 5
4ExprTuple5
5Lambdaparameter: 24
body: 7
6ExprTuple24
7Operationoperator: 8
operands: 9
8Literal
9ExprTuple10, 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operand: 17
12Literal
13ExprTuple16
14Literal
15ExprTuple17
16ExprRangelambda_map: 18
start_index: 34
end_index: 35
17Lambdaparameter: 28
body: 19
18Lambdaparameter: 39
body: 20
19Conditionalvalue: 21
condition: 22
20Operationoperator: 24
operand: 36
21Operationoperator: 24
operand: 28
22Operationoperator: 26
operands: 27
23ExprTuple36
24Variable
25ExprTuple28
26Literal
27ExprTuple28, 29
28Variable
29Operationoperator: 30
operands: 31
30Literal
31ExprTuple32
32ExprRangelambda_map: 33
start_index: 34
end_index: 35
33Lambdaparameter: 39
body: 36
34Literal
35Variable
36IndexedVarvariable: 37
index: 39
37Variable
38ExprTuple39
39Variable