logo

Expression of type Conditional

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 Conditional, 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 = Conditional(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), 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())
\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) \textrm{ if } S \subseteq \mathbb{R}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple41, 17
7Lambdaparameter: 44
body: 9
8ExprTuple44
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 37
operands: 14
12Literal
13ExprTuple15, 16
14ExprTuple44, 17
15Operationoperator: 19
operand: 21
16Operationoperator: 19
operand: 22
17Literal
18ExprTuple21
19Literal
20ExprTuple22
21Operationoperator: 24
operand: 26
22Operationoperator: 24
operand: 27
23ExprTuple26
24Literal
25ExprTuple27
26Lambdaparameter: 45
body: 28
27Lambdaparameter: 45
body: 30
28Conditionalvalue: 31
condition: 33
29ExprTuple45
30Conditionalvalue: 32
condition: 33
31Operationoperator: 35
operands: 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34ExprTuple39, 40
35Literal
36ExprTuple45, 40
37Literal
38ExprTuple45, 41
39Operationoperator: 42
operands: 43
40Variable
41Variable
42Literal
43ExprTuple44, 45
44Variable
45Variable