logo

Expression of type Conditional

from the theory of proveit.core_expr_types.tuples

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, i, j, k
from proveit.core_expr_types import f_i_to_j, fk, g_i_to_j, gk
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import Integer, Interval
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Implies(Forall(instance_param_or_params = [k], instance_expr = Equals(fk, gk), domain = Interval(i, j)), Equals([f_i_to_j], [g_i_to_j])), And(InSet(i, Integer), InSet(j, 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 \{i~\ldotp \ldotp~j\}}~\left(f\left(k\right) = g\left(k\right)\right)\right] \Rightarrow \left(\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) = \left(g\left(i\right), g\left(i + 1\right), \ldots, g\left(j\right)\right)\right) \textrm{ if } i \in \mathbb{Z} ,  j \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: 27
operands: 13
9Operationoperator: 29
operands: 14
10Operationoperator: 29
operands: 15
11Literal
12ExprTuple16
13ExprTuple17, 18
14ExprTuple44, 19
15ExprTuple45, 19
16Lambdaparameter: 43
body: 20
17ExprTuple21
18ExprTuple22
19Literal
20Conditionalvalue: 23
condition: 24
21ExprRangelambda_map: 25
start_index: 44
end_index: 45
22ExprRangelambda_map: 26
start_index: 44
end_index: 45
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25Lambdaparameter: 42
body: 31
26Lambdaparameter: 42
body: 32
27Literal
28ExprTuple33, 34
29Literal
30ExprTuple43, 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
41ExprTuple44, 45
42Variable
43Variable
44Variable
45Variable