简体   繁体   中英

What is the relationship between Gallina and OCaml?

I learned that Coq is written in OCaml, but it has the specification language as Gallina. How are these two languages related besides they are all functional programming languages?

That's a bit of a loaded question.

Gallina could exist independently from OCaml, though, being a lambda calculus, it shares some construct and semantics with it, and, having been developed in the OCaml world, it also shares some concrete syntax. But OCaml could not have been suitable to take the place of Gallina.

Some similarities:

  • They share a lambda calculus-inspired, functional language.
  • They have similar algebraic data type declarations (though there are lots of differences in what is allowable and expressible).

Some (major) differences:

  • Gallina has dependent types, while OCaml has a type system that is close to a prenex-polymorphic System F with some subtyping... I'm not sure how to call it, but it is less expressive than dependent types in some ways, though it has some extra features absent from Gallina.
  • Gallina is total, meaning all functions must be syntactically well-behaved, either clearly terminating, or clearly making computational progress. OCaml is a more general purpose language where non-termination is fine.
  • Gallina is pure, while OCaml has side-effectful primitives.
  • Gallina is "functional only" if you will. OCaml has a notion of objects, some "imperative"-looking features (due to all the differences previously listed).

In fact, historically, ML (which OCaml is some variant of) was to LCF sort of what Ltac is to Gallina! :-D (oh boy, I might get some angry comments because of this note...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM