<s>
ATS	B-Language
(	O
Applied	O
Type	O
System	O
)	O
is	O
a	O
programming	O
language	O
designed	O
to	O
unify	O
programming	O
with	O
formal	O
specification	O
.	O
</s>
<s>
ATS	B-Language
has	O
support	O
for	O
combining	O
theorem	O
proving	O
with	O
practical	O
programming	O
through	O
the	O
use	O
of	O
advanced	O
type	O
systems	O
.	O
</s>
<s>
A	O
past	O
version	O
of	O
The	O
Computer	O
Language	O
Benchmarks	O
Game	O
has	O
demonstrated	O
that	O
the	O
performance	O
of	O
ATS	B-Language
is	O
comparable	O
to	O
that	O
of	O
the	O
C	B-Language
and	O
C++	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
By	O
using	O
theorem	O
proving	O
and	O
strict	O
type	O
checking	O
,	O
the	O
compiler	O
can	O
detect	O
and	O
prove	O
that	O
its	O
implemented	O
functions	O
are	O
not	O
susceptible	O
to	O
bugs	O
such	O
as	O
division	B-Algorithm
by	I-Algorithm
zero	I-Algorithm
,	O
memory	B-Error_Name
leaks	I-Error_Name
,	O
buffer	B-General_Concept
overflow	I-General_Concept
,	O
and	O
other	O
forms	O
of	O
memory	B-General_Concept
corruption	I-General_Concept
by	O
verifying	O
pointer	O
arithmetic	O
and	O
reference	B-General_Concept
counting	I-General_Concept
before	O
the	O
program	O
compiles	O
.	O
</s>
<s>
Additionally	O
,	O
by	O
using	O
the	O
integrated	O
theorem-proving	O
system	O
of	O
ATS	B-Language
(	O
ATS/LF	O
)	O
,	O
the	O
programmer	O
may	O
make	O
use	O
of	O
static	O
constructs	O
that	O
are	O
intertwined	O
with	O
the	O
operative	O
code	O
to	O
prove	O
that	O
a	O
function	O
attains	O
its	O
specification	O
.	O
</s>
<s>
ATS	B-Language
is	O
derived	O
mostly	O
from	O
the	O
ML	B-Language
and	O
OCaml	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
An	O
earlier	O
language	O
,	O
Dependent	B-Language
ML	I-Language
,	O
by	O
the	O
same	O
author	O
has	O
been	O
incorporated	O
by	O
the	O
language	O
.	O
</s>
<s>
The	O
first	O
version	O
of	O
ATS2	B-Language
(	O
Postiats	O
)	O
was	O
released	O
in	O
September	O
2013	O
.	O
</s>
<s>
The	O
primary	O
focus	O
of	O
ATS	B-Language
is	O
to	O
support	O
theorem	O
proving	O
in	O
combination	O
with	O
practical	O
programming	O
.	O
</s>
<s>
With	O
theorem	O
proving	O
one	O
can	O
prove	O
,	O
for	O
instance	O
,	O
that	O
an	O
implemented	O
function	O
does	O
not	O
produce	O
memory	B-Error_Name
leaks	I-Error_Name
.	O
</s>
<s>
It	O
incorporates	O
a	O
system	O
similar	O
to	O
those	O
of	O
proof	O
assistants	O
which	O
usually	O
only	O
aim	O
to	O
verify	O
mathematical	O
proofs	O
—	O
except	O
ATS	B-Language
uses	O
this	O
ability	O
to	O
prove	O
that	O
the	O
implementations	O
of	O
its	O
functions	O
operate	O
correctly	O
,	O
and	O
produce	O
the	O
expected	O
output	O
.	O
</s>
<s>
As	O
a	O
simple	O
example	O
,	O
in	O
a	O
function	O
using	O
division	O
,	O
the	O
programmer	O
may	O
prove	O
that	O
the	O
divisor	O
will	O
never	O
equal	O
zero	O
,	O
preventing	O
a	O
division	B-Algorithm
by	I-Algorithm
zero	I-Algorithm
error	I-Algorithm
.	O
</s>
<s>
A	O
more	O
practical	O
example	O
would	O
be	O
proving	O
through	O
reference	B-General_Concept
counting	I-General_Concept
that	O
the	O
retain	O
count	O
on	O
an	O
allocated	O
block	O
of	O
memory	O
is	O
being	O
counted	O
correctly	O
for	O
each	O
pointer	O
.	O
</s>
<s>
Then	O
one	O
can	O
know	O
,	O
and	O
quite	O
literally	O
prove	O
,	O
that	O
the	O
object	O
will	O
not	O
be	O
deallocated	O
prematurely	O
,	O
and	O
that	O
memory	B-Error_Name
leaks	I-Error_Name
will	O
not	O
occur	O
.	O
</s>
<s>
The	O
benefit	O
of	O
the	O
ATS	B-Language
system	O
is	O
that	O
since	O
all	O
theorem	O
proving	O
occurs	O
strictly	O
within	O
the	O
compiler	O
,	O
it	O
has	O
no	O
effect	O
on	O
the	O
speed	O
of	O
the	O
executable	O
program	O
.	O
</s>
<s>
ATS	B-Language
code	O
is	O
often	O
harder	O
to	O
compile	O
than	O
standard	O
C	B-Language
code	O
,	O
but	O
once	O
it	O
compiles	O
the	O
programmer	O
can	O
be	O
certain	O
that	O
it	O
is	O
running	O
correctly	O
to	O
the	O
degree	O
specified	O
by	O
their	O
proofs	O
(	O
assuming	O
the	O
compiler	O
and	O
runtime	O
system	O
are	O
correct	O
)	O
.	O
</s>
<s>
In	O
ATS	B-Language
proofs	O
are	O
separate	O
from	O
implementation	O
,	O
so	O
it	O
is	O
possible	O
to	O
implement	O
a	O
function	O
without	O
proving	O
it	O
if	O
the	O
programmer	O
so	O
desires	O
.	O
</s>
<s>
According	O
to	O
the	O
author	O
(	O
Hongwei	O
Xi	O
)	O
,	O
ATS	B-Language
's	O
efficiency	O
is	O
largely	O
due	O
to	O
the	O
way	O
that	O
data	O
is	O
represented	O
in	O
the	O
language	O
and	O
tail-call	B-Language
optimizations	I-Language
(	O
which	O
are	O
generally	O
important	O
for	O
the	O
efficiency	O
of	O
functional	B-Language
programming	I-Language
languages	I-Language
)	O
.	O
</s>
<s>
dataprop	O
expresses	O
predicates	B-Algorithm
as	O
algebraic	O
types	O
.	O
</s>
<s>
Predicates	B-Algorithm
in	O
pseudo‑code	O
somewhat	O
similar	O
to	O
ATS	B-Language
source	O
(	O
see	O
below	O
for	O
valid	O
ATS	B-Language
source	O
)	O
:	O
</s>
<s>
In	O
ATS	B-Language
code	O
:	O
</s>
<s>
Non	O
tail-recursive	B-Language
factorial	O
with	O
proposition	O
or	O
"	O
Theorem	O
"	O
proving	O
through	O
the	O
construction	O
dataprop	O
.	O
</s>
<s>
The	O
proofs	O
express	O
the	O
predicates	B-Algorithm
of	O
the	O
proposition	O
.	O
</s>
<s>
Compilation	O
should	O
work	O
with	O
various	O
back	O
end	O
C	B-Language
compilers	O
,	O
e.g.	O
</s>
<s>
gcc	B-Application
.	O
</s>
