The Rational Speech Act pipeline on probability kernels #
This file defines the Rational Speech Act model in mathlib's probability vocabulary, following
Frank and Goodman's model as presented in Degen's review (eqs. 1–4) and in Franke and Bergen's
comparison of latent-variable variants (eqs. 5–22). The speaker believes a measure on states and
is the softmax of the expected log of the listener's mass under that belief less a real cost,
scaled by the rationality, so that Frank and Goodman's speaker, who knows the state, believes the
point mass there. The listener holds a prior over states and reweights it by the mass each
state's measure gives the utterance heard. At the channel of a speaker who is only truthful she is
the literal listener, who conditions the prior on the extension of the utterance, and at a speaker
she is the pragmatic listener, mathlib's posterior kernel wherever the utterance is heard; the
listener of a graded meaning is the density kernel Kernel.ofDensity. A latent the speaker also
knows is a coordinate of the state, and so is the speaker's choice when the listener hears only
its form: her prior is then the joint of the world prior and the speaker. A speaker whose
utility is not an expected log-probability, such as a question- or
politeness-weighted one, is the softmax kernel Kernel.softmax of her score, with ⊥ marking
the utterances she cannot use. Rationality, cost, meaning, and prior are arguments, so findings
quantify over them. Boolean meanings at a uniform prior on finitely many states, where masses
reduce to counting, are treated in Linglib.Pragmatics.RSA.Uniform.
Main definitions #
RSA.listener: the prior reweighted by the mass each state's measure gives the utterance heard, and normalized. At the channelRSA.truthful semof a speaker who is only truthful it is eq. 1, the prior conditioned on the denotation of the utterance.RSA.speaker: the softmax of the expected log of the listener's mass under the speaker's belief, less a cost. Its weights are the geometric mean of the listener's mass over the belief to the powerα, timesexp (-(α * C)); at the point-mass belief it is the speaker of eqs. 2/6–7, with weightsL ^ α * exp (-(α * C))(RSA.speaker_dirac_eq_ofWeights).
Main results #
RSA.speaker_apply_singleton_eq_zero_iff: the speaker produces exactly the utterances whose listener rules out no state she entertains.RSA.listener_prod_fst: lexical uncertainty. Against independent priors over states and a latent, the state marginal of the joint listener is the listener of the speaker averaged over the latent.RSA.speaker_ofDensity_apply_singleton: against the listener of a graded meaning the prior cancels from the speaker's choice, and she weighs an utterance by the geometric mean of its meaning over her belief and the inverse of the meaning's prior mass.RSA.tendsto_speaker_dirac_real_singleton_atTop: as rationality grows the speaker puts all its mass on the utterance the listener most favors.
References #
- M. C. Frank and N. D. Goodman, Predicting Pragmatic Reasoning in Language Games (2012)
- J. Degen, The Rational Speech Act Framework (2023)
- L. Bergen, R. Levy and N. D. Goodman, Pragmatic Reasoning through Semantic Inference (2016)
- M. Franke and L. Bergen, Theory-Driven Statistical Modeling for Semantics and Pragmatics: A Case Study on Grammatically Generated Implicature Readings (2020)
The RSA pipeline #
The channel of a speaker who is only required to be truthful. The denotation sem gives each
utterance the set of states it is true at, and the channel puts mass one on each utterance true at
the state. For utterances that denote sets of states, sem is fun u ↦ ⟦u⟧, and its value at a
lexicon, a threshold or a context when the denotation depends on one.
Equations
- RSA.truthful sem w = MeasureTheory.Measure.count.restrict {u : U | w ∈ sem u}
Instances For
The listener #
A listener holds a prior over states and takes the utterance to come from a channel, a measure on utterances at each state. She reweights the prior by the mass each state's measure gives the utterance she hears and normalizes, which is Bayes' rule with the zero measure at an utterance no state she entertains produces. The literal listener (eq. 1) takes the speaker to be truthful and no more, and so conditions the prior on the denotation of the utterance. The pragmatic listener (eq. 3) takes the channel of a speaker, and is mathlib's posterior wherever the utterance is heard.
The listener reweights the prior μ by the mass each state's measure S w gives the
utterance heard, and normalizes. Her row at an utterance that no state of positive prior produces
is the zero measure.
Equations
- RSA.listener μ S = ProbabilityTheory.Kernel.ofDensity μ fun (u : U) (w : W) => (S w) {u}
Instances For
A relabelling of the states that carries one prior and channel to another carries the listener along.
A state whose measure gives the utterance no mass gets none from the listener.
A state the listener gives mass has positive prior and produces the utterance.
The listener gives mass to a state of positive prior that produces the utterance.
The listener puts mass on a state exactly when it has positive prior and produces the utterance.
Events #
Bayes' rule on reals, for the mass of a state and of a finite event. It holds at every utterance, since an utterance that no state of positive prior produces gives the zero row and a zero normalizer.
Two states with the same prior mass that produce the utterance alike get the same mass.
The listener's row is a probability measure at an utterance that some state of positive prior produces.
Bayes' rule on reals for an event. Both sides vanish at an utterance that no state of positive prior produces.
Bayes' rule on reals at a state.
The listener prefers the event with the greater prior-weighted production probability, at every utterance, heard or not.
The listener prefers the state with the greater prior mass times production probability, at every utterance, heard or not.
A state producing the utterance with certainty outweighs any event of smaller total prior mass, when no state produces it with probability above one.
At a prior giving every state the same positive mass, the listener ranks two states as they produce the utterance.
The uniform prior #
Against the uniform prior the prior cancels, and the listener's mass on a state is its share of the production probability of the utterance.
Against the uniform prior the listener ranks two states as they produce the utterance.
Against the uniform prior the listener ranks two events as their states together produce the utterance.
Marginals of a listener over a product #
A latent the speaker also knows, a lexicon or a threshold or a question, is a coordinate of the
state: the speaker at a pair is fun p ↦ speaker α C (L p.2) Measure.dirac p.1, addressing that
latent's listener, and her listener holds a prior over pairs. Its marginals pool the
prior-weighted production probabilities over the other coordinate. When the prior over pairs is a
product, forgetting the latent after the joint inference is inverting the speaker averaged over
the latent, so the two presentations of lexical uncertainty agree (listener_prod_fst).
The first marginal of the listener is positive at a point exactly when some second coordinate pairs a positive prior with a positive production probability.
The first marginal of the listener pools the prior-weighted production probabilities over the second coordinate.
Comparing first marginals of the listener compares the prior-weighted production probabilities pooled over the second coordinate.
Lexical uncertainty. Against a product prior, the first marginal of the listener is the listener of the speaker averaged over the second coordinate by its prior.
Against a product prior the first marginal of the listener is the prior at the point times the production probability averaged over the second coordinate, normalized.
At a prior giving every pair the same positive mass, the first marginal of the listener prefers the point with the greater production probability summed over the second coordinate.
At a prior giving every pair the same positive mass, the second marginal of the listener prefers the point with the greater production probability summed over the first coordinate.
The listener of a kernel #
When the channel is a kernel, the normalizer is the marginal probability of the utterance, the listener is a probability measure exactly at the utterances that are heard, and there she is mathlib's posterior.
Bayes' rule holds at every utterance. The listener's mass on a state is its prior times the mass its row gives the utterance, over the utterance's marginal.
The listener's row at a heard utterance is a probability measure.
The listener is a probability kernel when every utterance is heard.
At every state and utterance, the utterance's marginal times the listener is the prior times the production, Bayes' rule on reals with the denominator cleared. Both sides vanish at an utterance that is not heard.
At a heard utterance the listener is the posterior, by Bayes' rule.
A listener who hears a function of the state conditions the prior on its fibre.
The listener of a truthful speaker #
The listener of a truthful speaker is the density kernel of the indicator of the denotation against the prior.
The listener of a truthful speaker (eq. 1) conditions the prior on the denotation of the utterance.
The listener of a truthful speaker is a probability measure at an utterance whose denotation has positive prior mass.
On reals the listener of a truthful speaker gives a state the utterance is true at its share of the prior mass of the denotation.
A tautology leaves a probability prior unchanged.
An utterance true at one state only puts all its mass there.
The listener of a truthful speaker puts mass on a state exactly when the utterance is true there and the state has positive prior.
A relabelling of the states that carries one prior and denotation to another carries the listener of a truthful speaker along.
The speaker #
A speaker believes a measure on states and addresses a listener. Her weight for an utterance is
the exponential of the rationality times its utility: the expected log of the listener's mass
under her belief, less a real cost. Written without logarithms, the weight is the geometric mean
of the listener's mass over her belief, to the power of the rationality, times the cost weight
exp (-(α * C u)).
The speaker at rationality α and cost C addresses the listener L and at o believes
b o. Her weight for an utterance is the geometric mean of its listener's mass over her belief,
to the power α, times the cost weight.
Equations
- RSA.speaker α C L b = ProbabilityTheory.Kernel.ofWeights fun (o : O) (u : U) => ((b o).geomMean fun (w : W) => (L u) {w}) ^ α * ENNReal.ofReal (Real.exp (-(α * C u)))
Instances For
A speaker row has total mass at most one.
Speaker shares are at most one.
Speaker shares over any set of utterances sum to at most one.
Another utterance of positive mass keeps a share strictly below one.
The speaker's row is a probability measure at an observation where some utterance's listener rules out no state she entertains.
The speaker is a probability kernel when at every observation some utterance's listener rules out no state she entertains.
An utterance whose listener rules out no state she entertains is produced with positive mass.
Row preference of the speaker compares the weights; the normalization cancels.
The speaker never produces an utterance whose listener rules out a state she entertains.
The speaker against a graded meaning #
The listener of a graded meaning reweights the prior by the meaning of the utterance. The prior, which no utterance changes, cancels from the speaker's choice, and she weighs an utterance by the geometric mean of its meaning over her belief against the meaning's prior mass.
Against the listener of a graded meaning the speaker weighs an utterance by the geometric mean of its meaning over her belief and by the inverse of the meaning's prior mass.
Against the listener of a graded meaning, two observations at which every meaning has the same geometric mean over the speaker's belief yield the same speaker.
The speaker who knows the state #
The speaker of eqs. 2/6–7 knows the state, so she believes the point mass there, and her weight
for an utterance is the listener's mass at the state to the power α, times the cost weight.
A speaker who knows the state weights an utterance by its listener's mass there to the power
α, times the cost weight exp (-(α * C u)).
A speaker who knows the state is the softmax of the log of the listener's mass there less the
cost, scaled by the rationality. The extended logarithm gives an utterance whose listener rules the
state out the score ⊥ at positive rationality, so no condition on the listener is needed.
The speaker who knows the state is a probability measure there when some utterance's listener gives it mass.
The speaker is a probability kernel whenever every state has a true utterance.
At zero cost the speaker's weights are the listener's masses to the power α.
Relabelling the utterances carries the speaker along, with the cost relabelled with them. A
listener that treats τ v at w' as the other treats v at w makes the speaker at w' produce
τ u as the other produces u at w.
A literally false utterance is never produced (positive rationality).
A literally true utterance is produced with positive mass.
A state with a unique applicable utterance produces it with certainty.
On reals a speaker share is the weighted listener value over the row's total.
At zero cost a speaker share on reals is the listener's mass to the power α over the row's
total.
Row-preference of the speaker reduces to comparing the weighted listener values; the normalization cancels.
The odds of one utterance against another do not depend on the other alternatives. They are
the ratio of the listener's masses at the state to the power α, discounted by the difference in
cost.
Of two utterances with listener mass at the state, the speaker prefers the one of greater utility, the log of the listener's mass less the cost.
When exactly two utterances have listener mass at the state, the share of one is the logistic function of its advantage in utility over the other, scaled by the rationality.
With Boolean meanings, a state whose only true utterance is u produces u with
certainty at any prior giving the state positive mass.
With Boolean meanings the speaker produces an utterance at a state exactly when it is true there and the state has positive prior.
With Boolean meanings the speaker never produces a false utterance.
With Boolean meanings the speaker sees a state only through the utterances true at it, so two states of positive prior verifying the same utterances have the same production row.
With Boolean meanings the prior cancels from the speaker, which at a state of positive prior
weights each true utterance by its extension's mass to the power -α and by its cost.
With Boolean meanings a state verifying more utterances produces each of its true utterances less, since the prior cancels from the speaker and only the inclusion of the true utterances matters.
As rationality grows, the speaker puts all its mass on the utterance whose listener mass,
discounted by its cost, is greatest at w, so the fully rational speaker maximizes the
utility.
With Boolean meanings and a constant cost, a state two utterances both fit produces the utterance with the smaller extension more often, since informativity is the inverse of extension mass.
The heard form #
When the listener hears only the form obs u of the speaker's choice u (eqs. 18b/21b), her
state is the pair of the world and the choice, her prior the joint of the world prior and the
speaker, and her channel the point mass at the form. Her first marginal is her belief about the
world and her second her belief about the choice.
The listener of the form gives mass to a pair of a state and a choice exactly when the choice has the form heard, the state has positive prior and it produces the choice.
The listener of the form prefers the state with the greater prior-weighted production probability pooled over the choices with the form heard.
Between two choices with the form heard, the listener of the form prefers the one with the greater prior-weighted production probability pooled over the states.
At a uniform prior the listener of the form prefers the state likelier to produce a choice with the form heard.
At a uniform prior the listener of the form prefers, of two choices with the form heard, the one the states together are likelier to produce.
Pragmatic listeners #
The pragmatic listener (eq. 3) is the listener of a speaker.
With Boolean meanings, hearing an utterance rules out every state it does not fit.