### isabelle

#### Isabelle: Class of topological vector spaces

I wanted to define the class of topological vector spaces in the obvious way: theory foo imports Real_Vector_Spaces begin class topological_vector = topological_space + real_vector + assumes add_cont_fst: "∀a. continuous_on UNIV (λb. a + b)" ... but I got the error Type inference imposes additional sort constraint topological_space of type parameter 'a of sort type I tried introducing type constraints in the condition, and it looks like continuous_on doesn't want to match with the default type 'a of the class. Of course I can work around this by replacing continuity with equivalent conditions, I'm just curious why this doesn't work.

Inside a class definition in Isabelle/HOL, there may occur only one type variable (namely 'a), which has the default HOL sort type. Thus, one cannot formalise multi-parameter type classes. This also affects definitions inside type classes, which may depend only on the parameters of one type class. For example, you can define a predicate cont :: 'a set => ('a => 'a) => bool inside the type class context topological_space as follows definition (in topological_space) cont :: "'a set ⇒ ('a ⇒ 'a) ⇒ bool" where "cont s f = (∀x∈s. (f ---> f x) (at x within s))" The target (in topological_space) tells the type class system that cont really depends only on one type. Thus, it is safe to use cont in assumptions of other type classes which inherit from topological_space. Now, the predicate continuous_on in Isabelle/HOL has the type 'a set => ('a => 'b) => bool where both 'a and 'b must be of sort topological_space. Thus, continuous_on is more general than cont, because it allows different topological spaces a and b. Conversely, continuous_on cannot be defined within any one type class. Consequently, you cannot use continuous_on in assumptions of type classes either. This restriction is not specific to continuous_on, it appears for all kinds of morphisms, e.g. mono for order-preserving functions, homomorphisms between algebraic structures, etc. Single-parameter type classes just cannot express such things. In your example, you get the error because Isabelle unifies all occuring type variables to 'a and then realises that continuous_on forces the sort topological_space on 'a, but for the above reasons, you may not depend on sorts in class specifications. Nevertheless, there might be a simple way out. Just define cont as described above and use it in the assumptions of topological_vector instead of continuous_on. Outside of the class context, you can then prove that cont = continuous_on and derive the original assumption with continuous_on instead of cont. This keeps you from reasoning abstractly within the class context, but this is only a minor restriction.

### Related Links

Creating a datatype with inequalities in Isabelle

Isabelle Logic simple natural deduction test

Instantiating variables ending in a digit using where-attribute (Isabelle)

Using an existing definition in Isabelle/ Hol

Pending sort hypotheses

How can I use proved goals of locale interpretation to prove the remaining ones

Isabelle class obligation prove blue

Type declaration in Isabelle

Isabelle2016 and Proof General

Theory level obtain command

Failed to apply initial proof method. Proving an empty trace contains no messages

Sledgehammer gives insufficient proof tactic

How to show that 2 formula sare semantically equivalent in Isabelle

Isabelle: proof obligation - proving using counterexamples

Error using tptp_isabelle: Unknown logic “HOL-TPTP”

Isabelle: changing an element inside a list