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 A, B, Conditional, Function, Omega, Q, Qx, f, fx, g, gy, x, y
from proveit.logic import And, Bijections, Equals, InSet, Injections
from proveit.statistics import ProbOfAll
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [gy]
expr = Conditional(Equals(ProbOfAll(instance_param_or_params = [x], instance_element = fx, domain = A, condition = Qx), ProbOfAll(instance_param_or_params = [y], instance_element = Function(f, sub_expr1), domain = B, condition = Function(Q, sub_expr1))), And(InSet(f, Injections(A, Omega)), InSet(g, Bijections(B, A))))
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\{\left[\textrm{Prob}_{x \in A~|~Q\left(x\right)}~f\left(x\right)\right] = \left[\textrm{Prob}_{y \in B~|~Q\left(g\left(y\right)\right)}~f\left(g\left(y\right)\right)\right] \textrm{ if } f \in \left[A \xrightarrow[]{\text{1-to-1}} \Omega\right] ,  g \in \left[B \xrightarrow[\text{onto}]{\text{1-to-1}} A\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: 32
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple8, 9
6Operationoperator: 11
operand: 15
7Operationoperator: 11
operand: 16
8Operationoperator: 40
operands: 13
9Operationoperator: 40
operands: 14
10ExprTuple15
11Literal
12ExprTuple16
13ExprTuple31, 17
14ExprTuple48, 18
15Lambdaparameter: 45
body: 19
16Lambdaparameter: 50
body: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 23
operands: 24
19Conditionalvalue: 25
condition: 26
20Conditionalvalue: 27
condition: 28
21Literal
22ExprTuple44, 29
23Literal
24ExprTuple46, 44
25Operationoperator: 31
operand: 45
26Operationoperator: 32
operands: 30
27Operationoperator: 31
operand: 47
28Operationoperator: 32
operands: 33
29Variable
30ExprTuple34, 35
31Variable
32Literal
33ExprTuple36, 37
34Operationoperator: 40
operands: 38
35Operationoperator: 42
operand: 45
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operand: 47
38ExprTuple45, 44
39ExprTuple45
40Literal
41ExprTuple50, 46
42Variable
43ExprTuple47
44Variable
45Variable
46Variable
47Operationoperator: 48
operand: 50
48Variable
49ExprTuple50
50Variable