https://futureofcoding.org/ logo
#share-your-work
Title
# share-your-work
r

Robin

01/04/2024, 6:22 AM
I really like TodePond's video "Screens in Screens in Screens". I've been wanting to do the same kinda thing with mathematical formulas instead of shapes, a kind of "formulas in formulas in formulas", but I'm an awful programmer so I'll describe some math you can do to that effect. Apologies in advance for the shoddy explanation though. Here's a thing you can do with "screens". You can name screens. Start with some screens A B C. Then if C is inside A, and A and B are the same color, then there is a copy of C inside B. What do you call this copy? "The copy of B from A to C"? It will be convenient if we give it a symbolic name. Call it (A->B)C. Or if you are really hardcore you can call it just t(A,B,C) where t is a ternary operator describing the result of copying C from A to B. You may think to only consider (A->B)C when C is inside A, but the math becomes tractable if you consider all screens at once. Then we can stipulate some axioms: 1. (A->A)B = B 2. (A->B)A=B 3. (B->C)(A->B)=(A->C) 3. (A->(X->Y)A)=(X->Y) The first axiom means if you are copying a screen from one screen to itself, you aren't changing anything. The second axiom is "obvious" except for considering (A->B)A in the first place. The third axiom means if you copy a screen from A to B and then from B to C that is the same as if you were to copy it from A to C directly. It is also shorthand for (B->C)((A->B)D) = (A->C)D for all screens D. The fourth axiom takes a bit more explaining. Basically we want this equation to be true whenever A is in X, and both sides are being used to copy something from A. But our theory at this point doesn't have a predicate for "A is contained in X" so we say it holds in all cases. With these axioms you can show the operators (A->B) form an algebraic structure called a group: You can multiply them by performing one copy after the other (C->D)(A->B). This operation is associative (I mean, it must be), and has an identity element and inverses. The identity being (A->A) and the inverse of (A->B) being (B->A). Another perspective is to view screens as points in an affine space (i.e. vector space without a specified origin). Then (A->B)C can be thought of as (B-A)+C, and each of the axioms above can be interpreted as vector equations. This isn't a good model though because it ends up saying some screens are the same when they should be different. You can still take the above axioms and show that screens form a generalization of affine spaces called torsors. I'll share more if anybody is interested. It really needs a much longer write up, but I thought somebody might know if its already been done before.
l

Lu Wilson

01/04/2024, 7:57 AM
hey interesting! I'm not sure I completely understand, but it's nice to see how different people might model this sort of thing. i know @Elliot has been working on a screens-like thing recently, and he modelled it completely differently from me. I'd love to write up a blog post explaining how I model it. it would be nice to see what people think of it
r

Robin

01/04/2024, 4:20 PM
If you do write up that post that would be awesome!
e

Elliot

01/04/2024, 5:25 PM
Cool! I really like screens too. I also like this mathematical modeling of screens! I like the idea to model screens as a group. I have been trying out some models related to the following model: screens as a category: the objects are screens and the arrows mean "contains".
I originally thought about this model when I was using it to solve some puzzles in "Patrick's Parabox" which also involves some recursive box stuff 🙂
You can turn this category into a groupoid by adding in an inverse arrow for every "contains" arrow. The inverse arrows mean "contained by".
The spatial relationships between screens is a functor from this category (or groupoid) to spatial transformations like Affine Transformations (Although @Lu Wilson told me that screens actually uses a different type of spatial transformation). The functor is really just saying "write down a specific transformation next to each arrow"
image.png
IRT your axioms: I have trouble understanding 2 and 4. I can't figure out how to interpret (A -> B)A. I guess it would be "The copy of A from A to B" based on your paragraph above the axioms, but I'm not sure what that means.
r

Robin

01/05/2024, 12:17 AM
I think axiom 2 is hard to picture because in the expression (A->B)C you normally think of C as lying inside A. But in the case of (A->B)A, where C is A, C is no longer strictly inside A, since it coincides with A. Maybe a better way to think of it is to let C vary in size and shape inside A, and let it "tend to A", making the size shape and position approach that of A. Then in the limit as C approaches A in size shape and position, the copy (A->B)C approaches B in size shape and position. Then if copying is a continuous function we are justified in inferring (A->B)A=B. Sorry for the math-speak.
Some diagrams will probably help. This is what (A->B)C looks like in the normal case when C is inside A:
Then when C=A, this is the mental image I have for axiom 2:
e

Elliot

01/05/2024, 12:31 AM
Ah I see! It is maybe quite different than how I've been thinking about things! Can you share how you came up with these axioms? It's starting to make sense but I'm wondering what your intuition was when you were making them.
r

Robin

01/05/2024, 6:30 AM
Oh, that question is so open ended, I love it but I'm really stumped on how to answer it! There is a lot of context I haven't shared, but much of it would be only marginally useful. Maybe I can say this though. A key component of the system I am trying to build are one way live copies. These copies would not only reflect the contents of their source but also the 'behavior' at their source. For instance in the image below the arrows indicate that we are copying from X to Y, from A to C, and from C to B. Then from the point of view of X, we are effectively copying from A to B, so this should be reflected in their copies in Y. One way to ensure this is to also formally copy C from X to Y, even though C isn't inside X, and ensure we copy from (X->Y)A to (X->Y)C, and from (X->Y)C to (X->Y)B. This was my motivation for considering all copies (A->B)C even if C isn't in A. This example also illustrates how my model really only answers how to name the different copies, and not how it is carried out in practice. I don't know if that is all useful to you, but I'm curious, in your implementation of screens is everything two way copies (plus transforms), or are there one way copies too? Is this the difference taking the category as is or making it into a groupoid first makes?
also, how have I never heard of Patricks Parabox before?
Okay, I've been thinking how my more abstract ideas can be applied to model screens, like the actual kind that make for cool looking programs and videos. I've described how screens can be modeled using four axioms. Pictures seem useful so I'll give a picture for axiom 4 first.
Explanation: Axiom 4 given above said that (A->(X->Y)A) = (X->Y). This was shorthand for (A->(X->Y)A)M=(X->Y)M for all screens M. You can also make this look a little nicer by giving the name B to (X->Y)A. Then axiom 4 just states (A->B)M=(X->Y)M. The case where M is in A and A is in X is depicted in the image. Then the axiom says you only get one little square inside B by copying M. Whether you are copying from A to B or from X to Y, it doesn't make a difference.
Hopefully that clears up axiom 4. Now if you take all these axioms you find that the this formal algebra comprises a structure called a torsor. If you stipulate there are no additional relations except those implied by the four axioms then you can probably term the structure a free torsor. The significance of this is that the actual visual objects and transformations between them (rectangles of different sizes and affine maps, and I would expect Lu's transformation group also) form torsors and you can map from free objects very easily by giving a handful of shapes. That's the birds eye view and takes a bit of unpacking.
The idea of torsors is essential so I'll start with that. Rectangles in the plane almost form a torsor. For any two rectangles you can map one to the other by an affine transformation (the composition of a translation and a linear map). This isn't quite unique though because you can always then flip the target rectangle across its major or minor axis, resulting in a distinct transformation.
However, if the rectangles are "framed", by specifying a corner and an orientation then there is a unique affine map from one to the other. The flip map F changes the orientation to in the example above T no longer maps to the same framed rectangle as S. A framed rectangle can be formally specified by a point (designating a corner) and an ordered pair of vectors (designating the two sides to the corner, and the order giving the orientation). Call the framed rectangles A and B. We can think of the transformation turning A into B as a difference B-A and think of applying this transformation to A as adding it to A, so formally B=(B-A)+A.
Because the transformation from A to B was unique the difference B-A is well defined, and we can apply it to any other framed rectangle C to get a transformed rectangle (B-A)+C. This is I think the main point of torsors: You can subtract any two elements of a torsor to get a transformation mapping one to the other. In general this transformation is an element of a group (abstract algebra) and that is called the structure group of the torsor. In the case of framed rectangles I think the structure group is all affine transformations. The other point of torsors is you can apply the transformation B-A to any other element C of the torsor to get a new element (B-A)+C. In the context of framed rectangles, if B is inside A then the transform B-A can be applied to B to get another rectangle (B-A)+B inside B, and you can apply B-A again to get another rectangle inside that.
I hope that explains torsors, at least enough to make my next point. I've mentioned that a system satisfying the four axioms I gave form a torsor. I don't know a simple rigorous proof of this. (I know how to show it forms a heap which is a known equivalent of torsors). But we can also give some intuition for this. To distinguish this from the more visual system, let us call elements of a system to which the axioms apply 'places' rather than 'screens'. Then for any places A B C you can form a new place (A->B)C. Then the set of places forms a torsor whose structure group consists of all transformations A->B. The expression A->B stands for an abstract operator mapping A to B, and this operator can be applied to any other place. You can also think of A->B as the difference B-A. So this abstract system at least has the main features of torsors. The structure group can also be verified to be a group, with A->A being the identity and B->A being the inverse of A->B.
Now suppose you start with some places A B C and consider the set of all places you can build up from those, so you have A, B, C, (A->B)C, (A->(A->B)C)A, (B->A)C, to name a few at random. If the only relations (equalities) between these are those implied by the axioms then I think the resulting algebraic object can be described as a free torsor on the set {A, B, C}. I imagine this notion could be made precise but I can't find it anywhere in the mathematical literature. The key property of a free torsor on a set X (in this case X={A,B,C}) should be that for any torsor T, any function from X to T extends to a homomorphism of torsors from the free torsor on X to T. In particular if T is the torsor of framed rectangles then by assigning framed rectangles to A, B, and C we automatically get framed rectangles for all places A, B, C, (A->B)C, (A->(A->B)C)A, (B->A)C, etc. that you can think of. These represent all possible copies and transforms of rectangles or more general shapes, not only those that display because one box is in another.
The last point I want to make is what I expect these free torsors look like. Briefly, I expect both the structure group and the torsor itself embed in the free group on X, with the structure group being the subgroup of the free group generated by all elements xy^{-1} with x and y in X, and the torsor itself consisting of all products tx with t in the structure group and x in X. And (A->B)C is represented as AB^{-1}C. If this is indeed isomorphic to the free torsor on X, then it gives us a much more convenient way of establishing algebraic identities of places without appealing directly to the axioms. For instance, try proving ((X->Y)A->B) = (A->B)(Y->X) from the axioms. You can do it, but it is much easier writing each side as words in A,B,X,Y, and their inverses, and simplifying. Anyway, @Lu Wilson and @Elliot, this gets a bit closer to actual screens, so you might find it interesting.
e

Elliot

01/22/2024, 1:00 AM
Thank you for this detailed explanation @Robin! I've never come across torsors before but framed rectangles and affine transforms make a lot of sense so I'm really interested.
I read that a torsor is like a group that has forgotten its identity. That makes sense to me by anology because I know that an affine space is like a vector space that has forgotten its origin.
I like your explanation of they key property of a free torsor. It kind of makes sense to me but it's a bit abstract so hard to wrap my brain around.
Oh I just read some more about torsors and heaps and I realized I read about heaps before when studying affine spaces.
I just read that given a group, the ternary operation that sends any three group elements A B and C to AB^{-1}C forms a torsor
And your explanations that this can be thought of as (A->B)C helps me understand this!!
This is really cool. I'm realizing I have been thinking about heaps and torsors but haven't had the language to research these concepts or talk about them!!
So I am getting some intuition, something like that torsors are about being able to form "differences" from two elements of the torsor, and those differences can be applied to any other element of the torsor, and those differences are themselves elements of the torsor. Or is that intuition just for free torsors?
When you write (X->Y)A->B does that associate like ((X->Y)A)->B?
Torsors seem really cool :O
r

Robin

01/23/2024, 11:24 PM
@Elliot Your intuition on torsors about being able to form differences is exactly correct. It holds for all torsors (e.g. of framed rectangles) and not just free torsors. You are also right, when I write (X->Y)A->B I mean ((X->Y)A)->B. The key property of free torsors (technically its 'universal property') is totally abstract. I don't have a great way of explaining it. Its very similar to other 'free' objects such as free monoids if you ever come across those.
The free torsor on two elements A and B I'm pretty sure is the set of all ((A->B)^n )A with n=0, +1, -1, +2, -2, etc. When you map it to framed rectangles (minus the rectangle part I suppose) you get all the frames in the video in this post. https://x.com/elliotokay/status/1723790635587572178?s=20
e

Elliot

01/24/2024, 3:54 PM
Does this mean that the free torsor on two elements A and B is given by the following procedure? 1. Construct the free monoid on two elements A and B (aside: this is easy in programming, this is just strings of As and Bs) 2. Construct the free group on two elements A and B by adding A^{-1} and B^{-1} to the monoid from last step and modifying concatenation (written as juxtaposition) so that the inverses actually satisfy AA^{-1}=id. 3. Construct the free torsor on two elements A and B by taking all elements X of the free group (from last step) of the form X=YZ^{-1}W and keeping concatenation the same (modified to be a group operation in the last step).
If so, then the free torsor has the same elements as the free group, and the same operation, but I suppose it has more automorphisms?
Which makes sense to me because an affine space has the same elements as a vector space but with more automorphisms
Going back, I realize I've pretty much just re-stated what you said
But I guess I feel now that a torsor is about taking a perspective on a group that gives you more transformations (automorphisms) to work with. I want to understand more about the automorphisms now. It feels like the automorphisms of a torsor might consist of something like "differences of group automorphisms"? I'm really not sure though.
Thank you again btw @Robin, I am really appreciating this discussion
l

Lu Wilson

01/24/2024, 4:06 PM
Note to self: I need to catch up with this thread!
r

Robin

01/25/2024, 5:46 AM
@Elliot I almost entirely agree with your description of the free torsor, but I would make one small change to step 3. You write "Construct the free torsor on two elements A and B by taking all elements X of the free group of the form X=YZ^{-1}W" but I don't think Y,Z, and W can be arbitrary elements of the free group. I think they have to be only those elements you get by starting with A and B and applying that operation repeatedly to get larger and larger subsets of the free group. Explicitly, let S be a subgroup of the free group on {A,B} and let H(S)={YZ^{-1}W | Y,Z,W \in S}. I'm thinking "H" for "Heap operation". Let T_0={A,B} and define T_n inductively by T_n = T_{n-1} U H(T_{n-1}). Then the free torsor on {A,B} is the union of all the T_n for n=0,1,2, etc. (I think this accurately describes the idea from the last paragraph, but the idea is the more important thing at any rate.) So for example, T_0 = {A,B} so these are both elements of the free torsor. Then we find T_1 = {A,B} U { YZ^{-1}W | Y,Z,W are in {A,B} }. The second set in this union equals {A,B, AB^{-1}A, BA^{-1}B}. Thus T_1={A,B,AB^{-1}A, BA^{-1}B} so each of these are elements of the free torsor. You can keep on doing this but I don't think you are ever able to construct A^{-1} from this procedure. Consequently the free torsor is a strict subset of the free group. What does it look like then? I'll quote from a previous post In general, for the free torsor on X "I expect both the structure group and the torsor itself embed in the free group on X, with the structure group being the subgroup of the free group generated by all elements xy^{-1} with x and y in X, and the torsor itself consisting of all products tx with t in the structure group and x in X. And (A->B)C is represented as AB^{-1}C." Thus a typical element of the free torsor looks like (ab^{-1})(cd^{-1})...(xy^{-1})z with each of the elements a...z belonging to X. In terms of how this is justified the very rough idea is that you can quantify how many heap operations it takes to produce a particular element starting with (the set the torsor is free on, namely) X. Then you can do induction on how many heap operations it takes to form each element in a particular expression.
"But I guess I feel now that a torsor is about taking a perspective on a group that gives you more transformations (automorphisms) to work with.I want to understand more about the automorphisms now. It feels like the automorphisms of a torsor might consist of something like "differences of group automorphisms"? I'm really not sure though." Even if the free torsors are a strict subset of the free group, this is a really interesting perspective! I've never thought of the relation between groups and torsors in terms of their automorphisms before but its an intriguing thought. One example I'm eager to explore it with: The dihedral group for the square, D8. This is super cool, so thanks! It also puts context to some general math I slogged through on the automorphisms of torsors. More to say, but that's all I have for tonight.
The automorphisms of torsors are interesting to me because they play a part in a feature of screens and the free group/torsor model that I find a bit mysterious. Remember this picture?

https://files.slack.com/files-pri/T5TCAFTA9-F06D7DYL9HN/autodraw_1_4_2024.png

You might think (A->B)C is the same as (A->C)B. It kinda makes sense. With (A->C)B you are taking the transformation A->C that scales A down and shifts it a little and applying the same transform to B. But this actually isn't the case. The transforms (A->C) and (B->(A->B)C) are distinct. (Aside: An interesting question is if this relation implies every transformation commutes with every other transformation). I'm certain these are distinct transformations in the case with the torsor of framed rectangles. The reason for this is the transformation A->B in some sense treats A (or some corner of it) as the origin. Consequently if (A->C) scales down the plane by a factor of 1/2 and B is, say, 100 units out from A, and if B is a 1 unit by 1 unit square (these are not the proportions depicted in the image above), then (A->C)B will scale B to about 50 units from A, far from its initial position. Finally the translation component of the transform A->C won't move B much.
The image below I like as a playground to test these ideas. In the image below M=(P->Q)X, N=(P->Q)Y, A= (P->M)X, B=(P->M)Y, C=(P->N)X), D=(P->N)Y. If the aforementioned transformations were the same we would have B=C.
Although the transforms (A->C) and (B->(A->B)C) are distinct (referring to the image three posts back), they are closely related. For brevity I will write D for (A->B)C. Then the actual relation is (B->D) = (A->B)(A->C)(B->A). In the language of linear algebra (B->D) and (A->C) are similar transforms. In the language of group theory (B->D) and (A->C) are conjugates of each other. You can work this out formally but the intuition is that B->D first shifts the reference frame back to A. Then it applies the transformation (A->C). Lastly it shifts the reference frame back to B. If this was all there was to it I would be happy to call it a day. The two transformations are distinct. There is a definitive simple relation between them. End of story. But there is more! There actually is a kind of way we can apply (A->C) to to B to get D, at least formally.
Recall that in the free group model of the free torsor we have (A->B)C = BA^{-1}C. Well, we can associate this to the right so it is B(A^{-1}C) and that we can think of as B(C<-A). This is just like (A->C)B, only flipped around. What does this mean?! There is surely a mundane mathematical explanation, but I don't know what that is. One intuitive idea that occurred to me as I was writing this is that in a sense (A->C)B implicitly treats A as the origin while B(C<-A) implicitly treats B as the origin. But torsors don't really have an origin/identity element so this really needs a proper explanation.
What does this have to do with automorphisms? We can think of B(C-A) as a kind of "right multiplication" or "right action" of (A-C) on B. This is rather unusual in the context of torsors. In those you are given only a left multiplication/action out of the gate. In only very specific cases do you have a natural right multiplication, namely, when the G-torsor is G itself. In that case, given g and x in G, you can multiply x by g on the right by forming xg. <- there it is, x multiplied by g on the right. This makes sense because they are both elements of G, so you can just multiply them. However, for a general G-torsor X you wouldn't be able to form the product xg because in general you can't multiply elements of a torsor, you can only divide/subtract them. The way around this is to first "trivialize" the torsor. All G-torsors are isomorphic to eachother. In particular every G-torsor is isomorphic to G as a G-torsor. Choosing an isomorphism of X with G is what we mean by "trivializing" X. This is equivalent to choosing an element of X to be the identity. It is also analogous to how you can make an affine space into a vector space by choosing an origin. By trivializing or identifying X with G, we can do right multiplication. The caveat being there are many different ways of doing right multiplication. And this has to do with automorphisms because right multiplication is always a torsor automorphism. This is a tenuous relation admittedly.
Tangential comments/Notes to self: -It's occurring to me when implementing screens either of you could have been implementing B(C-A) instead of (A-C)B. Its perhaps the more natural thing to do if you are only ever copying one shape into another. -One thing I don't understand is how B(C<-A) doesn't involve any arbitrary choices whereas for general torsors right multiplication involves an arbitrary choice. One thought is B(C<-A) only involves arbitrary choices when we try to write it out using conventional left multiplication, but that explanation has issues. -Affine transformations and affine spaces is probably a good place to try to make sense of B(C<-A). Is it related to the transpose?
e

Elliot

02/02/2024, 3:42 PM
Thank you for fixing my construction! I see how you have to iteratively construct each "layer" of the torsor; very roughly: you start by writing down the differences, then the differences of differences, then differences of differences of differences and so on forever. Then you can refer to any element of the torsor in a finite sequence of steps by saying what "layer" it is in.
I will have to think about it more but I see now where I may not have understood how the elements of the free torsor relate to the free group.
Re: exploring the automorphism perspective with D8. Yes! That is where my mind went as well! Actually I was thinking of the Klein 4 group. I haven't sat down and worked through it though.
Your exploration that follows is really interesting! I like how you take an algebraic approach to your exploration. I was going to say I have trouble following, but I read through again and it makes sense. I think its that the algebra makes sense, but its hard to connect it to a mental picture. So, like you say, it would be really interesting to hear how this algebra plays out in an affine space so we can get a picture of what is happening.
It makes me realize that I work from pictures but use algebra to describe the properties of pictures that I want to capture. On the other hand, you seem to be going about things algebra first which seems like a really cool way to find some relationships that wouldn't be obvious from pictures.
r

Robin

02/03/2024, 4:31 AM
@Elliot Yes, I'm going about it very algebraically. I have all sorts of images in my head of what different things mean, but I can't hold it all in my head at once. I hope once I have the math worked out I can translate it back into pictures 🙂.
2 Views