Natural Difference Geometry
Natural Difference Geometry is a method to generate geometry using operations on functions of type nat -> nat.
In this Rust library, the type u64 is used as an approximation of nat.
The basic idea is that each point has a number.
A function of type nat -> nat connects one point to another.
A simple such function is inc(x: nat) = x + 1.
This function connects 0 to 1, 1 to 2, 2 to 3 etc.
The sup ("super") function allows us create a more complex function,
by using a simple function as a basis and "duplicate" its behavior.
For example, if we want connect even and odd numbers we can use sup(2, inc).
Notice that when we create a number sequence of even numbers, we use even(n: nat) = 2 * n. For odd numbers, we use odd(n: nat) = 2 * n + 1. However, in Natural Difference Geometry, we are not interested in the particular values.
We are only interested in how numbers are connected to each other.
This means, sup(2, inc) behaves in a different way than when you think about
number sequences. In this case, both even and odd numbers are covered by sup(2, inc).
In general, if we have a function f that cover a set of number sequences,
such that each number only appears in once and for a single sequence,
then the difference is f(n) - n. This is an integer, because it can be both positive and negative. The difference is encoded implicitly inside f,
thus f is a Natural Difference. When we generate geometry using this method,
we get Natural Difference Geometry.
For example, if we want to generate rectangles, we can use cyc(4).
This function produces cycles of 4 for every number.
E.g. 0, 1, 2, 3, 0, 1, 2, 3, ... and 4, 5, 6, 7, 4, 5, 6, 7, ....
A more advanced example: If we want to generate cubes, we can use cyc(4)
and sup(4, cyc(2)).
The cyc(4) function generates the rectangles.
The sup(4, cyc(2)) function connects two rectangles into a cube.
You can also use 3 functions for generating cubes:
cyc(2), sup(2, cyc(2)) and sup(4, cyc(2)).
For any n-cube, you can generate dimension k as sup(2^k, cyc(2)).
The different methods correspond to symmetries in Group Theory.
In Natural Difference Geometry there are two standard encodings:
- even/odd method (no curvature allowed)
even_n2 - diagonal method (curvature allowed)
n2_embed
These two encodings are used to support higher dimensions.
In higher dimensions, a point is still just a nat,
but it uses an encoding such that one can store e.g. X and Y components.
By repeating an encoding, we can represent any N dimensional coordinates.
The n2 function does a similar thing as even_n2,
but uses the diagonal method instead of the even/odd method.
Curvature in Natural Difference Geometry means that at least one function of the two functions that are encoded into one, depends on two arguments.
E.g. in 2D, there are two functions, one that computes the X component and one function that computes the Y component. If there is no curvature, then we can use one function that maps X to X, plus a second function that maps Y to Y. When we have curvature, we use one function that maps X and Y to X, plus a second function that maps X and Y to Y.