logo

Expression of type Conditional

from the theory of proveit.linear_algebra.inner_products

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, H, K, a, x, y
from proveit.linear_algebra import InnerProd, InnerProdSpaces, ScalarMult
from proveit.logic import Equals, Forall, InClass
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a], instance_expr = Forall(instance_param_or_params = [x, y], instance_expr = Equals(InnerProd(ScalarMult(a, x), y), ScalarMult(a, InnerProd(x, y))), domain = H), domain = K), InClass(H, InnerProdSpaces(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_{a \in K}~\left[\forall_{x, y \in H}~\left(\left \langle a \cdot x, y\right \rangle = \left(a \cdot \left \langle x, y\right \rangle\right)\right)\right] \textrm{ if } H \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)\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: 14
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple37, 7
6Lambdaparameter: 42
body: 9
7Operationoperator: 10
operand: 18
8ExprTuple42
9Conditionalvalue: 12
condition: 13
10Literal
11ExprTuple18
12Operationoperator: 14
operand: 17
13Operationoperator: 33
operands: 16
14Literal
15ExprTuple17
16ExprTuple42, 18
17Lambdaparameters: 41
body: 19
18Variable
19Conditionalvalue: 20
condition: 21
20Operationoperator: 22
operands: 23
21Operationoperator: 24
operands: 25
22Literal
23ExprTuple26, 27
24Literal
25ExprTuple28, 29
26Operationoperator: 40
operands: 30
27Operationoperator: 38
operands: 31
28Operationoperator: 33
operands: 32
29Operationoperator: 33
operands: 34
30ExprTuple35, 44
31ExprTuple42, 36
32ExprTuple43, 37
33Literal
34ExprTuple44, 37
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operands: 41
37Variable
38Literal
39ExprTuple42, 43
40Literal
41ExprTuple43, 44
42Variable
43Variable
44Variable