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 = [K], instance_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_{K}~\left[\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]\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
2Lambdaparameter: 32
body: 3
3Operationoperator: 9
operand: 5
4ExprTuple5
5Lambdaparameters: 45
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operand: 12
8Operationoperator: 24
operands: 11
9Literal
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameters: 33
body: 15
13Operationoperator: 17
operands: 16
14Operationoperator: 17
operands: 18
15Conditionalvalue: 19
condition: 20
16ExprTuple48, 21
17Literal
18ExprTuple49, 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operand: 32
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple30, 31
26Literal
27ExprTuple32
28Operationoperator: 40
operands: 33
29Lambdaparameter: 53
body: 34
30Operationoperator: 42
operands: 35
31Operationoperator: 42
operands: 36
32Variable
33ExprTuple50, 51
34Conditionalvalue: 37
condition: 38
35ExprTuple50, 39
36ExprTuple51, 39
37Operationoperator: 40
operands: 41
38Operationoperator: 42
operands: 43
39Operationoperator: 44
operands: 45
40Literal
41ExprTuple46, 47
42Literal
43ExprTuple53, 48
44Literal
45ExprTuple48, 49
46Operationoperator: 50
operand: 53
47Operationoperator: 51
operand: 53
48Variable
49Variable
50Variable
51Variable
52ExprTuple53
53Variable