logo

Expression of type Conditional

from the theory of proveit.linear_algebra.linear_maps

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 A, B, Conditional, Function, K, Lambda, V, W, x
from proveit.linear_algebra import LinMap, VecAdd, VecSpaces
from proveit.logic import And, Equals, Forall, InClass, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = VecSpaces(K)
expr = Conditional(Forall(instance_param_or_params = [A, B], instance_expr = Equals(VecAdd(A, B), Lambda(x, Conditional(VecAdd(Function(A, sub_expr1), Function(B, sub_expr1)), InSet(x, V)))), domain = LinMap(V, W)), And(InClass(V, sub_expr2), InClass(W, sub_expr2)))
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_{A, B \in \mathcal{L}\left(V, W\right)}~\left(\left(A + B\right) = \left[x \mapsto \left\{A\left(x\right) + B\left(x\right) \textrm{ if } x \in V\right..\right]\right) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right) ,  W \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: 6
2Operationoperator: 18
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 27
body: 9
7Operationoperator: 11
operands: 10
8Operationoperator: 11
operands: 12
9Conditionalvalue: 13
condition: 14
10ExprTuple42, 15
11Literal
12ExprTuple43, 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operand: 26
16Literal
17ExprTuple22, 23
18Literal
19ExprTuple24, 25
20Literal
21ExprTuple26
22Operationoperator: 34
operands: 27
23Lambdaparameter: 47
body: 28
24Operationoperator: 36
operands: 29
25Operationoperator: 36
operands: 30
26Variable
27ExprTuple44, 45
28Conditionalvalue: 31
condition: 32
29ExprTuple44, 33
30ExprTuple45, 33
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operands: 39
34Literal
35ExprTuple40, 41
36Literal
37ExprTuple47, 42
38Literal
39ExprTuple42, 43
40Operationoperator: 44
operand: 47
41Operationoperator: 45
operand: 47
42Variable
43Variable
44Variable
45Variable
46ExprTuple47
47Variable