Formula-Combining Operators
Formula operators combine smaller formulas to produce new formulas. Many closely resemble similar operators from programming languages, like &&
, ||
, and !
.
List of Available Operators:
For the following <fmla>
means an arbitrary formula.
- Negation:
not (!)
- Conjunction:
and (&&)
- Disjunction:
or (||)
- Implication:
implies (=>)
- If-then-else:
else
- If-then-else:
- If-and-only-if:
iff (<=>)
Some operators have alternative syntax (marked by alt) which are equivalent. Use whichever is most natural and convenient to you.
not
(alt: !
)
not <fmla>
! <fmla>
true when <fmla>
evaluates to false
If some p.spouse
is true when the person p
is married, not (some p.spouse)
denotes the opposite, being true whenever p
is not married.
and
(alt: &&
)
<fmla-a> and <fmla-b>
<fmla-a> && <fmla-b>
true when both <fmla-a>
and <fmla-b>
evaluate to true.
If some p.spouse
is true when the person p
is married, and p.spouse != p
is true when p
is not married to themselves, then some p.spouse and p.spouse != p
is true exactly when p
is married, but not to themselves.
Forge treats consecutive formulas within { ... }
as implicitly combined using and
. For instance, the above example could also be written as:
{
some p.spouse
p.spouse != p
}
or
(alt: ||
)
<fmla-a> or <fmla-b>
<fmla-a> || <fmla-b>
true when either <fmla-a>
is true or <fmla-b>
evaluates to true.
If some p.spouse
is true when the person p
is married, and p.spouse != p
is true when p
is not married to themselves, then some p.spouse or p.spouse != p
is true exactly when p
is either:
- married; or
- not married to themselves (including the case where
p
is unmarried).
implies
(alt =>
)
<fmla-a> implies <fmla-b>
<fmla-a> => <fmla-b>
true when either <fmla-a>
evaluates to false or <fmla-b>
evaluates to true.
If some p.spouse
is true when the person p
is married, and p.spouse != p
is true when p
is not married to themselves, then some p.spouse implies p.spouse != p
is true exactly when p
is either:
- unmarried; or
- not married to themselves.
implies else
(alt: => else
)
{<fmla-a> implies <fmla-b> else <fmla-c>}
{<fmla-a> => <fmla-b> else <fmla-c>}
takes the value of <fmla-b>
when <fmla-a>
evaluates to true, and takes the value of <fmla-c>
otherwise.
If:
some p.spouse
is true when the personp
is married,p.spouse != p
is true whenp
is not married to themselves, andsome p.parent1
is true whenp
has aparent1
in the instance,
then some p.spouse => p.spouse != p else some p.parent1
is true exactly when:
p
is married, and not to themselves; orp
is not married and have aparent1
in the instance.
iff
(alt: <=>
)
<fmla-a> iff <fmla-b>
<fmla-a> <=> <fmla-b>
true when <fmla-a>
evaluates to true exactly when <fmla-b>
evaluates to true.
If some p.spouse
is true when the person p
is married, and some p.parent1
is true when p
has a parent1
in the instance, then some p.spouse iff some p.parent1
is true exactly when either:
p
is married and has aparent1
in the instance; orp
is unmarried has noparent1
in the instance.