--> **************************************************************** --> Generic Sequences --> **************************************************************** --> ---------------------------------------------------------------- --> SEQ: sequences (i.e. associative list) with {id: emp} --> ---------------------------------------------------------------- mod! SEQ (X :: TRIV) { [Elt < Seq] -- empty Sequence op emp : -> Seq {constr} . op __ : Seq Seq -> Seq {constr assoc id: emp} . } --> ---------------------------------------------------------------- --> TRIV=: TRIV with _=_ --> ---------------------------------------------------------------- mod* TRIV= { [Elt] -- equality on Elt pred _=e_ : Elt Elt {comm} . eq (E:Elt =e E) = true . cq [:nonexec]: E1:Elt = E2:Elt if (E1 =e E2) . } --> ---------------------------------------------------------------- --> SEQ= : SEQ with _=_ --> ---------------------------------------------------------------- mod! SEQ= (X :: TRIV=) { pr(SEQ(X)) -- equality on Seq pred _=s_ : Seq Seq {comm} . eq (S:Seq =s S:Seq) = true . cq [:nonexec]: S1:Seq = S2:Seq if (S1 =s S2) . -- for the case if either side is emp and other side is non-emp eq (emp =s (S1:Seq E:Elt S2:Seq)) = false . -- for the case if both sides are non-emp eq (E1:Elt S1:Seq =s E2:Elt S2:Seq) = ((E1 =e E2) and (S1 =s S2)) . } --> ---------------------------------------------------------------- --> SEQ=hd : SEQ= with hd_ --> ---------------------------------------------------------------- mod! SEQ=hd { pr(SEQ=) -- head (leftmost element) of a Seq op hd_ : Seq -> Elt . eq hd (E:Elt S:Seq) = E . } --> ---------------------------------------------------------------- --> provide seq provide seq --> **************************************************************** --> end of file eof --> ****************************************************************