I'd like to have a Nat
that remains within a fixed range. I would like functions incr
and decr
that fail if they are going to push the number outside the range. This seems like it might be a good use case for Fin
, but I'm not really sure how to make it work. The type signatures might look something like this:
- Returns the next value in the ordered finite set.
- Returns Nothing if the input element is the last element in the set.
incr : Fin n -> Maybe (Fin n)
- Returns the previous value in the ordered finite set.
- Returns Nothing if the input element is the first element in the set.
decr : Fin n -> Maybe (Fin n)
The Nat
will be used to index into a Vect n
. How can I implement incr
and decr
? Is Fin
even the right choice for this?
This module also provides information about the benefits of configuring NAT for IP address conservation. NAT enables private IP internetworks that use nonregistered IP addresses to connect to the Internet. NAT operates on a device, usually connecting two networks.
NAT policies can be rearranged within the policy list. NAT policies are applied to network traffic after a security policy. The central SNAT table allows you to create, edit, delete, and clone central SNAT entries.
When the device receives the packet with the inside global IP address, it performs a NAT table lookup by using a protocol, the inside global address and port, and the outside address and port as keys. It translates the address to the inside local address 10.1.1.1 and forwards the packet to host 10.1.1.1.
In Cisco IOS Release 15.1 (3)T and later releases, when you configure the traceroute command, NAT returns the same inside global IP address for all inside local IP addresses. The following figure illustrates a device that is translating a source address inside a network to a source address outside the network.
I guess the easiest way is to use some standard Fin↔Nat conversion functions from Data.Fin
:
incr, decr : {n : Nat} -> Fin n -> Maybe (Fin n)
incr {n=n} f = natToFin (succ $ finToNat f) n
decr {n=n} f = case finToNat f of
Z => Nothing
S k => natToFin k n
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With