I am aware that some of the proof assistants (e.g., Isabelle/HOL, Coq) provide an implementation of the so-called record types. For example, the library HOL-Algebra associated with the standard library of Isabelle/HOL relies on the record types for the specification of algebraic structures, such as groups:
- https://isabelle.in.tum.de/library/HOL/HOL-Algebra/document.pdf
- https://www.isa-afp.org/browser_info/devel/HOL/HOL-Algebra/Group.html
Here is a more specific use case:
record 'a monoid = "'a partial_object" +
mult :: "['a, 'a] ⇒ 'a" (infixl "⊗ı" 70)
one :: 'a ("𝟭ı")
As you can see, the record types are extensible (in the example above, monoid
is "derived" from partial_object
). Nonetheless, they are still very limited in their functionality in comparison to, for example, conventional classes in object-oriented programming. One particular limitation that had practical implications was exposed in several threads of the mailing list of Isabelle, including the following one:
The exposed problem could be seen as closely related to the lack of multiple inheritance in Isabelle's record types.
I have several closely related questions:
- Do any proof assistants provide more comprehensive record types that offer (better) support for multiple inheritance?
- Are there any ongoing/planned projects for bringing (further) OOP features into any of the proof assistants (e.g. introducing methods that can operate only on the record types, etc)?
- Has there been any further progress made on the aforementioned problem specifically in the Isabelle/HOL community?
A
is a type (record type or not),a : A
andA.f : A -> B -> C
(noticef
is in the namespaceA
) thena.f b
is short forA.f a b
. It works well in practice. Also, you can use type classes to similarly assign functions to some typesA
. For example, sincelist
is amonad
, thenl.map f
works forl : list A
. (That last feature reminds me a lot of Scala and Rust.) $\endgroup$l.map
dispatch via typeclasses example does not exist in Lean (but there is a separatelist.map
, of course). It has been suggested before though, so it may yet find its way into Lean 4. $\endgroup$l.map f
andf <$> l
. In particular, the OP might still be interested to know that even in Lean 3 type classes do allow one to assign operations to types. For examplef <$> l
is basically an abbreviation forfunctor.map f l
and reduces tolist.map f l
becauselist
is an instance of themonad
type class (which is an instance of thefunctor
type class). Similarly,n + m
reduces tonat.add n m
becausenat
is an instance of thehas_add
type class. $\endgroup$