<s>
In	O
object-oriented	B-Language
programming	I-Language
,	O
behavioral	B-Application
subtyping	I-Application
is	O
the	O
principle	O
that	O
subclasses	O
should	O
satisfy	O
the	O
expectations	O
of	O
clients	O
accessing	O
subclass	O
objects	O
through	O
references	O
of	O
superclass	O
type	O
,	O
not	O
just	O
as	O
regards	O
syntactic	O
safety	O
(	O
such	O
as	O
the	O
absence	O
of	O
"	O
method-not-found	O
"	O
errors	O
)	O
but	O
also	O
as	O
regards	O
behavioral	O
correctness	O
.	O
</s>
<s>
For	O
example	O
,	O
consider	O
a	O
type	O
Stack	B-Application
and	O
a	O
type	O
Queue	B-Application
,	O
which	O
both	O
have	O
a	O
put	O
method	O
to	O
add	O
an	O
element	O
and	O
a	O
get	O
method	O
to	O
remove	O
one	O
.	O
</s>
<s>
Suppose	O
the	O
documentation	O
associated	O
with	O
these	O
types	O
specifies	O
that	O
type	O
Stack	B-Application
's	O
methods	O
shall	O
behave	O
as	O
expected	O
for	O
stacks	B-Application
(	O
i.e.	O
</s>
<s>
they	O
shall	O
exhibit	O
LIFO	B-Application
behavior	O
)	O
,	O
and	O
that	O
type	O
Queue	B-Application
's	O
methods	O
shall	O
behave	O
as	O
expected	O
for	O
queues	B-Application
(	O
i.e.	O
</s>
<s>
they	O
shall	O
exhibit	O
FIFO	B-Operating_System
behavior	O
)	O
.	O
</s>
<s>
Suppose	O
,	O
now	O
,	O
that	O
type	O
Stack	B-Application
was	O
declared	O
as	O
a	O
subclass	O
of	O
type	O
Queue	B-Application
.	O
</s>
<s>
Most	O
programming	O
language	O
compilers	O
ignore	O
documentation	O
and	O
perform	O
only	O
the	O
checks	O
that	O
are	O
necessary	O
to	O
preserve	O
type	B-Language
safety	I-Language
.	O
</s>
<s>
Since	O
,	O
for	O
each	O
method	O
of	O
type	O
Queue	B-Application
,	O
type	O
Stack	B-Application
provides	O
a	O
method	O
with	O
a	O
matching	O
name	O
and	O
signature	O
,	O
this	O
check	O
would	O
succeed	O
.	O
</s>
<s>
However	O
,	O
clients	O
accessing	O
a	O
Stack	B-Application
object	O
through	O
a	O
reference	O
of	O
type	O
Queue	B-Application
would	O
,	O
based	O
on	O
Queue	B-Application
's	O
documentation	O
,	O
expect	O
FIFO	B-Operating_System
behavior	O
but	O
observe	O
LIFO	B-Application
behavior	O
,	O
invalidating	O
these	O
clients	O
 '	O
correctness	O
proofs	O
and	O
potentially	O
leading	O
to	O
incorrect	O
behavior	O
of	O
the	O
program	O
as	O
a	O
whole	O
.	O
</s>
<s>
This	O
example	O
violates	O
behavioral	B-Application
subtyping	I-Application
because	O
type	O
Stack	B-Application
is	O
not	O
a	O
behavioral	O
subtype	O
of	O
type	O
Queue	B-Application
:	O
it	O
is	O
not	O
the	O
case	O
that	O
the	O
behavior	O
described	O
by	O
the	O
documentation	O
of	O
type	O
Stack	B-Application
(	O
i.e.	O
</s>
<s>
LIFO	B-Application
behavior	O
)	O
complies	O
with	O
the	O
documentation	O
of	O
type	O
Queue	B-Application
(	O
which	O
requires	O
FIFO	B-Operating_System
behavior	O
)	O
.	O
</s>
<s>
In	O
contrast	O
,	O
a	O
program	O
where	O
both	O
Stack	B-Application
and	O
Queue	B-Application
are	O
subclasses	O
of	O
a	O
type	O
Bag	O
,	O
whose	O
specification	O
for	O
get	O
is	O
merely	O
that	O
it	O
removes	O
some	O
element	O
,	O
does	O
satisfy	O
behavioral	B-Application
subtyping	I-Application
and	O
allows	O
clients	O
to	O
safely	O
reason	O
about	O
correctness	O
based	O
on	O
the	O
presumed	O
types	O
of	O
the	O
objects	O
they	O
interact	O
with	O
.	O
</s>
<s>
Indeed	O
,	O
any	O
object	O
that	O
satisfies	O
the	O
Stack	B-Application
or	O
Queue	B-Application
specification	O
also	O
satisfies	O
the	O
Bag	O
specification	O
.	O
</s>
<s>
As	O
another	O
case	O
in	O
point	O
,	O
type	O
Stack	B-Application
above	O
is	O
a	O
behavioral	O
subtype	O
of	O
type	O
Bag	O
even	O
if	O
type	O
Bag	O
's	O
implementation	O
exhibits	O
FIFO	B-Operating_System
behavior	O
:	O
what	O
matters	O
is	O
that	O
type	O
Bag	O
's	O
specification	O
does	O
not	O
specify	O
which	O
element	O
is	O
removed	O
by	O
method	O
get	O
.	O
</s>
<s>
This	O
also	O
means	O
that	O
behavioral	B-Application
subtyping	I-Application
can	O
be	O
discussed	O
only	O
with	O
respect	O
to	O
a	O
particular	O
(	O
behavioral	O
)	O
specification	O
for	O
each	O
type	O
involved	O
and	O
that	O
if	O
the	O
types	O
involved	O
have	O
no	O
well-defined	O
behavioral	O
specification	O
,	O
behavioral	B-Application
subtyping	I-Application
cannot	O
be	O
discussed	O
meaningfully	O
.	O
</s>
<s>
for	O
,	O
then	O
S	O
is	O
a	O
subtype	O
of	O
T.	O
"	O
This	O
characterization	O
has	O
since	O
been	O
widely	O
known	O
as	O
the	O
Liskov	B-Application
Substitution	I-Application
Principle	I-Application
(	O
LSP	O
)	O
.	O
</s>
<s>
Firstly	O
,	O
in	O
its	O
original	O
formulation	O
,	O
it	O
is	O
too	O
strong	O
:	O
we	O
rarely	O
want	O
the	O
behavior	O
of	O
a	O
subclass	O
to	O
be	O
identical	O
to	O
that	O
of	O
its	O
superclass	O
;	O
substituting	O
a	O
subclass	O
object	O
for	O
a	O
superclass	O
object	O
is	O
often	O
done	O
with	O
the	O
intent	O
to	O
change	O
the	O
program	O
's	O
behavior	O
,	O
albeit	O
,	O
if	O
behavioral	B-Application
subtyping	I-Application
is	O
respected	O
,	O
in	O
a	O
way	O
that	O
maintains	O
the	O
program	O
's	O
desirable	O
properties	O
.	O
</s>
<s>
Thirdly	O
,	O
and	O
most	O
subtly	O
,	O
in	O
the	O
context	O
of	O
object-oriented	B-Language
imperative	O
programming	O
it	O
is	O
difficult	O
to	O
define	O
precisely	O
what	O
it	O
means	O
to	O
universally	O
or	O
existentially	O
quantify	O
over	O
objects	O
of	O
a	O
given	O
type	O
,	O
or	O
to	O
substitute	O
one	O
object	O
for	O
another	O
.	O
</s>
<s>
In	O
the	O
example	O
above	O
,	O
we	O
are	O
not	O
substituting	O
a	O
Stack	B-Application
object	O
for	O
a	O
Bag	O
object	O
,	O
we	O
are	O
simply	O
using	O
a	O
Stack	B-Application
object	O
as	O
a	O
Bag	O
object	O
.	O
</s>
<s>
In	O
an	O
interview	O
in	O
2016	O
,	O
Liskov	O
herself	O
explains	O
that	O
what	O
she	O
presented	O
in	O
her	O
keynote	O
address	O
was	O
an	O
"	O
informal	O
rule	O
"	O
,	O
that	O
Jeannette	O
Wing	O
later	O
proposed	O
that	O
they	O
"	O
try	O
to	O
figure	O
out	O
precisely	O
what	O
this	O
means	O
"	O
,	O
which	O
led	O
to	O
their	O
joint	O
publication	O
on	O
behavioral	B-Application
subtyping	I-Application
,	O
and	O
indeed	O
that	O
"	O
technically	O
,	O
it	O
's	O
called	O
behavioral	B-Application
subtyping	I-Application
"	O
.	O
</s>
