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 And, Equals, Forall, InSet
from proveit.numbers import Add, Integer, Interval, LessEq, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [V], instance_expr = 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), domain = VecSpaces(K)), And(InSet(j, Integer), InSet(k, Integer), LessEq(j, 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 \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\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)\right] \textrm{ if } j \in \mathbb{Z} ,  k \in \mathbb{Z} ,  j \leq k\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: 18
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8, 9
6Lambdaparameter: 36
body: 11
7Operationoperator: 50
operands: 12
8Operationoperator: 50
operands: 13
9Operationoperator: 14
operands: 58
10ExprTuple36
11Conditionalvalue: 15
condition: 16
12ExprTuple62, 17
13ExprTuple61, 17
14Literal
15Operationoperator: 18
operand: 22
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22
20Literal
21ExprTuple36, 23
22Lambdaparameter: 46
body: 25
23Operationoperator: 26
operand: 30
24ExprTuple46
25Conditionalvalue: 28
condition: 29
26Literal
27ExprTuple30
28Operationoperator: 31
operands: 32
29Operationoperator: 50
operands: 33
30Variable
31Literal
32ExprTuple34, 35
33ExprTuple46, 36
34Operationoperator: 37
operand: 41
35Operationoperator: 39
operands: 40
36Variable
37Literal
38ExprTuple41
39Literal
40ExprTuple42, 46
41Lambdaparameter: 54
body: 44
42Operationoperator: 52
operands: 45
43ExprTuple54
44Conditionalvalue: 46
condition: 47
45ExprTuple48, 49
46Variable
47Operationoperator: 50
operands: 51
48Operationoperator: 52
operands: 53
49Literal
50Literal
51ExprTuple54, 55
52Literal
53ExprTuple61, 56
54Variable
55Operationoperator: 57
operands: 58
56Operationoperator: 59
operand: 62
57Literal
58ExprTuple62, 61
59Literal
60ExprTuple62
61Variable
62Variable