logo

Expression of type Conditional

from the theory of proveit.linear_algebra.addition

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, V, n
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Forall, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = InSet(VecAdd(x_1_to_n), V), domain = V), domain = VecSpaces(K))), InSet(n, NaturalPos))
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_{K}~\left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\left(\left(x_{1} +  x_{2} +  \ldots +  x_{n}\right) \in V\right)\right]\right] \textrm{ if } n \in \mathbb{N}^+\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: 5
2Operationoperator: 39
operands: 4
3ExprTuple5
4ExprTuple38, 6
5Lambdaparameter: 25
body: 7
6Literal
7Operationoperator: 14
operand: 9
8ExprTuple9
9Lambdaparameter: 42
body: 11
10ExprTuple42
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 18
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18
16Literal
17ExprTuple42, 19
18Lambdaparameters: 32
body: 20
19Operationoperator: 21
operand: 25
20Conditionalvalue: 23
condition: 24
21Literal
22ExprTuple25
23Operationoperator: 39
operands: 26
24Operationoperator: 27
operands: 28
25Variable
26ExprTuple29, 42
27Literal
28ExprTuple30
29Operationoperator: 31
operands: 32
30ExprRangelambda_map: 33
start_index: 37
end_index: 38
31Literal
32ExprTuple34
33Lambdaparameter: 45
body: 35
34ExprRangelambda_map: 36
start_index: 37
end_index: 38
35Operationoperator: 39
operands: 40
36Lambdaparameter: 45
body: 41
37Literal
38Variable
39Literal
40ExprTuple41, 42
41IndexedVarvariable: 43
index: 45
42Variable
43Variable
44ExprTuple45
45Variable