logo

Expression of type Conditional

from the theory of proveit.linear_algebra.scalar_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, ExprRange, IndexedVar, K, V, Variable, a, i, v
from proveit.core_expr_types import a_1_to_i
from proveit.linear_algebra import ScalarMult, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, InClass
from proveit.numbers import Complex, Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Forall(instance_param_or_params = [i], instance_expr = Forall(instance_param_or_params = [a_1_to_i, v], instance_expr = Equals(VecAdd(ExprRange(sub_expr1, ScalarMult(IndexedVar(a, sub_expr1), v), one, i)), ScalarMult(VecAdd(a_1_to_i), v)).with_wrapping_at(2), domains = [Complex, V]), domain = Natural), 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_{i \in \mathbb{N}}~\left[\forall_{\left(a_{1} \in \mathbb{C}\right), \left(a_{2} \in \mathbb{C}\right), \ldots, \left(a_{i} \in \mathbb{C}\right), v \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} \cdot v\right) +  \left(a_{2} \cdot v\right) +  \ldots +  \left(a_{i} \cdot v\right)\right) =  \\ \left(\left(a_{1} +  a_{2} +  \ldots +  a_{i}\right) \cdot v\right) \end{array} \end{array}\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: 15
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple39, 7
6Lambdaparameter: 52
body: 9
7Operationoperator: 10
operand: 14
8ExprTuple52
9Conditionalvalue: 12
condition: 13
10Literal
11ExprTuple14
12Operationoperator: 15
operand: 18
13Operationoperator: 43
operands: 17
14Variable
15Literal
16ExprTuple18
17ExprTuple52, 19
18Lambdaparameters: 20
body: 21
19Literal
20ExprTuple46, 53
21Conditionalvalue: 22
condition: 23
22Operationoperator: 24
operands: 25
23Operationoperator: 26
operands: 27
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple30, 31
28Operationoperator: 41
operands: 32
29Operationoperator: 48
operands: 33
30ExprRangelambda_map: 34
start_index: 51
end_index: 52
31Operationoperator: 43
operands: 35
32ExprTuple36
33ExprTuple37, 53
34Lambdaparameter: 57
body: 38
35ExprTuple53, 39
36ExprRangelambda_map: 40
start_index: 51
end_index: 52
37Operationoperator: 41
operands: 42
38Operationoperator: 43
operands: 44
39Variable
40Lambdaparameter: 57
body: 45
41Literal
42ExprTuple46
43Literal
44ExprTuple54, 47
45Operationoperator: 48
operands: 49
46ExprRangelambda_map: 50
start_index: 51
end_index: 52
47Literal
48Literal
49ExprTuple54, 53
50Lambdaparameter: 57
body: 54
51Literal
52Variable
53Variable
54IndexedVarvariable: 55
index: 57
55Variable
56ExprTuple57
57Variable