logo

Expression of type Conditional

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
from proveit.logic import Equals, Forall, InSet
In [2]:
# build up the expression from sub-expressions
expr = Conditional(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)), InSet(c, 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())
\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) \textrm{ if } c \in K\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 27
operands: 5
3Literal
4ExprTuple6
5ExprTuple29, 7
6Lambdaparameter: 32
body: 9
7Variable
8ExprTuple32
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 27
operands: 14
12Literal
13ExprTuple15, 16
14ExprTuple32, 17
15Operationoperator: 25
operands: 18
16Lambdaparameter: 34
body: 19
17Operationoperator: 20
operands: 21
18ExprTuple29, 32
19Conditionalvalue: 22
condition: 23
20Literal
21ExprTuple31, 24
22Operationoperator: 25
operands: 26
23Operationoperator: 27
operands: 28
24Variable
25Literal
26ExprTuple29, 30
27Literal
28ExprTuple34, 31
29Variable
30Operationoperator: 32
operand: 34
31Variable
32Variable
33ExprTuple34
34Variable