logo

Expression of type Forall

from the theory of proveit.numbers.modular

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 N, a, b, c, x
from proveit.logic import Card, Equals, Forall, SetOfAll
from proveit.numbers import Add, Integer, Interval, Mod, NaturalPos, greater_eq, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Interval(a, b)
expr = Forall(instance_param_or_params = [N], instance_expr = Forall(instance_param_or_params = [a, b, c], instance_expr = Equals(SetOfAll(instance_param_or_params = [x], instance_element = Mod(Add(c, x), N), domain = sub_expr1), Interval(zero, subtract(N, one))), domain = Integer, condition = greater_eq(Card(sub_expr1), N)), 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())
\forall_{N \in \mathbb{N}^+}~\left[\forall_{a, b, c \in \mathbb{Z}~|~|\{a~\ldotp \ldotp~b\}| \geq N}~\left(\left\{\left(c + x\right) ~\textup{mod}~ N\right\}_{x \in \{a~\ldotp \ldotp~b\}} = \{0~\ldotp \ldotp~N - 1\}\right)\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
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
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 54
body: 4
3ExprTuple54
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 49
operands: 9
7Literal
8ExprTuple10
9ExprTuple54, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple63, 64, 61
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operands: 17
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22, 23, 24, 25
20Operationoperator: 26
operand: 34
21Operationoperator: 59
operands: 28
22Operationoperator: 49
operands: 29
23Operationoperator: 49
operands: 30
24Operationoperator: 49
operands: 31
25Operationoperator: 32
operands: 33
26Literal
27ExprTuple34
28ExprTuple35, 36
29ExprTuple63, 37
30ExprTuple64, 37
31ExprTuple61, 37
32Literal
33ExprTuple54, 38
34Lambdaparameter: 62
body: 40
35Literal
36Operationoperator: 57
operands: 41
37Literal
38Operationoperator: 42
operand: 55
39ExprTuple62
40Conditionalvalue: 44
condition: 45
41ExprTuple54, 46
42Literal
43ExprTuple55
44Operationoperator: 47
operands: 48
45Operationoperator: 49
operands: 50
46Operationoperator: 51
operand: 56
47Literal
48ExprTuple53, 54
49Literal
50ExprTuple62, 55
51Literal
52ExprTuple56
53Operationoperator: 57
operands: 58
54Variable
55Operationoperator: 59
operands: 60
56Literal
57Literal
58ExprTuple61, 62
59Literal
60ExprTuple63, 64
61Variable
62Variable
63Variable
64Variable