logo

Expression of type Forall

from the theory of proveit.logic.booleans.disjunction

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 A, ExprRange, IndexedVar, Variable, m
from proveit.logic import Boolean, Forall, InSet, Or
from proveit.numbers import Add, one, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(A, sub_expr1)
sub_expr3 = Add(m, one)
expr = Forall(instance_param_or_params = [ExprRange(sub_expr1, sub_expr2, one, Add(m, two))], instance_expr = InSet(Or(ExprRange(sub_expr1, sub_expr2, one, sub_expr3)), Boolean), condition = ExprRange(sub_expr1, InSet(sub_expr2, Boolean), one, sub_expr3))
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_{m + 2}~|~\left(A_{1} \in \mathbb{B}\right), \left(A_{2} \in \mathbb{B}\right), \ldots, \left(A_{m + 1} \in \mathbb{B}\right)}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m + 1}\right) \in \mathbb{B}\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
4ExprTuple6
5Conditionalvalue: 7
condition: 8
6ExprRangelambda_map: 22
start_index: 31
end_index: 9
7Operationoperator: 24
operands: 10
8Operationoperator: 11
operands: 12
9Operationoperator: 26
operands: 13
10ExprTuple14, 29
11Literal
12ExprTuple15
13ExprTuple30, 16
14Operationoperator: 17
operands: 18
15ExprRangelambda_map: 19
start_index: 31
end_index: 23
16Literal
17Literal
18ExprTuple20
19Lambdaparameter: 34
body: 21
20ExprRangelambda_map: 22
start_index: 31
end_index: 23
21Operationoperator: 24
operands: 25
22Lambdaparameter: 34
body: 28
23Operationoperator: 26
operands: 27
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple30, 31
28IndexedVarvariable: 32
index: 34
29Literal
30Variable
31Literal
32Variable
33ExprTuple34
34Variable