logo

Expression of type Conditional

from the theory of proveit.linear_algebra.addition

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, K, V, i, j, k, v
from proveit.linear_algebra import ScalarMult, VecSpaces, VecSum
from proveit.logic import Equals, Forall, InClass
from proveit.numbers import Add, Interval, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [v], instance_expr = Equals(VecSum(index_or_indices = [i], summand = v, domain = Interval(j, k)), ScalarMult(Add(subtract(k, j), one), v)), domain = V), InClass(V, VecSpaces(K)))
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_{v \in V}~\left(\left(\sum_{i=j}^{k} v\right) = \left(\left(\left(k - j\right) + 1\right) \cdot v\right)\right) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\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: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple21, 8
7Lambdaparameter: 31
body: 10
8Operationoperator: 11
operand: 15
9ExprTuple31
10Conditionalvalue: 13
condition: 14
11Literal
12ExprTuple15
13Operationoperator: 16
operands: 17
14Operationoperator: 35
operands: 18
15Variable
16Literal
17ExprTuple19, 20
18ExprTuple31, 21
19Operationoperator: 22
operand: 26
20Operationoperator: 24
operands: 25
21Variable
22Literal
23ExprTuple26
24Literal
25ExprTuple27, 31
26Lambdaparameter: 39
body: 29
27Operationoperator: 37
operands: 30
28ExprTuple39
29Conditionalvalue: 31
condition: 32
30ExprTuple33, 34
31Variable
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34Literal
35Literal
36ExprTuple39, 40
37Literal
38ExprTuple46, 41
39Variable
40Operationoperator: 42
operands: 43
41Operationoperator: 44
operand: 47
42Literal
43ExprTuple47, 46
44Literal
45ExprTuple47
46Variable
47Variable