Documentation

Complexity.MachineLearning.UniformLearning.KushilevitzMansour

The Kushilevitz–Mansour algorithm #

The Kushilevitz–Mansour algorithm [KM93] O'Donnell, Section 3.5 learns, with membership queries, every Boolean function of small spectral norm ∑_S |f̂(S)| (UniformLearning.spectralNormClass); for instance every function computed by a small decision tree (UniformLearning.decisionTreeClass). It finds the large Fourier coefficients by the bucket search of Goldreich and Levin [GL89]: the bucket of a set S ⊆ J is the family of the sets U with U ∩ J = S, and its weight is the bucket weight (BitString.bucketWeight, O'Donnell's W^{S | J̄} with J̄ the complement of J). Starting from the bucket of all sets, the search adds the coordinates one at a time, splitting each surviving bucket S of J into the buckets S and insert i S of insert i J, and keeps the buckets whose estimated weight is at least θ² / 2 (UniformLearning.bucketSearch). A set U with |f̂(U)| ≥ θ contributes θ² to each of its buckets and is never discarded (UniformLearning.inter_mem_bucketSearch), while every surviving bucket weighs at least θ² / 4, so at most 4 / θ² buckets survive at each level (UniformLearning.mul_card_bucketSearch_le_one).

The weights are estimated from samples (x, y, z) of three independent uniform points, as the average of f (x, z) χ_S(x) f (y, z) χ_S(y) (UniformLearning.bucketEstimate, BitString.bucketWeight_eq_expect_sample), where (x, z) takes the coordinates in J from x and the others from z. Here the same m samples serve every bucket of every level, so the queries are non-adaptive: the learner queries f at x and at the points (x, z), (y, z) of every sample and every level, m (2 n + 3) queries for n coordinates (UniformLearning.kmLearner_queriesAtMost), and then runs the search on the answers. The analysis takes a union bound over all 2 ^ n buckets of each level, which costs a factor n in the number of samples compared with fresh samples for each weighing. The hypothesis is the sign of the expansion on the found sets with coefficients estimated from the points x (UniformLearning.kmHypothesis, UniformLearning.kmLearner).

If all estimates are within θ² / 4 of their values, the hypothesis has error at most θ² / 4 + θ L for a function of spectral norm at most L (UniformLearning.uniformError_kmHypothesis_le): the found sets carry all coefficients of absolute value at least θ, and the others weigh at most θ L. Hoeffding's inequality and the union bound make the estimates accurate except with probability at most 2 (n + 2) 2 ^ n exp (-m θ⁴ / 32) (UniformLearning.uniform_not_accurate_le). With θ = ε / (2 L) this gives the Kushilevitz–Mansour theorem: the functions of spectral norm at most L are learned with error ε and confidence 1 - δ from m ≥ (512 L⁴ / ε⁴) log (2 (n + 2) 2 ^ n / δ) samples, hence m (2 n + 3) membership queries, polynomial in n, L, 1 / ε and log (1 / δ) (UniformLearning.kmLearner_learns) O'Donnell, Theorem 3.38. By the spectral norm bound for decision trees (DecisionTree.sum_abs_fourierCoeff_signVal_le_leafCount), this applies to the functions computed by decision trees with at most L leaves (UniformLearning.kmLearner_learns_decisionTree).

Cost. Only the number of queries is certified. On accurate samples the search computes at most 8 / θ² bucket estimates at each level, each from the m samples, and estimates at most 4 / θ² coefficients; this count of arithmetic operations is informal, and the running time is not certified by a machine model.

Main definitions #

Main results #

References #

The sets of coordinates weighed by the bucket search over the list l: the sets of coordinates of the suffixes of l, from l itself down to the empty list.

Instances For

    The coordinates of l are its first level.

    noncomputable def Cslib.MachineLearning.UniformLearning.bucketSearch {ι : Type u_1} [DecidableEq ι] (est : Finset ι → Finset ι → ℝ) (τ : ℝ) :
    List ι → Finset (Finset ι)

    The bucket search of Goldreich–Levin and Kushilevitz–Mansour over the list l of coordinates, given estimates est J S of the bucket weights W^{S | J} and a threshold τ. Starting from the bucket of all sets, it adds the coordinates of l from the last to the first, splits each surviving bucket S of J into the buckets S and insert i S of insert i J, and keeps the buckets whose estimated weight is at least τ.

    Instances For
      theorem Cslib.MachineLearning.UniformLearning.bucketSearch_congr {ι : Type u_1} [DecidableEq ι] {est est' : Finset ι → Finset ι → ℝ} {τ : ℝ} {l : List ι} (h : ∀ J ∈ searchLevels l, ∀ (S : Finset ι), est J S = est' J S) :
      bucketSearch est τ l = bucketSearch est' τ l

      The bucket search reads the estimates only at its levels.

      theorem Cslib.MachineLearning.UniformLearning.le_of_mem_bucketSearch {ι : Type u_1} [DecidableEq ι] {est : Finset ι → Finset ι → ℝ} {τ : ℝ} {l : List ι} {S : Finset ι} (hS : S ∈ bucketSearch est τ l) :
      τ ≤ est l.toFinset S

      Every bucket kept by the search over l has estimated weight at least τ at the level of the coordinates of l.

      theorem Cslib.MachineLearning.UniformLearning.inter_mem_bucketSearch {ι : Type u_1} [DecidableEq ι] {est : Finset ι → Finset ι → ℝ} {τ : ℝ} {l : List ι} {U : Finset ι} (h : ∀ J ∈ searchLevels l, τ ≤ est J (U ∩ J)) :

      Completeness of the bucket search: if at every level J the bucket of U ∩ J has estimated weight at least τ, then the search over l keeps the bucket U ∩ l.

      theorem Cslib.MachineLearning.UniformLearning.mul_card_bucketSearch_le_one {ι : Type u_1} [DecidableEq ι] [Fintype ι] (f : (ι → Bool) → Bool) {θ : ℝ} (est : Finset ι → Finset ι → ℝ) (l : List ι) (hW : ∀ (S : Finset ι), |est l.toFinset S - BitString.bucketWeight (fun (x : ι → Bool) => BitString.signVal (f x)) l.toFinset S| < θ ^ 2 / 4) :
      θ ^ 2 / 4 * ↑(bucketSearch est (θ ^ 2 / 2) l).card ≤ 1

      Few buckets survive: if the estimates at the level of the coordinates of l are within θ² / 4 of the bucket weights of a Boolean function, then the search over l with threshold θ² / 2 keeps at most 4 / θ² buckets.

      The algorithm #

      The Boolean functions whose spectral norm ∑_S |f̂(S)|, read as signs, is at most L.

      Instances For

        The functions computed by decision trees with at most L leaves.

        Instances For
          noncomputable def Cslib.MachineLearning.UniformLearning.bucketEstimate {ι : Type u_1} {m : ℕ} [DecidableEq ι] (g : (ι → Bool) → Bool) (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) (J S : Finset ι) :

          The empirical estimate of the bucket weight W^{S | J} of g, read as signs, from the samples ω j = (x, y, z): the average of g (x, z) χ_S(x) g (y, z) χ_S(y), where (x, z) takes the coordinates in J from x and the others from z.

          Instances For
            noncomputable def Cslib.MachineLearning.UniformLearning.sampleCoeff {ι : Type u_1} {m : ℕ} (g : (ι → Bool) → Bool) (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) (S : Finset ι) :

            The empirical Fourier coefficient of g on S from the first points of the samples.

            Instances For
              noncomputable def Cslib.MachineLearning.UniformLearning.kmCandidates {ι : Type u_1} {m : ℕ} [Fintype ι] [DecidableEq ι] (g : (ι → Bool) → Bool) (θ : ℝ) (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) :

              The sets found by the Kushilevitz–Mansour algorithm with threshold θ: the bucket search over all coordinates, keeping the buckets with estimated weight at least θ² / 2.

              Instances For
                noncomputable def Cslib.MachineLearning.UniformLearning.kmHypothesis {ι : Type u_1} {m : ℕ} [Fintype ι] [DecidableEq ι] (g : (ι → Bool) → Bool) (θ : ℝ) (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) :
                (ι → Bool) → Bool

                The hypothesis of the Kushilevitz–Mansour algorithm: the sign of the expansion on the found sets, with the empirical coefficients of the samples.

                Instances For
                  noncomputable def Cslib.MachineLearning.UniformLearning.kmQueries {ι : Type u_1} {m : ℕ} [Fintype ι] [DecidableEq ι] (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) :
                  List (ι → Bool)

                  The points queried by the Kushilevitz–Mansour algorithm: the first point x of each sample, and the points (x, z) and (y, z) of each sample (x, y, z) at every level J of the search.

                  Instances For
                    theorem Cslib.MachineLearning.UniformLearning.length_kmQueries {ι : Type u_1} {m : ℕ} [Fintype ι] [DecidableEq ι] (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) :
                    (kmQueries ω).length = m * (2 * Fintype.card ι + 3)

                    The algorithm queries m (2 n + 3) points for n coordinates.

                    theorem Cslib.MachineLearning.UniformLearning.kmHypothesis_congr {ι : Type u_1} {m : ℕ} [Fintype ι] [DecidableEq ι] (θ : ℝ) (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) {g g' : (ι → Bool) → Bool} (h : ∀ x ∈ kmQueries ω, g x = g' x) :
                    kmHypothesis g θ ω = kmHypothesis g' θ ω

                    The hypothesis depends only on the answers at the queried points.

                    noncomputable def Cslib.MachineLearning.UniformLearning.kmLearner (ι : Type u_1) (m : ℕ) [Fintype ι] [DecidableEq ι] (θ : ℝ) :
                    QueryLearner ι (Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool))

                    The Kushilevitz–Mansour algorithm with threshold θ from m samples: draw m independent samples of three uniform points, query the target at the points kmQueries, run the bucket search with threshold θ² / 2 on the estimated bucket weights, and output the sign of the expansion on the found sets with estimated coefficients. Its queries are non-adaptive.

                    Instances For
                      theorem Cslib.MachineLearning.UniformLearning.eval_kmLearner {ι : Type u_1} {m : ℕ} [Fintype ι] [DecidableEq ι] (θ : ℝ) (f : (ι → Bool) → Bool) (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) :
                      (kmLearner ι m θ ω).eval f = kmHypothesis f θ ω

                      Run on the target f, the algorithm outputs kmHypothesis f θ ω.

                      The Kushilevitz–Mansour algorithm makes m (2 n + 3) membership queries for n coordinates.

                      The analysis #

                      def Cslib.MachineLearning.UniformLearning.KMAccurate {ι : Type u_1} {m : ℕ} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) (γ : ℝ) (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) :

                      The samples ω are accurate for f at precision γ: every bucket estimate at every level of the search over all coordinates, and every sample coefficient, is within γ of its value.

                      Instances For
                        theorem Cslib.MachineLearning.UniformLearning.uniformError_kmHypothesis_le {ι : Type u_1} {m : ℕ} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) {L θ : ℝ} (hθ : 0 < θ) (hL : ∑ S : Finset ι, |BitString.fourierCoeff (fun (x : ι → Bool) => BitString.signVal (f x)) S| ≤ L) (ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool)) (hω : KMAccurate f (θ ^ 2 / 4) ω) :
                        uniformError f (kmHypothesis f θ ω) ≤ θ ^ 2 / 4 + θ * L

                        The Kushilevitz–Mansour algorithm on accurate samples. Let the spectral norm of f, read as signs, be at most L, and let θ > 0. If the samples are accurate at precision θ² / 4, then the hypothesis has error at most θ² / 4 + θ L.

                        theorem Cslib.MachineLearning.UniformLearning.uniform_not_accurate_le {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) (θ : ℝ) (m : ℕ) :
                        (Probability.PMF.uniformOfFintype (Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool))).toOuterMeasure {ω : Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool) | ¬KMAccurate f (θ ^ 2 / 4) ω} ≤ ENNReal.ofReal (2 * (↑(Fintype.card ι) + 2) * 2 ^ Fintype.card ι * Real.exp (-(↑m * θ ^ 4) / 32))

                        The samples are accurate with high probability: m samples fail to be accurate at precision θ² / 4 with probability at most 2 (n + 2) 2 ^ n exp (-m θ⁴ / 32) for n coordinates.

                        theorem Cslib.MachineLearning.UniformLearning.kmLearner_learns {ι : Type u_1} [Fintype ι] [DecidableEq ι] {L ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) {m : ℕ} (hm : 512 * L ^ 4 / ε ^ 4 * Real.log (2 * (↑(Fintype.card ι) + 2) * 2 ^ Fintype.card ι / δ) ≤ ↑m) :
                        (kmLearner ι m (ε / (2 * L))).Learns (Probability.PMF.uniformOfFintype (Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool))) (spectralNormClass ι L) ε δ

                        The Kushilevitz–Mansour theorem [KM93] O'Donnell, Theorem 3.38: for n coordinates, the Kushilevitz–Mansour algorithm with threshold ε / (2 L) from m ≥ (512 L⁴ / ε⁴) log (2 (n + 2) 2 ^ n / δ) samples, hence m (2 n + 3) membership queries (kmLearner_queriesAtMost), learns the Boolean functions whose spectral norm, read as signs, is at most L, with error ε and confidence 1 - δ.

                        theorem Cslib.MachineLearning.UniformLearning.kmLearner_learns_decisionTree {ι : Type u_1} [Fintype ι] [DecidableEq ι] {L : ℕ} {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) {m : ℕ} (hm : 512 * ↑L ^ 4 / ε ^ 4 * Real.log (2 * (↑(Fintype.card ι) + 2) * 2 ^ Fintype.card ι / δ) ≤ ↑m) :
                        (kmLearner ι m (ε / (2 * ↑L))).Learns (Probability.PMF.uniformOfFintype (Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool))) (decisionTreeClass ι L) ε δ

                        Learning decision trees with membership queries [KM93] O'Donnell, Theorem 3.38: for n coordinates, the Kushilevitz–Mansour algorithm with threshold ε / (2 L) from m ≥ (512 L⁴ / ε⁴) log (2 (n + 2) 2 ^ n / δ) samples, hence m (2 n + 3) membership queries, learns the functions computed by decision trees with at most L leaves, with error ε and confidence 1 - δ.

                        theorem Cslib.MachineLearning.UniformLearning.kmLearner_learns_and_queriesAtMost {ι : Type u_1} [Fintype ι] [DecidableEq ι] {L ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) {m : ℕ} (hm : 512 * L ^ 4 / ε ^ 4 * Real.log (2 * (↑(Fintype.card ι) + 2) * 2 ^ Fintype.card ι / δ) ≤ ↑m) :
                        (kmLearner ι m (ε / (2 * L))).Learns (Probability.PMF.uniformOfFintype (Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool))) (spectralNormClass ι L) ε δ ∧ (kmLearner ι m (ε / (2 * L))).QueriesAtMost (m * (2 * Fintype.card ι + 3))

                        The Kushilevitz–Mansour theorem with its query count: under the hypotheses of kmLearner_learns, the algorithm learns the functions of spectral norm at most L with m (2 n + 3) membership queries for n coordinates.

                        theorem Cslib.MachineLearning.UniformLearning.kmLearner_learns_decisionTree_and_queriesAtMost {ι : Type u_1} [Fintype ι] [DecidableEq ι] {L : ℕ} {ε δ : ℝ} (hε : 0 < ε) (hδ : 0 < δ) {m : ℕ} (hm : 512 * ↑L ^ 4 / ε ^ 4 * Real.log (2 * (↑(Fintype.card ι) + 2) * 2 ^ Fintype.card ι / δ) ≤ ↑m) :
                        (kmLearner ι m (ε / (2 * ↑L))).Learns (Probability.PMF.uniformOfFintype (Fin m → (ι → Bool) × (ι → Bool) × (ι → Bool))) (decisionTreeClass ι L) ε δ ∧ (kmLearner ι m (ε / (2 * ↑L))).QueriesAtMost (m * (2 * Fintype.card ι + 3))

                        Learning decision trees with membership queries, with the query count: under the hypotheses of kmLearner_learns_decisionTree, the algorithm learns the functions computed by decision trees with at most L leaves with m (2 n + 3) membership queries for n coordinates.