Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit a7e36e4

Browse files
arienmaleckim-em
andcommitted
refactor(data/seq): scope seq and wseq to namespace stream (#18284)
Adds namespace `stream` to `seq` and `wseq` to ease the Mathlib4 port (as `Seq` now name clashes with class `Seq` (`has_seq` in Lean 3). This requires disambiguation between `stream` and `computation` where lemmas in each namespace have the same name, and requires explicit scoping to mathlib files that reference `seq` and `wseq` (often by `open stream.seq as seq`) Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
1 parent 9512706 commit a7e36e4

12 files changed

Lines changed: 80 additions & 55 deletions

File tree

docs/overview.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ General algebra:
138138
perfection of a ring: 'ring.perfection'
139139
Transcendental numbers:
140140
Liouville's theorem on existence of transcendental numbers: liouville.is_transcendental
141-
141+
142142
Representation theory:
143143
representation : 'representation'
144144
category of finite dimensional representations : 'fdRep'
@@ -445,8 +445,8 @@ Data structures:
445445
difference list: 'dlist'
446446
lazy list: 'lazy_list'
447447
stream: 'stream'
448-
sequence: 'seq'
449-
weak sequence: 'wseq'
448+
sequence: 'stream.seq'
449+
weak sequence: 'stream.wseq'
450450

451451
Sets:
452452
set: 'set'

src/algebra/continued_fractions/basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ variable (α : Type*)
4747
protected structure generalized_continued_fraction.pair := (a : α) (b : α)
4848

4949
open generalized_continued_fraction
50+
open stream.seq as seq
5051

5152
/-! Interlude: define some expected coercions and instances. -/
5253
namespace generalized_continued_fraction.pair

src/algebra/continued_fractions/computation/approximations.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ theorem of_denom_mono : (of v).denominators n ≤ (of v).denominators (n + 1) :=
296296
begin
297297
let g := of v,
298298
cases (decidable.em $ g.partial_denominators.terminated_at n) with terminated not_terminated,
299-
{ have : g.partial_denominators.nth n = none, by rwa seq.terminated_at at terminated,
299+
{ have : g.partial_denominators.nth n = none, by rwa stream.seq.terminated_at at terminated,
300300
have : g.terminated_at n, from
301-
terminated_at_iff_part_denom_none.elim_right (by rwa seq.terminated_at at terminated),
301+
terminated_at_iff_part_denom_none.elim_right (by rwa stream.seq.terminated_at at terminated),
302302
have : g.denominators (n + 1) = g.denominators n, from
303303
denominators_stable_of_terminated n.le_succ this,
304304
rw this },

src/algebra/continued_fractions/computation/basic.lean

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ protected def stream (v : K) : stream $ option (int_fract_pair K)
131131
| (n + 1) := (stream n).bind $ λ ap_n,
132132
if ap_n.fr = 0 then none else some (int_fract_pair.of ap_n.fr⁻¹)
133133

134+
134135
/--
135136
Shows that `int_fract_pair.stream` has the sequence property, that is once we return `none` at
136137
position `n`, we also return `none` at `n + 1`.
@@ -147,10 +148,11 @@ This is just an intermediate representation and users should not (need to) direc
147148
it. The setup of rewriting/simplification lemmas that make the definitions easy to use is done in
148149
`algebra.continued_fractions.computation.translations`.
149150
-/
150-
protected def seq1 (v : K) : seq1 $ int_fract_pair K :=
151+
protected def seq1 (v : K) : stream.seq1 $ int_fract_pair K :=
151152
⟨ int_fract_pair.of v,--the head
152-
seq.tail -- take the tail of `int_fract_pair.stream` since the first element is already in the
153-
-- head create a sequence from `int_fract_pair.stream`
153+
stream.seq.tail -- take the tail of `int_fract_pair.stream` since the first element is already in
154+
-- the head
155+
-- create a sequence from `int_fract_pair.stream`
154156
⟨ int_fract_pair.stream v, -- the underlying stream
155157
@stream_is_seq _ _ _ v ⟩ ⟩ -- the proof that the stream is a sequence
156158

src/algebra/continued_fractions/computation/terminates_iff_rat.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ rational, continued fraction, termination
2828
-/
2929

3030
namespace generalized_continued_fraction
31+
open stream.seq as seq
3132

3233
open generalized_continued_fraction (of)
3334

src/algebra/continued_fractions/computation/translations.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ of three sections:
3838

3939
namespace generalized_continued_fraction
4040
open generalized_continued_fraction (of)
41+
open stream.seq as seq
4142

4243
/- Fix a discrete linear ordered floor field and a value `v`. -/
4344
variables {K : Type*} [linear_ordered_field K] [floor_ring K] {v : K}
@@ -193,7 +194,7 @@ option.map_eq_none
193194

194195
lemma of_terminated_at_n_iff_succ_nth_int_fract_pair_stream_eq_none :
195196
(of v).terminated_at n ↔ int_fract_pair.stream v (n + 1) = none :=
196-
by rw [of_terminated_at_iff_int_fract_pair_seq1_terminated_at, seq.terminated_at,
197+
by rw [of_terminated_at_iff_int_fract_pair_seq1_terminated_at, stream.seq.terminated_at,
197198
int_fract_pair.nth_seq1_eq_succ_nth_stream]
198199

199200
end termination

src/algebra/continued_fractions/convergents_equiv.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fractions, recurrence, equivalence
6565

6666
variables {K : Type*} {n : ℕ}
6767
namespace generalized_continued_fraction
68+
open stream.seq as seq
6869

6970
variables {g : generalized_continued_fraction K} {s : seq $ pair K}
7071

src/algebra/continued_fractions/terminated_stable.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ We show that the continuants and convergents of a gcf stabilise once the gcf ter
1313
-/
1414

1515
namespace generalized_continued_fraction
16+
open stream.seq as seq
1617

1718
variables {K : Type*} {g : generalized_continued_fraction K} {n m : ℕ}
1819

src/algebra/continued_fractions/translations.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Some simple translation lemmas between the different definitions of functions de
1414
-/
1515

1616
namespace generalized_continued_fraction
17+
open stream.seq as seq
1718

1819
section general
1920
/-!

src/data/seq/parallel.lean

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import data.seq.wseq
1414
universes u v
1515

1616
namespace computation
17-
open wseq
17+
open stream.wseq as wseq
18+
open stream.seq as seq
1819
variables {α : Type u} {β : Type v}
1920

2021
def parallel.aux2 : list (computation α) → α ⊕ list (computation α) :=
@@ -26,7 +27,7 @@ end) (sum.inr [])
2627
def parallel.aux1 : list (computation α) × wseq (computation α) →
2728
α ⊕ list (computation α) × wseq (computation α)
2829
| (l, S) := rmap (λ l', match seq.destruct S with
29-
| none := (l', nil)
30+
| none := (l', seq.nil)
3031
| some (none, S') := (l', S')
3132
| some (some c, S') := (c::l', S')
3233
end) (parallel.aux2 l)
@@ -156,7 +157,7 @@ begin
156157
exact ⟨c, or.inl cl, ac⟩ },
157158
{ induction e : seq.destruct S with a; rw e at h',
158159
{ exact let ⟨d, o, ad⟩ := IH _ _ h',
159-
⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (not_mem_nil _), ad⟩ in
160+
⟨c, cl, ac⟩ := this a ⟨d, o.resolve_right (wseq.not_mem_nil _), ad⟩ in
160161
⟨c, or.inl cl, ac⟩ },
161162
{ cases a with o S', cases o with c; simp [parallel.aux1] at h';
162163
rcases IH _ _ h' with ⟨d, dl | dS', ad⟩,
@@ -196,8 +197,8 @@ theorem parallel_empty (S : wseq (computation α)) (h : S.head ~> none) :
196197
parallel S = empty _ :=
197198
eq_empty_of_not_terminates $ λ ⟨⟨a, m⟩⟩,
198199
let ⟨c, cs, ac⟩ := exists_of_mem_parallel m,
199-
⟨n, nm⟩ := exists_nth_of_mem cs,
200-
⟨c', h'⟩ := head_some_of_nth_some nm in by injection h h'
200+
⟨n, nm⟩ := wseq.exists_nth_of_mem cs,
201+
⟨c', h'⟩ := wseq.head_some_of_nth_some nm in by injection h h'
201202

202203
-- The reason this isn't trivial from exists_of_mem_parallel is because it eliminates to Sort
203204
def parallel_rec {S : wseq (computation α)} (C : α → Sort v)

0 commit comments

Comments
 (0)