Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (analysis/topology): implement sequential spaces and sequential continuity, show metric spaces are sequential #440

Closed
wants to merge 13 commits into from

Conversation

jdsalchow
Copy link
Collaborator

feat (analysis/topology): implement sequential spaces and sequential continuity, show metric spaces are sequential

TO CONTRIBUTORS:

Make sure you have:

  • reviewed and applied the coding style: coding, naming
  • for tactics:
  • make sure definitions and lemmas are put in the right files
  • make sure definitions and lemmas are not redundant

For reviewers: code review check list

Copy link
Member

@robertylewis robertylewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very clean! The ‹ › notation isn't used so much in mathlib, and this is certainly verbose, but that's not necessarily bad. This is very legible to me.

Here are some quick stylistic comments. Many of them apply to multiple places in the file, you should be able to find where pretty quickly. I'm also trying out Github's suggestion feature, which I've never used...

analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
metrically_converges_to_iff_converges_to
... ↔ tendsto x at_top (nhds limit) : converges_to_iff_tendsto

private lemma one_div_succ_pos (n : ℕ) : 1 / ((n : ℝ) + 1) > 0 :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I did this originally, but this should probably be moved somewhere more general.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's a copy of your private lemma from the Cauchy sequence filter file. Any suggestions as to where a non private version of this can go? I was tempted to put it into real.lean, but the statement is true in a more general context.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

algebra/ordered_field.lean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems wrong as it would imply importing the reals in ordered field.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work more generally for some ordered fields

analysis/topology/sequences.lean Outdated Show resolved Hide resolved
-- from this, construct a "sequence of hypothesis" h, (h n) := _ ∈ {x // x ∈ ball (1/n+1) p ∩ M}
let h := λ n : ℕ, (classical.indefinite_description _ (set.exists_mem_of_ne_empty (this n))) in
-- an actual sequence
let x := λ n : ℕ, (h n).val in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can combine two lets into one:

let h := _,
    x := _ in

-- necessary for the next instance
set_option eqn_compiler.zeta true
/- Show that every metric space is sequential. -/
instance metric_space.to_sequential_space: sequential_space X :=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space before colon (otherwise the VS Code highlighting is off)

Suggested change
instance metric_space.to_sequential_space: sequential_space X :=
instance metric_space.to_sequential_space : sequential_space X :=

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robertylewis Thanks for the bug report! It's fixed now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, I guess I could have made this bug report easier to find.... Thanks!

@jcommelin
Copy link
Member

This certainly looks very readable! I should learn to write term-mode proofs like this!

- (*) define the sequential closure of a set and prove that it's contained in the closure,
- (*) define a type class "sequential_space" in which closure and sequential closure agree,
- (*) define sequential continuity and show that it coincides with continuity in sequential spaces,
- (*) provide and instance that shows that every metric space is a sequential space.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- (*) provide and instance that shows that every metric space is a sequential space.
- (*) provide an instance that shows that every metric space is a sequential space.


/- The notion of convergence of sequences in topological spaces. -/
def converges_to (x : ℕ → X) (limit : X) : Prop :=
∀ U : set X, limit ∈ U → is_open U → ∃ n0 : ℕ, ∀ n ≥ n0, (x n) ∈ U
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I would personally swap the order of the hypotheses: first assume that U is open, and then assume that the limit is in U. But that is certainly a matter of taste.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much of a preference either way.

let ⟨x, ⟨_, _⟩⟩ := this in
show p ∈ A, from h x ‹∀ n : ℕ, ((x n) ∈ A)› p ‹converges_to x p›))

/- The sequential closure of a set is containt in the closure of that set. The converse is not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/- The sequential closure of a set is containt in the closure of that set. The converse is not
/- The sequential closure of a set is contained in the closure of that set. The converse is not

@kckennylau
Copy link
Collaborator

Is there anything wrong with this PR?

@johoelzl
Copy link
Collaborator

I hope to find some in one or two weeks. I'm a little bit occupied with preparing a lecture and reviews.

@jdsalchow
Copy link
Collaborator Author

What's the state of this?

analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
show p ∈ closure M, from
-- we have to show that p is in the closure of M
-- using mem_closure_iff, this is equivalent to proving that every open neighbourhood
-- has nonempty intersection with A, but this is witnessed by our sequence x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M turned into A in the comment. Might be worth going through and changing all the As to M or vice versa.

-- using mem_closure_iff, this is equivalent to proving that every open neighbourhood
-- has nonempty intersection with A, but this is witnessed by our sequence x
suffices ∀ O, is_open O → p ∈ O → O ∩ M ≠ ∅, from mem_closure_iff.mpr this,
assume O is_open_O O_cap_M_neq_empty,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assume O is_open_O O_cap_M_neq_empty,
assume O is_open_O p_in_O,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be misleading, in general p is only in the sequential closure of M, not in M.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O_cap_M_neq_empty sounds like the type is O ∩ M ≠ ∅, but it is p ∈ O

analysis/topology/sequences.lean Outdated Show resolved Hide resolved
analysis/topology/sequences.lean Outdated Show resolved Hide resolved
metrically_converges_to_iff_converges_to
... ↔ tendsto x at_top (nhds limit) : converges_to_iff_tendsto

private lemma one_div_succ_pos (n : ℕ) : 1 / ((n : ℝ) + 1) > 0 :=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

algebra/ordered_field.lean?

Copy link
Collaborator

@johoelzl johoelzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdsalchow sorry for the long delay. Generally we try to use tendsto and not introduce too much additional constants.

-- using mem_closure_iff, this is equivalent to proving that every open neighbourhood
-- has nonempty intersection with A, but this is witnessed by our sequence x
suffices ∀ O, is_open O → p ∈ O → O ∩ M ≠ ∅, from mem_closure_iff.mpr this,
assume O is_open_O O_cap_M_neq_empty,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O_cap_M_neq_empty sounds like the type is O ∩ M ≠ ∅, but it is p ∈ O

universes u v
variables {X : Type u} {Y : Type v}

def to_filter (x : ℕ → X) : filter X := filter.map x at_top
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is never used

variables [topological_space X] [topological_space Y]

/-- The notion of convergence of sequences in topological spaces. -/
def converges_to (x : ℕ → X) (limit : X) : Prop :=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definition is not necessary. It would be nice to have a notation for this, and prove converges_to_iff_tendsto in the other way round.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by 'the other way around'? Just the symmetric statement i.e. converges_to_iff_tendsto?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to avoid introducing too many new concepts for slight variations of the same notion. It makes the library confusing; for example, converges_to might mean any of a number of things. You should use tendsto x at_top (nhds limit) directly rather than the new concept, converges_to. The lemma should then assert that tendsto x at_top (nhds limit) is equivalent to the current definition of converges_to.

Also, doesn't the equivalence hold for an arbitrary preorder, not just nat?

(mem_nhds_sets isOpenU limitInU),
show ∃ n0 : ℕ, ∀ n ≥ n0, (x n) ∈ U, from mem_at_top_sets.mp this)

/--
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the - in the next two lines. They occur in the tooltip, i.e, the tooltip is now - The sequential closure of a subset M ⊆ X of a topological space X is - the set of all p ∈ X which arise as limit of sequences in M.

show p ∈ A, from h x ‹∀ n : ℕ, ((x n) ∈ A)› p ‹converges_to x p›))

/--
- The sequential closure of a set is contained in the closure of that set. The converse is not
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for -

is_mem_of_conv_to_of_is_seq_closed (is_seq_closed_of_is_closed A ‹is_closed A›)
‹∀ n, x n ∈ A› ‹converges_to x limit›

/--
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto for -


/-- The usual notion of convergence of sequences in metric spaces. -/
def metrically_converges_to (x : ℕ → X) (limit : X) : Prop :=
∀ ε > 0, ∃ n0 : ℕ, ∀ n ≥ n0, dist (x n) limit < ε
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as converges_to, i.e. remove this definition

metrically_converges_to_iff_converges_to
... ↔ tendsto x at_top (nhds limit) : converges_to_iff_tendsto

private lemma one_div_succ_pos (n : ℕ) : 1 / ((n : ℝ) + 1) > 0 :=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work more generally for some ordered fields

@jdsalchow jdsalchow force-pushed the sequences branch 2 times, most recently from b787b7c to f07478c Compare January 15, 2019 14:35
@avigad
Copy link
Collaborator

avigad commented Jan 15, 2019

@jdsalchow Thank you for these theorems and definitions. They look very good to me, but there is one thing that should be improved.

I just confirmed that two of the main lemmas, topological_space.seq_tendsto_iff and metrtic_space.seq_tendsto_iff go through exactly as they are if you declare

variables {γ : Type*} [semilattice_sup γ] [inhabited γ]

and replace by γ everywhere. In other words, they have nothing to do with sequences. They work just as well for functions from the reals, for example. They are useful characterizations of convergence at infinity, and should be stated in full generality.

I would recommend naming them topological_space.tendsto_at_top_iff and metric_space.tendsto_at_top_iff and moving them to the files topological_space and metric_space, respectively.

(If you are feeling energetic, it would be nice to have the corresponding theorems for at_bot, but I would not insist on it for the PR.)

@jdsalchow
Copy link
Collaborator Author

I just confirmed that two of the main lemmas, topological_space.seq_tendsto_iff and metrtic_space.seq_tendsto_iff go through exactly as they are if you declare

variables {γ : Type*} [semilattice_sup γ] [inhabited γ]

and replace by γ everywhere. In other words, they have nothing to do with sequences. They work just as well for functions from the reals, for example. They are useful characterizations of convergence at infinity, and should be stated in full generality.

@avigad If I do that, the two lemmas would have to move out of the file about sequences, and be put into a logical context that fits such a general lemma. Then those two lemmas would need to be restated as a corollary of the general thing.

I'm happy to do that, if there is a place in which the more general statements would fit. Otherwise, I suggest to put a comment there, indicating that the proofs generalise. Then the first person who needs it can do this (trivial) generalisation.

@jdsalchow
Copy link
Collaborator Author

Is this failing because of some olean caching issue? It builds fine locally ...

@digama0
Copy link
Member

digama0 commented Jan 21, 2019

some files got moved around - analysis.topology.* is now topology.*. Check your imports

@johoelzl johoelzl closed this in 4018daf Jan 23, 2019
cipher1024 pushed a commit that referenced this pull request Feb 8, 2019
…ty (closes #440)

Co-Authored-By: Reid Barton <rwbarton@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants