<p>In the realm of <a href="http://en.wikipedia.org/wiki/Constructive_solid_geometry" rel="nofollow">constructive solid geometry</a>, questions like the one you asked can probably be answered. Here, solids are constructed by unions and differences of basic shapes (for example, a sphere with a tunnel can be described as Ball - Cylinder. Shapes are then built up as trees of operations on basic shapes (at the leaves), and the differencing problem can then be thought of as a labelled tree-diff problem (which has been examined among other things in the context of comparing XML documents).</p>

<p>I'm not claiming that these questions are already being studied, but CSG is definitely one place where the geometric questions you're asking might be addressed. </p>

CC BY-SA 2.5
2010-12-05T06:20:03.697Z
2010-12-05T07:02:40.650Z
2010-12-05T07:02:40.650Z
Suresh Venkat
<p>I think little is known about such questions because they are immediately in the NP-hard domain. As a concrete example, consider the problem of deciding given a set in the plane (with piecewise linear boundaries), what is the minimal number of triangles needed to cover it. However, after appropriate twiddling, this is minimum set cover of points in the plane by triangles, which is hard. And this is maybe the simplest variant of such a problem.</p>

<p>Another way of thinking about this problem (which is hand-wavy and just intuition, but nevertheless...), is that you are trying to find the simplest description of a decision surface that separates some set of points from another. And that is, in general, a very hard problem...</p>

CC BY-SA 2.5
2010-12-06T17:54:34.657Z
2010-12-06T19:04:47.280Z
2010-12-06T19:04:47.280Z
Sariel Har-Peled
<p>The <a href="http://en.wikipedia.org/wiki/Diff" rel="nofollow">diff</a> procedure can be generalized to operate on objects other than strings.<br>
For instance, I imagine that computational geometry asks questions like: "Given two volumes, and allowed only the operations of union and subtraction of volumes, what (shortest) sequence of operations transforms the first volume into the second?"</p>

<p>Seems like to generalize diff beyond strings requires three things:
1) a space of objects on which to operate (these are strings in classic diff, but could be anything like surfaces, volumes, etc).<br>
2) for any object, a decomposition of that object into components, along with an operation -, such that OBJECT1 - COMPONENT := OBJECT2. (e.g. "abcdef" - "de" := "abcf")<br>
3) a binary operation of addition such that OBJECT1 + OBJECT2 = OBJECT3 ("abc" + "def" = "abcdef"). Also, closure under this property.</p>

<p>My questions:<br>
Q1) Can you point me to any concrete incarnations of diff outside the string domain? For instance, what's the name of the computational geometry problem I described in the first paragraph? I'm sure there's extensive literature on this but I just don't know what to google.<br>
Q2) Is there an algebraic structure which fits the structure of generalized diff?</p>

CC BY-SA 2.5
2010-12-06T22:36:39.800Z
Would the word problem for groups (or semigroups) qualify as an algebraic instance of "diff"?
mhum
CC BY-SA 2.5
2010-12-07T19:02:32.647Z
It seems to me you need a fourth thing: 4) a measure of the 'size' of an expression.  Otherwise, in many instances diff could trivially return OBJECT2 = (OBJECT1 - OBJECT1) + OBJECT2.  In fact, this seems to be a universal answer to your original question whenever the two volumes are distinct (but still possibly overlap).
whuber
<ds.algorithms><cg.comp-geom>
Geometric differencing
pseudosudo
# Geometric differencing

(Asked by: username_0 on 2010-12-05)

The [diff](http://en.wikipedia.org/wiki/Diff) procedure can be generalized to operate on objects other than strings.  
For instance, I imagine that computational geometry asks questions like: "Given two volumes, and allowed only the operations of union and subtraction of volumes, what (shortest) sequence of operations transforms the first volume into the second?"

Seems like to generalize diff beyond strings requires three things:
1) a space of objects on which to operate (these are strings in classic diff, but could be anything like surfaces, volumes, etc).  
2) for any object, a decomposition of that object into components, along with an operation -, such that OBJECT1 - COMPONENT := OBJECT2. (e.g. "abcdef" - "de" := "abcf")  
3) a binary operation of addition such that OBJECT1 + OBJECT2 = OBJECT3 ("abc" + "def" = "abcdef"). Also, closure under this property.

My questions:  
Q1) Can you point me to any concrete incarnations of diff outside the string domain? For instance, what's the name of the computational geometry problem I described in the first paragraph? I'm sure there's extensive literature on this but I just don't know what to google.  
Q2) Is there an algebraic structure which fits the structure of generalized diff?

**Tags:** ds.algorithms, cg.comp-geom

> **Comments:**
> **username_1**: Would the word problem for groups (or semigroups) qualify as an algebraic instance of "diff"?  
> **username_2**: It seems to me you need a fourth thing: 4) a measure of the 'size' of an expression.  Otherwise, in many instances diff could trivially return OBJECT2 = (OBJECT1 - OBJECT1) + OBJECT2.  In fact, this seems to be a universal answer to your original question whenever the two volumes are distinct (but still possibly overlap).  

---

## 2 answers

### Answer by username_3 on 2010-12-05. Score: 3

In the realm of [constructive solid geometry](http://en.wikipedia.org/wiki/Constructive_solid_geometry), questions like the one you asked can probably be answered. Here, solids are constructed by unions and differences of basic shapes (for example, a sphere with a tunnel can be described as Ball - Cylinder. Shapes are then built up as trees of operations on basic shapes (at the leaves), and the differencing problem can then be thought of as a labelled tree-diff problem (which has been examined among other things in the context of comparing XML documents).

I'm not claiming that these questions are already being studied, but CSG is definitely one place where the geometric questions you're asking might be addressed.


---

### Answer by username_4 on 2010-12-06. Score: 2

I think little is known about such questions because they are immediately in the NP-hard domain. As a concrete example, consider the problem of deciding given a set in the plane (with piecewise linear boundaries), what is the minimal number of triangles needed to cover it. However, after appropriate twiddling, this is minimum set cover of points in the plane by triangles, which is hard. And this is maybe the simplest variant of such a problem.

Another way of thinking about this problem (which is hand-wavy and just intuition, but nevertheless...), is that you are trying to find the simplest description of a decision surface that separates some set of points from another. And that is, in general, a very hard problem...


---

