Applying a "to decide whether" phrase as an advanced kind

I would like to be able to encode a table that contains various conditions that NPCs would like to hold, such that they will complain about them if they do not hold. And I’d like the table to contain various different relations – the cat is on the table, the mouse is in the cupboard, Annie is located in the front parlor, Jane is angry at Eliza.

To do this, I want to be able to define various pseudorelations as phrases taking two objects as inputs and putting out a truth state, run through the table to check whether they hold, and output some text if they don’t hold.

The following rather twisted code seems to be working so far. (Note that the “sign” entry tells you whether the desirer wants the pseudorelation in question to hold or not – Hartington wants the knife to be on the table so the sign entry is true, Annie wants the cat not to be on the table so the sign entry is false.)

Use American dialect and the serial comma.

Front Parlor is a room. Jane is a woman in Front Parlor. Hartington is a man in Front Parlor. Alfred is a man in Front Parlor. The player is Alfred. Eliza is a woman in Front Parlor. Annie is a woman in Front Parlor.

The table is a supporter in the Front Parlor. The cat is on the table. The knife is in the Front Parlor.

A pseudotruth state is a kind of value. The pseudotruth states are oui and non.
	
To decide which pseudotruth state is si (top - object) overtops (bottom - object) (this is overtopping):
	if top is on bottom, decide on oui;
	decide on non.

Table of Desires
Desirer 	first relatum	pseudorelation	second relatum	sign
Eliza	cat	overtopping	the table	false
Hartington	knife	overtopping	the table	true


Every turn: 
	repeat through the Table of Desires:
		if the sign entry is true: 
			if the pseudorelation entry applied to the first relatum entry and the second relatum entry is non:
				say "[The desirer entry] says, 'I say! [The first relatum entry] [negative text of the pseudorelation entry] [the second relatum entry]!'";
		otherwise [the sign entry is false]:
			if the pseudorelation entry applied to the first relatum entry and the second relatum entry is oui:
				say "[The desirer entry] says, 'I say! [The first relatum entry] [positive text of the pseudorelation entry] [the second relatum entry]!'".


[note that order seems to matter here; we have to have the generic case first]

To say negative text of (generic pseudorelation - phrase (object, object) -> pseudotruth state): say "isn't [generic pseudorelation][run paragraph on]". 
					
To say negative text of (overtopping - phrase (object, object) -> pseudotruth state): say "isn't on[run paragraph on]".

To say positive text of (generic pseudorelation - phrase (object, object) -> pseudotruth state): say "is [generic pseudorelation][run paragraph on]".

To say positive text of (overtopping - phrase (object, object) -> pseudotruth state): say "is on[run paragraph on]".

test me with "take knife/take cat/put knife on table".

But this has a horrible hack involving “oui” and “non” as pseudotruth states, because
(1) phrases aren’t allowed to decide on a truth state (you have to said “to decide whether” instead of “to decide on what truth state is…” (see note below);
(2) this doesn’t compile:

To decide whether (top - object) overtops (bottom - object) (this is overtopping):
	decide on whether top is on bottom.

Table of Desires
Desirer 	first relatum	pseudorelation	second relatum	sign
Eliza	cat	overtopping	the table	false
Hartington	knife	overtopping	the table	true


Every turn: 
	repeat through the Table of Desires:
		if the sign entry is true: 
			if the pseudorelation entry applied to the first relatum entry and the second relatum entry is false:
				say "[The desirer entry] says, 'I say! [The first relatum entry] [negative text of the pseudorelation entry] [the second relatum entry]!'";
		otherwise [the sign entry is false]:
			if the pseudorelation entry applied to the first relatum entry and the second relatum entry is true:
				say "[The desirer entry] says, 'I say! [The first relatum entry] [positive text of the pseudorelation entry] [the second relatum entry]!'".


[note that order seems to matter here; we have to have the generic case first]

To say negative text of (generic pseudorelation - phrase (object, object) -> nothing): say "isn't [generic pseudorelation][run paragraph on]". 
					
To say negative text of (overtopping - phrase (object, object) -> nothing): say "isn't on[run paragraph on]".

To say positive text of (generic pseudorelation - phrase (object, object) -> nothing): say "is [generic pseudorelation][run paragraph on]".

To say positive text of (overtopping - phrase (object, object) -> nothing): say "is on[run paragraph on]".

Apparently the “to decide whether” phrase is a phrase (object, object) -> nothing rather than a phrase (object, object) -> truth state. But then how do I apply one of those to find out what its result is? Can I do that? Am I making a basic syntax error?

note below: the standard rules do have a phrase that decides on a truth state:

To decide what truth state is whether or not (C - condition) (documented at ph_whether): (- ({C}) -).

This compiles (obviously) but when I include another “to decide what truth state is…” phrase then the I7 compiler throws an error at this phrase of the Standard Rules as well as at the one I included.

The wrong type of “decide whether” was filed as a bug, a while ago (inform7.com/mantis/view.php?id=473).

I don’t have a better workaround.

OK, thanks; since this workaround is working I’ll leave it as is.

Are relations phrases of a sort that can be applied here? It might be nice to be able to use the built-in (searches the standard rules) “reversed support” relation in a table column instead of the pseudorelation I used here, but I couldn’t figure out how to apply a variable relation to two arguments.

That operation does seem to be missing, yes.

I’ve cobbled this together but it’s only very minimally tested:

To decide whether (X - K) relates to (Y - L) by
	(R - relation of values of kind K to values of kind L):
	(- RelationTest({-pointer-to:R}, RELS_TEST, {X}, {Y}) -).