Changes between Version 2 and Version 3 of PIL


Ignore:
Timestamp:
10/03/24 11:06:50 (20 months ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PIL

    v2 v3  
    3737- `$set<T>` : finite set of `T`, ops to add, contains, remove, size, ...
    3838- `$map<T1,T2>` : finite map from `T1` to `T2`, ops to put, get, containsKey, ...
    39 - `$fun<T1,T2>` : total functions from `T1` to `T2`
     39- `$fun<T1,T2>` :  "logic functions":  deterministic, total, side-effect free functions from `T1` to `T2`
    4040- `$tuple<T,...>` : tuples of specified type (similar to struct)
    4141- `$rel<T,...>` : relations of specified type (set of tuples)
     
    5050- `t.i`
    5151- `($tuple<T1,...>){ x1, ... }`
    52 - `$pure $tuple<T1,...> $tuple_write($tuple<T1,...> t, $int i, Ti x);`
     52- `$logic $tuple<T1,...> $tuple_write($tuple<T1,...> t, $int i, Ti x);`
    5353
    5454Mutating expressions:
     
    6060- `s1 == s2`
    6161- `($set<T>)$empty`   // empty set of type T
    62 - `$pure _Bool $set_in(T x, $set<T> s);`  // is x an element of s?
     62- `$logic _Bool $set_in(T x, $set<T> s);`  // is x an element of s?
    6363- `$pure $set<T> $set_with($set<T> s, T x);` // s U {x}
    6464- `$pure $set<T> $set_without($set<T> s, T x);` // s - {x}
     
    155155=== Lambda expressions
    156156
    157 These have the form
    158 {{{
    159   $lambda (T1 x1, ..., Tn xn) {U1 v1=init1; ... Um vm=initm; expr}
    160 }}}
    161 where the `Ti` and `Uj` are types, the `xi` and `vj` are variables, and `expr` is an expression in which the only variables that can occur free are the `x1`,..., `xn`, `v1`,..., `vm`.  The initializer expressions `initj` are expressions using any variables in scope.  The expression has type `$fun<T1,...,Tn; V>`, where `V` is the type of `expr`.
     157There are two kinds of lambda expressions.  The first kind defines a procedure, the second a logical function.
     158
     159Procedural lambda syntax:
     160{{{
     161  $lambda [U1 v1=init1; ... Um vm=initm;] R (T1 x1, ..., Tn xn) { S1; ... }
     162}}}
     163where
     164* the `Ti` and `Uj` are types
     165* the `xi` and `vj` are variables
     166* R is a type (the return type), which may be void
     167* {S1; ...} is a block (same as in function definition)
     168* the only variables that can occur free in the block are the xi and vj
     169* if R is not void, the block must return a value of type R
     170
     171The type of this expression is `R(T1, ..., Tn)`.
     172
     173Logic function lambda syntax:
     174{{{
     175  $lambda [U1 v1=init1; ... Um vm=initm;] R (T1 x1, ..., Tn xn) expr
     176}}}
     177where
     178* the `Ti` and `Uj` are types
     179* the `xi` and `vj` are variables
     180* R is a type (the return type), which cannot be void
     181* `expr` is a side-effect-free expression of type R
     182* the only variables that can occur free in `expr` are the xi and vj
     183
     184The type of this expression is `$fun<R, T1, ..., Tn>`.
     185
     186In both cases, the initializer expressions `initj` are expressions using any variables in scope.
    162187
    163188==== Semantics
     189
     190FIX THIS:  difference between logic and procedural functions...
     191
     192
    164193
    165194The lambda expression is evaluated to yield a *closure*:  an ordered pair consisting of a dyscope and an expression.  The dyscope has variables `v1`, ..., `vm`, initialized by evaluating `init1`, ..., `initm`.  The dyscope has no parent scope, it is associated only with the closure.  The expression is `expr`.  The dyscope is destroyed whenever it becomes unreachable, i.e., whenever no part of the state is assigned the closure.