logo

Expression of type And

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 ScalarMult, VecAdd
from proveit.logic import And, Equals, Forall, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = 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)
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} \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}
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 4)('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',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 22
operands: 1
1ExprTuple2, 3, 4
2Operationoperator: 24
operand: 8
3Operationoperator: 24
operand: 9
4Operationoperator: 24
operand: 10
5ExprTuple8
6ExprTuple9
7ExprTuple10
8Lambdaparameter: 61
body: 11
9Lambdaparameters: 42
body: 12
10Lambdaparameter: 60
body: 14
11Conditionalvalue: 15
condition: 40
12Conditionalvalue: 16
condition: 17
13ExprTuple60
14Conditionalvalue: 18
condition: 19
15Operationoperator: 46
operands: 20
16Operationoperator: 44
operands: 21
17Operationoperator: 22
operands: 23
18Operationoperator: 24
operand: 31
19Operationoperator: 46
operands: 26
20ExprTuple55, 27
21ExprTuple28, 29
22Literal
23ExprTuple40, 30
24Literal
25ExprTuple31
26ExprTuple60, 32
27Variable
28Operationoperator: 58
operand: 37
29Operationoperator: 41
operands: 34
30Operationoperator: 46
operands: 35
31Lambdaparameter: 61
body: 36
32Variable
33ExprTuple37
34ExprTuple55, 38
35ExprTuple48, 51
36Conditionalvalue: 39
condition: 40
37Operationoperator: 41
operands: 42
38Operationoperator: 58
operand: 48
39Operationoperator: 44
operands: 45
40Operationoperator: 46
operands: 47
41Literal
42ExprTuple61, 48
43ExprTuple48
44Literal
45ExprTuple49, 50
46Literal
47ExprTuple61, 51
48Variable
49Operationoperator: 58
operand: 54
50Operationoperator: 56
operands: 53
51Variable
52ExprTuple54
53ExprTuple60, 55
54Operationoperator: 56
operands: 57
55Operationoperator: 58
operand: 61
56Literal
57ExprTuple60, 61
58Variable
59ExprTuple61
60Variable
61Variable