Given a set of two or more logical conditions, is it possible to algorithmically determine that exactly ONE of them will evaluate to TRUE? For example:
# this should pass, since for every X, only one condition is taken
cond 1: (X >= 1.0)
cond 2: (X < 1.0)
# this should fail
cond 1: (X < 1.0)
cond 2: (X > 2.0)
# this should also fail, since X=1.0 would meet both conditions
cond 1: (X < 2.0)
cond 2: (X > 0.0)
# there may be more than one variable involved
cond 1: (X >= 1.0 && Y >= 0)
cond 2: (X < 1.0 && Y <= -1)
These conditions are generated from a domain specific language and used to determine the next execution path. i.e. users compose a condition for each option when the execution tree splits into multiple paths, and the condition that evaluates to true determines the path that is to be taken. For the simulation to be valid these should be only one possible path that can be taken for any given values.
At present, I evaluate these conditions at runtime and throw a tantrum if more than one (or none) of them are True.
I would like to be able to check errorneous conditions during the parse stage (domain language to compilable source code). Is it possible? How would one go about validating the conditions?
update
With regards to what can be included in the conditions, the scope is rather wide in practice. All these are possible conditions:
X >= Y && Y < Z
X.within_radius(0.4)
X IN some_array
X * Y < Z
final update
It does seem like a solution that covers all possible conditions is not possible (or at least, given my limited knowledge, not possible within the time allocated for the problem). Will revisit this some day, but for now accepting answer that brought me forward the furthest.