logo

Expression of type Forall

from the theory of proveit.numbers.summation

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 Function, R, S, a, f, fa, fx, g, gy, n, x, y
from proveit.logic import Card, Equals, Forall, Implies, InSet, SetOfAll
from proveit.numbers import Complex, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y]
expr = Forall(instance_param_or_params = [f, g, R, S], instance_expr = Implies(Forall(instance_param_or_params = [a], instance_expr = InSet(fa, Complex), domain = R), Equals(Sum(index_or_indices = [x], summand = fx, domain = R), Sum(index_or_indices = sub_expr1, summand = Function(f, [gy]), domain = S))), conditions = [Equals(SetOfAll(instance_param_or_params = sub_expr1, instance_element = gy, domain = S), R), Equals(Card(S), n), Equals(Card(R), 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_{f, g, R, S~|~\left\{g\left(y\right)\right\}_{y \in S} = R, |S| = n, |R| = n}~\left(\left[\forall_{a \in R}~\left(f\left(a\right) \in \mathbb{C}\right)\right] \Rightarrow \left(\left[\sum_{x \in R}~f\left(x\right)\right] = \left[\sum_{y \in S}~f\left(g\left(y\right)\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: 16
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple58, 67, 64, 66
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15
11Operationoperator: 16
operand: 23
12Operationoperator: 21
operands: 18
13Operationoperator: 21
operands: 19
14Operationoperator: 21
operands: 20
15Operationoperator: 21
operands: 22
16Literal
17ExprTuple23
18ExprTuple24, 25
19ExprTuple26, 64
20ExprTuple27, 29
21Literal
22ExprTuple28, 29
23Lambdaparameter: 62
body: 30
24Operationoperator: 32
operand: 41
25Operationoperator: 32
operand: 42
26Operationoperator: 34
operand: 43
27Operationoperator: 37
operand: 66
28Operationoperator: 37
operand: 64
29Variable
30Conditionalvalue: 39
condition: 40
31ExprTuple41
32Literal
33ExprTuple42
34Literal
35ExprTuple43
36ExprTuple66
37Literal
38ExprTuple64
39Operationoperator: 60
operands: 44
40Operationoperator: 60
operands: 45
41Lambdaparameter: 63
body: 46
42Lambdaparameter: 69
body: 47
43Lambdaparameter: 69
body: 48
44ExprTuple49, 50
45ExprTuple62, 64
46Conditionalvalue: 51
condition: 52
47Conditionalvalue: 53
condition: 54
48Conditionalvalue: 65
condition: 54
49Operationoperator: 58
operand: 62
50Literal
51Operationoperator: 58
operand: 63
52Operationoperator: 60
operands: 57
53Operationoperator: 58
operand: 65
54Operationoperator: 60
operands: 61
55ExprTuple62
56ExprTuple63
57ExprTuple63, 64
58Variable
59ExprTuple65
60Literal
61ExprTuple69, 66
62Variable
63Variable
64Variable
65Operationoperator: 67
operand: 69
66Variable
67Variable
68ExprTuple69
69Variable