logo

Expression of type Forall

from the theory of proveit.logic.sets.cartesian_products

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 x
from proveit.core_expr_types import A_1_to_m, a_1_to_m
from proveit.logic import And, CartProd, Equals, Forall, InSet
from proveit.logic.sets.cartesian_products import a_in_A__1_to_m
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [x, A_1_to_m, a_1_to_m], instance_expr = Equals(InSet(x, CartProd(A_1_to_m)), And(Equals(x, [a_1_to_m]), a_in_A__1_to_m)).with_wrapping_at(2))
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_{x, A_{1}, A_{2}, \ldots, A_{m}, a_{1}, a_{2}, \ldots, a_{m}}~\left(\begin{array}{c} \begin{array}{l} \left(x \in \left(A_{1} \times  A_{2} \times  \ldots \times  A_{m}\right)\right) =  \\ \left(\left(x = \left(a_{1}, a_{2}, \ldots, a_{m}\right)\right)\land \left(a_{1} \in A_{1}\right) \land  \left(a_{2} \in A_{2}\right) \land  \ldots \land  \left(a_{m} \in A_{m}\right)\right) \end{array} \end{array}\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple21, 20, 25
5Operationoperator: 17
operands: 6
6ExprTuple7, 8
7Operationoperator: 26
operands: 9
8Operationoperator: 10
operands: 11
9ExprTuple21, 12
10Literal
11ExprTuple13, 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprRangelambda_map: 19
start_index: 29
end_index: 30
15Literal
16ExprTuple20
17Literal
18ExprTuple21, 22
19Lambdaparameter: 36
body: 23
20ExprRangelambda_map: 24
start_index: 29
end_index: 30
21Variable
22ExprTuple25
23Operationoperator: 26
operands: 27
24Lambdaparameter: 36
body: 31
25ExprRangelambda_map: 28
start_index: 29
end_index: 30
26Literal
27ExprTuple32, 31
28Lambdaparameter: 36
body: 32
29Literal
30Variable
31IndexedVarvariable: 33
index: 36
32IndexedVarvariable: 34
index: 36
33Variable
34Variable
35ExprTuple36
36Variable