PrSAT Demo

Branden Fitelson
October 8, 2014

PrSAT is a Mathematica package I have written, which supports algebraic reasoning about the probability calculus.  It is freely available from:

	http://fitelson.org/PrSAT/

There is also a journal paper that goes along with PrSAT, which explains the basic ideas behind its operation.  That paper can be downloaded from:

	http://fitelson.org/pm.pdf

In this demo, I will go through some homework exercises (HW #2).

HW #2 Problems

First, we load in the PrSAT package.

<<PrSAT`

Problem 2.5

Mike specifies a probability distribution over the states involving three atomic sentences: P,Q,R.  We can have PrSAT compute this model, by specifying all of these state-probabilities.  PrSAT takes a set of probabilistic constraints as input and outputs a probability model (iff there is one) satisfying those constraints.  Here’s what input specifying the distribution from Problem 2.5 looks like.  Note: Mathematica uses the symbol ∧ (rather than &) for conjunction; ¬ (rather than ~) for negation; and Pr(•), rather than cr(•), for the probability function.  Also, Mathematica uses brackets rather than parentheses for functions (e.g., Pr[•]); and it uses the symbol “==” for equational constraints (rather than “=”).

Model25=PrSAT[{
Pr[P∧Q∧R]==0.1,
Pr[P∧Q∧¬R]==0.2,
Pr[P∧¬Q∧R]==0,
Pr[P∧¬Q∧¬R]==0.3,
Pr[¬P∧Q∧R]==0.1,
Pr[¬P∧Q∧¬R]==0.2,
Pr[¬P∧¬Q∧R]==0,
Pr[¬P∧¬Q∧¬R]==0.1
}]

We can use the TruthTable function to visualize the stochastic truth-table for the above probability model.

TruthTable[Model25]

Now, we can use the EvaluateProbability function to calculate probabilities of any propositions, under this probability distribution (which we have named Model25).

(a) cr(P ≡ Q)

Mathematica uses the symbol ⧦ for the biconditional. Also, Mathematica uses the symbol => for the material conditional.  We can define our own operators here, so as to maintain our familiar notations:

p_⥰q_:=p\[Implies]q;
p_≡q_:=p⧦q;

Now, we can use EvaluateProbability to calculate the value of cr(P ≡ Q), according to Model25.

EvaluateProbability[Pr[P≡Q],Model25]

(b) cr(R ⥰ Q)

EvaluateProbability[Pr[R⥰Q],Model25]

(c) cr(P & R) – cr(~P & R)

Recall, Mathematica uses ∧ for conjunction and ¬ for negation.

EvaluateProbability[Pr[P∧R]-Pr[¬P∧R],Model25]

(d) cr(P & Q & R) / cr(R)

EvaluateProbability[Pr[P∧Q∧R]/Pr[R],Model25]

Problem 2.6

Can a probabilistic credence distribution assign cr(P) = 0.5, cr(Q) = 0.5, and cr(~P & ~Q) = 0.8.  No.

PrSAT[{
Pr[P]==(1/2),
Pr[Q]==(1/2),
Pr[¬P∧¬Q]==(8/10)
}]

Undocumented feature: PrReduce — finds the general conditions under which a set of probabilistic conditions is satisfied.

PrReduce[{
Pr[P]==(1/2),
Pr[Q]>Pr[P∧Q],
Pr[¬P∧¬Q]<(8/10)
}]

Problem 2.7

Can a probability distribution satisfy all four of the following constraints?

1.  Pr(A ⥰ (B ≡ 𝒞)) = 1.
2.  Pr(B) = Pr(~B).
3.  Pr(𝒞) = 2*Pr(𝒞 & A).
4.  Pr(B & 𝒞 & ~A) = 1/5.

Yes.

Model27=PrSAT[{
Pr[A⥰(B≡𝒞)]==1,
Pr[B]==Pr[¬B],
Pr[𝒞]==2*Pr[𝒞∧A],
Pr[B∧𝒞∧¬A]==(1/5)
},BypassSearch->True]

TruthTable[Model27]

We can use EvaluateProbability to check that our model above has the four desired properties.

EvaluateProbability[{
Pr[A⥰(B≡𝒞)]==1,
Pr[B]==Pr[¬B],
Pr[𝒞]==2*Pr[𝒞∧A],
Pr[B∧𝒞∧¬A]==(1/5)
},Model27]

Two Problems from Chapter 3 (not on HW #3)

Problem 3.11

This problem involves showing that the following four probabilistic constraints:

1. Pr(A | 𝒞) > Pr(A | ¬𝒞)
2. Pr(B | 𝒞) > Pr(B | ¬𝒞)
3. Pr(A & B | 𝒞) = Pr(A | 𝒞) * Pr(B | 𝒞)
4. Pr(A & B | ¬𝒞) = Pr(A | ¬𝒞) * Pr(B | ¬𝒞)

jointly imply the following fifth constraint:

5. Pr(A & B) > Pr(A) * Pr(B)

This is equivalent to showing that there is no probability distribution that satisfies (1)-(4), but also satisfies:

6. Pr(A & B) ≤ Pr(A) * Pr(B)

We can verify this claim (of Reichenbach’s) using PrSAT, which tells us there are no such distributions.

PrSAT[{
Pr[A|𝒞]>Pr[A|¬𝒞],
Pr[B|𝒞]>Pr[B|¬𝒞],
Pr[A∧B|𝒞]==Pr[A|𝒞]*Pr[B|𝒞],
Pr[A∧B|¬𝒞]==Pr[A|¬𝒞]*Pr[B|¬𝒞],
Pr[A∧B]≤Pr[A]*Pr[B]
}]

Here is a model satisfying all of Reichenbach’s conditions:

ModelReich=PrSAT[{
Pr[A|𝒞]>Pr[A|¬𝒞],
Pr[B|𝒞]>Pr[B|¬𝒞],
Pr[A∧B|𝒞]==Pr[A|𝒞]*Pr[B|𝒞],
Pr[A∧B|¬𝒞]==Pr[A|¬𝒞]*Pr[B|¬𝒞],
Pr[A∧B]>Pr[A]*Pr[B]
}]

TruthTable[ModelReich]

EvaluateProbability[{
Pr[A|𝒞]>Pr[A|¬𝒞],
Pr[B|𝒞]>Pr[B|¬𝒞],
Pr[A∧B|𝒞]==Pr[A|𝒞]*Pr[B|𝒞],
Pr[A∧B|¬𝒞]==Pr[A|¬𝒞]*Pr[B|¬𝒞],
Pr[A∧B]>Pr[A]*Pr[B]
},ModelReich]

Problem 3.12

(a) find a probability model/distribution according to which:

	Pr(𝒞 | A) = Pr(𝒞 | B), but
	Pr(𝒞 | A) ≠ Pr(𝒞 | A ∨ B)
	
Easily solved with PrSAT.

Model312=PrSAT[{
Pr[𝒞|A]==Pr[𝒞|B],
Pr[𝒞|A]≠Pr[𝒞|A∨B]
}]

TruthTable[Model312]

(b) show that — if A and B are mutually exclusive — then there can be no such probability distributions.  In other words, show that the following three constraints cannot be jointly satisfied.

	Pr(𝒞 | A) = Pr(𝒞 | B), 
	Pr(𝒞 | A) ≠ Pr(𝒞 | A ∨ B),
	Pr(A & B) = 0.
	
Again, easily solved with PrSAT.

PrSAT[{
Pr[𝒞|A]==Pr[𝒞|B],
Pr[𝒞|A]≠Pr[𝒞|A∨B],
Pr[A∧B]==0
}]

Accessing PrSAT’s Underlying Algebraic Represenation

The Function AlgebraicForm allows you to work directly with the underlying algebraic representations of probability claims.  For instance, we can look at the algebraic constraints corresponding to the set of constraints from the previous problem, as follows:

AlgebraicForm[{
Pr[𝒞|A]==Pr[𝒞|B],
Pr[𝒞|A]≠Pr[𝒞|A∨B],
Pr[A∧B]==0
},{A,B,𝒞}]

The function PrKey allows you to see a stochastic truth-table representation of the states involved for a given set of propositional letters.

PrKey[{A,B,𝒞}]