Compfiles/KolmogorovStreams.lean

GitHub source file

Explanation legend Lean4 Domain Explanation Language (L4DEL)

L4DEL explanations are a separate layer. They do not change the Lean source. Intuition is explanatory prose; numbered items are a reading path; sources link the wording back to evidence.

L4DEL
Lean4 Domain Explanation Language

Credit: The upstream authors and contributors retain credit for the project and mathematics. lean4-explainer only renders their pinned source and adds the separately disclosed explanation layer.

Project sources: Pinned compfiles documentation, Pinned compfiles corpus index

9 declarations, 0 contain sorry, 0 declared as axioms

Puzzle referenced from this tweet: https://twitter.com/sigfpe/status/1474173467016589323

From the book Out of their Minds: The Lives and Discoveries of 15 Great Computer Scientists by Dennis Shasha and Cathy Lazere.

Problem: Suppose each (finite) word is either "decent" or "indecent". Given an infinite sequence of characters, can you always break it into finite words so that all of them except perhaps the first one belong to the same class?

Imports (4)
Imported by 1 file
  1. def KolmogorovStreams.break_into_words line 38 source

    no axioms what this means

    Statement uses: Stream', Nat, List

    Proof uses: Function.curry, Stream'.corec, Prod, KolmogorovStreams.break_into_words.match_1, Stream'.take, Stream'.head, Prod.mk, Stream'.tail, Stream'.drop

  2. lemma KolmogorovStreams.break_into_words_cons Dropping the first word is equivalent to dropping first_length symbols of the original stream line 52 source

    Source documentation

    Dropping the first word is equivalent to dropping first_length symbols of the original stream.

    standard axioms: Quot.sound, propext what this means

    Statement uses: Stream', Nat, Eq, List, Stream'.tail, KolmogorovStreams.break_into_words, Stream'.cons, Stream'.drop

    Proof uses: of_eq_true, Stream'.map, Prod, Stream'.take, Stream'.head, Prod.fst, Prod.snd, Stream'.iterate, Prod.mk, Eq.trans, True, congrFun', congrArg, Stream'.tail_iterate, eq_self

    Tactic trace: 1 steps

    Open to load the checked before-and-after goal states.

    lemma break_into_words_cons
        (lengths : Stream' ℕ)
        (first_length : ℕ)
        (a : Stream' α) :
        (break_into_words (first_length::lengths) a).tail =
               break_into_words lengths (a.drop first_length) := by
    …

    Mentions: KolmogorovStreams.break_into_words

  3. lemma KolmogorovStreams.break_into_words_closed_form line 60 source

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: Stream', Nat, Eq, List, KolmogorovStreams.break_into_words, Stream'.take, Stream'.drop, Finset.sum, Finset.range

    Proof uses: funext, Nat.recAux, Eq.refl, OfNat.ofNat, Stream'.tail, Stream'.head, Eq.mpr, Stream'.cons, id, Eq.rec, Eq.trans, congrArg, Eq.symm, Stream'.eta, KolmogorovStreams.break_into_words_cons, Trans.trans, HAdd.hAdd, congrFun, congr, Stream'.drop_drop and 3 more

    10 instances, coercions and auxiliary constants left out.

    Tactic trace: 10 steps

    Open to load the checked before-and-after goal states.

  4. def KolmogorovStreams.all_prefixes line 80 source

    no axioms what this means

    Statement uses: List, Stream'

    Proof uses: Stream'.All, Stream'.inits

  5. lemma KolmogorovStreams.take_prefix line 82 source

    standard axioms: Quot.sound what this means

    Statement uses: List, Stream', KolmogorovStreams.all_prefixes, Nat, LT.lt, OfNat.ofNat, Stream'.take

    Proof uses: Nat.casesAuxOn, Eq, absurd, lt_irrefl, Eq.symm, HAdd.hAdd, Eq.mp, Stream'.get, Stream'.inits, congrArg, Stream'.get_inits, Eq.refl

    8 instances, coercions and auxiliary constants left out.

    Tactic trace: 3 steps

    Open to load the checked before-and-after goal states.

  6. lemma KolmogorovStreams.not_all_prefixes line 92 source

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: List, Stream', Not, KolmogorovStreams.all_prefixes, Exists, Nat, Stream'.take, Nat.succ

    Proof uses: id, Eq.mp, HAdd.hAdd, OfNat.ofNat, Eq.trans, congrArg, forall_congr, Stream'.get, Stream'.inits, Stream'.get_inits

    4 instances, coercions and auxiliary constants left out.

    Tactic trace: 1 steps

    Open to load the checked before-and-after goal states.

  7. lemma KolmogorovStreams.exists_break_into_words Documented declaration: exists_break_into_words line 104 source

    Source documentation

    If from every "good" position of the stream we can carve off a nonempty word satisfying q, landing at another good position, then the stream can be broken into words that all satisfy q.

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: List, Nat, Stream', OfNat.ofNat, Exists, And, LT.lt, HAdd.hAdd, Stream'.take, Stream'.drop, Stream'.All, KolmogorovStreams.break_into_words

    Proof uses: Subtype, Nat.rec, Subtype.mk, Subtype.property, And.left, And.right, Eq, Finset.sum, Finset.range, Nat.recAux, Eq.refl, Eq.mpr, id, congrArg, Finset.sum_range_succ, Eq.symm, KolmogorovStreams.break_into_words_closed_form, Stream'.get, Exists.intro, And.intro and 2 more

    14 instances, coercions and auxiliary constants left out.

    Tactic trace: 15 steps

    Open to load the checked before-and-after goal states.

    lemma exists_break_into_words
        (q : List α → Prop)
        (good : ℕ → Prop)
        (a : Stream' α)
        (h0 : good 0)
        (h : ∀ n, good n → ∃ k, 0 < k ∧ good (n + k) ∧ q ((a.drop n).take k)) :
        ∃ lengths : Stream' ℕ,
          lengths.All (0 < ·) ∧ (break_into_words lengths a).All q := by
    …

    Mentions: h, KolmogorovStreams.break_into_words

  8. def KolmogorovStreams.all_same_class line 132 source

    no axioms what this means

    Statement uses: List, Stream'

    Proof uses: Or, Stream'.All, Not

  9. problem KolmogorovStreams.kolmogorov_streams line 138 source

    standard axioms: Classical.choice, Quot.sound, propext what this means

    Statement uses: List, Stream', Exists, Nat, And, Stream'.All, LT.lt, OfNat.ofNat, KolmogorovStreams.all_same_class, Stream'.tail, KolmogorovStreams.break_into_words

    Proof uses: Not, KolmogorovStreams.all_prefixes, Stream'.drop, HAdd.hAdd, Or, Classical.em, True, Stream'.take, Eq.mpr, id, Eq, congrArg, Stream'.drop_drop, Nat.succ_pos, Nat.succ, KolmogorovStreams.not_all_prefixes, Exists.intro, And.intro, trivial, KolmogorovStreams.exists_break_into_words and 18 more

    17 instances, coercions and auxiliary constants left out.

    Tactic trace: 41 steps

    Open to load the checked before-and-after goal states.