Binary_Integer_Tree Module Interface Specification

(0) CHARACTERISTICS

-type specified: tree

-features: deterministic, non-parameterized

-foreign types: path

(1) SYNTAX

ACCESS-PROGRAMS

Program Name
Arg#1Arg#2Arg#3Arg#4Result Type
SETNILtree:O       
SETTREEtree:Oint:Vtree:Vtree:V 
ALTERNODEtree:VOpath:Vint:V   
ALTERTREEtree:VOpath:Vtree:V   
GETNODEtree:Vpath:V    int

(2) CANONICAL TRACES

canonical(T) T = _ i:<int>; U,V:<tree> [T = SETTREE(*, i, U, V) ]

AUXILIARY FUNCTIONS

change: <tree> × <path> × <int> <tree>

change(R, P, j) (validpath(R, P)) =

ConditionValue
path::emptypath(P)SETTREE(*, j, U, V) where U,V:<tree>; i:<int> [R = SETTREE(*, i, U, V) ]
path::goleft(P)SETTREE(*, i, change(U, path::subpath(P), j), V) where U,V:<tree>; i:<int> [R = SETTREE(*, i, U, V) ]
path::goright(P)SETTREE(*, i, U, change(V, path::subpath(P), j)) where U,V:<tree>; i:<int> [R = SETTREE(*, i, U, V) ]

getval: <tree> × <path> <int>

getval(R, P) (validpath(R, P)) =

ConditionValue
path::emptypath(P)i where U,V:<tree>; i:<int> [R = SETTREE(*, i, U, V) ]
path::goleft(P)getval(U, path::subpath(P)) where U,V:<tree>; i:<int> [R = SETTREE(*, i, U, V) ]
path::goright(P)getval(V, path::subpath(P)) where U,V:<tree>; i:<int> [R = SETTREE(*, i, U, V) ]

update: <tree> × <path> × <tree> <tree>

update(R, P, X) (validpath(R, P)) =

ConditionValue
path::emptypath(P)X
path::goleft(P)SETTREE(*, i, update(U, path::subpath(P), X), V) where U,V:<tree>; i:<int> [R = SETTREE(*, i, U, V) ]
path::goright(P)SETTREE(*, i, U, update(V, path::subpath(P), X)) where U,V:<tree>; i:<int> [R = SETTREE(*, i, U, V) ]

validpath: <tree> × <path> <bool>

validpath(R, P) = i:<int>; U,V:<tree> [R = SETTREE(*, i, U, V) (path::emptypath(P) path::goleft(P) validpath(U, path::subpath(P)) path::goright(P) validpath(V, path::subpath(P)))]

(3) SEMANTICS

ACCESS-PROGRAMS

Legality(SETNIL(n)) = %legal%

SETNIL(n ) = _

Legality(SETTREE(n, i, U, V)) = %legal%

SETTREE(n , i, U, V) = SETTREE(*, i, U, V)

Legality(ALTERNODE((n, T), P, i)) =

ConditionValue
¬validpath(T, P)%invalidpath%
validpath(T, P)%legal%

ALTERNODE((n, T) , P, i) = change(T, P, i)

Legality(ALTERTREE((n, T), P, X)) =

ConditionValue
¬validpath(T, P)%invalidpath%
validpath(T, P)%legal%

ALTERTREE((n, T) , P, X) = update(T, P, X)

Legality(GETNODE(T, P)) =

ConditionValue
¬validpath(T, P)%invalidpath%
validpath(T, P) T = _ %empty%
validpath(T, P) T _%legal%

GETNODE(T, P) = getval(T, P)