byte_sequence Module Interface Specification

Informal Introduction

Unix file is a sequence of bytes.

(0) CHARACTERISTICS

-type specified: sequence

-features: deterministic, non-parameterized

-foreign types: byte, global

(1) SYNTAX

ACCESS-PROGRAMS

Program Name
Arg#1Arg#2Arg#3Result Type
PUTsequence:VOint:Vbyte:V 
GETsequence:Vint:Vbyte:VO 
TRUNCsequence:VOint:V   
SIZEsequence: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) =

ConditionValue
s = _ 0
! s1:<sequence>; p:<int>; b:<byte> [s = s1.PUT(*, p, b) ]p + 1

get: <sequence> × <int> <byte>

get(seq, pos) =

ConditionValue
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-PROGRAMS

Legality(PUT((n, T), p, b)) =

ConditionValue
p < 0 p global::G_sequence_size()%invalid position%
p 0 p < global::G_sequence_size()%legal%

PUT((n, T) , p, b) =

ConditionValue
! 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))) =

ConditionValue
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)) =

ConditionValue
p < 0 p global::G_sequence_size()%invalid position%
p 0 p < global::G_sequence_size()%legal%

TRUNC((n, T) , p) =

ConditionValue
size(T) pT
! 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)