Changes between Version 13 and Version 14 of PIL
- Timestamp:
- 10/05/24 16:53:06 (19 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PIL
v13 v14 155 155 156 156 Expressions: these are all side-effect-free, assuming `expr1`, ... are side-effect-free. 157 - `t1 == t2` : the two tuples have the same number of components and corresponding components are equal 158 - `t.i` : the value of component `i` (a constant integer) of tuple `t` 159 - `($tuple<T1,...>){ expr1, ... }` : the literal tuple with the given list of components. 160 - `t.[i : expr1]` : the tuple which is the same as `t`, except for component `i` (a constant integer), which has value `expr1` 157 - `t1 == t2` 158 * the two tuples have the same type and corresponding components are equal 159 - `t.(i)` 160 * the value of component `i` (a constant integer) of tuple `t` 161 - `($tuple<T1,...>){ expr1, ... }` 162 * the literal tuple with the given list of components. 163 - `t[.(i) := expr1]` 164 *the tuple which is the same as `t`, except for component `i` (a constant integer), which has value `expr1` 161 165 162 166 Mutating expressions: 163 - `t. [i]= expr` : sets component `i` of tuple `t` to `expr`167 - `t.(i) = expr` : sets component `i` of tuple `t` to `expr` 164 168 165 169 == Sets … … 167 171 Side-effect free expressions: 168 172 - `s1 == s2` 169 - `($set<T>)$empty` // empty set of type T 173 * the two sets have the same type and contain the same elements 174 - `($set<T>)$empty` 175 * empty set of type T 170 176 171 177 Logic functions: 172 178 - `$pure $logic $bool $set_contains($set<T> s, T x);` 173 * is `x` an element of `s`?179 * is x an element of s? 174 180 - `$pure $logic $set<T> $set_with($set<T> s, T x);` 175 * `s` U {`x`}181 * s U {x} 176 182 - `$pure $logic $set<T> $set_without($set<T> s, T x);` 177 * `s` - {`x`}183 * s - {x} 178 184 - `$pure $logic $set<T> $set_union($set<T> s1, $set<T> s2);` 179 * `s1` U `s2`185 * s1 U s2 180 186 - `$pure $logic $set<T> $set_difference($set<T> s1, $set<T> s2);` 181 * `s1`-`s2`187 * s1-s2 182 188 - `$pure $logic $set_intersection($set<T> s1, $set<T> s2);` 183 * `s1` \cap `s2`189 * s1 \cap s2 184 190 - `$pure $logic T[] $set_elements($set<T> s);` 185 * returns the set of elements of `s`as an array in some deterministic order186 - `$pure $logic $bool $set_ isSubsetOf($set<T> s1, $set<T> s2);`187 * is `s1` a subset of `s2`?191 * returns the set of elements of s as an array in some deterministic order 192 - `$pure $logic $bool $set_subset($set<T> s1, $set<T> s2);` 193 * is s1 a subset of s2? 188 194 - `$pure $logic $set<U> $set_map($set<T> s, $fun<T,U> f);` 189 * { `f`(`x`) | `x` in `s`}195 * { f(x) | x in s} 190 196 - `$pure logic $set<T> $set_comprehension($set<T>, $fun<T,$bool> p);` 191 * { `x` in `s` | `p`(`x`) }197 * { x in s | p(x) } 192 198 193 199 Mutating procedures: … … 202 208 Expressions: 203 209 - `a1 == a2` 210 * the two arrays have the same type and length and corresponding elements are equal 204 211 - `a[i]` 212 * the `i`-th element of `a` 213 - `a[i:=x]` 214 * the sequence which is the same as `a`, exception in position `i`, where it has value `x` 205 215 - `(T[]){ expr1, ... }` 206 216 … … 209 219 - `$pure $logic T[] $seq_uniform($int n, T val);` 210 220 - `$pure $logic $int $length(T[] a);` // length of a 211 - `$pure $logic T[] $seq_write(T[] a, int i, T x);` // a[i:=x]212 221 - `$pure $logic T[] $seq_subseq(T[] a, int i, int n);` // a[i..i+n-1] 213 222 - `$pure $logic T[] $seq_without(T[] a, int i);` // a with position i removed … … 229 238 == Maps 230 239 231 Non-mutatingexpressions:240 Side-effect-free expressions: 232 241 - `m1 == m2` 233 242 - `($map<K,V>)$empty` 234 - `$logic V $map_get($map<K,V> K key);` 235 - `$logic $bool $map_containsKey($map<K,V> map, K key);` 236 - `$logic $bool $map_containsValue($map<K,V> map, V val);` 237 - `$logic $map<K,V> $map_with($map<K,V> map, K key, V val);` 238 - `$logic $map<K,V> $map_without($map<K,V> map, K key);` 239 - `$logic $set<K> $map_keys($map<K,V> map);` 240 - `$logic $set<$tuple<K,V>> $map_entries($map<K,V> map);` 243 244 Logic functions: 245 - `$pure $logic V $map_get($map<K,V> K key);` 246 - `$pure $logic $bool $map_containsKey($map<K,V> map, K key);` 247 - `$pure $logic $bool $map_containsValue($map<K,V> map, V val);` 248 - `$pure $logic $map<K,V> $map_with($map<K,V> map, K key, V val);` 249 - `$pure $logic $map<K,V> $map_without($map<K,V> map, K key);` 250 - `$pure $logic $set<K> $map_keys($map<K,V> map);` 251 - `$pure $logic $set<$tuple<K,V>> $map_entries($map<K,V> map);` 241 252 242 253 Mutating procedures: … … 246 257 - `void $map_addAll($map<K,V> * this, $map<K,V> that);` 247 258 248 249 259 == Heaps 250 260 251 261 There is a single heap for dynamic allocation. The following built-in procedures are provided: 252 262 253 - `T* $new<T>()`: creates an object `A` of type `T` in heap and returns `&A`. 254 - `T* $alloc<T>(int n)`: creates an array `A` of length `n` of `T` in heap and returns `&A[0]`. 255 - `void $free<T>(T* p)`: frees the object referred to by `p`, the pointer returned by an earlier call to `$new` or `$alloc`. 263 - `T* $new<T>()` 264 * creates an object `A` of type `T` in heap and returns `&A`. 265 - `T* $alloc<T>(int n)` 266 * creates an array `A` of length `n` of `T` in heap and returns `&A[0]`. 267 - `void $free<T>(T* p)` 268 * frees the object referred to by `p`, the pointer returned by an earlier call to `$new` or `$alloc`. 256 269 257 270 … … 261 274 * can there be nondeterministic expressions, i.e., expressions that evaluate to a set of values instead of one value? 262 275 * how to implement C's malloc? 276 * what to return when something is wrong, e.g., $map_get$ when the specified key is not in the map (default value of type?) 263 277 264 278 Ideas on malloc:
