logo

Expression of type Implies

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, ExprRange, IndexedVar, Variable, m, n
from proveit.core_expr_types import A_1_to_m
from proveit.logic import And, Boolean, Forall, Implies, InSet, Or
from proveit.numbers import Add, NaturalPos, one, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(A, one)
sub_expr3 = IndexedVar(A, sub_expr1)
sub_expr4 = Add(m, one)
sub_expr5 = ExprRange(sub_expr1, sub_expr3, one, n)
expr = Implies(And(Forall(instance_param_or_params = [sub_expr2], instance_expr = InSet(sub_expr2, Boolean), domain = Boolean), Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [ExprRange(sub_expr1, sub_expr3, one, Add(m, two))], instance_expr = InSet(Or(ExprRange(sub_expr1, sub_expr3, one, sub_expr4)), Boolean), condition = ExprRange(sub_expr1, InSet(sub_expr3, Boolean), one, sub_expr4)), domain = NaturalPos, condition = Forall(instance_param_or_params = [A_1_to_m], instance_expr = InSet(Or(A_1_to_m), Boolean), domain = Boolean))), Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [sub_expr5], instance_expr = InSet(Or(sub_expr5), Boolean), domain = Boolean), domain = NaturalPos))
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_{A_{1} \in \mathbb{B}}~\left(A_{1} \in \mathbb{B}\right)\right] \land \left[\forall_{m \in \mathbb{N}^+~|~\forall_{A_{1}, A_{2}, \ldots, A_{m} \in \mathbb{B}}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m}\right) \in \mathbb{B}\right)}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{m + 2}~|~\left(A_{1} \in \mathbb{B}\right), \left(A_{2} \in \mathbb{B}\right), \ldots, \left(A_{m + 1} \in \mathbb{B}\right)}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m + 1}\right) \in \mathbb{B}\right)\right]\right]\right) \Rightarrow \left[\forall_{n \in \mathbb{N}^+}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{n} \in \mathbb{B}}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{n}\right) \in \mathbb{B}\right)\right]\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 67
operands: 5
4Operationoperator: 42
operand: 9
5ExprTuple7, 8
6ExprTuple9
7Operationoperator: 42
operand: 14
8Operationoperator: 42
operand: 15
9Lambdaparameter: 69
body: 13
10ExprTuple14
11ExprTuple15
12ExprTuple69
13Conditionalvalue: 16
condition: 17
14Lambdaparameter: 32
body: 19
15Lambdaparameter: 83
body: 21
16Operationoperator: 42
operand: 27
17Operationoperator: 84
operands: 23
18ExprTuple32
19Conditionalvalue: 24
condition: 24
20ExprTuple83
21Conditionalvalue: 25
condition: 26
22ExprTuple27
23ExprTuple69, 49
24Operationoperator: 84
operands: 28
25Operationoperator: 42
operand: 33
26Operationoperator: 67
operands: 30
27Lambdaparameters: 57
body: 31
28ExprTuple32, 87
29ExprTuple33
30ExprTuple34, 35
31Conditionalvalue: 36
condition: 37
32IndexedVarvariable: 88
index: 82
33Lambdaparameters: 39
body: 40
34Operationoperator: 84
operands: 41
35Operationoperator: 42
operand: 50
36Operationoperator: 84
operands: 44
37Operationoperator: 67
operands: 45
38ExprTuple82
39ExprTuple46
40Conditionalvalue: 47
condition: 48
41ExprTuple83, 49
42Literal
43ExprTuple50
44ExprTuple51, 87
45ExprTuple52
46ExprRangelambda_map: 81
start_index: 82
end_index: 53
47Operationoperator: 84
operands: 54
48Operationoperator: 67
operands: 55
49Literal
50Lambdaparameters: 75
body: 56
51Operationoperator: 74
operands: 57
52ExprRangelambda_map: 76
start_index: 82
end_index: 69
53Operationoperator: 77
operands: 58
54ExprTuple59, 87
55ExprTuple60
56Conditionalvalue: 61
condition: 62
57ExprTuple63
58ExprTuple83, 64
59Operationoperator: 74
operands: 65
60ExprRangelambda_map: 76
start_index: 82
end_index: 73
61Operationoperator: 84
operands: 66
62Operationoperator: 67
operands: 68
63ExprRangelambda_map: 81
start_index: 82
end_index: 69
64Literal
65ExprTuple70
66ExprTuple71, 87
67Literal
68ExprTuple72
69Variable
70ExprRangelambda_map: 81
start_index: 82
end_index: 73
71Operationoperator: 74
operands: 75
72ExprRangelambda_map: 76
start_index: 82
end_index: 83
73Operationoperator: 77
operands: 78
74Literal
75ExprTuple79
76Lambdaparameter: 90
body: 80
77Literal
78ExprTuple83, 82
79ExprRangelambda_map: 81
start_index: 82
end_index: 83
80Operationoperator: 84
operands: 85
81Lambdaparameter: 90
body: 86
82Literal
83Variable
84Literal
85ExprTuple86, 87
86IndexedVarvariable: 88
index: 90
87Literal
88Variable
89ExprTuple90
90Variable