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 And, Bijections, Equals, Forall, Implies, InClass, InSet
from proveit.statistics import Prob, SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Implies(Forall(instance_param_or_params = [x], instance_expr = Equals(Prob(fx), Prob(gx)), domain = X), InClass(Y, SampleSpaces)).with_wrapping_at(1), And(InSet(f, Bijections(X, Omega)), InSet(g, Bijections(X, Y))))
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\{\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} \textrm{ if } 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]\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
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10
7Operationoperator: 11
operand: 17
8Operationoperator: 13
operands: 14
9Operationoperator: 31
operands: 15
10Operationoperator: 31
operands: 16
11Literal
12ExprTuple17
13Literal
14ExprTuple28, 18
15ExprTuple41, 19
16ExprTuple42, 20
17Lambdaparameter: 44
body: 21
18Literal
19Operationoperator: 23
operands: 22
20Operationoperator: 23
operands: 24
21Conditionalvalue: 25
condition: 26
22ExprTuple35, 27
23Literal
24ExprTuple35, 28
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27Variable
28Variable
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple44, 35
33Operationoperator: 37
operand: 39
34Operationoperator: 37
operand: 40
35Variable
36ExprTuple39
37Literal
38ExprTuple40
39Operationoperator: 41
operand: 44
40Operationoperator: 42
operand: 44
41Variable
42Variable
43ExprTuple44
44Variable