logo

Expression of type Conditional

from the theory of proveit.linear_algebra.vector_sets

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, n, x
from proveit.core_expr_types import a_1_to_n, x_1_to_n
from proveit.linear_algebra import Span, lin_comb_axn
from proveit.logic import And, Equals, InSet, Set, SetOfAll
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Equals(Span(Set(x_1_to_n)), SetOfAll(instance_param_or_params = [a_1_to_n], instance_element = lin_comb_axn, domain = K)).with_wrapping_at(2), And(ExprRange(sub_expr1, InSet(IndexedVar(x, sub_expr1), V), one, n)))
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\{\begin{array}{c} \begin{array}{l} \textrm{Span}\left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\}\right) =  \\ \left\{\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right)\right\}_{a_{1}, a_{2}, \ldots, a_{n} \in K} \end{array} \end{array} \textrm{ if } \left(x_{1} \in V\right) \land  \left(x_{2} \in V\right) \land  \ldots \land  \left(x_{n} \in V\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
operands: 4
2Operationoperator: 31
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple8
6Operationoperator: 9
operand: 14
7Operationoperator: 11
operand: 15
8ExprRangelambda_map: 13
start_index: 37
end_index: 38
9Literal
10ExprTuple14
11Literal
12ExprTuple15
13Lambdaparameter: 51
body: 16
14Operationoperator: 17
operands: 18
15Lambdaparameters: 19
body: 20
16Operationoperator: 43
operands: 21
17Literal
18ExprTuple22
19ExprTuple23
20Conditionalvalue: 24
condition: 25
21ExprTuple45, 26
22ExprRangelambda_map: 27
start_index: 37
end_index: 38
23ExprRangelambda_map: 28
start_index: 37
end_index: 38
24Operationoperator: 29
operands: 30
25Operationoperator: 31
operands: 32
26Variable
27Lambdaparameter: 51
body: 45
28Lambdaparameter: 51
body: 46
29Literal
30ExprTuple33
31Literal
32ExprTuple34
33ExprRangelambda_map: 35
start_index: 37
end_index: 38
34ExprRangelambda_map: 36
start_index: 37
end_index: 38
35Lambdaparameter: 51
body: 39
36Lambdaparameter: 51
body: 40
37Literal
38Variable
39Operationoperator: 41
operands: 42
40Operationoperator: 43
operands: 44
41Literal
42ExprTuple46, 45
43Literal
44ExprTuple46, 47
45IndexedVarvariable: 48
index: 51
46IndexedVarvariable: 49
index: 51
47Variable
48Variable
49Variable
50ExprTuple51
51Variable