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, Function, f, g, k, l, m, n
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import Integer, Interval, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = [l]
sub_expr3 = Interval(m, n)
expr = Conditional(Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(f, sub_expr1), Function(g, sub_expr1)), domain = sub_expr3), Equals(Sum(index_or_indices = sub_expr2, summand = Function(f, sub_expr2), domain = sub_expr3), Sum(index_or_indices = sub_expr2, summand = Function(g, sub_expr2), domain = sub_expr3))), And(InSet(m, Integer), InSet(n, Integer)))
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 \{m~\ldotp \ldotp~n\}}~\left(f\left(k\right) = g\left(k\right)\right)\right] \Rightarrow \left(\left(\sum_{l = m}^{n} f\left(l\right)\right) = \left(\sum_{l = m}^{n} g\left(l\right)\right)\right) \textrm{ if } m \in \mathbb{Z} ,  n \in \mathbb{Z}\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: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10
7Operationoperator: 11
operand: 16
8Operationoperator: 28
operands: 13
9Operationoperator: 42
operands: 14
10Operationoperator: 42
operands: 15
11Literal
12ExprTuple16
13ExprTuple17, 18
14ExprTuple49, 19
15ExprTuple50, 19
16Lambdaparameter: 44
body: 20
17Operationoperator: 22
operand: 26
18Operationoperator: 22
operand: 27
19Literal
20Conditionalvalue: 24
condition: 25
21ExprTuple26
22Literal
23ExprTuple27
24Operationoperator: 28
operands: 29
25Operationoperator: 42
operands: 30
26Lambdaparameter: 45
body: 31
27Lambdaparameter: 45
body: 32
28Literal
29ExprTuple33, 34
30ExprTuple44, 46
31Conditionalvalue: 35
condition: 37
32Conditionalvalue: 36
condition: 37
33Operationoperator: 39
operand: 44
34Operationoperator: 40
operand: 44
35Operationoperator: 39
operand: 45
36Operationoperator: 40
operand: 45
37Operationoperator: 42
operands: 43
38ExprTuple44
39Variable
40Variable
41ExprTuple45
42Literal
43ExprTuple45, 46
44Variable
45Variable
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50
49Variable
50Variable