logo

Expression of type Conditional

from the theory of proveit.core_expr_types.conditionals

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, ConditionalSet, ExprRange, IndexedVar, Variable, a, b, c, m, n
from proveit.core_expr_types import a_1_to_m, c_1_to_n
from proveit.logic import And, Equals, FALSE, Forall, InSet
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Forall(instance_param_or_params = [a_1_to_m, b, c_1_to_n], instance_expr = Equals(ConditionalSet(ExprRange(sub_expr1, Conditional(IndexedVar(a, sub_expr1), FALSE), one, m), b, ExprRange(sub_expr1, Conditional(IndexedVar(c, sub_expr1), FALSE), one, n)), b)), And(InSet(m, Natural), InSet(n, Natural)))
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_{1}, a_{2}, \ldots, a_{m}, b, c_{1}, c_{2}, \ldots, c_{n}}~\left(\left\{\begin{array}{ccc}a_{1} \textrm{ if } \bot \\ a_{2} \textrm{ if } \bot \\  \vdots \\ a_{m} \textrm{ if } \bot \\ b \\ c_{1} \textrm{ if } \bot \\ c_{2} \textrm{ if } \bot \\  \vdots \\ c_{n} \textrm{ if } \bot\end{array}\right.. = b\right) \textrm{ if } m \in \mathbb{N} ,  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: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple15, 26, 16
11Operationoperator: 17
operands: 18
12ExprTuple29, 19
13Literal
14ExprTuple32, 19
15ExprRangelambda_map: 20
start_index: 31
end_index: 29
16ExprRangelambda_map: 21
start_index: 31
end_index: 32
17Literal
18ExprTuple22, 26
19Literal
20Lambdaparameter: 41
body: 35
21Lambdaparameter: 41
body: 36
22Operationoperator: 23
operands: 24
23Literal
24ExprTuple25, 26, 27
25ExprRangelambda_map: 28
start_index: 31
end_index: 29
26Variable
27ExprRangelambda_map: 30
start_index: 31
end_index: 32
28Lambdaparameter: 41
body: 33
29Variable
30Lambdaparameter: 41
body: 34
31Literal
32Variable
33Conditionalvalue: 35
condition: 37
34Conditionalvalue: 36
condition: 37
35IndexedVarvariable: 38
index: 41
36IndexedVarvariable: 39
index: 41
37Literal
38Variable
39Variable
40ExprTuple41
41Variable