Compfiles/KolmogorovStreams.lean
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?
Imported by 1 file
- def
KolmogorovStreams.break_into_wordsline 38 sourceno axioms what this means
Statement uses:
Stream',Nat,ListProof uses:
Function.curry,Stream'.corec,Prod,KolmogorovStreams.break_into_words.match_1,Stream'.take,Stream'.head,Prod.mk,Stream'.tail,Stream'.drop - lemma
KolmogorovStreams.break_into_words_consDropping the first word is equivalent to droppingfirst_lengthsymbols of the original stream line 52 sourceSource documentation
Dropping the first word is equivalent to dropping
first_lengthsymbols 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'.dropProof 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_selfTactic 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
- lemma
KolmogorovStreams.break_into_words_closed_formline 60 sourcestandard 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.rangeProof 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_dropand 3 more10 instances, coercions and auxiliary constants left out.
Tactic trace: 10 steps
Open to load the checked before-and-after goal states.
- def
KolmogorovStreams.all_prefixesline 80 sourceno axioms what this means
Statement uses:
List,Stream'Proof uses:
Stream'.All,Stream'.inits - lemma
KolmogorovStreams.take_prefixline 82 sourcestandard axioms: Quot.sound what this means
Statement uses:
List,Stream', KolmogorovStreams.all_prefixes,Nat,LT.lt,OfNat.ofNat,Stream'.takeProof uses:
Nat.casesAuxOn,Eq,absurd,lt_irrefl,Eq.symm,HAdd.hAdd,Eq.mp,Stream'.get,Stream'.inits,congrArg,Stream'.get_inits,Eq.refl8 instances, coercions and auxiliary constants left out.
Tactic trace: 3 steps
Open to load the checked before-and-after goal states.
- lemma
KolmogorovStreams.not_all_prefixesline 92 sourcestandard axioms: Classical.choice, Quot.sound, propext what this means
Statement uses:
List,Stream',Not, KolmogorovStreams.all_prefixes,Exists,Nat,Stream'.take,Nat.succProof uses:
id,Eq.mp,HAdd.hAdd,OfNat.ofNat,Eq.trans,congrArg,forall_congr,Stream'.get,Stream'.inits,Stream'.get_inits4 instances, coercions and auxiliary constants left out.
Tactic trace: 1 steps
Open to load the checked before-and-after goal states.
- lemma
KolmogorovStreams.exists_break_into_wordsDocumented declaration: exists_break_into_words line 104 sourceSource 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 satisfyq.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_wordsProof 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.introand 2 more14 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
- def
KolmogorovStreams.all_same_classline 132 sourceno axioms what this means
Statement uses:
List,Stream'Proof uses:
Or,Stream'.All,Not - problem
KolmogorovStreams.kolmogorov_streamsline 138 sourcestandard 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_wordsProof 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 more17 instances, coercions and auxiliary constants left out.
Tactic trace: 41 steps
Open to load the checked before-and-after goal states.