☰

*ON THIS PAGE*# share: sharing (abstract domain)

**Author(s):** Kalyan Muthukumar, Maria Garcia de la Banda, Francisco Bueno. **Meaning of the Program Variables** `domain_dependent.pl`.

## Usage and interface

## Documentation on exports

## Documentation on multifiles

## Documentation on imports

This module has the following direct dependencies:

- The CiaoPP Program Processor »

- PART I - Using CiaoPP »

- Available abstract domains »

**share: sharing (abstract domain)**

**Stability: [****prod****] **Apt for production use (but please report any bugs).

- BPrime : similar to the abstract prime constraint: abstract subtitution obtained after the analysis of the clause being considered still projected onto Hv (i.e. just before going Sv and thus, to Prime).
- Binds : List of primitive bindings corresponding to the unification of Term1 = Term2.
- Gv : set of ground variables (can be added as a prefix of a set of variables, e.g. GvHv means the set of ground variables of the head variables).
- Partition: Set of set of variables in which ach variable appears only in one set. It is the result of a transitive closure.
- _args : Added as a prefix of a term, means the set of variables s.t. the i-th set contains the set of variables (ordered) in the i-th argument of the Term.
- Star : a closure under union of a set of sets (can be added as a suffix of a set of sets).
- ArgShare : Sets of numbers representing the possible set sharing among the argument positions indicated by the numbers.
- ShareArgs: Set of sets of numbers in which each set represents the possible set sharing among the argument positions indicated by the numbers.

**Library usage:**`:- use_module(domain(sharing)).`**Exports:***Predicates:*`project/5`,`project_share/3`,`call_to_entry/9`,`exit_to_prime/7`,`abs_sort/2`,`compute_lub/2`,`lub/3`,`glb/3`,`extend/5`,`call_to_success_fact/9`,`call_to_prime_fact/6`,`pos/4`,`script_p_star/3`,`script_p/3`,`unknown_entry/3`,`empty_entry/3`,`asub_to_native/5`,`input_user_interface/5`,`input_interface/4`,`unknown_call/4`,`less_or_equal/2`,`special_builtin/5`,`success_builtin/6`,`call_to_success_builtin/6`.*Multifiles:*`aidomain/1`,`aidom.init_abstract_domain/2`,`aidom.amgu/5`,`aidom.augment_asub/4`,`aidom.augment_two_asub/4`,`aidom.call_to_entry/10`,`aidom.exit_to_prime/8`,`aidom.project/6`,`aidom.widencall/4`,`aidom.needs/2`,`aidom.widen/4`,`aidom.compute_lub/3`,`aidom.compute_clauses_lub/4`,`aidom.compute_clauses_glb/4`,`aidom.fixpoint_covered/3`,`aidom.fixpoint_covered_gfp/3`,`aidom.identical_abstract/3`,`aidom.abs_sort/3`,`aidom.extend/6`,`aidom.less_or_equal/3`,`aidom.glb/4`,`aidom.eliminate_equivalent/3`,`aidom.abs_subset/3`,`aidom.call_to_success_fact/10`,`aidom.special_builtin/6`,`aidom.combined_special_builtin0/3`,`aidom.body_succ_builtin/9`,`aidom.split_combined_domain/4`,`aidom.success_builtin/7`,`aidom.call_to_success_builtin/7`,`aidom.obtain_info/5`,`aidom.input_interface/5`,`aidom.input_user_interface/6`,`aidom.asub_to_native/6`,`aidom.concrete/4`,`aidom.unknown_call/5`,`aidom.unknown_entry/4`,`aidom.empty_entry/4`,`aidom.part_conc/5`,`aidom.multi_part_conc/4`,`aidom.collect_auxinfo_asub/4`,`aidom.rename_auxinfo_asub/4`,`aidom.dom_statistics/2`,`aidom.contains_parameters/2`.

PREDICATEproject/5

Usage:`project(Sg,Vars,HvFv_u,ASub,Proj)`

Eliminates from each element of the list of lists of variables given as second argument any variable which is not an element of the first argument. Both ordered. i.e. Proj = `{` Ys | Xs in ASub, Ys = Xs intersect Vars `}`

*The following properties should hold at call time:*

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)Vars is currently a term which is not a free variable.

(`nonvar/1`)HvFv_u is currently a term which is not a free variable.

(`nonvar/1`)ASub is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)Proj is currently a term which is not a free variable.

PREDICATEproject_share/3

No further documentation available for this predicate.

PREDICATEcall_to_entry/9

Usage:`call_to_entry(Sv,Sg,Hv,Head,K,Fv,Proj,Entry,ExtraInfo)`

It obtains the abstract substitution (Entry) which results from adding the abstraction of the Sg = Head to Proj, later projecting the resulting substitution onto Hv. This is done as follows:

- If Sg and Head are identical up to renaming it is just a question or renaming Proj and adding the Fv as singletons.
- If Hv = [], Entry is just the Fv as singletons.
- Otherwise, it will
- obtain Gv1 (ground variables in Sv due to Proj).
- obtain Binds (sorted list of primitive equations corresponding to the equation Sg = Head).
- obtain Gv2 (variables in Sv or Hv involved in a primitive equation with a ground term).
- propagate the groundnes of Gv1 and Gv2 to Proj through Binds obtaining NewBinds (grounding bindings eliminated) NewProj (ground variables eliinated) Gv (final set of ground variables) GvSv and GvHv (subset of vars in Gv belonging to Sg and Head respectively).
- then it obtains Partition (the transitive closure of due to the sharing established by NewProj) and H_partition (Partition projected onto the Hv variables).
- then it obtains in ShareArgsStar the star of the sharing among the arguments of Sg established by NewProj, and in Head_args the set of variables belonging to each argument of Head.
- Then the idea is to obtain Entry by computing the powerset of each equivalence class in H_partition and eliminating those sets in the powerset which are not allowed (they would imply sharing among arguments in the head while there is no sharing among those arguments in ShareArgsStar).

*The following properties should hold at call time:*

(`nonvar/1`)Sv is currently a term which is not a free variable.

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)Hv is currently a term which is not a free variable.

(`nonvar/1`)Head is currently a term which is not a free variable.

(`nonvar/1`)K is currently a term which is not a free variable.

(`nonvar/1`)Fv is currently a term which is not a free variable.

(`nonvar/1`)Proj is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)Entry is currently a term which is not a free variable.

(`nonvar/1`)ExtraInfo is currently a term which is not a free variable.

PREDICATEexit_to_prime/7

Usage:`exit_to_prime(Sg,Hv,Head,Sv,Exit,ExtraInfo,Prime)`

It computes the prime abstract substitution Prime, i.e. the result of going from the abstract substitution over the head variables (Exit), to the abstract substitution over the variables in the subgoal. It will:

- If Exit is
`$bottom`, Prime will be also`$bottom`. - If Flag = yes (Head and Sg identical up to renaming) it is just a question or renaming Exit.
- If Hv = [], Prime = [].
- Otherwise, it will:
- project Exit onto Hv obtaining BPrime.
- subtract from Hv those vars which were ground due to the equation Head = Sg (Gv) obtaining Hv_rem.
- obtain the vars Hv_rem which had becomed ground after the of the clause (NewGv_Hv).
- Then if NewGv_Hv is
`==`[], groundness must be propagated to obtain ASub. - Otherwise, ASub is just equal to NewProj.
- Then Prime is obtained by obtaining New_partition (transitive closure of the sharing specified in BPrime) and performing the same kind of prunning that in the
`call_to_entry`but in the opposite direction.

*The following properties should hold at call time:*

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)Hv is currently a term which is not a free variable.

(`nonvar/1`)Head is currently a term which is not a free variable.

(`nonvar/1`)Sv is currently a term which is not a free variable.

(`nonvar/1`)Exit is currently a term which is not a free variable.

(`nonvar/1`)ExtraInfo is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)Prime is currently a term which is not a free variable.

PREDICATEabs_sort/2

Usage:`abs_sort(Asub,Asub_s)`

sorts the set of set of variables ASub to obtaint the Asub_s.

PREDICATEcompute_lub/2

Usage:`compute_lub(ListASub,Lub)`

It computes the lub of a set of Asub. For each two abstract substitutions ASub1 and ASub2 in ListASub, obtaining the lub is just merging the ASub1 and ASub2.

PREDICATElub/3

No further documentation available for this predicate.

PREDICATEglb/3

Usage:`glb(ASub0,ASub1,Lub)`

Glb is just intersection.

PREDICATEextend/5

Usage:`extend(Sg,Prime,Sv,Call,Succ)`

If Prime = `bottom`, Succ = `bottom`. If Sv = [], Call = Succ. Otherwise, it splits Call into two sets of sets: Intersect (those sets containing at least a variabe in Sv) and Disjunct (the rest). Then is obtains in Star the closure under union of Intersect. Finally, it prunes Star with the information in Prime adding, at the end, Disjunct.

*The following properties should hold at call time:*

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)Prime is currently a term which is not a free variable.

(`nonvar/1`)Sv is currently a term which is not a free variable.

(`nonvar/1`)Call is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)Succ is currently a term which is not a free variable.

PREDICATEcall_to_success_fact/9

Usage:

Specialized version of `call_to_entry` + `exit_to_prime` + `extend` for facts

PREDICATEcall_to_prime_fact/6

No further documentation available for this predicate.

PREDICATEpos/4

Usage:`pos(Xss,Arg,Xs,ArgShare)`

Xss is a list containing in each Set_i the variables in the i-th arg of the Term. Arg is the number of the current arg. Xs is a sorted list of variables. It will obtain ArgShare, the set of arguments in at least one variable in Xs appears.

*The following properties should hold at call time:*

(`nonvar/1`)Xss is currently a term which is not a free variable.

(`nonvar/1`)Arg is currently a term which is not a free variable.

(`nonvar/1`)Xs is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)ArgShare is currently a term which is not a free variable.

PREDICATEscript_p_star/3

Usage:`script_p_star(Atom,ASub,ShareArgsStar)`

It first obtains in ArgSare_info the set of sets of argument numbers of Atom each one corresponding to each set in ASub. Then it obtains the closure under union.

*The following properties should hold at call time:*

(`nonvar/1`)Atom is currently a term which is not a free variable.

(`nonvar/1`)ASub is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)ShareArgsStar is currently a term which is not a free variable.

PREDICATEscript_p/3

No further documentation available for this predicate.

PREDICATEunknown_entry/3

Usage:`unknown_entry(Sg,Qv,Call)`

The top value in Sharing for a set of variables is the powerset.

PREDICATEempty_entry/3

Usage:`empty_entry(Sg,Vars,Entry)`

Gives the *empty* value in this domain for a given set of variables Vars, resulting in the abstract substitution Entry. I.e., obtains the abstraction of a substitution in which all variables Vars are unbound: free and unaliased. In this domain is the list of singleton lists of variables.

*The following properties should hold at call time:*

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)Vars is currently a term which is not a free variable.

(`cgoal/1`)Sg is a term which represents a goal, i.e., an atom or a structure.

(`list/1`)Vars is a list.

(`absu/1`)Entry is an abstract substitution*The following properties should hold upon exit:*

(`nonvar/1`)Entry is currently a term which is not a free variable.

PREDICATEasub_to_native/5

Usage:`asub_to_native(ASub,Qv,OutFlag,ASub_user,Comps)`

The user friendly format consists in extracting the ground variables.

*The following properties should hold at call time:*

(`nonvar/1`)ASub is currently a term which is not a free variable.

(`nonvar/1`)Qv is currently a term which is not a free variable.

(`nonvar/1`)OutFlag is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)ASub_user is currently a term which is not a free variable.

(`nonvar/1`)Comps is currently a term which is not a free variable.

PREDICATEinput_user_interface/5

Usage:`input_user_interface(InputUser,Qv,ASub,Sg,MaybeCallASub)`

Obtaining the abstract substitution for Sharing from the user supplied information just consists in taking the `mshare(Sharing)` element of InputUser and sorting it. If there is no such element, get the *top* sharing for the variables involved.

*The following properties should hold at call time:*

(`nonvar/1`)Qv is currently a term which is not a free variable.

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)MaybeCallASub is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)ASub is currently a term which is not a free variable.

PREDICATEinput_interface/4

No further documentation available for this predicate.

PREDICATEunknown_call/4

Usage:`unknown_call(Sg,Vars,Call,Succ)`

Obtained by selecting those sets in Call for which at least a variable in Vars appears, making the star of those sets, and adding the sets with empty intersection with Vars.

*The following properties should hold at call time:*

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)Vars is currently a term which is not a free variable.

(`nonvar/1`)Call is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)Succ is currently a term which is not a free variable.

PREDICATEless_or_equal/2

PREDICATEspecial_builtin/5

Usage:`special_builtin(SgKey,Sg,Subgoal,Type,Condvars)`

Satisfied if the builtin does not need a very complex action. It divides builtins into groups determined by the flag returned in the second argument + some special handling for some builtins:

*ground*: if the builtin makes all variables ground whithout imposing any condition on the previous freeness values of the variables.*bottom*: if the abstract execution of the builtin returns bottom*.*unchanged*: if we cannot infer anything from the builtin, the substitution remains unchanged and there are no conditions imposed on the previous freeness values of the variables.*some*: if it makes some variables ground without imposing conditions.- Sgkey : special handling of some particular builtins.

*The following properties should hold at call time:*

(`nonvar/1`)SgKey is currently a term which is not a free variable.

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)Subgoal is currently a term which is not a free variable.

(`var/1`)Condvars is a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)Type is currently a term which is not a free variable.

PREDICATEsuccess_builtin/6

Usage:`success_builtin(Type,Sv_u,Condv,HvFv_u,Call,Succ)`

Obtains the success for some particular builtins:

- If Type =
*ground*, it updates Call making all vars in Sv_u ground. - If Type =
*bottom*, Succ =`$bottom`. - If Type =
*unchanged*, Succ = Call. - If Type =
*some*, it updates Call making all vars in Condv ground. - Otherwise Type is the SgKey of a particular builtin for each the Succ is computed.

*The following properties should hold at call time:*

(`nonvar/1`)Type is currently a term which is not a free variable.

(`nonvar/1`)Sv_u is currently a term which is not a free variable.

(`nonvar/1`)Call is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)Succ is currently a term which is not a free variable.

PREDICATEcall_to_success_builtin/6

Usage:`call_to_success_builtin(SgKey,Sg,Sv,Call,Proj,Succ)`

Handles those builtins for which computing Prime is easier than Succ.

*The following properties should hold at call time:*

(`nonvar/1`)SgKey is currently a term which is not a free variable.

(`nonvar/1`)Sg is currently a term which is not a free variable.

(`nonvar/1`)Sv is currently a term which is not a free variable.

(`nonvar/1`)Call is currently a term which is not a free variable.

(`nonvar/1`)Proj is currently a term which is not a free variable.*The following properties should hold upon exit:*

(`nonvar/1`)Succ is currently a term which is not a free variable.

PREDICATEaidomain/1

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.init_abstract_domain/2

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.amgu/5

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.augment_asub/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.augment_two_asub/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.call_to_entry/10

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.exit_to_prime/8

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.project/6

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.widencall/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.needs/2

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.widen/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.compute_lub/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.compute_clauses_lub/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.compute_clauses_glb/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.fixpoint_covered/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.fixpoint_covered_gfp/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.identical_abstract/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.abs_sort/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.extend/6

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.less_or_equal/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.glb/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.eliminate_equivalent/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.abs_subset/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.call_to_success_fact/10

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.special_builtin/6

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.combined_special_builtin0/3

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.body_succ_builtin/9

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.split_combined_domain/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.success_builtin/7

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.call_to_success_builtin/7

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.obtain_info/5

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.input_interface/5

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.input_user_interface/6

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.asub_to_native/6

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.concrete/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.unknown_call/5

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.unknown_entry/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.empty_entry/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.part_conc/5

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.multi_part_conc/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.collect_auxinfo_asub/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.rename_auxinfo_asub/4

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.dom_statistics/2

No further documentation available for this predicate.
The predicate is *multifile*.

PREDICATEaidom.contains_parameters/2

No further documentation available for this predicate.
The predicate is *multifile*.

*Application modules:*`preprocess_flags`,`domains`,`sharing_amgu`,`s_grshfr`,`eterms`,`share_aux`.*System library modules:*`sets`,`sort`,`lsets`,`terms_check`,`terms_vars`,`lists`,`typeslib`.*Internal (engine) modules:*`term_basic`,`arithmetic`,`atomic_basic`,`basiccontrol`,`exceptions`,`term_compare`,`term_typing`,`debugger_support`,`basic_props`,`hiord_rt`.*Packages:*`prelude`,`initial`,`condcomp`,`assertions`,`assertions/assertions_basic`,`regtypes`,`modes_extra`,`modes`,`aidomain`.

Generated with LPdoc using Ciao