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 Conditional, K, Lambda, P, Px, V, W, c, x
from proveit.linear_algebra import LinMap, ScalarMult, VecSpaces
from proveit.logic import Equals, Forall, InSet
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [V, W], instance_expr = Forall(instance_param_or_params = [c], instance_expr = Forall(instance_param_or_params = [P], instance_expr = Equals(ScalarMult(c, P), Lambda(x, Conditional(ScalarMult(c, Px), InSet(x, V)))), domain = LinMap(V, W)), domain = K), 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_{c \in K}~\left[\forall_{P \in \mathcal{L}\left(V, W\right)}~\left(\left(c \cdot P\right) = \left[x \mapsto \left\{c \cdot P\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: 20
operand: 2
1ExprTuple2
2Lambdaparameters: 40
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 20
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 48
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple48
13Conditionalvalue: 17
condition: 18
14ExprTuple50, 19
15Literal
16ExprTuple43, 19
17Operationoperator: 20
operand: 25
18Operationoperator: 46
operands: 22
19Operationoperator: 23
operand: 26
20Literal
21ExprTuple25
22ExprTuple48, 26
23Literal
24ExprTuple26
25Lambdaparameter: 51
body: 28
26Variable
27ExprTuple51
28Conditionalvalue: 29
condition: 30
29Operationoperator: 31
operands: 32
30Operationoperator: 46
operands: 33
31Literal
32ExprTuple34, 35
33ExprTuple51, 36
34Operationoperator: 44
operands: 37
35Lambdaparameter: 53
body: 38
36Operationoperator: 39
operands: 40
37ExprTuple48, 51
38Conditionalvalue: 41
condition: 42
39Literal
40ExprTuple50, 43
41Operationoperator: 44
operands: 45
42Operationoperator: 46
operands: 47
43Variable
44Literal
45ExprTuple48, 49
46Literal
47ExprTuple53, 50
48Variable
49Operationoperator: 51
operand: 53
50Variable
51Variable
52ExprTuple53
53Variable