Documentation

Studies.HayesWilson2008

Hayes and Wilson (2008): A Maximum Entropy Model of Phonotactics and Phonotactic Learning #

This file formalizes Hayes and Wilson's maximum-entropy model of phonotactics. A constraint is a sequence of feature matrices, one of which may be complemented, and a grammar assigns each form a score, a maxent value, and a probability. The weights are learned by maximizing the probability of the data, whose partial derivatives are differences between expected and observed violation counts (hasDerivAt_logLik), and the weights that maximize it give the distribution of greatest entropy among those that match the observed violations (isGreatest_measureEntropy_of_isMaxOn_logLik).

The grammar the learner found for English onsets (Table 4) is stated over the paper's feature chart (Table 3), and every score the paper reports is recomputed from it (rows_scores), including the ten attested onsets the grammar penalizes (attested_penalized). The predicted rating orders forms as the score does (rating_lt_iff), so the reported correlation with Scholes's ratings is a claim about the score alone.

Implementation notes #

Weights are kept in hundredths over ℕ, so every score is computed by decide; the maxent value and probability then live over ℝ. Scores computed from the two-decimal weights of Table 4 can differ from the paper's reported values by one hundredth ([ð] 4.53 here against 4.54; [θw] 3.90 against 3.91; [θ] and [θr] 1.84 against 1.85), and rows_scores states the reproduction to within that rounding. Complement matrices are read against the underspecified chart, so [^+back] contains every consonant unspecified for backness, as #15 requires. The probability (6) over the infinite set of forms is realized over a finite form space, the subtype of a candidate set for the learned grammar (onsetProb); the paper's finite-state approximation of the expected counts is not modelled. The ratings of Scholes's experiment appear only as a scattergram (Figure 3), so the correlation of 0.946 and Table 5 stay in prose.

TODO #

References #

The segments of Table 3 #

Seg enumerates the English consonants of Table 3. Segments without an ASCII letter take their ARPAbet names, with ch for [tʃ], jh for [dʒ], th for [θ], sh for [ʃ], hh for [h], dh for [ð], zh for [ʒ], and ng for [ŋ].

Instances For
    @[instance_reducible]
    Equations
    @[instance_reducible]
    Equations
    def HayesWilson2008.instReprSeg.repr :
    Seg → ℕ → Std.Format
    Equations
    Instances For

      The chart of Table 3 lists, for each feature, the segments specified + and then those specified −. A segment in neither list is unspecified for the feature, as in the chart's blanks (privative and contrastive underspecification, §4.1.2).

      Equations
      Instances For

        The feature specification of a segment is read off the chart.

        Equations
        Instances For
          def HayesWilson2008.Seg.parse :
          List Char → Option (List Seg)

          parse reads an onset off a row's IPA string, with the affricates written as digraphs.

          Equations
          Instances For

            Constraints (§4.1.1) #

            A matrix of a constraint (9) is a natural class [αF, βG, …], its complement [^αF, βG, …] (the implication operator), or the word boundary #.

            Instances For
              def HayesWilson2008.Matrix.Matches {α : Type u_1} (spec : α → Phonology.Segment) :
              Matrix → Option α → Prop

              A matrix matches one symbol of a boundary-padded form, read through the segment specification spec; none is a word boundary.

              Equations
              Instances For
                @[instance_reducible]
                instance HayesWilson2008.instDecidableMatches {α : Type u_1} (spec : α → Phonology.Segment) (m : Matrix) (x : Option α) :
                Decidable (Matrix.Matches spec m x)
                Equations
                @[reducible, inline]

                A phonotactic constraint (9) is a sequence of matrices.

                Equations
                Instances For
                  def HayesWilson2008.Cx.prefixMatch {α : Type u_1} (spec : α → Phonology.Segment) :
                  Cx → List (Option α) → Bool

                  The matrices match the padded form from its first symbol on.

                  Equations
                  Instances For
                    def HayesWilson2008.Cx.violations {α : Type u_1} (spec : α → Phonology.Segment) (c : Cx) (form : List α) :
                    ℕ

                    A constraint's violation count on a form is the number of positions of the boundary-padded form at which its matrices match, as (9) specifies.

                    Equations
                    Instances For
                      def HayesWilson2008.M (l : List (Phonology.Feature × Bool)) :

                      M l is the natural class [αF, βG, …] of the specifications l.

                      Equations
                      Instances For
                        def HayesWilson2008.M' (l : List (Phonology.Feature × Bool)) :

                        M' l is the complement class [^αF, βG, …] of the specifications l.

                        Equations
                        Instances For

                          The empty matrix [ ] matches any segment.

                          Equations
                          Instances For

                            Score, maxent value, and probability (§3.2) #

                            def HayesWilson2008.score {α : Type u_1} {n : ℕ} (spec : α → Phonology.Segment) (con : Fin n → Cx) (w : Fin n → ℕ) (form : List α) :
                            ℕ

                            The score (4) of a form is its weighted violation count, with weights in hundredths.

                            Equations
                            Instances For
                              noncomputable def HayesWilson2008.maxentValue (k : ℕ) :
                              ℝ

                              The maxent value (5) of a form whose score in hundredths is k is exp (−h(x)).

                              Equations
                              Instances For
                                theorem HayesWilson2008.maxentValue_lt_iff {k₁ k₂ : ℕ} :
                                maxentValue k₁ < maxentValue k₂ ↔ k₂ < k₁

                                Forms with more violations get lower values.

                                A violation-free form has the highest possible maxent value, 1.

                                noncomputable def HayesWilson2008.rating (T : ℝ) (k : ℕ) :
                                ℝ

                                The predicted rating (12) is the maxent value raised to 1 / T for a temperature T.

                                Equations
                                Instances For
                                  theorem HayesWilson2008.rating_lt_iff {T : ℝ} (hT : 0 < T) {k₁ k₂ : ℕ} :
                                  rating T k₁ < rating T k₂ ↔ k₂ < k₁

                                  The rating orders forms exactly as the score does, so a correlation with the ratings is a claim about the score.

                                  Table 1 evaluates schematic forms over consonants C and vowels V with two constraints, *#V weighted 3.0 and *C# weighted 2.0.

                                  Instances For
                                    @[instance_reducible]
                                    Equations
                                    @[instance_reducible]
                                    Equations
                                    def HayesWilson2008.instReprCV.repr :
                                    CV → ℕ → Std.Format
                                    Equations
                                    Instances For
                                      def HayesWilson2008.table1 :
                                      Fin 2 → Cx

                                      Table 1 has the constraints *#V and *C#.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        def HayesWilson2008.table1W :
                                        Fin 2 → ℕ

                                        The weights of Table 1 are written in hundredths.

                                        Equations
                                        Instances For

                                          Table 1 scores CV 0, CVC 2.0, and V 3.0.

                                          Table 1 gives CV, CVC, and V the maxent values 1, exp (−2), and exp (−3).

                                          Learning the weights (§3.3) #

                                          def HayesWilson2008.observed {Ω : Type u_2} [Fintype Ω] {n : ℕ} (viol : OptimalityTheory.ConstraintSet Ω (Fin n)) (D : Ω → ℕ) (i : Fin n) :
                                          ℕ

                                          The observed number of violations of constraint i sums its counts over data given as counts per form.

                                          Equations
                                          Instances For
                                            noncomputable def HayesWilson2008.logLik {Ω : Type u_2} [Fintype Ω] [MeasurableSpace Ω] {n : ℕ} (viol : OptimalityTheory.ConstraintSet Ω (Fin n)) (w : Fin n → ℝ) (D : Ω → ℕ) :
                                            ℝ

                                            The log probability of the data (7) sums the log probabilities (6) of the forms, each weighted by its count, since the forms are independent.

                                            Equations
                                            Instances For
                                              noncomputable def HayesWilson2008.empirical {Ω : Type u_2} [Fintype Ω] [MeasurableSpace Ω] (D : Ω → ℕ) :
                                              MeasureTheory.Measure Ω

                                              The empirical distribution of data given as counts per form.

                                              Equations
                                              Instances For
                                                theorem HayesWilson2008.isProbabilityMeasure_empirical {Ω : Type u_2} [Fintype Ω] [MeasurableSpace Ω] (D : Ω → ℕ) (hD : ∑ x : Ω, D x ≠ 0) :
                                                MeasureTheory.IsProbabilityMeasure (empirical D)
                                                theorem HayesWilson2008.empirical_real_singleton {Ω : Type u_2} [Fintype Ω] [MeasurableSpace Ω] (D : Ω → ℕ) [MeasurableSingletonClass Ω] (x : Ω) :
                                                (empirical D).real {x} = ↑(D x) / ∑ y : Ω, ↑(D y)
                                                theorem HayesWilson2008.logLik_eq {Ω : Type u_2} [Fintype Ω] [MeasurableSpace Ω] {n : ℕ} (viol : OptimalityTheory.ConstraintSet Ω (Fin n)) (w : Fin n → ℝ) (D : Ω → ℕ) [MeasurableSingletonClass Ω] (hD : ∑ x : Ω, D x ≠ 0) :
                                                logLik viol w D = ↑(∑ x : Ω, D x) * HarmonicGrammar.logLikelihood viol.violations (empirical D) w

                                                The log probability of the data is its size times the log-likelihood of its empirical distribution.

                                                theorem HayesWilson2008.integral_violations_empirical {Ω : Type u_2} [Fintype Ω] [MeasurableSpace Ω] {n : ℕ} (viol : OptimalityTheory.ConstraintSet Ω (Fin n)) (D : Ω → ℕ) [MeasurableSingletonClass Ω] (hD : ∑ x : Ω, D x ≠ 0) (i : Fin n) :
                                                (∫ (x : Ω), viol.violations x ∂empirical D) i = ↑(observed viol D i) / ∑ x : Ω, ↑(D x)

                                                The empirical distribution's expected violations are the observed counts over the size of the data.

                                                theorem HayesWilson2008.hasDerivAt_logLik {Ω : Type u_2} [Fintype Ω] [MeasurableSpace Ω] {n : ℕ} (viol : OptimalityTheory.ConstraintSet Ω (Fin n)) (w : Fin n → ℝ) (D : Ω → ℕ) [MeasurableSingletonClass Ω] [Nonempty Ω] (i : Fin n) :
                                                HasDerivAt (fun (t : ℝ) => logLik viol (Function.update w i t) D) (↑(∑ x : Ω, D x) * (∫ (x : Ω), viol.violations x ∂HarmonicGrammar.maxEnt viol.violations w) i - ↑(observed viol D i)) (w i)

                                                The partial derivative of the log probability of the data in the weight of constraint i is its expected count (8), scaled by the size of the data, minus its observed count ([DPDPL97]). The paper's §3.3.2 states the two terms as O[Cᵢ] − E[Cᵢ], with the penalty direction in mind.

                                                theorem HayesWilson2008.isGreatest_measureEntropy_of_isMaxOn_logLik {Ω : Type u_2} [Fintype Ω] [MeasurableSpace Ω] {n : ℕ} (viol : OptimalityTheory.ConstraintSet Ω (Fin n)) (w : Fin n → ℝ) (D : Ω → ℕ) [MeasurableSingletonClass Ω] [Nonempty Ω] (hD : ∑ x : Ω, D x ≠ 0) (h : IsMaxOn (fun (w : Fin n → ℝ) => logLik viol w D) Set.univ w) :
                                                IsGreatest (InformationTheory.measureEntropy '' {q : MeasureTheory.Measure Ω | MeasureTheory.IsProbabilityMeasure q ∧ ∫ (x : Ω), viol.violations x ∂q = ∫ (x : Ω), viol.violations x ∂empirical D}) (InformationTheory.measureEntropy (HarmonicGrammar.maxEnt viol.violations w))

                                                Maximizing the probability of the data is maximizing entropy (§3.3.1, [DPDPL97]). Weights that make the data most probable give the distribution of greatest entropy among those whose expected violations average the observed ones.

                                                The learned grammar for English onsets (Table 4) #

                                                def HayesWilson2008.table4 :
                                                Fin 23 → Cx

                                                Table 4 lists 23 constraints in the order they were learned.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  def HayesWilson2008.table4W :
                                                  Fin 23 → ℕ

                                                  The weights of Table 4 are written in hundredths.

                                                  Equations
                                                  • HayesWilson2008.table4W = ![564, 328, 591, 517, 537, 666, 440, 131, 496, 484, 484, 317, 504, 280, 482, 269, 297, 206, 305, 206, 184, 210, 170]
                                                  Instances For
                                                    def HayesWilson2008.h (o : List Seg) :
                                                    ℕ

                                                    h o is the score (4) of the onset o under the learned grammar, in hundredths.

                                                    Equations
                                                    Instances For
                                                      def HayesWilson2008.viol (k : Fin 23) (o : List Seg) :
                                                      ℕ

                                                      viol k o counts the violations of constraint k + 1 of Table 4 on the onset o.

                                                      Equations
                                                      Instances For
                                                        def HayesWilson2008.attested :
                                                        List (List Seg)

                                                        The learning data (11) are the onsets of the nonexotic corpus, read off the rows.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          theorem HayesWilson2008.attested_le (o : List Seg) :
                                                          o ∈ attested → h o ≤ 453

                                                          Every attested onset is penalized by at most 4.53; most score 0 (§5.3.1).

                                                          theorem HayesWilson2008.attested_penalized :
                                                          List.map (fun (o : List Seg) => (o, h o)) (List.filter (fun (x : List Seg) => decide (h x ≠ 0)) attested) = [([Seg.th], 184), ([Seg.z], 269), ([Seg.th, Seg.r], 184), ([Seg.t, Seg.w], 170), ([Seg.sh, Seg.r], 210), ([Seg.dh], 453), ([Seg.d, Seg.w], 297), ([Seg.g, Seg.w], 297), ([Seg.th, Seg.w], 390), ([Seg.s, Seg.k, Seg.l], 305)]

                                                          Exactly ten attested onsets receive penalties, the rarest ones, namely [θ], [z], [θr], [tw], [ʃr], [ð], [dw], [gw], [θw], and [skl] in the corpus order of (11) (§5.3.1).

                                                          def HayesWilson2008.twelve :
                                                          List (List Seg)

                                                          These are the twelve unattested onsets with the best scores (§5.3.1).

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            theorem HayesWilson2008.twelve_scores :
                                                            List.map h twelve = [376, 440, 482, 482, 484, 484, 484, 484, 490, 496, 496, 496]

                                                            The accidental gap [stw] scores 3.76, followed by [dl] 4.40, [hl] and [hr] 4.82, [vl], [vr], [ʃl], and [ʃw] 4.84, [sr] 4.90, and [fw], [pw], and [spw] 4.96 (§5.3.1).

                                                            theorem HayesWilson2008.h_rt :
                                                            h [Seg.r, Seg.t] = 2181 ∧ viol 2 [Seg.r, Seg.t] = 1 ∧ viol 5 [Seg.r, Seg.t] = 1 ∧ viol 6 [Seg.r, Seg.t] = 1 ∧ viol 9 [Seg.r, Seg.t] = 1

                                                            Most unattested onsets score far worse, as [rt] scores 21.81 from #3, #6, #7, and #10.

                                                            theorem HayesWilson2008.stch_gang :
                                                            h [Seg.s, Seg.ch] = 621 ∧ viol 7 [Seg.s, Seg.ch] = 1 ∧ viol 13 [Seg.s, Seg.ch] = 1 ∧ viol 21 [Seg.s, Seg.ch] = 1 ∧ table4W 7 < 400 ∧ table4W 13 < 400 ∧ table4W 21 < 400

                                                            In the gang of §5.2, constraints #8, #14, and #22, each weighted below the threshold of about 4, together give *[stʃ] the bad score 6.21.

                                                            theorem HayesWilson2008.zh_gang :
                                                            h [Seg.zh] = 597 ∧ viol 1 [Seg.zh] = 1 ∧ viol 15 [Seg.zh] = 1

                                                            #2 ganging with #16 rules out *[ʒ].

                                                            theorem HayesWilson2008.thw_gang :
                                                            h [Seg.th, Seg.w] = 390 ∧ viol 17 [Seg.th, Seg.w] = 1 ∧ viol 20 [Seg.th, Seg.w] = 1

                                                            #18 and #21 gang to penalize the especially rare attested onset [θw].

                                                            def HayesWilson2008.digits (cs : List Char) :
                                                            Option ℕ

                                                            digits cs reads a decimal numeral.

                                                            Equations
                                                            • HayesWilson2008.digits cs = if cs ≠ [] ∧ cs.all Char.isDigit = true then some (List.foldl (fun (n : ℕ) (c : Char) => 10 * n + (c.toNat - '0'.toNat)) 0 cs) else none
                                                            Instances For
                                                              def HayesWilson2008.hundredths (s : String) :
                                                              Option ℕ

                                                              hundredths s reads a reported two-decimal score in hundredths.

                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For

                                                                A row that reports a score is reproduced when its onset parses and the grammar's score is within one hundredth of the reported one.

                                                                Equations
                                                                • One or more equations did not get rendered due to their size.
                                                                Instances For
                                                                  @[instance_reducible]
                                                                  Equations

                                                                  Every score the paper reports (§5.2–5.3) is reproduced by the grammar to within one hundredth, the rounding of the printed weights.

                                                                  Probability over a candidate set (§3.2, (6)) #

                                                                  def HayesWilson2008.candidates :
                                                                  Finset (List Seg)

                                                                  The candidate set contains the attested onsets and the unattested ones discussed.

                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For

                                                                    The constraints of Table 4 on the candidate set.

                                                                    Equations
                                                                    Instances For
                                                                      noncomputable def HayesWilson2008.onsetProb (o : ↥candidates) :
                                                                      ℝ

                                                                      onsetProb is the probability (6) of each candidate under the learned grammar, with the weights of Table 4 read as reals.

                                                                      Equations
                                                                      Instances For
                                                                        theorem HayesWilson2008.onsetProb_eq_softmax :
                                                                        onsetProb = Real.softmax fun (o : ↥candidates) => -↑(h ↑o) / 100

                                                                        The probability (6) is the softmax of the negated scores (4).

                                                                        theorem HayesWilson2008.onsetProb_lt_iff {o₁ o₂ : ↥candidates} :
                                                                        onsetProb o₁ < onsetProb o₂ ↔ h ↑o₂ < h ↑o₁

                                                                        On the candidate set, the probability (6) orders forms as the score does.