July 24th, 2024

Space-filling curves, constructively

Andrej Bauer discusses space-filling curves, focusing on the Hilbert curve's surjectivity and its constructive properties. He introduces generalized curves to ensure coverage and explores limitations in constructive mathematics.

Read original articleLink Icon
CuriositySkepticismInterest
Space-filling curves, constructively

In a recent blog post, Andrej Bauer discusses the concept of space-filling curves, particularly focusing on the Hilbert curve and its constructive properties. He references the original discoveries by Giuseppe Peano and David Hilbert in the late 19th century, noting that while the curves are defined constructively, their surjectivity requires further examination. Bauer presents Theorem 1, which establishes that the Hilbert curve is surjective in a classical sense, as it approaches every point in the unit square. However, he points out that constructively, the curve's self-similar nature complicates this, necessitating a modification to ensure coverage of the square.

To address this, he introduces a generalized Hilbert curve defined with a scaling factor, α, which allows for overlapping segments that ensure surjectivity for values between 0.5 and 1, as stated in Theorem 2. Theorem 3 explores the limitations of constructing a square-filling curve in the topos of sheaves, concluding that such a curve cannot exist due to the requirement for local sections, which may not be feasible.

Bauer emphasizes the distinction between classical and constructive mathematics, illustrating the complexities involved in defining and proving properties of space-filling curves. He also notes that comments on the blog are currently disabled but invites readers to engage with him on Mastodon or directly.

Related

Desperately Seeking Squircles

Desperately Seeking Squircles

An engineer aims to incorporate Apple's 'squircle' shape into Figma, navigating mathematical complexities with superellipse formulas and Bézier curves. Challenges in mirroring and transitioning the shape prompt a proposed smoothing scheme for versatile designs. Differential geometry aids in mathematically analyzing the squircle's perimeter, showcasing the intricate process of digital design translation.

A mathematical thought experiment for accepting the continuum hypothesis

A mathematical thought experiment for accepting the continuum hypothesis

The article explores the theoretical implications of considering the continuum hypothesis a fundamental axiom in mathematics, potentially impacting mathematical reasoning and structures. Alternative foundational schemes and implications of historical developments are discussed.

The "Horgan Surface" and "The Death of Proof"

The "Horgan Surface" and "The Death of Proof"

John Horgan's namesake "Horgan surface" in mathematics sparked debate on proofs and technology's role. Despite controversy, he reflects on evolving math and the impact of computerization on human discovery.

Undergraduate Texts in Mathematical Comics – A Tour of Complex Analysis

Undergraduate Texts in Mathematical Comics – A Tour of Complex Analysis

The website showcases mathematical comics by Andrea Tomatis, introducing rigorous concepts like Complex Analysis. Supported by the National Science Foundation, it combines math rigor with comics to engage readers effectively.

Closed form arc length parametrization is impossible for quadratic Bézier curves

Closed form arc length parametrization is impossible for quadratic Bézier curves

The blog explores arc length parametrizations of Bézier curves, focusing on quadratic and cubic types in computer graphics. It discusses challenges, closed form solutions, Schanuel's conjecture, and limitations in mathematical contexts.

AI: What people are saying
The discussion around space-filling curves, particularly the Hilbert curve, reveals various applications and opinions on their utility and effectiveness.
  • Space-filling curves are recognized for their applications in database indexing, with several databases like DuckDB, SQL Server, and Postgres implementing Hilbert indexing for performance gains.
  • Geohashing is highlighted as an interesting application of space-filling curves for location representation and indexing.
  • Some commenters express skepticism about the practical effectiveness of space-filling curves, suggesting that simpler methods like Z-order indexing are more commonly used.
  • Concerns are raised about the limitations of inverse mapping in Hilbert curves, which may not preserve locality as expected.
  • There is interest in the artistic potential of space-filling curves, with inquiries about generative art applications.
Link Icon 11 comments
By @aguynamedben - 9 months
An interesting variant of space-filling curves + dimensionality reduction is Geohash (https://en.wikipedia.org/wiki/Geohash, http://geohash.org/) which takes a lon/lat and uses a Z-curve approach to produce a hash such as `u4pruydqqvj` representing the location. This hash value is basically "how far along the space-filling curve is the lon/lat located". You're reducing two dimensions (lon/lat) into one dimension (how far along the space-filling curve).

There's a unique side-effect to Geohashes in that the value (`u4pruydqqvj`) can have it's end "lopped off" (i.e. cut down to `u4pru`) and it still represents a less precise, but generally accurate representation of the original lon/lat in most cases (when the curve isn't near the edge of the 2d map!). This allows you to index locations (lat/lon) using a string ('u4pru') which opens you up to doing b-tree, range queries, etc. in traditional database, with one field.

Just a rad math quirk! I'm not an expert, and it's a very dense book, but if someone really wants to get into this kind of stuff the "Bible" is "Foundations of Multidimensional and Metric Data Structures" by Hanan Samet.

By @wenc - 9 months
Space filling curves like Hilbert sound esoteric but they’re actually useful in for high performance database indexing.

DuckDB has a Hilbert index.

https://github.com/rustyconover/duckdb-lindel-extension

It’s not just DuckDB. SQL server and Postgres support Hilbert too.

The big idea is that you can project tuples e.g (lat, long) or just about any other tuple structure (string or floats) in a single integer, ordered in a way that is locality preserving.

Because most queries tend to lookup data close to each other, this can lead to performance gains. Parquet statistics can be built to be locality sensitive (locality defined broadly, not just numbers).

If you index on Hilbert, you can specific compute a max min of the Hilbert range of your predicate and eliminate looking outside that range, speeding up query performance.

By @j2kun - 9 months
I read an entire book on applications of space filling curves, and none of the applications seemed to actually work as advertised (though perhaps they did at the time the book was written, I am skeptical).

All the stuff about database indexing and cache locality seems to have become obsolete with improvements in compilers; the overhead of computing the Hilbert curve indices is just too high. The indexing method that people seem to actually use is the Z-order/Morton order, which just interleaves bits and is mathematically less interesting [1].

[1]: https://en.wikipedia.org/wiki/Z-order_curve

By @perone - 9 months
I wrote an article about it and S2 some time ago as well for those interested: https://blog.christianperone.com/2015/08/googles-s2-geometry...
By @wenc - 9 months
One problem I’ve encountered is the inverse mapping is not necessarily locality preserving.

Hilbert maps (x,y) -> h such that nearby h correspond to nearby x,y.

But the inverse isn’t true: similar x,y don’t always have similar h.

This is a problem for some applications where we are trying to find dense hot spots cheaply by only looking at h’s, but turns out this doesn’t work out so well.

By @tylerhannan - 9 months
ahhhh...space-filling curves.

With some of the recent work done with ClickHouse this has been an area I've had to learn about and, tbh, wish I had found this earlier.

Our CTO started using Morton curves for interesting purposes several months ago with initially piqued my interest and started me down the path.

https://reversedns.space/ (a map of the Internet) - Morton curve is used as a visualization tool;

https://adsb.exposed/ (a visualizer of air traffic) - Morton curve is used as a database index;

Our most recent release post dove into the usage of Hilbert curves in context of maintaining spatial locality for weather measurements

https://clickhouse.com/blog/clickhouse-release-24-06#hilbert...

Quite an interesting area of study and optimisation!

By @JKCalhoun - 9 months
I'm imagining a physical world analog: shoving a bicycle chain into a shallow box until you can't shove any more of the chain in.
By @smusamashah - 9 months
This reminds of https://binvis.io a binary file visualisation tool that uses space filling curves for visualisation. Discussed here previously https://news.ycombinator.com/item?id=39210436
By @brcmthrowaway - 9 months
Has anyone made generative art with SFC?
By @zholer - 9 months
Drawing hilbert curves is especially great at evaluating the performance of online whiteboards!
By @brcmthrowaway - 9 months
David Hilbert myst be the least German German name of all time.