logo

Expression of type Conditional

from the theory of proveit.statistics

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, Omega, X, Y, f, fx, g, gx, x
from proveit.logic import Bijections, Equals, Forall, Implies, InClass
from proveit.statistics import Prob, SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [X, Y], instance_expr = Forall(instance_param_or_params = [f, g], instance_expr = Implies(Forall(instance_param_or_params = [x], instance_expr = Equals(Prob(fx), Prob(gx)), domain = X), InClass(Y, SampleSpaces)).with_wrapping_at(1), domains = [Bijections(X, Omega), Bijections(X, Y)])), InClass(Omega, SampleSpaces))
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_{X, Y}~\left[\forall_{f \in \left[X \xrightarrow[\text{onto}]{\text{1-to-1}} \Omega\right], g \in \left[X \xrightarrow[\text{onto}]{\text{1-to-1}} Y\right]}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x \in X}~\left(\textrm{Pr}\left(f\left(x\right)\right) = \textrm{Pr}\left(g\left(x\right)\right)\right)\right] \\  \Rightarrow \left(Y \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\right) \end{array} \end{array}\right)\right] \textrm{ if } \Omega \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}\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: 21
operand: 5
2Operationoperator: 23
operands: 4
3ExprTuple5
4ExprTuple37, 28
5Lambdaparameters: 34
body: 6
6Operationoperator: 21
operand: 8
7ExprTuple8
8Lambdaparameters: 9
body: 10
9ExprTuple51, 52
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18
15Literal
16ExprTuple19, 20
17Operationoperator: 21
operand: 27
18Operationoperator: 23
operands: 24
19Operationoperator: 41
operands: 25
20Operationoperator: 41
operands: 26
21Literal
22ExprTuple27
23Literal
24ExprTuple38, 28
25ExprTuple51, 29
26ExprTuple52, 30
27Lambdaparameter: 54
body: 31
28Literal
29Operationoperator: 33
operands: 32
30Operationoperator: 33
operands: 34
31Conditionalvalue: 35
condition: 36
32ExprTuple45, 37
33Literal
34ExprTuple45, 38
35Operationoperator: 39
operands: 40
36Operationoperator: 41
operands: 42
37Variable
38Variable
39Literal
40ExprTuple43, 44
41Literal
42ExprTuple54, 45
43Operationoperator: 47
operand: 49
44Operationoperator: 47
operand: 50
45Variable
46ExprTuple49
47Literal
48ExprTuple50
49Operationoperator: 51
operand: 54
50Operationoperator: 52
operand: 54
51Variable
52Variable
53ExprTuple54
54Variable