caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Formal specifications of programming languages
@ 2008-02-13 18:22 Andrej Bauer
  2008-02-13 18:27 ` [Caml-list] " Christopher L Conway
  0 siblings, 1 reply; 9+ messages in thread
From: Andrej Bauer @ 2008-02-13 18:22 UTC (permalink / raw)
  To: caml-list

I see people have opinions about formal semantics.

Having formal semantics for a programming language is a valuable thing,
even if most people do not understand it. Such semantics is a piece of
mathematics that removes (hopefully) every doubt as to what we are
talking about, and has other benefits as well. High priests can then
write sermons in common language and explain the meaning of the Holy Word.

It would probably be quite hard to provide formal semantics for complete
ocaml, for several reasons, such as sheer size, C interface, and the
fact that it is a moving target.

But what is formal semantics good for?

Complete formal semantics written with a tool such as Coq, together with
formal proofs of its properties (existence of principal types,
uniqueness of typing, type preservation, progress lemma) is good for
automatic extraction of a prototype type-checker and/or interpreter.
This can be extremely valuable for PL researchers who want to experiment
with new features.

Incomplete formal semantics written in a series of papers and
dissertations is still quite useful. It allows researchers to clearly
express and communicate ideas. Once a person learns how to read the
mathematics that may greatly help his or her understanding of corner
cases and peculiar examples.

We (researchers) should encourage "ordinary programmers" to read formal
semantics by writing manuals and textbooks that incorporate the
formalism and decorate it with sufficient explanation.

Think about the fact that specifying concrete syntax in BNF-like
formalism has become the norm. Programmers happily read it and the
benefits are obvious. Nobody suggests that syntax should be explained in
English prose because BNF is too hard to understand. So why are you
suggesting that the norm for describing other pieces of a programming
language, such as typing rules and operational semantics, should be
primarily (or only) English prose?

Andrej


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Formal specifications of programming languages
  2008-02-13 18:22 Formal specifications of programming languages Andrej Bauer
@ 2008-02-13 18:27 ` Christopher L Conway
  2008-02-13 19:45   ` Andrej Bauer
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher L Conway @ 2008-02-13 18:27 UTC (permalink / raw)
  To: Andrej Bauer; +Cc: caml-list

But, Andrej, we don't even have an *informal* semantics. :-( You've
got to walk before you run.

Chris

On Feb 13, 2008 1:22 PM, Andrej Bauer <Andrej.Bauer@fmf.uni-lj.si> wrote:
> I see people have opinions about formal semantics.
>
> Having formal semantics for a programming language is a valuable thing,
> even if most people do not understand it. Such semantics is a piece of
> mathematics that removes (hopefully) every doubt as to what we are
> talking about, and has other benefits as well. High priests can then
> write sermons in common language and explain the meaning of the Holy Word.
>
> It would probably be quite hard to provide formal semantics for complete
> ocaml, for several reasons, such as sheer size, C interface, and the
> fact that it is a moving target.
>
> But what is formal semantics good for?
>
> Complete formal semantics written with a tool such as Coq, together with
> formal proofs of its properties (existence of principal types,
> uniqueness of typing, type preservation, progress lemma) is good for
> automatic extraction of a prototype type-checker and/or interpreter.
> This can be extremely valuable for PL researchers who want to experiment
> with new features.
>
> Incomplete formal semantics written in a series of papers and
> dissertations is still quite useful. It allows researchers to clearly
> express and communicate ideas. Once a person learns how to read the
> mathematics that may greatly help his or her understanding of corner
> cases and peculiar examples.
>
> We (researchers) should encourage "ordinary programmers" to read formal
> semantics by writing manuals and textbooks that incorporate the
> formalism and decorate it with sufficient explanation.
>
> Think about the fact that specifying concrete syntax in BNF-like
> formalism has become the norm. Programmers happily read it and the
> benefits are obvious. Nobody suggests that syntax should be explained in
> English prose because BNF is too hard to understand. So why are you
> suggesting that the norm for describing other pieces of a programming
> language, such as typing rules and operational semantics, should be
> primarily (or only) English prose?
>
> Andrej
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Formal specifications of programming languages
  2008-02-13 18:27 ` [Caml-list] " Christopher L Conway
@ 2008-02-13 19:45   ` Andrej Bauer
  2008-02-14  9:00     ` Jacques Garrigue
  2008-02-14  9:08     ` Xavier Leroy
  0 siblings, 2 replies; 9+ messages in thread
From: Andrej Bauer @ 2008-02-13 19:45 UTC (permalink / raw)
  To: Christopher L Conway; +Cc: caml-list

Christopher L Conway wrote:
> But, Andrej, we don't even have an *informal* semantics. :-( You've
> got to walk before you run.

Didn't Jacques say in a related post "Most of the type system is
formalized, but there is no single place to look at"? Jacques, does the
"type system" mean "type checking", "type inference", "operational
semantics", or what. Heck, I should just look up the papers.

Maybe we should collect the relevant URLs and place them in the wiki. It
would be a start. I might do that.

Andrej


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Formal specifications of programming languages
  2008-02-13 19:45   ` Andrej Bauer
@ 2008-02-14  9:00     ` Jacques Garrigue
  2008-02-14  9:08     ` Xavier Leroy
  1 sibling, 0 replies; 9+ messages in thread
From: Jacques Garrigue @ 2008-02-14  9:00 UTC (permalink / raw)
  To: Andrej.Bauer; +Cc: caml-list

From: Andrej Bauer <Andrej.Bauer@fmf.uni-lj.si>
> Christopher L Conway wrote:
> > But, Andrej, we don't even have an *informal* semantics. :-( You've
> > got to walk before you run.
> 
> Didn't Jacques say in a related post "Most of the type system is
> formalized, but there is no single place to look at"? Jacques, does the
> "type system" mean "type checking", "type inference", "operational
> semantics", or what. Heck, I should just look up the papers.

This is mostly about providing a formal type system (what you would
call type checking) and prove that it admits principal types (so that
an inference algorithm exists). Of course, for the modules system
there is no inference (it still use core-language inference).

Concerning the operational semantics, the reference manual is quite
complete I believe. Of course some things are left unspecified, but
this is actually part of the specification (you should be able to
write programs without knowing the exact evaluation orer for instance.)
 
> Maybe we should collect the relevant URLs and place them in the wiki. It
> would be a start. I might do that.

Good idea indeed.

Jacques Garrigue


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Formal specifications of programming languages
  2008-02-13 19:45   ` Andrej Bauer
  2008-02-14  9:00     ` Jacques Garrigue
@ 2008-02-14  9:08     ` Xavier Leroy
  2008-02-15 14:30       ` Christopher L Conway
  1 sibling, 1 reply; 9+ messages in thread
From: Xavier Leroy @ 2008-02-14  9:08 UTC (permalink / raw)
  To: Andrej.Bauer; +Cc: caml-list

> Didn't Jacques say in a related post "Most of the type system is
> formalized, but there is no single place to look at"? Jacques, does the
> "type system" mean "type checking", "type inference", "operational
> semantics", or what. Heck, I should just look up the papers.
>
> Maybe we should collect the relevant URLs and place them in the wiki. It
> would be a start. I might do that.

It's been done a long time ago: http://caml.inria.fr/about/papers.en.html

- Xavier Leroy


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Formal specifications of programming languages
  2008-02-14  9:08     ` Xavier Leroy
@ 2008-02-15 14:30       ` Christopher L Conway
  2008-02-18 10:05         ` Jacques Garrigue
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher L Conway @ 2008-02-15 14:30 UTC (permalink / raw)
  To: Xavier Leroy; +Cc: Andrej.Bauer, caml-list

Xavier,

Do any of these papers address existentials?

Regards,
Chris

On Thu, Feb 14, 2008 at 4:08 AM, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:
> > Didn't Jacques say in a related post "Most of the type system is
>  > formalized, but there is no single place to look at"? Jacques, does the
>  > "type system" mean "type checking", "type inference", "operational
>  > semantics", or what. Heck, I should just look up the papers.
>  >
>  > Maybe we should collect the relevant URLs and place them in the wiki. It
>  > would be a start. I might do that.
>
>  It's been done a long time ago: http://caml.inria.fr/about/papers.en.html
>
>  - Xavier Leroy
>
>
>
>  _______________________________________________
>  Caml-list mailing list. Subscription management:
>  http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
>  Archives: http://caml.inria.fr
>  Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>  Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Formal specifications of programming languages
  2008-02-15 14:30       ` Christopher L Conway
@ 2008-02-18 10:05         ` Jacques Garrigue
  2008-02-18 16:44           ` Jacques Carette
  0 siblings, 1 reply; 9+ messages in thread
From: Jacques Garrigue @ 2008-02-18 10:05 UTC (permalink / raw)
  To: cconway; +Cc: caml-list

From: "Christopher L Conway" <cconway@cs.nyu.edu>

> Do any of these papers address existentials?

There are no existentials in ocaml, only first-class universal types
(in polymorphic methods and polymorphic record fields.)
Universal types can be used to encode existentials through the usual
dual encoding.
The theory behind polymorpic methods is described in my paper with
Didier Remy, in the Objects section. Polymorphic fields in records are
simpler, and they were already formalized in earlier papers by Didier
Remy.

(Actually, abstract types in modules can also be seen as existentials,
but I don't think this is what you are talking about.)

Jacques Garrigue


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Formal specifications of programming languages
  2008-02-18 10:05         ` Jacques Garrigue
@ 2008-02-18 16:44           ` Jacques Carette
  2008-02-18 21:52             ` Christophe Raffalli
  0 siblings, 1 reply; 9+ messages in thread
From: Jacques Carette @ 2008-02-18 16:44 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: caml-list

Jacques Garrigue wrote:
> (Actually, abstract types in modules can also be seen as existentials,
> but I don't think this is what you are talking about.)
>   
This is a subtle issue that I have yet to understand 'completely'.  Can 
you expand on this "can also be seen as existentials" please?

To me, there seems to be a difference between these, but I have never 
been able to quite put my finger on it.  It may be because they are not 
really different, ie both can encode the other. 

This is not just an idle question.  In two separate papers (with 
co-authors), abstract types in module types (and Functors) are used as 
what I think of as "constrained existentials", to good effect.  But 
maybe I really ought to think of those as "for all types that can be 
used as implementations of this signature" rather than "some _specific_ 
type that satisfies this signature".  I say 'specific' because while 
users of the module cannot see the implementation, inside the 
implementation, the actual representation is rather crucial.

Jacques Carette


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Caml-list] Formal specifications of programming languages
  2008-02-18 16:44           ` Jacques Carette
@ 2008-02-18 21:52             ` Christophe Raffalli
  0 siblings, 0 replies; 9+ messages in thread
From: Christophe Raffalli @ 2008-02-18 21:52 UTC (permalink / raw)
  To: Jacques Carette; +Cc: Jacques Garrigue, caml-list

Jacques Carette a écrit :
> Jacques Garrigue wrote:
>> (Actually, abstract types in modules can also be seen as existentials,
>> but I don't think this is what you are talking about.)
>>   
> This is a subtle issue that I have yet to understand 'completely'.  
> Can you expand on this "can also be seen as existentials" please?
>
> To me, there seems to be a difference between these, but I have never 
> been able to quite put my finger on it.  It may be because they are 
> not really different, ie both can encode the other.
> This is not just an idle question.  In two separate papers (with 
> co-authors), abstract types in module types (and Functors) are used as 
> what I think of as "constrained existentials", to good effect.  But 
> maybe I really ought to think of those as "for all types that can be 
> used as implementations of this signature" rather than "some 
> _specific_ type that satisfies this signature".  I say 'specific' 
> because while users of the module cannot see the implementation, 
> inside the implementation, the actual representation is rather crucial.
Abstract types are existential types with a projecton operator (like a 
choice operator) and they can have contraints. Unfortunatly, modules are 
not first class and you can not do a list of modules with the same 
signature but distinct implementation for their abstract types. This is 
the lack of first class modules that prevent to encode existential types 
using abstract types.

The best to do is to use universal types in records with "the usual dual 
encoding" as said by J. Garrigues.

Do not forget that an abstract type occurring in the signature of an 
argument to a functor is a universal type because it is "negated" ...

>
> Jacques Carette
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-02-18 21:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-13 18:22 Formal specifications of programming languages Andrej Bauer
2008-02-13 18:27 ` [Caml-list] " Christopher L Conway
2008-02-13 19:45   ` Andrej Bauer
2008-02-14  9:00     ` Jacques Garrigue
2008-02-14  9:08     ` Xavier Leroy
2008-02-15 14:30       ` Christopher L Conway
2008-02-18 10:05         ` Jacques Garrigue
2008-02-18 16:44           ` Jacques Carette
2008-02-18 21:52             ` Christophe Raffalli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).