NAME

Language::MuldisD::Ext::Bag - Muldis D extension for Bag specific operators

VERSION

This document is Language::MuldisD::Ext::Bag version 0.20.0.

PREFACE

This document is part of the Muldis D language specification, whose root document is Language::MuldisD; you should read that root document before you read this one, which provides subservient details.

DESCRIPTION

Muldis D has a mandatory core set of system-defined (eternally available) entities, which is referred to as the Muldis D core or the core; they are the minimal entities that all Muldis D implementations need to provide; they are mutually self-describing and are used to bootstrap the language; any entities outside the core, called Muldis D extensions, are non-mandatory and are defined in terms of the core or each other, but the reverse isn't true.

This current Bag document describes the system-defined Muldis D Bag Extension, which consists of generic operators that are specific to the Bag parameterized relation type, and said operators are short-hands for generic relational operators in the language core.

This current document does not describe the polymorphic operators that all types, or some types including core types, have defined over them; said operators are defined once for all types in Language::MuldisD::Core.

This documentation is pending.

SYSTEM-DEFINED BAG-CONCERNING FUNCTIONS

function sys.Bag.Bag.cardinality result UInt params { topic(Bag) }

This function is like sys.Core.Relation.cardinality but that it accounts for the greater-than-one multiplicity of values in its argument; it results in the sum of the count attribute of its argument.

function sys.Bag.Bag.is_member result Bool params { bag(Bag), value(ScaTupRel) }

This function is the same as sys.Set.Set.is_member, including that matching of value is done against the value attribute, except that it works with a Bag rather than a Set.

function sys.Bag.Bag.is_not_member result Bool params { bag(Bag), value(ScaTupRel) }

This function is exactly the same as sys.Bag.Bag.is_member except that it results in the opposite boolean value when given the same arguments.

function sys.Bag.Bag.count result UInt params { bag(Bag), value(ScaTupRel) }

This function results in the multiplicity / count of occurrances of value in bag; if a tuple exists in bag whose value attribute is value, then the result is its count attribute; otherwise the result is zero.

function sys.Bag.Bag.insertion result Bag params { bag(Bag), value(ScaTupRel) }

This function is the same as sys.Set.Set.insertion as per is_member but that its result differs depending on whether value already exists in bag; if it does, then no new tuple is added, but the count attribute for the matching tuple is incremented by 1; if it does not, then a new tuple is added where its value is value and its count is 1.

function sys.Bag.Bag.deletion result Bag params { bag(Bag), value(ScaTupRel) }

This function is the same as sys.Set.Set.deletion as per is_member but that its result differs depending on what the count for any tuple matching value that already exists in bag is; if the count is greater than 1, then it is decremented by 1; if it is equal to 1, then the tuple whose value is value is deleted.

function sys.Bag.Bag.reduction result ScaTupRel params { topic(Bag), func(Cat.NameChain), assuming(Tuple), identity(ScaTupRel) }

This function is the same as sys.Set.Set.reduction, including that input values for the reduction come from the value attribute of topic, except that it works with a Bag rather than a Set; func is invoked extra times, where both its v1 and v2 arguments might be different instances of the same value having >= 2 multiplicity.

function sys.Bag.Bag.maybe_reduction result Maybe params { topic(Bag), func(Cat.NameChain), assuming(Tuple) }

This function is to sys.Set.Set.maybe_reduction as sys.Bag.Bag.reduction is to sys.Set.Set.reduction.

function sys.Bag.Bag.Set_from_Bag result Set params { topic(Bag) }

This function results in the Set that is the projection of the value attribute of its Bag argument.

function sys.Bag.Bag.Bag_from_Set result Bag params { topic(Set) }

This function results in the Bag that is the extension of its Set argument with a new count attribute whose value for every tuple is 1.

function sys.Bag.Bag.Bag_from_wrap result BagOfTuple params { topic(Relation) }

This function results in a Bag whose value attribute is tuple-typed and that attribute's values are all the tuples of topic; is a short-hand for a relational wrap of all attributes of topic such that the new tuple-valued attribute is named value, and then that result is extended with a count attribute whose value for every tuple is 1.

function sys.Bag.Bag.Bag_from_attr result Bag params { topic(Relation), name(Cat.Name) }

This function results in a Bag consisting of all the values of the attribute of topic named by name. It is a short-hand for first doing a relational group on all attributes of topic besides name to produce a new relation-typed attribute, and then extending the result of the group with a new positive integer attribute whose values are the cardinality of the relation-valued attribute's values, and then doing a binary projection of the named attribute and the new integer attribute plus their renaming to value and count respectively.

function sys.Bag.Bag.is_subset result Bool params { look_in(Bag), look_for(Bag) }

This function is like sys.Core.Relation.is_subset but that it accounts for the greater-than-one multiplicity of values in its arguments; this function returns Bool:true iff the multiplicity of each look_for value is less than or equal to the multiplicity of its counterpart look_in value.

function sys.Bag.Bag.is_not_subset result Bool params { look_in(Bag), look_for(Bag) }

This function is like sys.Core.Relation.is_not_subset as per is_subset.

function sys.Bag.Bag.is_proper_subset result Bool params { look_in(Bag), look_for(Bag) }

This function is like sys.Core.Relation.is_proper_subset as per is_subset. TODO: What is its definition?

function sys.Bag.Bag.is_not_proper_subset result Bool params { look_in(Bag), look_for(Bag) }

This function is like sys.Core.Relation.is_not_proper_subset as per is_subset. TODO: What is its definition?

function sys.Bag.Bag.union result Bag params { topic(SetOfBag) }

This function is like sys.Core.Relation.union but that it just looks at the value attribute of its argument elements when determining what element tuples correspond; then for each tuple in the result, its count attribute value is the maximum of the count attribute values of its corresponding input element tuples.

function sys.Bag.Bag.intersection result Bag params { topic(SetOfBag) }

This function is like sys.Core.Relation.intersection as union is like sys.Core.Relation.union; the minimum of count attribute values is used rather than the maximum.

function sys.Bag.Bag.difference result Bag params { source(Bag), filter(Bag) }

This function is like sys.Core.Relation.difference as union is like sys.Core.Relation.union; for corresponding input tuples, the result only has a tuple with the same value if the count of the source tuple is greater than the count of the filter tuple, and the count of the result tuple is the difference of those two.

SEE ALSO

Go to Language::MuldisD for the majority of distribution-internal references, and Language::MuldisD::SeeAlso for the majority of distribution-external references.

AUTHOR

Darren Duncan (perl@DarrenDuncan.net)

LICENSE AND COPYRIGHT

This file is part of the formal specification of the Muldis D language.

Muldis D is Copyright © 2002-2008, Darren Duncan.

See the LICENSE AND COPYRIGHT of Language::MuldisD for details.

ACKNOWLEDGEMENTS

The ACKNOWLEDGEMENTS in Language::MuldisD apply to this file too.