[Fwd: Part11e2: AND in SUBTYPE_CONSTRAINTs]
Ed Barkmeyer
edbark at nist.gov
Fri May 10 15:36:21 EDT 2002
Peter Wilson reminded me that WG11 generally had not seen this message,
which was sent only to the Express Ed2 editing committee in Myrtle Beach.
Since he has raised some of the same issues again, I am now forwarding
Barkmeyer lecture #706.2 to WG11.
-------- Original Message --------
Subject: Part11e2: AND in SUBTYPE_CONSTRAINTs
Date: Tue, 30 Apr 2002 12:09:27 -0400
From: Ed Barkmeyer <edbark at nist.gov>
Reply-To: edbark at nist.gov
Organization: NIST
To: Phil.Spiby at Eurostep.com
CC: Jochen Haenisch <Jochen.Haenisch at epmtech.jotne.com>,Dave Loffredo
<loffredo at steptools.com>,Ed Barkmeyer <edbark at cme.nist.gov>,"Günter Staub"
<staub at pdtec.de>,Lothar Klein <lothar.klein at lksoft.com>,Yoshihito KIKUCHI
<kikuchi at eli.hokkai-s-u.ac.jp>,David Price <david.price at Eurostep.com>,Hans
Karsten Dahl <Hans.Karsten.Dahl at epmtech.jotne.com>,"'Tom Hendrix'"
<Thomas.E.Hendrix at boeing.com>,"Arne Tøn" <Arne.Ton at epmtech.jotne.com>
References: <000401c1efc7$0c554610$0465a8c0 at esukpc04>
All,
Following up on the relationship between TOTAL_OVER and ABSTRACT SUPERTYPE OF,
I tripped over the old problem of AND in ABSTRACT SUPERTYPE clauses.
AND is needed in v1 ABSTRACT SUPERTYPE OF clauses, when we want to state
constraints on the relationships among the subtypes and state one or
more TOTAL_OVER constraints *at the same time*. The famous example:
ENTITY Person ABSTRACT SUPERTYPE OF
(ONEOF(Male, Female) AND ONEOF(Citizen, Alien))
is a *simple* example of this overload. What AND really means is that
we are stating two separate constraints about subtypes AND two
separate TOTAL_OVER constraints, all of which must hold. That is, it
is the same as:
ENTITY Person; ... END_ENTITY;
SUBTYPE_CONSTRAINT person_rules FOR Person;
TOTAL_OVER (Male, Female);
TOTAL_OVER (Citizen, Alien);
ONEOF(Male, Female);
ONEOF(Citizen, Alien);
END_SUBTYPE_CONSTRAINT;
except that the above violates the syntax rules for v2. V2 requires
me to write that as 4 separate SUBTYPE_CONSTRAINT rules! Why?
Actually v2 allows me to write *just 3* SUBTYPE_CONSTRAINT rules:
SUBTYPE_CONSTRAINT sc1 FOR Person;
TOTAL_OVER (Male, Female);
END_SUBTYPE_CONSTRAINT;
SUBTYPE_CONSTRAINT sc2 FOR Person;
TOTAL_OVER (Citizen, Alien);
END_SUBTYPE_CONSTRAINT;
SUBTYPE_CONSTRAINT sc3 FOR Person;
ONEOF(Male, Female) AND ONEOF(Citizen, Alien);
END_SUBTYPE_CONSTRAINT;
This requires us to understand what AND really means.
If I read Annex B correctly, it says that X AND Y means that only
X&Y and X&Y&others can be instantiated. That is:
every instance of X must also be an instance of Y and
every instance of Y must also be an instance of X.
That is X AND Y means:
RULE FOR (X,Y); X = Y; END_RULE;
So the AND in constraint sc3 is redundant with sc1 and sc2, and sc3 is a
shorthand for writing two ONEOF constraints on Person.
The fundamental observation here is:
There are exactly *three* kinds of constraint supported by the proposed
SUBTYPE_CONSTRAINT syntax:
ONEOF, TOTAL_OVER and *identity* (written "AND")!
And if each TOTAL_OVER must be a separate SUBTYPE_CONSTRAINT, why not require
each ONEOF constraint and each AND constraint to be a separate
SUBTYPE_CONSTRAINT?
And if we separate AND constraints and ONEOF constraints, then
supertype-expressions can only consist of entity-refs and ANDOR (which is *not*
a constraint)!
What we did is to create TOTAL_OVER constraints and v1 supertype-expressions.
But the general supertype-expression is a holdover from the v1 problem of having
to cram all the constraints into one unreadable SUPERTYPE OF declaration.
SUBTYPE_CONSTRAINT eliminates that requirement, but it still allows the complex
expressions. But if we separate the AND, ONEOF and TOTAL_OVER constraints into
multiple declarations, we should be able to use a uniform syntax that is
simpler:
TOTAL_OVER(<subtype-exp>, ...);
ONE_OF(<subtype-exp>, ...);
EQUAL(<subtype-exp>, ...);
where <subtype-exp> ::= <entity-ref> [ ANDOR <subtype-exp> ] .
(I would note that an ANDOR in the TOTAL_OVER list is exactly equivalent to a
comma! So requiring TOTAL_OVER operands to be entity-ref doesn't restrict
anything.)
Note that TOTAL_OVER is also a kind of "identity rule". That is,
Person TOTAL_OVER (Male, Female)
is exactly the same as:
Person AND (Male ANDOR Female);
[As a RULE this is written:
Person = (Male + Female);]
And I would bet that every AND in a v1 supertype-expression in an SC4 standard
is part of a would-be TOTAL_OVER declaration!
Note also that there are 3 more kinds of subtype constraint, which can only be
written as RULEs:
1) RULE FOR (x, y, z); WHERE x = y * z; END_RULE;
i.e. X is the set of all instances of Y&Z
2) RULE FOR (x, y); WHERE x = x * y; END_RULE;
i.e. Y contains X, which can sometimes be written in Express as:
x SUBTYPE OF (y);
but not when x is not defined that way, or when Y is an ANDOR expression, as
above.
3) RULE FOR (x, y, z); WHERE x = z - y; END_RULE;
i.e. X is the set of all instances of Z that are not in Y,
which can sometimes be written in Express v2 as:
z TOTAL_OVER(x, y);
ONEOF(x, y);
but not when Y is an ANDOR expression, as above.
(These all have explicit syntax in some languages of the mid-1980s that were
parallel to Express in their development. But none of these languages had
RULE-like capability.)
I'm not suggesting that we change the expression syntax at this point (although
I think it would be appropriate to change it in v3). But I would like to
suggest:
1. allow SUBTYPE_CONSTRAINT to contain multiple separate "rules" for the same
supertype (like RULE). (I didn't realize that it didn't allow that, or there
would have been a U.S. comment to that effect. Was there a reason for this
limitation?)
2. add a Note that recommends separating ONEOF and "AND" constraints into
separate rules, avoiding redundant ANDs, and using TOTAL_OVER when that is what
the AND is stating, e.g.
"Note -- A supertype-expression can be used to state two kinds of subtype
constraint:
- a ONEOF relationship among subtypes (or ANDOR combinations of subtypes),
which states that they have no common instances, or
- an AND relationship between subtypes (or combinations of subtypes), which
states that they have exactly the same set of instances (all instances are
common).
To improve readability and correct interpretation of a model, separate ONEOF and
AND constraints should be written as separate subtype-constraints rather than
combined into a complex supertype-expression. Many AND constraints can be, and
should be, more clearly represented as TOTAL_OVER constraints."
-Ed
--
Edward J. Barkmeyer Email: edbark at nist.gov
National Institute of Standards & Technology
Manufacturing Systems Integration Division
100 Bureau Drive, Mail Stop 8260 Tel: +1 301-975-3528
Gaithersburg, MD 20899-8260 FAX: +1 301-975-4482
"The opinions expressed above do not reflect consensus of NIST,
and have not been reviewed by any Government authority."
More information about the wg11
mailing list