y0 icon indicating copy to clipboard operation
y0 copied to clipboard

DSL to natural language

Open djinnome opened this issue 8 months ago • 1 comments

Hi @cthoyt

I am developing a syllabus for a 2 hour workshop on causal reasoning, and I want to teach the participants how read causal and counterfactual notation.

For example:

Causal Hierarchy Level Probabilistic notation $Y_0$ notation English interpretation
Observation $$P(Cancer=true| Smoking=true)$$
P(+Cancer | +Smoking)
Given a subpopulation of people who smoke, what is the probability that they will get cancer?
Action $$P(Cancer=true| do(Smoking=true))$$
P[+Smoking](+Cancer)
In a world where everyone is required to smoke, what is the probability that they will get cancer?
Imagination $$P(Cancer_{do(Smoking=true)}=true| Cancer=false, Smoking=false))$$
P(+Cancer @ +Smoking | -Smoking, -Cancer)
Given a subpopulation of people who do not smoke and do not have cancer, what is the probability that they would get cancer in a world where I forced them to smoke?

I wonder if we could add a method to the DSL called to_english() that converted the probabilistic expression to its english language interpretation?

djinnome avatar Mar 25 '25 03:03 djinnome

I don't think this needs to be the entire DSL, but just a function that operates on a probability object, correct? Therefore, I'd suggest if you implement, then to do it as an external function outside the class definition, so it could be used like:

from y0.dsl import probability_to_english, Variable, P

cancer = Variable("cancer")
smoking = Variable("smoking")

observation = P(+cancer | +smoking)

print(probability_to_english(observation))

cthoyt avatar Mar 25 '25 07:03 cthoyt