### operator: inverse

description:
inverse[op] sp
reverses the direction of a literal operator, even |*> rules
eg, say we have: op |A> => |B>
then: inverse[op] |B> returns |A>
and it really is an inverse, since:
op inverse[op] |B> returns |B>
and:
inverse[op] op |A> returns |A>
(though there are cases where it is not an exact inverse)
NB: potentially quite slow, especially for |*> rules
examples:
load family.sw
load family-relations.sw
-- find who is an uncle in this data-set:
such-that[is-an-uncle] rel-kets[*]
|peter>
-- find who Peter is an uncle for:
inverse[uncle] |peter>
|sally> + |erica>
-- find who Peter is a brother-in-law for:
inverse[brother-in-law] |peter>
|trude>
-- check this result:
brother-in-law |trude>
|peter>
-- find who are grand-parents:
such-that[is-a-grand-parent] rel-kets[*]
|sara> + |sam> + |ruth> + |mike> + |gina> + |mary> + |mark>
-- find who they are grand-parents for:
inverse[grand-parent] |sara>
|sally> + |erica>
inverse[grand-parent] |sam>
|sally> + |erica>
inverse[grand-parent] |gina>
|peter> + |tom>
inverse[grand-parent] |mark>
|peter> + |tom>
see also:
find-inverse

Home