0

I'm attempting to formalize a series of proofs about topology from a book [1] in Isabelle.

I want to encode the idea that a topological space (X,T) consists of a set X of "points" (elements of some arbitrary type 'a), and a set of subsets of X, called T, such that:

  • A1. if an element p is in X, then there exists at least one set N in T that also contains p.
  • A2. if sets U and V are in T, and if p∈(U∩V), then there must exist at a set N in T where N⊆(U∩V) and x∈N. (If two sets intersect, then there must be a neighborhood that covers the intersection.).

Currently I have the following definition:

class topspace =
    fixes X :: "'a set"
    fixes T :: "('a set) set"
    assumes A1: "p∈X ≡ ∃N∈T. p∈N"
    assumes A2: "U∈T ∧ V∈T ∧ x∈(U∩V) ⟹ ∃N∈T. x∈N ∧ N⊆(U∩V)"
begin 
  (* ... *)
end

So far, so good. I'm able to add various definitions and prove various lemmas and theorems about hypothetical topspace instances.

But how do I actually create one? Unless I'm misinterpreting things, the examples I've seen so far for the instance and instantiate keywords all seem to be been about declaring that one particular abstract class (or type or locale) is an instance of another.

How do I tell Isabelle that a particular pair of sets (e.g. X={1::int, 2, 3}, T={X,{}}) form a topspace?

Likewise, how can I use my definition to prove that X={1::int, 2, 3}, T={} does not fit the requirements?

Finally, once I show that a particular concrete object X meets the definition of a topspace, how do I tell Isabelle to now make use of all the definitions and theorems I've proven about topspace when proving things about X?

BTW, I'm using class because I don't know any better. If it's not the right tool for the job, I'm happy to do something else.


[1]: A Bridge to Advanced Mathematics by Dennis Sentilles

tangentstorm
  • 7,183
  • 2
  • 29
  • 38

2 Answers2

0

I've made some progress here: a class is a special type of locale, but it isn't necessary for this sort of usage, and using the locale keyword directly simplifies the situation a bit. Every locale has an associated theorem that you can use to instantiate it:

locale topspace =
    fixes X :: "'a set"
    fixes T :: "('a set) set"
    assumes A1 [simp]: "x∈X ≡ ∃N∈T. x∈N"
    assumes A2 [simp]: "U∈T ∧ V∈T ∧ x∈(U∩V) ⟹ ∃N∈T. x∈N ∧ N⊆(U∩V)"

theorem
  assumes "X⇩A={1,2,3::int}" and "T⇩A={{}, {1,2,3::int}}"
  shows "topspace X⇩A T⇩A"
  proof
    show "⋀U V x. U∈T⇩A ∧ V∈T⇩A ∧ x∈U∩V ⟹ ∃N∈T⇩A. x∈N ∧ N⊆U∩V"
     and "⋀x. x∈X⇩A ≡ ∃N∈T⇩A. x∈N" using assms by auto
  qed

If we want to use definition for declarations, the proof goal becomes a bit more complex, and we need to use the unfolding keyword. (The locales.pdf that comes with isabelle covers this, but I'm not sure I'm not yet able to explain it in my own words). Anyway, this works:

experiment
begin

  definition X⇩B where "X⇩B={1,2,3::int}"
  definition T⇩B where "T⇩B={{}, {1,2,3::int}}"

  lemma istop0: "topspace X⇩B T⇩B" proof 
    show "⋀U V x. U∈T⇩B ∧ V∈T⇩B ∧ x∈U∩V ⟹ ∃N∈T⇩B. x∈N ∧ N⊆U∩V" 
     and "⋀x. x∈X⇩B ≡ ∃N∈T⇩B. x∈N" unfolding X⇩B_def T⇩B_def by auto
  qed

end

I believe it's also possible, and possibly preferable, to do all this work inside of a sub-locale, but I haven't quite worked out the syntax for this.

tangentstorm
  • 7,183
  • 2
  • 29
  • 38
0

Although locales are implemented in the calculus itself and hence their predicates can be used in any regular proposition, this is usually not recommended. Instead, you should instantiate locales using e.g. interpretation, as in the following example.

locale topspace =
  fixes X :: "'a set"
  fixes T :: "('a set) set"
  assumes A1 [simp]: "x∈X ⟷ (∃N∈T. x∈N)"
  assumes A2 [simp]: "U∈T ∧ V∈T ∧ x∈(U∩V) ⟹ ∃N∈T. x∈N ∧ N⊆(U∩V)"

context
  fixes X⇩A T⇩A
  assumes X⇩A_eq: "X⇩A = {1, 2, 3 :: int}"
    and T⇩A_eq: "T⇩A = {{}, {1, 2, 3 :: int}}"
begin

interpretation example: topspace X⇩A T⇩A
  by standard (auto simp add: X⇩A_eq T⇩A_eq)

lemmas facts = example.A1 example.A2

end

thm facts

Whether this pattern really fits for your needs depends on your application; if you just want to have a predicate, it is better to define it directly without using locale at all.

Note: there is really need to the Pure equality »≡«; prefer HOL equality »=«, or its syntactic variant »⟷«.