#!/usr/bin/env python # coding: utf-8 # # StringApplet to SageMath converter # # This is a manual of [`converter.py`](https://github.com/haruhisa-enomoto/StringApplet-to-SageMath-converter). # It converts the exported tex file produced by [String Applet](https://www.math.uni-bielefeld.de/~jgeuenich/string-applet/) # into a data which we can use to construct the poset of torsion classes in [SageMath](https://www.sagemath.org/). # We assume that you have installed SageMath. # # AUTHOR: [Haruhisa Enomoto](http://haruhisa-enomoto.github.io/) # # ### Table of contents # # - [String Applet](#String-Applet): an explanation of String Applet. # - [Usage](#Usage): how to use `converter.py`. In particular, you can use two functions: # - [SAtoSage](#SAtoSage%28tex_path%29) # - [export](#export%28tex_path,-output_path%29) # - [See also](#See-also): Other materials which can be helpful. # ## String Applet # # [String Applet](https://www.math.uni-bielefeld.de/~jgeuenich/string-applet/) is a web program developed by [Jan Geuenich](https://www.math.uni-bielefeld.de/~jgeuenich/), which is a **very** useful tool when we want to observe (and play with) concrete examples in the representation theory of algebras. Here are the description from the site. # # This web program can deal with special biserial algebras, string algebras, and gentle algebras, thus a large class of algebras (you don't have to know definitions to use it, since this program automatically checks whether your inputed algebra is OK). After inputing your algebra, it displays many combinatorial invariants of these algebras and their module categories. # # We can easily input our finite-dimensional algebras intuitively by a quiver and relations in the left bottom input form. # For example, the following represents an algebra $\Lambda:= k[1 \xrightarrow{a}2 \xrightarrow{b}3]/\langle ab \rangle$. # # # # Then, by clicking **Update**, lots of information on this algebra is shown in the right part. # In particular, String Applet computes the support $\tau$-tilting quiver if a given algebra is representation-finite. # This quiver is nothing but the Hasse quiver of the lattice of torsion classes $\mathsf{tors}\,\Lambda$ like this: # # # # *The aim of this code is* **to make this poset available in SageMath.** # ## Usage # # First, please download [``converter.py``](https://github.com/haruhisa-enomoto/StringApplet-to-SageMath-converter/blob/main/converter.py) in your PC ([this](https://github.com/haruhisa-enomoto/StringApplet-to-SageMath-converter/raw/main/converter.py) is a direct link of this file). It is recommended that you download it in your working directory (where your Jupyter Notebook or Sage file belongs). # # ### Step 1. Export the tex file from String Applet # # The first step is to export the tex file from String Applet **after showing the s$\tau$-Tilting quiver**. # # 1. Input your favorite algebra on String Applet by a quiver with relations, and click "Update" on the left part. # 2. Click "$\tau$-Tilting" tab on the right part. Then there is a button "Show" in the s$\tau$-Tilting quiver part. # # # # (If there is no "Show" button, make sure that your algebra is representation-finite, which is shown in the left part.) # 3. Click this "Show" button. Then the Hasse quiver will be shown. # 4. Place the cursor over "Export", then click "As LaTeX". Then save the latex file in the same directory as [``converter.py``](https://github.com/haruhisa-enomoto/StringApplet-to-SageMath-converter/blob/main/converter.py). # # # # For example, suppose the filename is ``SA.tex``. # ### Step 2. Load `converter.py` and use it # # Then load `converter.py` in SageMath. There are several ways to do it. # If you are using SageMath on Jupyter Notebook or Interactive Shell, then just write # In[1]: load("converter.py") # and excute it. In this case, make sure that `converter.py` is in your working directory. # If you are writing your own SageMath file (like `foo.sage`), then write # # ``` # import converter # ``` # # in the beginning of your file (also in this case, make sure that `foo.sage` and `converter.py` belong to the same directory). # For simplicity, we assume the former case from now on. (For the latter case, you should write ``converter.SAtoSage`` instead of just `SAtoSage`, or write ``from converter import SAtoSage``.) # After loading `converter.py`, you can use two functions: # # - [SAtoSage](#SAtoSage%28tex_path%29) # - [export](#export%28tex_path,-output_path%29) # ### SAtoSage(`tex_path`) # # Return the data which can be used to construct the poset of torsion classes in SageMath from the tex file exported by StringApplet. # # INPUT: # # - `tex_path` -- a path of the exported tex file. # # OUTPUT: # # a data from which we can construct poset or lattice in SageMath. # # EXAMPLE: # Assume that you has `SA.tex` in the working directory. Then for example, we have # In[2]: data = SAtoSage("SA.tex") data # This data consists of a tuple `(tors, rels)`, where # - `tors` is a list of torsion classes, indexed by integers. # - `rels` is a list of covering relations (U,T) of torsion classes. (U,T) is a covering relation if there is a Hasse arrow $U \leftarrow T$. # # To construct a poset from this data, you just do the following in SageMath. # In[3]: tors_poset = Poset(data) tors_poset # Note that **the orientation of Hasse quiver in SageMath is opposite to the representation theorist's convention**, so `0` is the largest torsion class $\mathsf{mod}\, \Lambda$ and `11` is the smallest torsion class $0$. # # In case you want to consider this poset as a lattice, use ``LatticePoset`` instead of ``Poset``. # In[4]: tors_lattice = LatticePoset(data) tors_lattice # Maybe *it's recommended to use `LatticePoset` because we can use more functions including join, meets and so on*. For example, the following count the number of join-irreducible torsion classes. # In[5]: print("The number of join-irreducible torsion class is") print(len(tors_lattice.join_irreducibles())) # Since join-irreducibles are in bijection with bricks, from this, we can conclude that our algebra $\Lambda$ has $5$ bricks! # ### export(`tex_path`, `output_path`) # # If you want to export the data of this poset to another file, then use this function. This will be useful if you want to use the poset data later. # # INPUT: # # - ``tex_path`` -- a path of the exported tex file # # - ``output_path`` -- a path of the output file # (error will be raised if the file already exists) # # EXAMPLE: # # By executing this function, we make another file of the name `output_path`. # For example, if you want to export the poset data to a new file `output.sage`, do the following. # In[6]: export("SA.tex", "output.sage") # The content of `output.sage` is as follows: # # ``` # data = ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [(1, 0), (2, 0), (3, 0), (4, 1), (5, 1), (6, 3), (7, 3), (4, 2), (8, 2), (9, 4), (6, 5), (9, 5), (10, 6), (8, 7), (10, 7), (11, 8), (11, 9), (11, 10)]) # ``` # # Namely, the data created by `SAtoSage` function is saved in the variable `data`. # Therefore, you can use this data as follows. # In[7]: load("output.sage") # In[8]: tors_lattice = LatticePoset(data) tors_lattice # ## See also # # - [Manual of Lattices in SageMath](https://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/lattices.html). You can see various operations which you can apply to our lattice of torsion classes. # - [The lattice of torsion classes in SageMath](https://github.com/haruhisa-enomoto/tors-lattice), which is another SageMath program I've developed. This computes various objects from the poset of torsion classes.