03 luglio, 2019

Notarelle storiche sul Lisp - 1


Uno dei miei passatempi è la storia, andare a vedere (o rivedere se ero presente al tempo) cose, fatti, persone e altro ancora che poi sarebbe evoluto, in modo spesso imprevedibile. Per esempio io di Silvio (sì, allui, aqquello) ne ho sentito parlare quando ancora --OK, personale qui, censuro.

Vale anche per la programmazione, ho passato la prima metà della carriera professionale con il Fortran; ma ero nuovo (allora) e propendevo per il 77 avendo contro tutti i vecchi (cioè tutti; quando il capo ha un'opinione quella dev'essere la tua). Ho già raccontato una cosa che voi giovani --tutti quelli più giovani di me-- faticano a credere, ma è codice che si può compilare ed eseguire, vedi qui: Evoluzione - archeologia.

Era codice corrente al tempo. Anzi c'era una generazione precedente che scriveva in assembler (purtroppo non sono più in contatto da tempo con nessuno che mi possa fornire un esempio, che comunque non funzionerebbe ormai, dipendeva dalla macchina). Nel mio caso si parla di cicli, fatti con l'uso di GOTOs; a rigore i GOTO sono mascherati, io li avrei usati (allo stesso modo in cui si sarebbero usati nel Basic) ma i vecchi erano abituati agli IF calcolati.

Ecco l'istruzione IF, quanto e come si è evoluta nel tempo. Il Fortran ha seguito la via tracciata da Algol/Pascal, Basic e tanti altri diventando quello che si usa oggi if then/else if/else/end if --OK non tutti scrivono così.

Il Lisp è diverso e la sintassi dell'if è diversa, particolare, unica: (if test-expr then-expr else-expr); non mi addentro, andrei fuori tema. Ma è una form speciale, valuta una sola delle espressioni in funzione del risultato di test-expr. Io credevo, sbagliandomi, che ci fosse da sempre, cioè da quando c'è il Lisp. E invece no, è arrivata molto dopo. Non è un post giallo e do subito la soluzione: si usava COND (sì allora tutto maiuscolo).

La curiosità su if è nata a seguito di una discussione conseguente a un mio errore (e siccome è un errore mio non metto il link). Non riguardava il Lisp ma Unix e la sua evoluzione Linux, l'if di bc adesso aveva else e ho letto troppo in fretta tanto che mi è sembrato Lisp.

Basta; quest'introduzione è troppo lunga, vengo all'argomento. Elenco e cito documenti trovati online che illustrano (almeno a me, secondo me) la nascita e le prime fasi del linguaggio. Risulta fin da subito che il linguaggio di programmazione che si andrà a proporre è legato, quasi un effetto collaterale, all'intelligenza artificiale --espressione nuova appena creata dallo stesso John McCarthy.

Programs with Common Sense
Programs with Common Sense was probably the first paper on logical AI, i.e. AI in which logic is the method of representing information in computer memory and not just the subject matter of the program. The paper was given in the Teddington Conference on the Mechanization of Thought Processes in December 1958 and printed in the proceedings of that conference. It may also be the first paper to propose common sense reasoning ability as the key to AI.

C'è il PDF, 15 pagine, raccomandatissimo. Allora il computer era una cosa nuova, e allora

Interesting work is being done in programming computers to solve problems which require a high degree of intelligence in humans. However, certain elementary verbal reasoning processes so simple that they can be carried out by any non-feeble minded human have yet to be simulated by machine programs.

[...]

The advice taker is a proposed program for solving problems by manipulating sentences in formal languages.

[...]

The main advantages we expect the advice taker to have is that its behavior will be improvable merely by making statements to it, telling it about its symbolic environment and what is wanted from it. To make these statements will require little if any knowledge of the program or the previous knowledge of the advice taker.

[...] is expected to have much in common with what makes us describe certain humans as having common sense. We shall therefore say that a program has common sense if it automatically deduces for itself a sufficiently wide class of immediate consequences of anything it is told and what it already knows.

Before describing the advice taker in any detail, I would like to describe more fully our motivation for proceeding in this direction. Our ultimate objective is to make programs that learn from their experience as effectively as humans do.

[...]

Sarebbe tutto da copiare ma molto meglio leggerlo di là. Piuttosto l'elenco in 5 punti di cosa advice taker dovrebbe fare:
  1. All behaviors must be representable in the system. Therefore, the system should either be able to construct arbitrary automata or to program in some general purpose programming language;
  2. Interesting changes in behavior must be expressible in a simple way;
  3. All aspects of behavior except the most routine must be improvable. In particular, the improving mechanism should be improvable;
  4. The machine must have or evolve concepts of partial success because on difficult problems decisive successes or failures come too infrequently;
  5. The system must be able to create subroutines which can be included in procedures as units. The learning of subroutines is complicated by the fact that the effect of a subroutine is not usually good or bad in itself. Therefore, the mechanism that selects subroutines should have concepts of interesting or powerful subroutine whose application may be good under suitable conditions.
Un programma enorme, per cominciare [o]f the 5 points mentioned above, our work concentrates mainly on the second.

Ecco si parte da qui. A p.5 c'è "The Construction of the Advice Taker" dove si introducono gli elementi costituenti il linguaggio. Non è ancora il Lisp e la sintassi usata non è quella che sarebbe diventata. È quella che poi avrebbe costituito le M-expressions, M per meta.

Pausa? vero che il Lisp non è ancora comparso ma prossimamente... Probabilmente. Forse.

🔴

Nessun commento:

Posta un commento