logo

Expression of type Conditional

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 Conditional, n, x
from proveit.core_expr_types import a_1_to_n
from proveit.logic import And, Equals, Forall, InSet, Set
from proveit.numbers import Add, Complex, Mult, Natural
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a_1_to_n], instance_expr = Equals(Add(a_1_to_n), Mult(x, n)), domain = Set(x)), And(InSet(n, Natural), InSet(x, 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())
\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) \textrm{ if } n \in \mathbb{N} ,  x \in \mathbb{C}\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: 18
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 24
body: 9
7Operationoperator: 33
operands: 10
8Operationoperator: 33
operands: 11
9Conditionalvalue: 12
condition: 13
10ExprTuple32, 14
11ExprTuple42, 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Literal
15Literal
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22ExprRangelambda_map: 27
start_index: 31
end_index: 32
23Literal
24ExprTuple28
25Literal
26ExprTuple42, 32
27Lambdaparameter: 41
body: 29
28ExprRangelambda_map: 30
start_index: 31
end_index: 32
29Operationoperator: 33
operands: 34
30Lambdaparameter: 41
body: 35
31Literal
32Variable
33Literal
34ExprTuple35, 36
35IndexedVarvariable: 37
index: 41
36Operationoperator: 39
operand: 42
37Variable
38ExprTuple41
39Literal
40ExprTuple42
41Variable
42Variable