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 L, S, c, x
from proveit.logic import Card, Equals, Forall, SetOfAll, SubsetEq
from proveit.numbers import Add, Mod, Real
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [L], instance_expr = Forall(instance_param_or_params = [S], instance_expr = Forall(instance_param_or_params = [c], instance_expr = Equals(Card(SetOfAll(instance_param_or_params = sub_expr1, instance_element = Mod(Add(c, x), L), domain = S)), Card(SetOfAll(instance_param_or_params = sub_expr1, instance_element = Mod(x, L), domain = S))), domain = Real), condition = SubsetEq(S, Real)), domain = Real)
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_{L \in \mathbb{R}}~\left[\forall_{S~|~S \subseteq \mathbb{R}}~\left[\forall_{c \in \mathbb{R}}~\left(|\left\{\left(c + x\right) ~\textup{mod}~ L\right\}_{x \in S}| = |\left\{x ~\textup{mod}~ L\right\}_{x \in S}|\right)\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: 14
operand: 2
1ExprTuple2
2Lambdaparameter: 51
body: 4
3ExprTuple51
4Conditionalvalue: 5
condition: 6
5Operationoperator: 14
operand: 9
6Operationoperator: 48
operands: 8
7ExprTuple9
8ExprTuple51, 28
9Lambdaparameter: 52
body: 11
10ExprTuple52
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 18
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18
16Literal
17ExprTuple52, 28
18Lambdaparameter: 55
body: 20
19ExprTuple55
20Conditionalvalue: 21
condition: 22
21Operationoperator: 23
operands: 24
22Operationoperator: 48
operands: 25
23Literal
24ExprTuple26, 27
25ExprTuple55, 28
26Operationoperator: 30
operand: 32
27Operationoperator: 30
operand: 33
28Literal
29ExprTuple32
30Literal
31ExprTuple33
32Operationoperator: 35
operand: 37
33Operationoperator: 35
operand: 38
34ExprTuple37
35Literal
36ExprTuple38
37Lambdaparameter: 56
body: 39
38Lambdaparameter: 56
body: 41
39Conditionalvalue: 42
condition: 44
40ExprTuple56
41Conditionalvalue: 43
condition: 44
42Operationoperator: 46
operands: 45
43Operationoperator: 46
operands: 47
44Operationoperator: 48
operands: 49
45ExprTuple50, 51
46Literal
47ExprTuple56, 51
48Literal
49ExprTuple56, 52
50Operationoperator: 53
operands: 54
51Variable
52Variable
53Literal
54ExprTuple55, 56
55Variable
56Variable