manpagez: man pages & more
info gmpl
Home | html | info | man
 [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]

3.4 Set expressions

Set expression is a rule for computing an elemental set, i.e. a collection of n-tuples, where components of n-tuples are numeric and symbolic quantities.

The primary set expression may be a literal set, unsubscripted set, subscripted set, “arithmetic” set, indexing expression, iterated set expression, conditional set expression, or another set expression enclosed in parentheses.

Examples

 {(123,'aa'), (i,'bb'), (j-1,'cc')} (literal set) I (unsubscripted set) S[i-1,j+1] (subscripted set) 1..t-1 by 2 (“arithmetic” set) {t in 1..T, (t+1,j) in S: (t,j) in F} (indexing expression) setof{i in I, j in J}(i+1,j-1) (iterated expression) if i < j then S[i] else F diff S[j] (conditional expression) (1..10 union 21..30) (parenthesized expression)

More general set expressions containing two or more primary set expressions may be constructed by using certain set operators.

Examples

 ```(A union B) inter (I cross J) 1..10 cross (if i < j then {'a', 'b', 'c'} else {'d', 'e', 'f'}) ```

Literal sets

Literal set is a primary set expression, which has the following two syntactic forms:

{e1, e2, …, em}

{(e11, …, e1n), (e21, …, e2n), …, (em1, …, emn)}

where e1, …, em, e11, …, emn are numeric or symbolic expressions.

If the first form is used, the resultant set consists of 1-tuples (singles) enumerated within the curly braces. It is allowed to specify an empty set, which has no 1-tuples.

If the second form is used, the resultant set consists of n-tuples enumerated within the curly braces, where a particular n-tuple consists of corresponding components enumerated within the parentheses. All n-tuples must have the same number of components.

Unsubscripted sets

If the primary set expression is an unsubscripted set (which must be 0-dimensional), the resultant set is an elemental set associated with the corresponding set object.

Subscripted sets

The primary set expression, which refers to a subscripted set, has the following syntactic form:

name[i1, i2, …, in],

where name is the symbolic name of the set object, i1, i2, …, in are subscripts.

Each subscript must be a numeric or symbolic expression. The number of subscripts in the subscript list must be the same as the dimension of the set object with which the subscript list is associated.

Actual values of subscript expressions are used to identify a particular member of the set object that determines the resultant set.

“Arithmetic” set

The primary set expression, which is an “arithmetic” set, has the following two syntactic forms:

t0 .. tf by dt

t0 .. tf

where t0, t1, and dt are numeric expressions (the value of dt must not be zero). The second form is equivalent to the first form, where dt = 1.

If dt > 0, the resultant set is determined as follows:

{t: exists k in Z (t = t0 + k dt, t0 <= t <= tf)}

Otherwise, if dt < 0, the resultant set is determined as follows:

{t: exists k in Z (t = t0 + k dt, tf <= t <= t0)}

Indexing expressions

If the primary set expression is an indexing expression, the resultant set is determined as described in Section “Indexing expressions and dummy indices” (see above).

Iterated expressions

Iterated set expression is a primary set expression, which has the following syntactic form:

setof indexing-expression integrand

where indexing-expression is an indexing expression which introduces dummy indices and controls iterating, integrand is either a single numeric or symbolic expression or a list of numeric and symbolic expressions separated by commae and enclosed in parentheses.

If the integrand is a single numeric or symbolic expression, the resultant set consists of 1-tuples and is determined as follows:

{x: (i1, …, in) in D},

where x is a value of the integrand, i1, …, in are dummy indices introduced in the indexing expression, D is the domain, a set of n-tuples specified by the indexing expression which defines particular values assigned to the dummy indices on performing the iterated operation.

If the integrand is a list containing m numeric and symbolic expressions, the resultant set consists of m-tuples and is determined as follows:

{(x1, …, xm): (i1, …, in) in D},

where x1, …, xm are values of the expressions in the integrand list, i1, …, in and D have the same meaning as above.

Conditional expressions

Conditional set expression is a primary set expression that has the following syntactic form:

if b then X else Y

where b is an logical expression, X and Y are set expressions, which must define sets of the same dimension.

The resultant value of the conditional expression depends on the value of the logical expression that follows the keyword if. If it takes on the value true, the resultant set is the value of the expression that follows the keyword then. Otherwise, if the logical expression takes on the value false, the resultant set is the value of the expression that follows the keyword else.

Parenthesized expressions

Any set expression may be enclosed in parentheses that syntactically makes it primary set expression.

Parentheses may be used in set expressions, as in algebra, to specify the desired order in which operations are to be performed. Where parentheses are used, the expression within the parentheses is evaluated before the resultant value is used.

The resultant value of the parenthesized expression is the same as the value of the expression enclosed within parentheses.

Set operators

In MathProg there are the following set operators, which may be used in set expressions:

 X union Y union X diff Y difference X symdiff Y symmetric difference X inter Y intersection X cross Y cross (Cartesian) product

where X and Y are set expressions, which must define sets of the identical dimension (except for the Cartesian product).

If the expression includes more than one set operator, all operators are performed from left to right according to the hierarchy of operations (see below).

The resultant value of the expression, which contains set operators, is the result of applying the operators to their operands.

The dimension of the resultant set, i.e. the dimension of n-tuples, of which the resultant set consists of, is the same as the dimension of the operands, except the Cartesian product, where the dimension of the resultant set is the sum of dimensions of the operands.

Hierarchy of operations

The following list shows the hierarchy of operations in set expressions:

 Operation Hierarchy Evaluation of numeric operations 1st-7th Evaluation of symbolic operations 8th-9th Evaluation of iterated or “arithmetic” set (setof, ..) 10th Cartesian product (cross) 11th Intersection (inter) 12th Union and difference (union, diff, symdiff) 13th Conditional evaluation (if … then … else) 14th

This hierarchy is used to determine which of two consecutive operations is performed first. If the first operator is higher than or equal to the second, the first operation is performed. If it is not, the second operator is compared to the third, etc. When the end of the expression is reached, all of the remaining operations are performed in the reverse order.

 [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? ]
```© manpagez.com 2000-2019
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://www.manpagez.com/info/gmpl/gmpl-4.35/gmpl_16.php", "fetch_time": 1566145656000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2019-35/segments/1566027313936.42/warc/CC-MAIN-20190818145013-20190818171013-00293.warc.gz", "warc_record_offset": 288258581, "warc_record_length": 6360, "token_count": 1712, "char_count": 7314, "score": 3.703125, "int_score": 4, "crawl": "CC-MAIN-2019-35", "snapshot_type": "latest", "language": "en", "language_score": 0.769199550151825, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00027-of-00064.parquet"}