Clean implementation of the new algorithm

Still needs work!
Slight clean-up, add stats.erl in Makefile
Add some assertions, skip restoration for s values

Restoration of arguments for functions fully resolved is unnecessary.

Add some assertions when collecting dependencies.
Update tests, fix HOF limitation

Update all purity-related test cases to handle the new results, and a
slightly simpler syntax for describing HOFs. It is now unnecessary to
have separate results for different purity levels. However, certain
subtle test cases which depend on the reason for which a function was
characterised impure are now indistinguishable.

Termination-related test cases are left as-is for the moment, and
subsequently cause 2 failing tests.

Do not restore self-dependencies after the contamination pass, only
{arg,_} tuples. This change does not really affect HOFs, since they are
unresolvable anyway, but it enables resolution of functions which
acquired self-dependencies because of HOF unfolding, roughly 0.1% of
OTP.

By moving self-dependency removal to the pre-processing stage, it is now
possible to resolve some uncommon corner cases as described in
test/nested. However, we now miss a case previously resolved, where
indirect HOFs and HOFs being passed concrete arguments are combined
(only one such case actually resolved in the whole of OTP, several
others were still unresolvable before).
Fix combined concrete and indirect arg detection

Allow for handling of both concrete and indirect HOF arguments without
marking the function as unknown, if the combination covers the calls
completely.

Minimal impact on analysis results.
Slightly enhance HOF detection

Enable resolution of calls to HOFs where the concrete argument passed is
the HOF itself (for e.g. recursion with anonymous functions).

While this pattern is seldom used in Erlang, it influences about 0.5% of
OTP results (probably caused by no-more than 2 or 3 low level
dependencies).
Add termination analysis with the new algorithm

Termination analysis is about two times slower for OTP than purity
analysis at this point, but this should be fixed soon.

Update tests to the new result format.
Minor tweak

Move purity lookup of the contaminating function out of the loop.
Speed gains are insignificant, although this saves an average of 4
lookups per function.
Minor tweak

When contaminating with `s' values do it in one big swoop. No noticeable
performance gain in termination analysis yet.
Optimise contamination loop

Achieve significant speedup in contamination (8x for termination
analysis and ~1.5x for purity analysis) by keeping track of the working
set as a nested list with possible duplicates, instead of an ordered
set.

Since the working set is not used in the inner loop, only incremented,
it is possible to move the working set invariant (list of unique
functions) to the outer loop, where it is actually used.

Performance is now similar (if not better) to the old algorithm.
Refactor detection of recursive functions

Don't depend on code from the old termination algorithm. This makes for
a simpler and cleaner implementation.
Merge branch 'feature/new-termination' into feature/clean-algorithm
Update broken test

The termination result of m/2 in test/higher was incorrectly left to
`s', instead of the more accurate `>= p [1]'. While there is no
difference in practice, the significance lies in telling apart recursion
(which is resolved correctly here) from unhandled HOFs.

The issue was uncovered because the recursion removal functions of the
previous algorithm did not work on unhandled HOFs.
Clean up code from previous algorithm

Remove most of the code in purity and related tests. There should still
be left over code in other modules I suppose.
Minor fix

Keep track of indirect HOFs even if they are marked as unknown because
not all of the passed arguments are ultimately resolved. This should not
have any impact on analysis results, besides slightly more refined
values.
Update plt and utils

For the moment rewrite into separate modules for easier testing.

Besides updating any relevant functions to work on the new values of
purity, there have been some minor enhancements and fixes.

For instance, the PLT update function did not check that the caches it
kept were consistent. Also, the dependency resolution of affected
modules was not correct, as it only took into account direct
dependencies.
Update values of predefined BIFs

Switch values to the new format, and add convenience functions in the
generated module.

Built-ins whose purity cannot be statically determined (like
erlang:apply/3) are marked specifically as unknown. This changes the
results for dependent functions slightly, but should not otherwise
influence the analysis results (the are still impure from a conservative
standpoint).

Fix minor omissions, and remove obsolete test case for combined analysis.
Fix bug in termination analysis

Setting all BIFs as terminating is wrong. Part of this is fixed now,
namely honoring dependency lists and unresolvable BIFs. Still there is
work to be done here, since the current approach cannot express other
types of non-terminating BIFs at the moment.

This is not very serious in the sense that any such BIFs are most likely
impure functions too (e.g. port calls), so there should be no impact on
the combined results of the analysis (which is the ultimate goal), just
the termination part.

Note also that two commits ago a significant fix went unnoticed. Some
BIFs were not properly converted to the new values for termination
(those marked with `false' in the cheat sheets), and were erroneously
marked as non-terminating.
Update specs

Also refactor purity_cli slightly, and remove leftover old purity_utils
dependencies.
Remove old implementations completely

Replace old implementations with their new counterparts.