logo

Expression of type Forall

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 Equals, Forall, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [V, W], instance_expr = 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)), domain = VecSpaces(K))
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 \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\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)\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: 6
operand: 2
1ExprTuple2
2Lambdaparameters: 42
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 21
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 30
body: 12
10Operationoperator: 14
operands: 13
11Operationoperator: 14
operands: 15
12Conditionalvalue: 16
condition: 17
13ExprTuple45, 18
14Literal
15ExprTuple46, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operand: 29
19Literal
20ExprTuple25, 26
21Literal
22ExprTuple27, 28
23Literal
24ExprTuple29
25Operationoperator: 37
operands: 30
26Lambdaparameter: 50
body: 31
27Operationoperator: 39
operands: 32
28Operationoperator: 39
operands: 33
29Variable
30ExprTuple47, 48
31Conditionalvalue: 34
condition: 35
32ExprTuple47, 36
33ExprTuple48, 36
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36Operationoperator: 41
operands: 42
37Literal
38ExprTuple43, 44
39Literal
40ExprTuple50, 45
41Literal
42ExprTuple45, 46
43Operationoperator: 47
operand: 50
44Operationoperator: 48
operand: 50
45Variable
46Variable
47Variable
48Variable
49ExprTuple50
50Variable