Stream: Beginner Questions

Topic: Locale usage: Clash of types "_ set" and "_ itself"


view this post on Zulip Chengsong Tan (Jul 03 2024 at 11:47):

Hi,

I'm new to locale and trying to learn it via fomalising math.

I'm trying to define topological spaces using locale and define an example of a non-topology:

theory Examples
  imports Main TopologicalSpace
begin


locale topological_space =
  fixes X :: "'a set" and tau :: "'a set set"
  assumes
    (* The empty set and the whole set are in the topology *)
    empty_in_tau: "{} \<in> tau" and
    whole_in_tau: "X \<in> tau" and
    (* The topology is closed under arbitrary unions *)
    arbitrary_union_closed: "\<forall>U. (\<forall>i. U i \<in> tau) \<longrightarrow> (\<Union>i. U i) \<in> tau" and
    (* The topology is closed under finite intersections *)
    finite_intersection_closed: "\<forall>F. finite F \<longrightarrow> (\<forall>A \<in> F. A \<in> tau) \<longrightarrow> (\<Inter>F) \<in> tau"



(* Example 1: Trivial or Indiscrete Topology *)
locale trivial_topology = topological_space
  where X = "{1, 2, 3, 4}" and tau = "{{}, {1, 2, 3, 4}}"

(* Example 2: Another Topology *)
locale another_topology = topological_space
  where X = "{1, 2, 3, 4}" and tau = "{{}, {2}, {1, 2}, {2, 3}, {1, 2, 3}, {1, 2, 3, 4}}"

(* Example 3: Discrete Topology *)
locale discrete_topology = topological_space
  where X = "{1, 2, 3, 4}" and tau = "Pow {1, 2, 3, 4}"


(* Example 4: Non-Topology *)
locale non_topology =
  fixes X :: "int set" and tau :: "int set set"
  defines "X ≡ UNIV :: int set" (* Definition of X as the set of all integers *)
  defines "tau ≡ {A :: int set. finite A} ∪ {UNIV :: int set}" (* Definition of tau *)
  assumes non_topology_axioms: "¬ topological_space X tau"

end

Why do we have this error for example 4?

Type unification failed: Clash of types "_ set" and "_ itself"

Type error in application: incompatible operand type

Operator:  topological_space ::
  ??'a itself  ??'b set  ??'b set set  bool
Operand:   X :: int set

Thanks a lot,
Chengsong

view this post on Zulip Mathias Fleury (Jul 03 2024 at 11:54):

How about looking at the big yellow warning by topological_space?

view this post on Zulip Mathias Fleury (Jul 03 2024 at 11:54):

Hint: look at the type of U in arbitrary_union_closed.

view this post on Zulip Wenda Li (Jul 03 2024 at 14:02):

Apart from the problem Mathias pointed out, I guess you can also have a look at the commands 'interpretation'/'interpret' or 'sublocale', both of which can be used to encode a trivial topology being a topological space (we need a proof of that):

interpretation trivial_topology:topological_space "{1, 2, 3, 4}"  "{{}, {1, 2, 3, 4}}"
  sorry

(* OR *)

locale trivial_topology =
  fixes X :: "'a::numeral set" and tau :: "'a set set"
  assumes "X = {1, 2, 3, 4}" and "tau = {{}, {1, 2, 3, 4}}"
begin

sublocale topological_space
  sorry

end

Last updated: Dec 21 2024 at 16:20 UTC