Home

CondWithA

CondWithA is a generalized conditional operator used in formal logic and computer science to select between two expressions based on a predicate A. Rather than a fixed true/false switch, CondWithA ties the branch choice to whether a given input satisfies A.

Formal definition can be given in a functional style. Let D be a domain, A: D → Bool

Usage and applications. CondWithA is used in functional programming to enable predicate-based control flow, in program

Variants and relationship. The concept can be extended to multi-way branches with a family of predicates or

See also: if-then-else, conditional operator, generalized conditionals.

a
predicate,
and
T,
F:
D
→
C
be
total
functions
into
some
codomain
C.
Then
CondWithA_A(T,
F)(x)
equals
T(x)
if
A(x)
is
true,
and
F(x)
if
A(x)
is
false.
Equivalently,
CondWithA
can
be
expressed
as
a
higher-order
function:
CondWithA
=
λA.
λT.
λF.
λx.
if
A(x)
then
T(x)
else
F(x).
This
form
makes
the
dependency
on
the
input
explicit
and
separates
the
predicate
from
the
outcome
expressions.
synthesis
to
reason
about
branching
conditioned
on
properties
of
inputs,
and
in
formal
verification
to
model
decision
points
that
hinge
on
a
property
rather
than
a
simple
boolean
flag.
It
supports
constructing
adaptive
or
data-dependent
branches
and
can
simplify
reasoning
about
families
of
conditionals
parameterized
by
A.
to
compose
CondWithA
with
other
control
structures.
CondWithA
reduces
to
a
standard
if-then-else
when
A
is
a
fixed
constant
predicate,
illustrating
it
as
a
generalization
of
traditional
conditionals.