# from the theory of proveit.linear_algebra¶

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.
# import Expression classes needed to build the expression
from proveit import Function, S, T, V, W, v
from proveit.logic import Equals, Forall

In [2]:
# build up the expression from sub-expressions
sub_expr1 = [v]
expr = Forall(instance_param_or_params = [V, W], instance_expr = Forall(instance_param_or_params = [S, T], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(LinMapAdd(S, T), sub_expr1), Add(Function(S, sub_expr1), Function(T, sub_expr1))), domain = V), domain = LinMap(V, W)))

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())

\forall_{V, W}~\left[\forall_{S, T \in \mathcal{L}\left(V, W\right)}~\left[\forall_{v \in V}~\left(\left(S + T\right)\left(v\right) = \left(S\left(v\right) + T\left(v\right)\right)\right)\right]\right]

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Operationoperator: 9
operand: 2
1ExprTuple2
2Lambdaparameters: 27
body: 3
3Operationoperator: 9
operand: 5
4ExprTuple5
5Lambdaparameters: 36
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operand: 13
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13
11Literal
12ExprTuple14, 15
13Lambdaparameter: 42
body: 16
14Operationoperator: 24
operands: 17
15Operationoperator: 24
operands: 18
16Conditionalvalue: 19
condition: 20
17ExprTuple39, 21
18ExprTuple40, 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple42, 30
26Literal
27ExprTuple30, 31
28Operationoperator: 32
operand: 42
29Operationoperator: 33
operands: 34
30Variable
31Variable
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37, 38
35Literal
36ExprTuple39, 40
37Operationoperator: 39
operand: 42
38Operationoperator: 40
operand: 42
39Variable
40Variable
41ExprTuple42
42Variable