next up previous contents
Next: D User-Defined Sorts Dialog Up: RELFUN Guide: Programming with Previous: B Type-System Dialog

C Builtin-Sorts Dialog

 

rfi-p> exec "buisob.bat"

relfun
rfi-p> sp
rfi-p> destroy
rfi-p> inter
rfi-p> sortstyle static
rfi-p> destroy-sortbase
rfi-p> 
rfi-p> %  EXAMPLES FOR BUILTIN SORTS
rfi-p> % ============================
rfi-p> 
rfi-p> 
rfi-p> % Simone Andel
rfi-p> 
rfi-p> % The builtin sorts $atom, $symbolp, $stringp, $numberp, $floatp,
rfi-p> % $integerp, $oddp and $evenp are structured as shown below. In contrast
rfi-p> % to user-defined sorts in the sortbase they have infinite extensions. 
rfi-p> % This causes an error on unification of exclusions with builtin sorts.
rfi-p> %
rfi-p> %                         $atom
rfi-p> %                        /  |   \
rfi-p> %                       /   |    \
rfi-p> %               $numberp $symbolp $stringp
rfi-p> %                /   \
rfi-p> %          $floatp   $integerp
rfi-p> %                      /   \
rfi-p> %                 $evenp   $oddp
rfi-p> %
rfi-p> 
rfi-p> % Compute glb of two builtin sorts: 
rfi-p> $integerp is $floatp
unknown
rfi-p> $integerp is $oddp
bnd[_2*0,$oddp]
rfi-p> $oddp is $integerp
bnd[_2*0,$oddp]
rfi-p> 
rfi-p> % Compute glb of a domain and a builtin sort:
rfi-p> X is dom[1,2,3,4,5,6,a,b], X is $integerp
bnd[X,dom[1,2,3,4,5,6]]
X=dom[1,2,3,4,5,6]
rfi-p> X is dom[1,2,3,4,5,6,a,b], X is $symbolp
bnd[X,dom[a,b]]
X=dom[a,b]
rfi-p> X is dom[1,2,3,4,5,6], X is $oddp
bnd[X,dom[1,3,5]]
X=dom[1,3,5]
rfi-p> 
rfi-p> % Computation of glb of an exclusion and a builtin sort returns an error:
rfi-p> X is exc[1,2,3,4], X is $evenp
error (unify): glb is not computable between exclusion and builtin-sort
rfi-p> 
rfi-p> mcd sortbase
Module:  sortbase
Context: 
rfi-p> consult "int.rfp"
Reading file "int.rfp"
rfi-p> compile-sortbase
rfi-p> listing
subsumes(int,num).
int(0).
int(1).
int(2).
int(3).
int(4).
int(5).
num(2).
rfi-p> mcd
Module:  workspace
Context: 
rfi-p> 
rfi-p> % Compute glb of an user-defined and a builtin-sort: 
rfi-p> $int is $oddp 
bnd[_2*0,dom[1,3,5]]
rfi-p> $int is $integerp
bnd[_2*0,dom[0,1,2,3,4,5]]
rfi-p> $evenp is $int
bnd[_2*0,dom[0,2,4]]
rfi-p> $num is $evenp
2
rfi-p> 
rfi-p> % Compute glb of two user-defined sorts:
rfi-p> $int is $num
bnd[_2*0,$num]
rfi-p>



Harold Boley (boley@informatik.uni-kl.de)