logo

Expression of type Forall

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, a, b, c, i, m, n
from proveit.logic import Equals, FALSE, Forall
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
expr = Forall([m, n], Forall([a, b, c], Equals(ConditionalSet(ExprRange(i, Conditional(IndexedVar(a, i), FALSE), one, m), b, ExprRange(i, Conditional(IndexedVar(c, i), FALSE), one, m)), b)), domain = Natural)
Out[2]:
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(expr.latex())
\forall_{m, n \in \mathbb{N}}~\left[\forall_{a, b, c}~\left(\left\{\begin{array}{ccc}\left\{a_{1} \textrm{ if } \bot\right.., \ldots, \left\{a_{m} \textrm{ if } \bot\right.. \\ b \\ \left\{c_{1} \textrm{ if } \bot\right.., \ldots, \left\{c_{m} \textrm{ if } \bot\right..\end{array}\right.. = b\right)\right]
In [5]:
expr.style_options()
Out[5]:
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
expr.expr_info()
Out[6]:
 core typesub-expressionsexpression
0Operationoperator: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple32, 21
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13
11Lambdaparameters: 14
body: 15
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple38, 27, 39
15Operationoperator: 19
operands: 20
16ExprTuple32, 22
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 27
21Variable
22Literal
23Operationoperator: 24
operands: 25
24Literal
25ExprTuple26, 27, 28
26ExprRangelambda_map: 29
start_index: 31
end_index: 32
27Variable
28ExprRangelambda_map: 30
start_index: 31
end_index: 32
29Lambdaparameter: 41
body: 33
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