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 = [S], instance_expr = Forall(instance_param_or_params = [c], instance_expr = Equals(Card(SetOfAll(instance_param_or_params = sub_expr1, instance_element = Mod(Add(x, c), L), domain = S)), Card(SetOfAll(instance_param_or_params = sub_expr1, instance_element = Mod(x, L), domain = S))), domain = Real), condition = SubsetEq(S, 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_{S~|~S \subseteq \mathbb{R}}~\left[\forall_{c \in \mathbb{R}}~\left(|\left\{\left(x + c\right) ~\textup{mod}~ L\right\}_{x \in S}| = |\left\{x ~\textup{mod}~ L\right\}_{x \in S}|\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: 45
body: 4
3ExprTuple45
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple45, 21
11Lambdaparameter: 49
body: 13
12ExprTuple49
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operands: 17
15Operationoperator: 41
operands: 18
16Literal
17ExprTuple19, 20
18ExprTuple49, 21
19Operationoperator: 23
operand: 25
20Operationoperator: 23
operand: 26
21Literal
22ExprTuple25
23Literal
24ExprTuple26
25Operationoperator: 28
operand: 30
26Operationoperator: 28
operand: 31
27ExprTuple30
28Literal
29ExprTuple31
30Lambdaparameter: 48
body: 32
31Lambdaparameter: 48
body: 34
32Conditionalvalue: 35
condition: 37
33ExprTuple48
34Conditionalvalue: 36
condition: 37
35Operationoperator: 39
operands: 38
36Operationoperator: 39
operands: 40
37Operationoperator: 41
operands: 42
38ExprTuple43, 44
39Literal
40ExprTuple48, 44
41Literal
42ExprTuple48, 45
43Operationoperator: 46
operands: 47
44Variable
45Variable
46Literal
47ExprTuple48, 49
48Variable
49Variable