logo

Expression of type Forall

from the theory of proveit.numbers.multiplication

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 n, x
from proveit.core_expr_types import a_1_to_n
from proveit.logic import Equals, Forall, Set
from proveit.numbers import Add, Complex, Mult, Natural
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [n, x], instance_expr = Forall(instance_param_or_params = [a_1_to_n], instance_expr = Equals(Add(a_1_to_n), Mult(x, n)), domain = Set(x)), domains = [Natural, Complex])
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}, x \in \mathbb{C}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{n} \in \left\{x\right\}}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{n}\right) = \left(x \cdot 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: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple36, 46
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 22
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 28
body: 13
11Operationoperator: 37
operands: 14
12Operationoperator: 37
operands: 15
13Conditionalvalue: 16
condition: 17
14ExprTuple36, 18
15ExprTuple46, 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Literal
19Literal
20Literal
21ExprTuple24, 25
22Literal
23ExprTuple26
24Operationoperator: 27
operands: 28
25Operationoperator: 29
operands: 30
26ExprRangelambda_map: 31
start_index: 35
end_index: 36
27Literal
28ExprTuple32
29Literal
30ExprTuple46, 36
31Lambdaparameter: 45
body: 33
32ExprRangelambda_map: 34
start_index: 35
end_index: 36
33Operationoperator: 37
operands: 38
34Lambdaparameter: 45
body: 39
35Literal
36Variable
37Literal
38ExprTuple39, 40
39IndexedVarvariable: 41
index: 45
40Operationoperator: 43
operand: 46
41Variable
42ExprTuple45
43Literal
44ExprTuple46
45Variable
46Variable