logo

Expression of type Conditional

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 Conditional, ExprRange, IndexedVar, Variable, n, x, y
from proveit.core_expr_types import x_1_to_n
from proveit.logic import Equals, Forall, InSet, NotEquals
from proveit.numbers import Add, Complex, NaturalPos, frac, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Forall(instance_param_or_params = [x_1_to_n, y], instance_expr = Equals(frac(Add(x_1_to_n), y), Add(ExprRange(sub_expr1, frac(IndexedVar(x, sub_expr1), y), one, n))), domain = Complex, condition = NotEquals(y, zero)), InSet(n, NaturalPos))
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())
\left\{\forall_{x_{1}, x_{2}, \ldots, x_{n}, y \in \mathbb{C}~|~y \neq 0}~\left(\frac{x_{1} +  x_{2} +  \ldots +  x_{n}}{y} = \left(\frac{x_{1}}{y} +  \frac{x_{2}}{y} +  \ldots +  \frac{x_{n}}{y}\right)\right) \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 34
operands: 5
3Literal
4ExprTuple6
5ExprTuple41, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple36, 45
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 17
14Literal
15ExprTuple18, 19, 20
16Operationoperator: 42
operands: 21
17Operationoperator: 31
operands: 22
18ExprRangelambda_map: 23
start_index: 40
end_index: 41
19Operationoperator: 34
operands: 24
20Operationoperator: 25
operands: 26
21ExprTuple27, 45
22ExprTuple28
23Lambdaparameter: 48
body: 29
24ExprTuple45, 38
25Literal
26ExprTuple45, 30
27Operationoperator: 31
operands: 32
28ExprRangelambda_map: 33
start_index: 40
end_index: 41
29Operationoperator: 34
operands: 35
30Literal
31Literal
32ExprTuple36
33Lambdaparameter: 48
body: 37
34Literal
35ExprTuple44, 38
36ExprRangelambda_map: 39
start_index: 40
end_index: 41
37Operationoperator: 42
operands: 43
38Literal
39Lambdaparameter: 48
body: 44
40Literal
41Variable
42Literal
43ExprTuple44, 45
44IndexedVarvariable: 46
index: 48
45Variable
46Variable
47ExprTuple48
48Variable