Skip to content

Commit 6be5d16

Browse files
authored
feat: prove the distributivity of forall over OmegaSequence.flatten (#532)
Prove a small result that is useful in a separate work.
1 parent 6d112db commit 6be5d16

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Cslib/Foundations/Data/OmegaSequence/Flatten.lean

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ theorem flatten_drop [Inhabited α]
150150
(flatten_take_drop h_ls n).2
151151

152152
/-- `ls n` is the segement from position `ls.cumLen n` to position `ls.cumLen (n + 1) - 1`
153-
of ls.flatten` -/
153+
of `ls.flatten` -/
154154
@[simp, scoped grind =]
155155
theorem extract_flatten [Inhabited α] {ls : ωSequence (List α)} (h_ls : ∀ k, (ls k).length > 0)
156156
(n : ℕ) : ls.flatten.extract (ls.cumLen n) (ls.cumLen (n + 1)) = ls n := by
@@ -159,6 +159,15 @@ theorem extract_flatten [Inhabited α] {ls : ωSequence (List α)} (h_ls : ∀ k
159159
have h_take := flatten_take h_ls' 1
160160
grind [extract_eq_drop_take]
161161

162+
/-- Distributivity of "forall" over `flatten`. -/
163+
theorem forall_flatten_iff [Inhabited α] {ls : ωSequence (List α)} (h_ls : ∀ k, (ls k).length > 0)
164+
(p : α → Prop) : (∀ n, p (ls.flatten n)) ↔ ∀ k, (ls k).Forall p := by
165+
constructor
166+
· simp only [List.forall_iff_forall_mem, List.forall_mem_iff_getElem, ← extract_flatten h_ls]
167+
grind
168+
· have := segment_upper_bound (cumLen_strictMono h_ls)
169+
grind [List.forall_iff_forall_mem, flatten_def]
170+
162171
/-- Given an ω-sequence `s` and a function `f : ℕ → ℕ`, `s.toSegs f` is the ω-sequence
163172
whose `n`-th element is the list `s.extract (f n) (f (n + 1))`. In all its uses, the
164173
function `f` will always be assumed to be strictly monotonic with `f 0 = 0`. -/

0 commit comments

Comments
 (0)