Fix a bug in bin_local noticed by Marco
Merge pull request #161 from frenetic-lang/nate-marco-bugfix

Fix a bug in bin_local noticed by Marco
Make the LocalCompiler more local

- thread switch argument through compilation

- interpret Test on Switch at compile time

- this means that a flow table is only for one switch

Slower, but simpler. And correct-ier.

- Also fixed up front-end and unit test code in light of this change.
Merge pull request #163 from frenetic-lang/nate-marco-bugfix-ii

Make the LocalCompiler more local
autofix: Remove constructor from link_provider

A link_provider can accumulate link-free policies, but only via
sequential composition. That's because a link_provider represents a
policy that looks like this:

   (lfp ; r)

where lfp is a link-free policy, and r is a policy that's almost a
regular expression, when lfp is distributed across it. Associativity
matters here, so you can only extend lfp via sequential composition.

Related to #152, #155, and #158.
autofix: Revert change to Seq(NL, NL) case

This reverts the essential part of commit 7d240da0270, introduced in
pull request #155, which was intended to be a fix to #152. While it
fixed some of the errant behavior, it broke some tests as well.

Still in the process of figuring this out.
autofix: Get examples running again
autofix: Better-working regex_of_policy

This commit changes the way that regex_of_policy works, and fixes some
bugs along the way. regex_of_policy now does two passes. First, it
draws boxes around link-free policies, and link-free policy, link pairs.
Then the algorithm works as it did before. There's one exception to
that, which is the Seq(NL, NL) case now works as it should.

The dump and run commands for automaton also now guards according to the
switch the policy should run on.
print-sw: print a header for the policy too
Merge branch 'print-sw'

Conflicts:
	frenetic/katnetic.ml
Merge pull request #166 from frenetic-lang/autofix

Fixing Automaton
autofix: Fix bug in branchy(TP, S) case

The Alt constructor was hardcoded. It should have been using the `cr`
constructor that's passed to rpc_branchy.
autofix: fix branchy(NL, NL) case

This is a much simpler and correct implementation, and corresponds to to
distribution laws of parallel composition and choice.

Related to #152
autofix: correct ingress and egress policies

Previously, the egress policy was of the form:

  (filter vlan = egress; vlan := 1) | id

This had the effect of both ejecting packets from the network, and
allowing them remain in the network. At the next hop they would have
been elminated, so this was technically correct, but at the cost of
duplicating all traffic, which is unacceptable. The new policy is this:

  (filter vlan = egress; vlan := 1) | (filter not(vlan = egress); id)

This will ensure that egress packets are ejected and not duplicated,
while leaving internal packets unchanged.
autofix: cache per-switch compilation results

At the moment, trying to compile a switch policy when a switch connects
to the controller will lead to connection time-outs. To avoid this in
the short term, katnetic will now compile all switch policies and cache
them before the controller starts.
autofix: eliminate Choice from lf_policy

Choices cannot appear in link-free policies, because the automaton
states have to represent those choices. By removing Choice from
lf_policy, that forces dehopification to return a policy instead of an
lf_policy, since choices may appear when setting the vlan tag in the
local policy.
autofix: off-by-one error accounting for pick states

The epsilon elimination code was assuming that an automaton would alway
transition to a choice node via a character. This is not always the
case. In fact, if a choice node is never preceded by a sequental
composition, it will always be the case. Examples:

  p + q
  (p + q) | r
autofix: correctly handle initial choice

A choice node may be an initial state. In this case, all states that are
reachable by epsilon transitions from that initial states are potential
start states and the ingress policy must choose between them.

The initial state may not be a choice node, but a choice node may be
reachable from the initial state by epsilon transitions. In that case,
find all the states that are reachable from those choice nodes via
epsilon transition. The ingress policy must choose between these, but
may also in parallel perform other character transitions from the
initial state.
Add reverse direction forwarding.
Extend the inactivity period timeout.