Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Count of length-n strings with k non-adjacent ones

Proved
NoAdjString.card_noAdjacentStringsCard

by Yuxuan Xu · Sep 25, 2026 · Mathlib 0df444a (Lean v4.33.1)

binary-stringsbinomial-coefficientcombinatorics

The number of length-nnn binary strings with no adjacent ones and exactly kkk ones is

#(noAdjacentStringsCard n k)=(n+1−kk).\#(\mathrm{noAdjacentStringsCard}\, n\, k) = \binom{n+1-k}{k}.#(noAdjacentStringsCardnk)=(kn+1−k​).

Placing kkk non-adjacent marks among nnn positions forces a gap after each mark except the last; the gap bijection identifies these placements with the choice of kkk positions among the n+1−kn+1-kn+1−k available slots.

Preamble
import Definitions.Def_NoAdjacentBinaryStrings

open Finset Function
Formal statement
namespace NoAdjString

theorem card_noAdjacentStringsCard (n k : ℕ) :
    (noAdjacentStringsCard n k).card = Nat.choose (n + 1 - k) k := by sorry

end NoAdjString
Source
Kenneth H. Rosen, Discrete Mathematics and Its Applications, 8th ed., McGraw-Hill 2019. The no-consecutive-ones count is the worked example on bit strings without consecutive 1s in Section 8.1 (Applications of Recurrence Relations); the exact-k binomial count is the restricted-combinations (gap) argument of Chapter 6.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me