Consider this example—note that F1 and F2 are identical.
theory Scratch
imports Main
begin
locale F0 =
fixes meaning :: ‹'model ⇒ 'a set› ("⟦_⟧")
locale F1 = F0 +
fixes γ :: ‹'a set ⇒ 'model›
assumes sound: ‹L ⊆ ⟦γ L⟧›
(* Typechecks. *)
definition (in F0) "models m L ≡ L ⊆ ⟦m⟧"
locale F2 = F0 +
fixes γ :: ‹'a set ⇒ 'model›
assumes sound: ‹L ⊆ ⟦γ L⟧›
(* Does not typecheck, see below. *)
end
The locale F2—which is the same as the well-typed F1 except we've added a definition to F0—fails type-checking with the error message:
Type unification failed
Type error in application: incompatible operand type
Operator: meaning :: 'a ⇒ 'b set
Operand: γ L :: 'model
Apparently, when type-checking F2, does the type checker suddenly decide that the free type variables 'a and 'model cannot be the same thing?