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 LinDepSets, VecZero, lin_comb_axn, some_nonzero_a
from proveit.logic import And, Equals, Exists, InSet, Set
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(InSet(Set(x_1_to_n), LinDepSets(V)), Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(lin_comb_axn, VecZero(V)), domain = K, condition = some_nonzero_a).with_wrapping()).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} \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{LinDepSets}\left(V\right)\right) =  \\ \left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in K~|~\left(a_{1} \neq 0\right) \lor  \left(a_{2} \neq 0\right) \lor  \ldots \lor  \left(a_{n} \neq 0\right)}~\\
\left(\left(\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right)\right) = \vec{0}\left(V\right)\right)\end{array}\right] \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: 28
operands: 3
2Operationoperator: 30
operands: 4
3ExprTuple5, 6
4ExprTuple7
5Operationoperator: 48
operands: 8
6Operationoperator: 9
operand: 14
7ExprRangelambda_map: 11
start_index: 51
end_index: 52
8ExprTuple12, 13
9Literal
10ExprTuple14
11Lambdaparameter: 66
body: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operand: 44
14Lambdaparameters: 19
body: 20
15Operationoperator: 48
operands: 21
16Literal
17ExprTuple22
18Literal
19ExprTuple23
20Conditionalvalue: 24
condition: 25
21ExprTuple60, 44
22ExprRangelambda_map: 26
start_index: 51
end_index: 52
23ExprRangelambda_map: 27
start_index: 51
end_index: 52
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operands: 31
26Lambdaparameter: 66
body: 60
27Lambdaparameter: 66
body: 61
28Literal
29ExprTuple32, 33
30Literal
31ExprTuple34, 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operand: 44
34ExprRangelambda_map: 40
start_index: 51
end_index: 52
35Operationoperator: 41
operands: 42
36Literal
37ExprTuple43
38Literal
39ExprTuple44
40Lambdaparameter: 66
body: 45
41Literal
42ExprTuple46
43ExprRangelambda_map: 47
start_index: 51
end_index: 52
44Variable
45Operationoperator: 48
operands: 49
46ExprRangelambda_map: 50
start_index: 51
end_index: 52
47Lambdaparameter: 66
body: 53
48Literal
49ExprTuple61, 54
50Lambdaparameter: 66
body: 55
51Literal
52Variable
53Operationoperator: 56
operands: 57
54Variable
55Operationoperator: 58
operands: 59
56Literal
57ExprTuple61, 60
58Literal
59ExprTuple61, 62
60IndexedVarvariable: 63
index: 66
61IndexedVarvariable: 64
index: 66
62Literal
63Variable
64Variable
65ExprTuple66
66Variable