logo

Expression of type Conditional

from the theory of proveit.numbers.summation

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, S, k, l
from proveit.logic import Card, Forall, Implies
from proveit.numbers import Less, Sum, greater, zero
from proveit.numbers.summation import ak, al, bk, bl
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
expr = Conditional(Implies(Forall(instance_param_or_params = [k], instance_expr = Less(ak, bk), domain = S), Less(Sum(index_or_indices = sub_expr1, summand = al, domain = S), Sum(index_or_indices = sub_expr1, summand = bl, domain = S))), greater(Card(S), zero))
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\{\left[\forall_{k \in S}~\left(a\left(k\right) < b\left(k\right)\right)\right] \Rightarrow \left(\left[\sum_{l \in S}~a\left(l\right)\right] < \left[\sum_{l \in S}~b\left(l\right)\right]\right) \textrm{ if } |S| > 0\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
operands: 4
2Operationoperator: 26
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple8, 9
6Operationoperator: 10
operand: 15
7Operationoperator: 26
operands: 12
8Literal
9Operationoperator: 13
operand: 44
10Literal
11ExprTuple15
12ExprTuple16, 17
13Literal
14ExprTuple44
15Lambdaparameter: 42
body: 18
16Operationoperator: 20
operand: 24
17Operationoperator: 20
operand: 25
18Conditionalvalue: 22
condition: 23
19ExprTuple24
20Literal
21ExprTuple25
22Operationoperator: 26
operands: 27
23Operationoperator: 40
operands: 28
24Lambdaparameter: 43
body: 29
25Lambdaparameter: 43
body: 30
26Literal
27ExprTuple31, 32
28ExprTuple42, 44
29Conditionalvalue: 33
condition: 35
30Conditionalvalue: 34
condition: 35
31Operationoperator: 37
operand: 42
32Operationoperator: 38
operand: 42
33Operationoperator: 37
operand: 43
34Operationoperator: 38
operand: 43
35Operationoperator: 40
operands: 41
36ExprTuple42
37Variable
38Variable
39ExprTuple43
40Literal
41ExprTuple43, 44
42Variable
43Variable
44Variable