p(x) and NOT p(x)

4 views
Skip to first unread message

Jim Steel

unread,
Nov 17, 2010, 12:40:48 AM11/17/10
to tef...@googlegroups.com
I've been staring at this pattern for too long. I have two rules which
invoke it, one of which invokes it as notEntitySelect(s), and the
other of which invokes it as NOT notEntitySelect(s). I've modified so
that one of them sets a boolean attribute to true, and the other sets
is to false. For the same s, they are both firing (which I know
because tefkat is complaining that it is unable to make the attribute
both true and false).

Before I get into large unwieldy example
models/transformations/metamodels, is there anything immediately wrong
with my pattern?

PATTERN notEntitySelect(select)
FORALL SelectType select
WHERE select.selectList = listType
AND ( ( NOT ( (EntityType listType) OR (SelectType listType)) )
OR notEntitySelect(listType)
)
;

To explain, a SelectType has a list of other types, which may be
SelectTypes, EntityTypes, or other types. I want to distinguish
between SelectTypes that transitively contain only Entity Types, from
those that contain some of the other types.

Any help is useful.

Jim.

Jim Steel

unread,
Nov 17, 2010, 1:05:34 AM11/17/10
to tef...@googlegroups.com
In the half hour since I sent this, I have found a workaround.

PATTERN notEntitySelect(select)
FORALL SelectType select
WHERE select.selectList = listType

AND (SpecializedType listType
OR EnumerationType listType
OR (SelectType listType AND notEntitySelect(listType))
)
;

(where SpecializedType, EnumerationType, SelectType and EntityType are
all the types that can appear in selectList).

I still don't understand why my old one didn't work.

Jim.

David

unread,
Nov 17, 2010, 4:36:33 AM11/17/10
to Tefkat
I think Tefkat flounders on negation with unbounded terms, so you can
probably rule that out as a possibility.

All that negation makes my head hurt. Would a transitive-closure
style pattern be a bit simpler? i.e.:

//
// Matches SelectTypes that transitively contain only Entity Types.
//
PATTERN entitySelect(select)
FORALL SelectType select
WHERE select.selectList = listType
AND (EntityList listType OR entitySelect(listType))
;

I'm pretty sure that FORALL SelectType s WHERE isEntitySelect(s) and
FORALL SelectType s WHERE NOT isEntitySelect(s) can't both succeed for
the same s...

Jim Steel

unread,
Nov 17, 2010, 8:39:38 AM11/17/10
to tef...@googlegroups.com
This was one of my early attempts, but it suffers because FORALL is a
mislead word ;)

Specifically, it will match any SelectType which has at least one
EntityType in it, which includes SelectTypes which have a mix of
EntityTypes and other types. So I went looking for a list type which
would make it not an entity type instead :)

Jim.

> --
> You received this message because you are subscribed to the Google Groups "Tefkat" group.
> To post to this group, send an email to tef...@googlegroups.com.
> To unsubscribe from this group, send email to tefkat+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/tefkat?hl=en-GB.
>
>

michael lawley

unread,
Nov 17, 2010, 4:03:58 PM11/17/10
to tef...@googlegroups.com
Does the following work for you? It should match SelectType instances
that directly contain a non- EntityType or contain (transitively) a
SelectType that contains a non- EntityType

PATTERN notEntitySelect(select)
FORALL SelectType select
WHERE select.selectList = listType
AND (

(NOT EntityType listType)
        OR notEntitySelect(listType)
)
;

[And, yes, if you're trying to match a set of objects {X | forall Y
p(X,Y) }, then you need to transform this
into {X | not exists Y not p(X, Y)) since Tefkat does not provide
explicit quantifiers.]

michael

Reply all
Reply to author
Forward
0 new messages