Informal Introduction
Unix file is a sequence of bytes.
(0) CHARACTERISTICS
-type specified: sequence
-features: deterministic, non-parameterized
(1) SYNTAX
ACCESS-PROGRAMS
Arg#1 | Arg#2 | Arg#3 | Result Type | PUT | sequence:VO | int:V | byte:V | | GET | sequence:V | int:V | byte:VO | | TRUNC | sequence:VO | int:V | | | SIZE | sequence:V | | | int | |
---|
(2) CANONICAL TRACES
canonical(T) T = _ n:<int>; p[0]..p[n]:<int>; b[0]..b[n]:<byte>n 0 p[0] 0 p[n] < global::G_sequence_size() i:<int>0 i i < n [p[i] < p[i + 1]] [T = [PUT(*, p[i], b[i])]i=0..n ]AUXILIARY FUNCTIONS
errorval: <byte>
errorval() = -1
size: <sequence> <int>
size(s) =
Condition | Value |
---|---|
s = _ | 0 |
! s1:<sequence>; p:<int>; b:<byte> [s = s1.PUT(*, p, b) ] | p + 1 |
get: <sequence> × <int> <byte>
get(seq, pos) =
Condition | Value |
---|---|
pos < 0 pos global::G_sequence_size() | errorval() |
size(seq) pos pos < global::G_sequence_size() | global::EOF() |
¬( ! s1,s2:<sequence>; b:<byte> [seq = s1.PUT(*, pos, b).s2 ] 0 pos pos < size(seq)) | byte::_ |
! s1,s2:<sequence>; b:<byte> [seq = s1.PUT(*, pos, b).s2 ] | b |
(3) SEMANTICS
ACCESS-PROGRAMSLegality(PUT((n, T), p, b)) =
Condition | Value |
---|---|
p < 0 p global::G_sequence_size() | %invalid position% |
p 0 p < global::G_sequence_size() | %legal% |
PUT((n, T) , p, b) =
Condition | Value |
---|---|
! T1,T2:<sequence>; b1:<byte> [T = T1.PUT(*, p, b1).T2 ] | T1.PUT(*, p, b).T2 |
¬ ! T1,T2:<sequence>; b1:<byte> [T = T1.PUT(*, p, b1).T2 ] | T1.PUT(*, p, b).T2 where T1,T2:<sequence> [T = T1.T2 canonical(T1.PUT(*, p, b).T2)] |
Legality(GET(T, p, (n, b))) =
Condition | Value |
---|---|
p < 0 p global::G_sequence_size() | %invalid position% |
p 0 p < global::G_sequence_size() | %legal% |
GET(T, p, (n, b) ) = get(T, p)
Legality(TRUNC((n, T), p)) =
Condition | Value |
---|---|
p < 0 p global::G_sequence_size() | %invalid position% |
p 0 p < global::G_sequence_size() | %legal% |
TRUNC((n, T) , p) =
Condition | Value |
---|---|
size(T) p | T |
! T1,T2:<sequence>; p1,p2:<int>; b1,b2:<byte>p1 < p p p2 [T = T1.PUT(*, p1, b1).PUT(*, p2, b2).T2 ] | T1.PUT(*, p1, b1).[PUT(*, i, byte::_)]i=p1 + 1..p - 1 |
T1:<sequence>; p1:<int>; b1:<byte>p p1 [T = PUT(*, p1, b1) ] | _ |
Legality(SIZE(T)) = %legal%
SIZE(T) = size(T)