1 00:00:01,000 --> 00:00:09,300 [Hal Turing] Alrighty! Thanks for tuning in! Hello AI world! I am your host, Hal Turing, and my co-host is Dr. Ada Shannon. 2 00:00:09,300 --> 00:00:37,549 [Hal Turing] Today's paper is A Formal Proof of PAC Learnability for Decision Stumps, from Joseph Tassarotti of Boston College and colleagues at the University of Pittsburgh and the IMDEA Software Institute. It appeared at CPP, the Certified Programs and Proofs conference, in 2021. The question: can a classic textbook learning-theory result be proved fully formally in the Lean theorem prover, with the measure theory done properly? And what does the machine-checked proof actually tell us? 3 00:00:37,549 --> 00:00:52,949 [Dr. Ada Shannon] The punchline is that the textbook proofs of this result hide a subtle error. A step that everyone waves through turns out not to hold as stated. A computer that refuses to skip steps caught it. We'll get to why, but first we need the setting. 4 00:00:52,949 --> 00:00:56,774 [Hal Turing] Then start with the setting. What's a decision stump? 5 00:00:56,774 --> 00:01:16,974 [Dr. Ada Shannon] Take a blood-protein level, a nonnegative real number. Somewhere there's a hidden threshold t. Patients at or below it have the disease, and patients above it don't. A decision stump is a classifier with exactly one cutoff. It labels a point 1 if x is at most the threshold, and 0 otherwise. It's a decision tree with a single split. 6 00:01:16,974 --> 00:01:21,974 [Hal Turing] And learning means finding that threshold from labeled patients. 7 00:01:21,974 --> 00:01:41,299 [Dr. Ada Shannon] Yes. The learner in the paper is simple. Look at the training points labeled 1 and put your threshold at the largest one. If none are labeled 1, use zero. This learner never overshoots the true threshold, because a point labeled 1 is always at or below t. It can only make one kind of mistake: calling a true 1 a 0, on points that fall between your threshold and the real one. 8 00:01:41,299 --> 00:01:44,599 [Hal Turing] So how do we measure how bad that is? 9 00:01:44,599 --> 00:02:00,599 [Dr. Ada Shannon] By the error of a hypothesis. Draw a fresh test point from the same distribution, which I'll call μ, and ask how likely it is to be mislabeled. For a fixed threshold, that's just a number. The training samples and the test point are separate random draws. 10 00:02:00,599 --> 00:02:03,924 [Hal Turing] Now PAC. Probably approximately correct. 11 00:02:03,924 --> 00:02:32,324 [Dr. Ada Shannon] That's Valiant, 1984, in A Theory of the Learnable. A class is PAC learnable if an algorithm, given enough samples, returns a hypothesis with error at most ε, with probability at least 1 minus δ. ε is how approximate you tolerate. δ is how often you tolerate being unlucky. It has to work for every distribution μ and every labeling that some stump in the class gets exactly right. That's the realizable setting: no label noise, and the true threshold really is in the class. 12 00:02:32,324 --> 00:02:34,774 [Hal Turing] What does the theorem promise? 13 00:02:34,774 --> 00:02:55,074 [Dr. Ada Shannon] Theorem 2.1. For ε and δ between zero and one, n at least ln δ over ln(1−ε), minus one, samples give error at most ε with probability at least 1−δ. Lean states it with n plus one samples, so the failure probability is at most (1−ε) to the n plus one, which is at most δ. 14 00:02:55,074 --> 00:02:59,674 [Hal Turing] Why does a one-dimensional threshold deserve a whole paper? 15 00:02:59,674 --> 00:03:20,524 [Dr. Ada Shannon] It's the one-dimensional cousin of the axis-aligned rectangle example that opens Kearns and Vazirani, Shalev-Shwartz and Ben-David, and Mohri and coauthors. It's the standard first PAC proof. Stumps also have infinitely many hypotheses on continuous data, so you can't hide behind finite counting. Practically, stumps are the weak learners inside boosting, like AdaBoost. 16 00:03:20,524 --> 00:03:24,124 [Hal Turing] So where does the formalization trouble come from? 17 00:03:24,124 --> 00:03:49,999 [Dr. Ada Shannon] Probability on the reals. Most formal-methods work uses discrete probability, where every set gets a probability. On an uncountable space like the reals, you can't assign probabilities to every subset consistently. You pick a family of measurable sets, called a sigma-algebra. A function is measurable if the preimage of every measurable set is measurable. For the statement to mean anything, the sample, the learner, and the error function all have to be measurable. On paper, textbooks skip that. A prover can't. 18 00:03:49,999 --> 00:03:53,324 [Hal Turing] What's the Giry monad doing in here? 19 00:03:53,324 --> 00:04:16,349 [Dr. Ada Shannon] It's a way to write 'sample from a distribution, then continue' as ordinary functional code, with bind, return and map. The paper uses it to define the distribution over training samples and the distribution over learned thresholds, so the formal statement stays close to the pencil-and-paper one. Lean is an interactive theorem prover, so a small kernel checks every step. Mathlib is its community library, which supplies the measure theory. The paper uses Lean 3 syntax. 20 00:04:16,349 --> 00:04:19,324 [Hal Turing] Who else has formalized ML? 21 00:04:19,324 --> 00:05:00,000 [Dr. Ada Shannon] Selsam, Liang and Dill, 2017, Developing Bug-Free Machine Learning Systems With Formal Mathematics, at ICML. That's Certigrad. They proved in Lean that stochastic backpropagation gives unbiased gradients. That's about training code, not generalization, and they added axioms for some basic math facts. Then Bagnall and Stewart, 2019, Certifying the True Error, at AAAI. They verified Hoeffding-based generalization bounds in Coq, but for discrete distributions and finite hypothesis classes, and applied them to quantized ReLU networks. They aren't the only prior work touching neural networks, though. Bentkamp and coauthors did Isabelle work on the expressiveness of deep arithmetic circuits. 22 00:05:00,000 --> 00:05:03,175 [Hal Turing] And the general theory they didn't touch? 23 00:05:03,175 --> 00:05:22,550 [Dr. Ada Shannon] Blumer, Ehrenfeucht, Haussler and Warmuth, 1989, Learnability and the Vapnik-Chervonenkis Dimension, in the Journal of the ACM. VC theory is the general reason stumps are learnable. This paper deliberately doesn't formalize it. It proves the one concrete case, and that's where the textbook trouble shows up. 24 00:05:22,550 --> 00:05:28,875 [Hal Turing] Okay, so the proof itself. Walk me through it in the order the argument actually runs. 25 00:05:28,875 --> 00:05:47,875 [Dr. Ada Shannon] It starts with a fact about the learner. The learner never overshoots the true threshold, because every positive training point sits at or below t. So the only mistake it can make is calling a true 1 a 0. That happens only on points strictly above the learned threshold and at or below t. Call that sliver the danger zone. 26 00:05:47,875 --> 00:05:53,425 [Hal Turing] So everything depends on how much probability the danger zone holds. 27 00:05:53,425 --> 00:06:10,350 [Dr. Ada Shannon] Right, and the proof splits on that. Case one: the whole region from zero to t holds at most epsilon of the mass. Then the danger zone sits inside it, and the error is at most epsilon no matter what the samples are. Done, with no probability over samples needed. 28 00:06:10,350 --> 00:06:13,950 [Hal Turing] And case two is where positives are common. 29 00:06:13,950 --> 00:06:47,975 [Dr. Ada Shannon] Yes. Then you pick an interval I that ends at t and holds epsilon of the mass. If even one training point lands in I, the learned threshold is inside I. That squeezes the danger zone into I, so the error is at most epsilon. The only bad outcome is that every sample misses I. Each sample misses with probability at most one minus epsilon, and the samples are independent. In the Lean version there are n plus one of them, so all of them miss with probability at most one minus epsilon, to the n plus one. Pick n so that this is at most delta, and you have the sample bound. 30 00:06:47,975 --> 00:06:52,150 [Hal Turing] So where does the textbook go wrong? It all sounds fine. 31 00:06:52,150 --> 00:07:17,500 [Dr. Ada Shannon] It goes wrong in the phrase "an interval with mass exactly epsilon." Kearns and Vazirani say to slide the left edge until the interval holds exactly epsilon. Shalev-Shwartz and Ben-David say the same. Sliding works only if the probability changes smoothly as the edge moves. Take a coin that lands on zero or one with equal chance, with t at one half and epsilon at one quarter. An interval from a to t holds half the mass if a is zero or below, and nothing otherwise. No interval holds a quarter. 32 00:07:17,500 --> 00:07:21,900 [Hal Turing] Because the mass jumps at an atom. So what replaces it? 33 00:07:21,900 --> 00:07:50,250 [Dr. Ada Shannon] Define theta as the supremum of all points d where the interval from d to t holds at least epsilon. That gives two facts. The closed interval from theta to t holds at least epsilon, so a sample is likely to land in it. The half-open interval just past theta holds at most epsilon, so the danger zone is small enough. In the coin example, theta is zero, and the atom there carries the jump. For a continuous distribution the two facts squeeze to exactly epsilon, which recovers the textbook picture. 34 00:07:50,250 --> 00:07:52,825 [Hal Turing] How was that proved formally? 35 00:07:52,825 --> 00:08:36,450 [Dr. Ada Shannon] By continuity of measures. Take points approaching theta from below, each with interval mass at least epsilon. Their intervals are nested, and they intersect in the closed interval from theta to t. Continuity from above says the limit of the masses is the mass of the intersection, so that mass is at least epsilon. The other inequality is the mirror argument using continuity from below. The authors say this was the hardest part to formalize. The paper credits Blumer and colleagues with the correct theta, and says Mohri and colleagues call these properties "not hard to see." Neither supplies the proof. The paper also notes that an errata for the first printing of Mohri documents the problem in Kearns and Vazirani. The authors say the textbooks either give an incorrect proof or omit this step, and they don't oversell it, since the textbooks later re-prove the result from general theorems. 36 00:08:36,450 --> 00:08:40,000 [Hal Turing] Now the Lean side. How is it organized? 37 00:08:40,000 --> 00:09:02,049 [Dr. Ada Shannon] Four concerns, kept apart. First, the Giry monad pipeline. The distribution over learned thresholds is the vector of sampled points mapped through the labeler, then through the learner, written with map from the monad. Second, deterministic facts about the learner. There are two: the returned threshold is at most the target, and it is at least every positively labeled training point. Both proofs are short, and those two facts are all the error bound uses. 38 00:09:02,049 --> 00:09:06,125 [Hal Turing] And the third is the measurability work you flagged. 39 00:09:06,125 --> 00:09:26,174 [Dr. Ada Shannon] About a quarter of the formalization. The fourth is the quantitative part: the always-succeed lemma for case one, the theta lemma, a miss-probability lemma, a lemma saying a bad error forces every sample to miss, and a lemma that the sample count makes one minus epsilon to the n plus one at most delta. These combine into the final theorem, choose_PAC. 40 00:09:26,174 --> 00:09:29,500 [Hal Turing] What did formalizing force them to change? 41 00:09:29,500 --> 00:09:49,950 [Dr. Ada Shannon] Several things. The learner returns a threshold, not a function. There is no canonical sigma-algebra on function spaces, because measurable spaces aren't Cartesian closed. But a stump is determined by its threshold, and thresholds have the Borel sigma-algebra. Lists became fixed-length vectors, and the domain is the nonnegative reals. 42 00:09:49,950 --> 00:09:53,075 [Hal Turing] Any snags in the measurability? 43 00:09:53,075 --> 00:10:12,325 [Dr. Ada Shannon] Two stand out. A vector can carry either the Borel or the product sigma-algebra, and Lean has to pick one automatically. They coincide because the nonnegative reals have a countable basis. And proving the error function measurable needed a lemma that monotone functions are measurable, which mathlib didn't have yet. 44 00:10:12,325 --> 00:10:14,900 [Hal Turing] Last one. What are the results? 45 00:10:14,900 --> 00:10:34,125 [Dr. Ada Shannon] There are no benchmarks or experiments. The result is the checked theorem: with n greater than log delta over log of one minus epsilon, minus one, the failure probability is at most delta. The sample count is indexed so the vector holds n plus one points, and that's how the Lean statement lines up with the paper's bound. 46 00:10:34,125 --> 00:10:45,200 [Hal Turing] So the result is one checked theorem. How far does it reach? It formalizes one learner, the largest-positive-example rule. Does it cover any other stump learner? 47 00:10:45,200 --> 00:11:05,325 [Dr. Ada Shannon] Possibly, and that's the strongest reuse claim in the paper. The bound only uses the two deterministic properties. The threshold is at most the target, and at least every positively labeled training point. The authors say those are the only facts about the learner the proof relies on. So any stump learner with those two properties gets the same theorem. 48 00:11:05,325 --> 00:11:07,950 [Hal Turing] That sounds fairly general. 49 00:11:07,950 --> 00:11:26,600 [Dr. Ada Shannon] The properties are very strong, though. They pin the threshold between the largest positive sample and the target. That's only possible when labels are noise-free. One flipped label and a learner can't satisfy both. So nothing here covers a noise-tolerant learner. Agnostic PAC learning is left as future work. 50 00:11:26,600 --> 00:11:34,550 [Hal Turing] What about the stumps people actually use, like the ones picked by an impurity criterion or boosted in an ensemble? 51 00:11:34,550 --> 00:11:54,550 [Dr. Ada Shannon] Those choose a threshold that trades off misclassified points, so they violate the second property by design. The paper doesn't discuss empirical risk minimization or boosting. That's our reading, not theirs. But I think it's the right reading, and it means the motivating story about medical diagnosis and fraud detection doesn't connect to what's proved. 52 00:11:54,550 --> 00:12:01,650 [Hal Turing] Then the other gap. The intro promises to close the distance between theory and implementation. 53 00:12:01,650 --> 00:12:21,400 [Dr. Ada Shannon] The paper doesn't deliver that. Footnote 1 admits the algorithm uses non-computable real operations. The learner is a pure function on nonnegative reals. The theorem says nothing about floating-point rounding, sorting, ties, or extracted code. The paper gives no plan for closing the gap, so what follows is our sketch. 54 00:12:21,400 --> 00:12:23,575 [Hal Turing] What would the sketch need? 55 00:12:23,575 --> 00:12:44,200 [Dr. Ada Shannon] A float64 model of thresholds and samples. Then either a proof that rounding preserves the two deterministic properties, or an explicit error term in the bound. Then code extraction or a verified compiler. Taking a maximum over floats might preserve the second property in a simple setting. That's an observation, not a claim from the paper, and nobody has checked it here. 56 00:12:44,200 --> 00:12:52,375 [Hal Turing] Now the motivating claim. Three textbooks give a wrong proof or skip a step. Is that a real finding or a nitpick? 57 00:12:52,375 --> 00:13:13,850 [Dr. Ada Shannon] Real but minor, and the authors say so. The proofs can be fixed, and the results are re-proven correctly from general theorems later. Blumer and colleagues already had the right supremum-based definition. So "formalization caught an error" is fair only in a narrow sense. It forced the missing step into the open, and the Bernoulli example shows the textbook step really fails for atomic distributions. 58 00:13:13,850 --> 00:13:17,725 [Hal Turing] And the proof route? You said it's the elementary one. 59 00:13:17,725 --> 00:13:37,825 [Dr. Ada Shannon] Yes. The general route through the VC dimension, using symmetrization and uniform convergence, avoids the exact-mass interval altogether. The authors chose the route that's easiest to mechanize. That's reasonable for a case study. But it means the proof shows feasibility, not that this architecture is how you'd prove the general theory. 60 00:13:37,825 --> 00:13:50,850 [Hal Turing] The paper claims the structure carries over to other PAC proofs. Specify randomness with the Giry monad, prove the deterministic properties, prove measurability, then bound probabilities. 61 00:13:50,850 --> 00:14:13,400 [Dr. Ada Shannon] Only one example supports that. And it avoids the hardest design problem by returning a threshold instead of a classifier, since function spaces have no canonical sigma-algebra. Rectangles or halfspaces would need the measurability conditions Blumer and Dudley discuss. Adaptive learners like boosting or SGD would stress the monadic setup further. The template is plausible. The evidence is one-dimensional. 62 00:14:13,400 --> 00:14:19,025 [Hal Turing] What about cost? The paper says measurability was about a quarter of the work. 63 00:14:19,025 --> 00:14:35,700 [Dr. Ada Shannon] That's all it gives. No line counts, no person-months, no comparison with the one-page pencil proof. For a paper arguing that formalization is feasible, that's the missing number. Without it you can't tell whether a VC theorem or a PAC-Bayes bound is practical. 64 00:14:35,700 --> 00:14:45,300 [Hal Turing] Is the statement uniform in the right way? The sample size should depend only on epsilon and delta, not on the distribution or the target. 65 00:14:45,300 --> 00:15:07,475 [Dr. Ada Shannon] That's what the definition requires, and the bound as stated depends only on epsilon and delta. But I'd want to read the Lean signature of choose_PAC to confirm where the quantifiers sit. The summary I have doesn't settle it. Same for the trusted base. The paper presents the work as built on mathlib without added axioms, unlike Certigrad or Bagnall and Stewart. But it doesn't say whether it uses classical choice, which would block extracting a computable learner. 66 00:15:07,475 --> 00:15:10,225 [Hal Turing] Where does it sit against those two? 67 00:15:10,225 --> 00:15:32,950 [Dr. Ada Shannon] Certigrad proves that training gradients are unbiased, so it targets code-level training correctness, not generalization. Bagnall and Stewart prove generalization bounds in Coq via Hoeffding, but for discrete distributions and finite classes. This paper handles arbitrary distributions and an infinite class. Zinkevich's formal-ml library, also in Lean, covers finite hypothesis classes, so stumps fall outside it. 68 00:15:32,950 --> 00:15:35,100 [Hal Turing] And the code today? 69 00:15:35,100 --> 00:15:54,725 [Dr. Ada Shannon] It's Lean 3 against a 2020 mathlib. Lean 3 has since been replaced by Lean 4 and a ported mathlib. The paper doesn't discuss porting, and I can't tell from this whether its missing-lemma additions, like monotone functions being measurable, went upstream. That decides whether the library gap it found actually closed. 70 00:15:54,725 --> 00:15:57,425 [Hal Turing] So what should someone take from it? 71 00:15:57,425 --> 00:16:12,375 [Dr. Ada Shannon] It's a proof of feasibility and a template, not a verified ML tool. Next steps the authors name are VC theory, agnostic learning, multiclass, other error functions. The open question is the distance to running code. 72 00:16:12,375 --> 00:16:31,100 [Hal Turing] Then I'd put it this way. The work establishes a fully machine-checked sample-complexity theorem for realizable stump learning, with a corrected treatment of a subtle step. Its boundary is one noise-free learner, an idealized real-valued model, and no link to executable code. 73 00:16:31,100 --> 00:16:33,425 [Dr. Ada Shannon] That's right. Thanks for listening. 74 00:16:33,425 --> 00:16:35,975 [Hal Turing] Thanks, everyone. Goodbye.