From mjcg%cam.sri.com@ai.sri.com  Mon May 28 07:28:26 1990
Received: by iris.ucdavis.edu (5.57/UCD.EECS.2.0)
        id AA06106; Mon, 28 May 90 07:28:26 PDT
Received: from Warbucks.AI.SRI.COM by clover.ucdavis.edu (5.59/UCD.EECS.1.11)
        id AA19470; Mon, 28 May 90 07:32:19 PDT
Received: from Sunset.AI.SRI.COM by Warbucks.AI.SRI.COM with INTERNET ;
          Mon, 28 May 90 07:28:33 PDT
Received: from cam.sri.com by Sunset.AI.SRI.COM (4.1/4.16)
        id AA12156 for info-hol@clover.ucdavis.edu; Mon, 28 May 90 07:29:31 PDT
Received: from denbigh.cam.sri.com by cam.sri.com (4.1/4.16)
        id AA14889 for info-hol@clover.ucdavis.edu; Mon, 28 May 90 15:28:43 BST
Received: by denbigh.cam.sri.com (4.1/4.16)
        id AA28159 for info-hol@clover.ucdavis.edu; Mon, 28 May 90 15:28:37 BST
Date: Mon, 28 May 90 15:28:37 BST
From: mjcg%cam.sri.com@Warbucks.AI.SRI.COM (Mike Gordon)
Message-Id: <9005281428.AA28159@denbigh.cam.sri.com>
To: info-hol@clover.ucdavis.edu
Subject: definitions


Have you ever got fed up writing names three times in things like:

  let Foo =
   new_definition
    (`Foo`,
     "Foo x1 ... xn = ...");;

If so, then the ML function define (see below) enables you to
abbreviate this to

   define "Foo x1 ... xn = ...";;

-----------------------------------------------------------------------------

%****************************************************************************%
% define "!x1 ... xn. FOO x1 ... xn = ...";;                                 %
%                                                                            %
% is equivalent to                                                           %
%                                                                            %
% let FOO =                                                                  %
%  new_definition                                                            %
%   (`FOO`,                                                                  %
%    "FOO x1 ... xn = ...");;                                                %
%****************************************************************************%

%----------------------------------------------------------------------------%
% The assignable variable def_buffer is a register for passing an argument   %
% to the function new_defn, which is called using let_before. This hack is   %
% necessary because only strings can be passed as parameters via calls of    %
% let_before (see DESCRIPTION).                                              %
%----------------------------------------------------------------------------%

letref def_buffer = "T";;

%----------------------------------------------------------------------------%
% Function invoked by let_before; gets argument through def_buffer.          %
%----------------------------------------------------------------------------%

let new_defn [name] = new_definition(name,def_buffer);;

%----------------------------------------------------------------------------%
% The function define extracts the name of the constant to be defined,       %
% then stashes the defining term in def_buffer,                              %
% then calls new_defn.                                                       %
%----------------------------------------------------------------------------%

let define t =
 let head =
  ((fst o dest_var o fst o strip_comb o lhs o snd o strip_forall) t
   ? failwith `bad term to define`)
 in
 def_buffer:=t;
 let_before(head,`new_defn`,[head]);;



