Term manipulation utilities

Author(s): The CLIP Group.

This module implements some utils to do term manipulation.

Usage and interface

Documentation on exports

PREDICATE

(True) Usage:term_size(Term,N)

Determines the size of a term.

  • The following properties should hold at call time:
    (basic_props:term/1)Term is any term.
    (basic_props:nnegint/1)N is a non-negative integer.
General properties:

Test:term_size(A,B)

  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=p(a,b,c(d,e))
    then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:B=6

Test:term_size(A,B)

  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=p(a,b,c(d,_241827))
    then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:B=6

Test:term_size(A,B)

  • If the following properties should hold at call time:
    (term_basic:= /2)term_basic:A=[1,2,3]
    then the following properties should hold upon exit:
    (term_basic:= /2)term_basic:B=7

PREDICATE

Usage:copy_args(N,Term,Copy)

Term and Copy have the same first N arguments.

  • The following properties should hold at call time:
    (basic_props:nnegint/1)N is a non-negative integer.
General properties:

Trust:copy_args(N,Term,Copy)

  • If the following properties hold at call time:
    (term_typing:ground/1)N is currently ground (it contains no variables).
    (term_typing:nonvar/1)Term is currently a term which is not a free variable.
    then the following properties hold globally:
    (basic_props:eval/1)copy_args(N,Term,Copy) is evaluable at compile-time.

Trust:copy_args(N,Term,Copy)

  • The following properties hold globally:
    (basic_props:sideff/2)copy_args(N,Term,Copy) is side-effect free.

PREDICATE

Usage:arg(Term,Arg)

Arg is an argument of Term. Gives each of the arguments on backtracking.

    PREDICATE
    atom_concat(Atms,Atm)

    Atm is the atom resulting from concatenating all atoms in the list Atms in the order in which they appear. If Atm is an atom at call then Atms can contain free variables.

    Usage 1:atom_concat(Atms,Atm)

    • The following properties should hold at call time:
      (basic_props:list/2)Atms is a list of atms.
    • The following properties should hold upon exit:
      (basic_props:atm/1)Atm is an atom.

    Usage 2:atom_concat(Atms,Atm)

    • Call and exit should be compatible with:
      (basic_props:list/2)Atms is a list of atms.
    • The following properties should hold at call time:
      (basic_props:atm/1)Atm is an atom.
    • The following properties should hold upon exit:
      (basic_props:list/2)Atms is a list of atms.
    General properties:

    Test:atom_concat(A,B)

    • If the following properties should hold at call time:
      (term_basic:= /2)term_basic:A=[/home/edison/svn/dist/CiaoDE/bin,/,X,-,1.11,]
      (term_basic:= /2)term_basic:B=/home/edison/svn/dist/CiaoDE/bin/fileinfo-1.11
      then the following properties should hold upon exit:
      (term_compare:== /2)The terms X and fileinfo are strictly identical.

    Test:atom_concat(A,B)

    • If the following properties should hold at call time:
      (term_basic:= /2)term_basic:A=[a,b,c]
      then the following properties should hold upon exit:
      (term_compare:== /2)The terms B and abc are strictly identical.

    Test:atom_concat(X,Y)

    atom_concat that generates several solutions.

    • If the following properties should hold at call time:
      (term_basic:= /2)term_basic:X=[a,B|C]
      (term_basic:= /2)term_basic:Y=abcde
      then the following properties should hold upon exit:
      (basic_props:member/2)B,C is an element of [(,[b,c,d,e]),(,[b,c,de]),(,[b,cd,e]),(,[b,cde]),(,[bc,d,e]),(,[bc,de]),(,[bcd,e]),(,[bcde]),(b,[c,d,e]),(b,[c,de]),(b,[cd,e]),(b,[cde]),(bc,[d,e]),(bc,[de]),(bcd,[e]),(bcde,[])].

    Test:atom_concat(X,Y)

    atom_concat that generates several solutions.

    • If the following properties should hold at call time:
      (term_basic:= /2)term_basic:X=[a,B|C]
      (term_basic:= /2)term_basic:Y=abcde
      then the following properties should hold globally:
      (native_props:solutions/2)Goal atom_concat(X,Y) produces the solutions listed in [atom_concat([a,,b,c,d,e],abcde),atom_concat([a,,b,c,de],abcde),atom_concat([a,,b,cd,e],abcde),atom_concat([a,,b,cde],abcde),atom_concat([a,,bc,d,e],abcde),atom_concat([a,,bc,de],abcde),atom_concat([a,,bcd,e],abcde),atom_concat([a,,bcde],abcde),atom_concat([a,b,c,d,e],abcde),atom_concat([a,b,c,de],abcde),atom_concat([a,b,cd,e],abcde),atom_concat([a,b,cde],abcde),atom_concat([a,bc,d,e],abcde),atom_concat([a,bc,de],abcde),atom_concat([a,bcd,e],abcde),atom_concat([a,bcde],abcde)].

    Test:atom_concat(X,Y)

    • If the following properties should hold at call time:
      (term_basic:= /2)term_basic:X=[A,b,C]
      (term_basic:= /2)term_basic:Y=abc
      then the following properties should hold upon exit:
      (term_compare:== /2)The terms A and a are strictly identical.
      (term_compare:== /2)The terms C and c are strictly identical.

    Test:atom_concat(X,Y)

    • If the following properties should hold at call time:
      (term_basic:= /2)term_basic:X=[A,b,]
      (term_basic:= /2)term_basic:Y=ab
      then the following properties should hold upon exit:
      (term_basic:= /2)term_basic:A=a