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
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 = [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)
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_{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)
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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 40
body: 5
4ExprTuple40
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 33
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple40, 13
11Operationoperator: 15
operand: 17
12Operationoperator: 15
operand: 18
13Literal
14ExprTuple17
15Literal
16ExprTuple18
17Operationoperator: 20
operand: 22
18Operationoperator: 20
operand: 23
19ExprTuple22
20Literal
21ExprTuple23
22Lambdaparameter: 41
body: 24
23Lambdaparameter: 41
body: 26
24Conditionalvalue: 27
condition: 29
25ExprTuple41
26Conditionalvalue: 28
condition: 29
27Operationoperator: 31
operands: 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30ExprTuple35, 36
31Literal
32ExprTuple41, 36
33Literal
34ExprTuple41, 37
35Operationoperator: 38
operands: 39
36Variable
37Variable
38Literal
39ExprTuple40, 41
40Variable
41Variable