logo

Expression of type Forall

from the theory of proveit.numbers.division

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, Py, S, y, z
from proveit.logic import Equals, Forall, Implies, InSet, NotEquals
from proveit.numbers import Complex, Sum, frac, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y]
expr = Forall(instance_param_or_params = [P, S], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(Py, Complex), domain = S), Forall(instance_param_or_params = [z], instance_expr = Equals(frac(Sum(index_or_indices = sub_expr1, summand = Py, domain = S), z), Sum(index_or_indices = sub_expr1, summand = frac(Py, z), domain = S)), domain = Complex, condition = NotEquals(z, zero))))
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_{P, S}~\left(\left[\forall_{y \in S}~\left(P\left(y\right) \in \mathbb{C}\right)\right] \Rightarrow \left[\forall_{z \in \mathbb{C}~|~z \neq 0}~\left(\frac{\sum_{y \in S}~P\left(y\right)}{z} = \left[\sum_{y \in S}~\frac{P\left(y\right)}{z}\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: 10
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple51, 53
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8
7Operationoperator: 10
operand: 12
8Operationoperator: 10
operand: 13
9ExprTuple12
10Literal
11ExprTuple13
12Lambdaparameter: 54
body: 14
13Lambdaparameter: 48
body: 16
14Conditionalvalue: 17
condition: 46
15ExprTuple48
16Conditionalvalue: 18
condition: 19
17Operationoperator: 49
operands: 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20ExprTuple47, 36
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27, 28
25Operationoperator: 44
operands: 29
26Operationoperator: 38
operand: 35
27Operationoperator: 49
operands: 31
28Operationoperator: 32
operands: 33
29ExprTuple34, 48
30ExprTuple35
31ExprTuple48, 36
32Literal
33ExprTuple48, 37
34Operationoperator: 38
operand: 41
35Lambdaparameter: 54
body: 40
36Literal
37Literal
38Literal
39ExprTuple41
40Conditionalvalue: 42
condition: 46
41Lambdaparameter: 54
body: 43
42Operationoperator: 44
operands: 45
43Conditionalvalue: 47
condition: 46
44Literal
45ExprTuple47, 48
46Operationoperator: 49
operands: 50
47Operationoperator: 51
operand: 54
48Variable
49Literal
50ExprTuple54, 53
51Variable
52ExprTuple54
53Variable
54Variable