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, 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
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(And(Q_1_to_m), And(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} \land  Q_{2} \land  \ldots \land  Q_{m} ,  R_{1} \land  R_{2} \land  \ldots \land  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: 27
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 12
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple20, 29, 30
10Operationoperator: 14
operands: 15
11ExprTuple32, 16
12Literal
13ExprTuple35, 16
14Literal
15ExprTuple17, 18
16Literal
17Conditionalvalue: 20
condition: 19
18Conditionalvalue: 20
condition: 21
19Operationoperator: 27
operands: 22
20Variable
21Operationoperator: 27
operands: 23
22ExprTuple24, 25
23ExprTuple29, 30
24Operationoperator: 27
operands: 26
25Operationoperator: 27
operands: 28
26ExprTuple29
27Literal
28ExprTuple30
29ExprRangelambda_map: 31
start_index: 34
end_index: 32
30ExprRangelambda_map: 33
start_index: 34
end_index: 35
31Lambdaparameter: 41
body: 36
32Variable
33Lambdaparameter: 41
body: 37
34Literal
35Variable
36IndexedVarvariable: 38
index: 41
37IndexedVarvariable: 39
index: 41
38Variable
39Variable
40ExprTuple41
41Variable