logo

Expression of type Conditional

from the theory of proveit.logic.booleans.disjunction

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 A, B, Conditional, ExprRange, IndexedVar, Variable, m
from proveit.core_expr_types import A_1_to_m, B_1_to_m
from proveit.logic import Boolean, Forall, Implies, InSet, Not, Or
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(B, sub_expr1)
sub_expr3 = IndexedVar(A, sub_expr1)
expr = Conditional(Forall(instance_param_or_params = [A_1_to_m, B_1_to_m], instance_expr = Or(ExprRange(sub_expr1, Not(sub_expr2), one, m)), domain = Boolean, conditions = [Or(ExprRange(sub_expr1, Not(sub_expr3), one, m)), ExprRange(sub_expr1, Implies(sub_expr3, sub_expr2), one, m)]), InSet(m, 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_{1}, B_{2}, \ldots, B_{m} \in \mathbb{B}~|~(\lnot A_{1}) \lor  (\lnot A_{2}) \lor  \ldots \lor  (\lnot A_{m}),\left(A_{1} \Rightarrow B_{1}\right), \left(A_{2} \Rightarrow B_{2}\right), \ldots, \left(A_{m} \Rightarrow B_{m}\right)}~\left((\lnot B_{1}) \lor  (\lnot B_{2}) \lor  \ldots \lor  (\lnot B_{m})\right) \textrm{ if } m \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: 37
operands: 5
3Literal
4ExprTuple6
5ExprTuple41, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple10, 11
9Conditionalvalue: 12
condition: 13
10ExprRangelambda_map: 14
start_index: 40
end_index: 41
11ExprRangelambda_map: 15
start_index: 40
end_index: 41
12Operationoperator: 27
operands: 16
13Operationoperator: 17
operands: 18
14Lambdaparameter: 53
body: 50
15Lambdaparameter: 53
body: 46
16ExprTuple19
17Literal
18ExprTuple20, 21, 22, 23
19ExprRangelambda_map: 24
start_index: 40
end_index: 41
20ExprRangelambda_map: 25
start_index: 40
end_index: 41
21ExprRangelambda_map: 26
start_index: 40
end_index: 41
22Operationoperator: 27
operands: 28
23ExprRangelambda_map: 29
start_index: 40
end_index: 41
24Lambdaparameter: 53
body: 30
25Lambdaparameter: 53
body: 31
26Lambdaparameter: 53
body: 32
27Literal
28ExprTuple33
29Lambdaparameter: 53
body: 34
30Operationoperator: 47
operand: 46
31Operationoperator: 37
operands: 36
32Operationoperator: 37
operands: 38
33ExprRangelambda_map: 39
start_index: 40
end_index: 41
34Operationoperator: 42
operands: 43
35ExprTuple46
36ExprTuple50, 44
37Literal
38ExprTuple46, 44
39Lambdaparameter: 53
body: 45
40Literal
41Variable
42Literal
43ExprTuple50, 46
44Literal
45Operationoperator: 47
operand: 50
46IndexedVarvariable: 49
index: 53
47Literal
48ExprTuple50
49Variable
50IndexedVarvariable: 51
index: 53
51Variable
52ExprTuple53
53Variable