logo

Expression of type Iff

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 Function, K, P, Px, Py, V, W, c, x, y
from proveit.linear_algebra import LinMap, ScalarMult, VecAdd
from proveit.logic import And, Equals, Forall, Iff, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
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)
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()(2)('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 54
operands: 5
4Operationoperator: 30
operands: 6
5ExprTuple66, 7
6ExprTuple8, 9, 10
7Operationoperator: 11
operands: 12
8Operationoperator: 32
operand: 16
9Operationoperator: 32
operand: 17
10Operationoperator: 32
operand: 18
11Literal
12ExprTuple59, 35
13ExprTuple16
14ExprTuple17
15ExprTuple18
16Lambdaparameter: 69
body: 19
17Lambdaparameters: 50
body: 20
18Lambdaparameter: 68
body: 22
19Conditionalvalue: 23
condition: 48
20Conditionalvalue: 24
condition: 25
21ExprTuple68
22Conditionalvalue: 26
condition: 27
23Operationoperator: 54
operands: 28
24Operationoperator: 52
operands: 29
25Operationoperator: 30
operands: 31
26Operationoperator: 32
operand: 39
27Operationoperator: 54
operands: 34
28ExprTuple63, 35
29ExprTuple36, 37
30Literal
31ExprTuple48, 38
32Literal
33ExprTuple39
34ExprTuple68, 40
35Variable
36Operationoperator: 66
operand: 45
37Operationoperator: 49
operands: 42
38Operationoperator: 54
operands: 43
39Lambdaparameter: 69
body: 44
40Variable
41ExprTuple45
42ExprTuple63, 46
43ExprTuple56, 59
44Conditionalvalue: 47
condition: 48
45Operationoperator: 49
operands: 50
46Operationoperator: 66
operand: 56
47Operationoperator: 52
operands: 53
48Operationoperator: 54
operands: 55
49Literal
50ExprTuple69, 56
51ExprTuple56
52Literal
53ExprTuple57, 58
54Literal
55ExprTuple69, 59
56Variable
57Operationoperator: 66
operand: 62
58Operationoperator: 64
operands: 61
59Variable
60ExprTuple62
61ExprTuple68, 63
62Operationoperator: 64
operands: 65
63Operationoperator: 66
operand: 69
64Literal
65ExprTuple68, 69
66Variable
67ExprTuple69
68Variable
69Variable