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 Conditional, Function, K, P, Px, Py, V, W, c, x, y
from proveit.linear_algebra import LinMap, ScalarMult, VecAdd, VecSpaces
from proveit.logic import And, Equals, Forall, Iff, 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 = [P], instance_expr = Iff(InSet(P, LinMap(V, W)), And(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(Px, W), domain = V), Forall(instance_param_or_params = [x, y], instance_expr = Equals(Function(P, [VecAdd(x, y)]), VecAdd(Px, Py)), domain = V), Forall(instance_param_or_params = [c], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(P, [ScalarMult(c, x)]), ScalarMult(c, Px)), domain = V), domain = K)).with_wrapping_at(2,4)).with_wrapping_at(2)), 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_{P}~\left(\begin{array}{c} \begin{array}{l} \left(P \in \mathcal{L}\left(V, W\right)\right) \Leftrightarrow  \\ \left(\begin{array}{c} \left[\forall_{x \in V}~\left(P\left(x\right) \in W\right)\right] \land  \\ \left[\forall_{x, y \in V}~\left(P\left(x + y\right) = \left(P\left(x\right) + P\left(y\right)\right)\right)\right] \land  \\ \left[\forall_{c \in K}~\left[\forall_{x \in V}~\left(P\left(c \cdot x\right) = \left(c \cdot P\left(x\right)\right)\right)\right]\right] \end{array}\right) \end{array} \end{array}\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: 47
operand: 5
2Operationoperator: 45
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameter: 81
body: 9
6Operationoperator: 11
operands: 10
7Operationoperator: 11
operands: 12
8ExprTuple81
9Operationoperator: 13
operands: 14
10ExprTuple74, 15
11Literal
12ExprTuple50, 15
13Literal
14ExprTuple16, 17
15Operationoperator: 18
operand: 55
16Operationoperator: 69
operands: 20
17Operationoperator: 45
operands: 21
18Literal
19ExprTuple55
20ExprTuple81, 22
21ExprTuple23, 24, 25
22Operationoperator: 26
operands: 27
23Operationoperator: 47
operand: 31
24Operationoperator: 47
operand: 32
25Operationoperator: 47
operand: 33
26Literal
27ExprTuple74, 50
28ExprTuple31
29ExprTuple32
30ExprTuple33
31Lambdaparameter: 84
body: 34
32Lambdaparameters: 65
body: 35
33Lambdaparameter: 83
body: 37
34Conditionalvalue: 38
condition: 63
35Conditionalvalue: 39
condition: 40
36ExprTuple83
37Conditionalvalue: 41
condition: 42
38Operationoperator: 69
operands: 43
39Operationoperator: 67
operands: 44
40Operationoperator: 45
operands: 46
41Operationoperator: 47
operand: 54
42Operationoperator: 69
operands: 49
43ExprTuple78, 50
44ExprTuple51, 52
45Literal
46ExprTuple63, 53
47Literal
48ExprTuple54
49ExprTuple83, 55
50Variable
51Operationoperator: 81
operand: 60
52Operationoperator: 64
operands: 57
53Operationoperator: 69
operands: 58
54Lambdaparameter: 84
body: 59
55Variable
56ExprTuple60
57ExprTuple78, 61
58ExprTuple71, 74
59Conditionalvalue: 62
condition: 63
60Operationoperator: 64
operands: 65
61Operationoperator: 81
operand: 71
62Operationoperator: 67
operands: 68
63Operationoperator: 69
operands: 70
64Literal
65ExprTuple84, 71
66ExprTuple71
67Literal
68ExprTuple72, 73
69Literal
70ExprTuple84, 74
71Variable
72Operationoperator: 81
operand: 77
73Operationoperator: 79
operands: 76
74Variable
75ExprTuple77
76ExprTuple83, 78
77Operationoperator: 79
operands: 80
78Operationoperator: 81
operand: 84
79Literal
80ExprTuple83, 84
81Variable
82ExprTuple84
83Variable
84Variable