# 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.
# import Expression classes needed to build the expression
from proveit import Conditional, a, m, n
from proveit.core_expr_types import Q_1_to_m, R_1_to_n
from proveit.logic import And, Equals, Forall, InSet, TRUE
from proveit.numbers import Natural

In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a, Q_1_to_m, R_1_to_n], instance_expr = Equals(Conditional(a, And(Q_1_to_m, TRUE, R_1_to_n)), Conditional(a, And(Q_1_to_m, R_1_to_n))).with_wrapping_at(1)), 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, Q_{1}, Q_{2}, \ldots, Q_{m}, R_{1}, R_{2}, \ldots, R_{n}}~\left(\begin{array}{c} \begin{array}{l} \left\{a \textrm{ if } Q_{1} ,  Q_{2} ,  \ldots ,  Q_{m} ,  \top, R_{1} ,  R_{2} ,  \ldots ,  R_{n}\right.. \\  = \left\{a \textrm{ if } Q_{1} ,  Q_{2} ,  \ldots ,  Q_{m}, R_{1} ,  R_{2} ,  \ldots ,  R_{n}\right.. \end{array} \end{array}\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: 6
2Operationoperator: 23
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 12
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple20, 26, 27
10Operationoperator: 14
operands: 15
11ExprTuple29, 16
12Literal
13ExprTuple32, 16
14Literal
15ExprTuple17, 18
16Literal
17Conditionalvalue: 20
condition: 19
18Conditionalvalue: 20
condition: 21
19Operationoperator: 23
operands: 22
20Variable
21Operationoperator: 23
operands: 24
22ExprTuple26, 25, 27
23Literal
24ExprTuple26, 27
25Literal
26ExprRangelambda_map: 28
start_index: 31
end_index: 29
27ExprRangelambda_map: 30
start_index: 31
end_index: 32
28Lambdaparameter: 38
body: 33
29Variable
30Lambdaparameter: 38
body: 34
31Literal
32Variable
33IndexedVarvariable: 35
index: 38
34IndexedVarvariable: 36
index: 38
35Variable
36Variable
37ExprTuple38
38Variable