Variable name dictionaries
Author(s): Francisco Bueno, Edison Mera.Usage and interface
- Library usage:
:- use_module(library(vndict)). - Exports:
- Predicates:
create_dict/2, create_pretty_dict/2, complete_dict/3, complete_vars_dict/3, prune_dict/3, sort_dict/2, dict2varnamesl/2, varnamesl2dict/2, find_name/4, prettyvars/2, rename/2, vars_names_dict/3. - Regular Types:
null_dict/1, varnamedict/1.
- Predicates:
- Imports:
- System library modules:
varnames/dict_types, idlists, terms_vars, sets, sort. - Packages:
prelude, nonpure, assertions, basicmodes, regtypes.
- System library modules:
Documentation on exports
Usage:create_dict(Term,Dict)
Dict has names for all variables in Term.
- The following properties should hold at call time:
(basic_props:term/1)Term is any term. - The following properties should hold upon exit:
(vndict:varnamedict/1)Dict is a dictionary of variable names.
Usage:create_pretty_dict(Term,Dict)
Dict has names for all variables in Term. The difference with create_dict/2 is that prettier names are generated
- The following properties should hold at call time:
(basic_props:term/1)Term is any term. - The following properties should hold upon exit:
(vndict:varnamedict/1)Dict is a dictionary of variable names.
Usage:complete_dict(Dict,Term,NewDict)
NewDict is Dict augmented with the variables of Term not yet in Dict.
- The following properties should hold at call time:
(term_typing:nonvar/1)Dict is currently a term which is not a free variable.
(term_typing:nonvar/1)Term is currently a term which is not a free variable.
(term_typing:var/1)NewDict is a free variable.
Usage:complete_vars_dict(Dict,Vars,NewDict)
NewDict is Dict augmented with the variables of the list Vars not yet in Dict.
- The following properties should hold at call time:
(term_typing:nonvar/1)Dict is currently a term which is not a free variable.
(term_typing:nonvar/1)Vars is currently a term which is not a free variable.
(term_typing:var/1)NewDict is a free variable.
Usage:prune_dict(Term,Dict,NewDict)
NewDict is Dict reduced to just the variables of Term.
- The following properties should hold at call time:
(term_typing:nonvar/1)Term is currently a term which is not a free variable.
(term_typing:nonvar/1)Dict is currently a term which is not a free variable.
(term_typing:var/1)NewDict is a free variable.
Usage:sort_dict(D,Dict)
D is sorted into Dict.
- The following properties should hold at call time:
(vndict:varnamedict/1)D is a dictionary of variable names. - The following properties should hold upon exit:
(vndict:varnamedict/1)Dict is a dictionary of variable names.
Usage:dict2varnamesl(Dict,VNs)
Translates Dict to VNs.
- The following properties should hold at call time:
(vndict:varnamedict/1)Dict is a dictionary of variable names. - The following properties should hold upon exit:
(dict_types:varnamesl/1)VNs is a list of Name=Var pairs, where Var is a variable and Name its name.
Usage:varnamesl2dict(VNs,Dict)
Translates VNs to Dict.
- The following properties should hold at call time:
(dict_types:varnamesl/1)VNs is a list of Name=Var pairs, where Var is a variable and Name its name. - The following properties should hold upon exit:
(vndict:varnamedict/1)Dict is a dictionary of variable names.
Given that vars_names_dict(Dict,Vars,Names) holds, it acts as rename(X,Dict), but the name of X is given as Name instead of unified with it.
Usage:
Give names to the variables in the term Term using the dictionary Dict. Intended to replace prettyvars/1 in those places where is possible to get the dictionary of variables.
- Call and exit should be compatible with:
(basic_props:term/1)Arg1 is any term.
(dict_types:varnamesl/1)Arg2 is a list of Name=Var pairs, where Var is a variable and Name its name. - The following properties should hold at call time:
(term_typing:nonvar/1)Arg2 is currently a term which is not a free variable.
Usage:rename(Term,Dict)
Unifies each variable in Term with its name in Dict. If no name is found, a new name is created.
- The following properties should hold at call time:
(vndict:varnamedict/1)Dict is a dictionary of variable names.
Usage:vars_names_dict(Dict,Vars,Names)
Varss is a sorted list of variables, and Names is a list of their names, which correspond in the same order.
- Call and exit should be compatible with:
(vndict:varnamedict/1)Dict is a dictionary of variable names.
(basic_props:list/1)Vars is a list.
(basic_props:list/1)Names is a list.