|
1 | 1 | # LangToGroup
|
2 | 2 |
|
| 3 | +[](https://travis-ci.org/YaccConstructor/LangToGroup) |
| 4 | + |
3 | 5 | This project provides an opportunity to build a grammar group representation in two ways, which is displayed in the following picture:
|
4 | 6 | 
|
5 | 7 |
|
@@ -36,65 +38,68 @@ This conversion uses different set of generators as opposed to the first convers
|
36 | 38 |
|
37 | 39 | <img src="https://latex.codecogs.com/png.latex?\\&space;G(T)&space;=&space;\{&space;q,&space;h,&space;s_0,&space;\ldots,&space;s_M,&space;q_0,&space;\ldots,&space;q_N,&space;q^R_0,&space;\ldots,&space;q^R_N&space;\}&space;\\&space;R(T)&space;=&space;\forall&space;\alpha&space;\in&space;0..N,&space;\beta&space;\in&space;0..M&space;:&space;\\&space;\begin{array}{r@{~=~}lc@{~if~}c@{~\in&space;T}}&space;q_i&space;s_j&space;&&space;q_l&space;s_k&space;&&space;&&space;q_i&space;s_j&space;s_k&space;q_l&space;\\&space;q_i&space;s_j&space;&&space;s_j&space;q_l&space;&&space;&&space;q_i&space;s_i&space;R&space;q_l&space;\\&space;s_j&space;q^R_i&space;&&space;q^R_l&space;s_j&space;&&space;&&space;q_i&space;s_i&space;L&space;q_l&space;\\&space;q_\alpha&space;s_\beta&space;&&space;s_\beta&space;q^R_\alpha&space;\\&space;q_\alpha&space;h&space;&&space;s_0&space;q^R_\alpha&space;h&space;\\&space;h&space;q^R_\alpha&space;&&space;h&space;q_\alpha&space;s_0&space;\\&space;q_0&space;s_\beta&space;&&space;q_0&space;\\&space;s_\beta&space;q_0&space;h&space;&&space;q_0&space;h&space;\\&space;h&space;q_0&space;h&space;&&space;q&space;\end{array}" />
|
38 | 40 |
|
39 |
| -## Build status |
40 |
| -[](https://travis-ci.org/YaccConstructor/LangToGroup) |
41 |
| - |
42 | 41 | ## Building
|
43 |
| -To build run: |
44 |
| - |
45 |
| -``stack build`` |
| 42 | +```bash |
| 43 | +stack build |
| 44 | +``` |
46 | 45 |
|
47 | 46 | ## Testing
|
48 |
| -For run the tests: |
49 |
| - |
50 |
| -``stack test`` |
| 47 | +```bash |
| 48 | +stack test |
| 49 | +``` |
51 | 50 |
|
52 | 51 | ## Usage
|
53 | 52 | ```bash
|
54 |
| -stack run -- LangToGroup-cli |
| 53 | +stack run -- LangToGroup-cli <options> |
55 | 54 | ```
|
56 | 55 |
|
57 |
| -``` |
58 |
| -Usage: LangToGroup-cli <options> |
59 |
| -
|
60 |
| -Options: |
61 |
| - -i file_path --input=file_path Full path to file with grammar definition |
62 |
| - -o file_path --output=file_path Full path to file for printing results |
63 |
| - -e file_path --error=file_path Full path to file, where errors should be recorded during parsing |
64 |
| - -a approach --approach=approach Used approach (see section `Approaches`) |
65 |
| - -L --LaTeX Print result in LaTeX format (while doesn't work) |
66 |
| - -I objects --info=objects Print useful information about objects (see section `Objects`) |
67 |
| - -h --help Print help and exit |
68 |
| -
|
69 |
| -Approaches: |
70 |
| - first |
71 |
| - Implementation of algorithm from "Isoperimetric and Isodiametric Functions of Groups" |
72 |
| - second |
73 |
| - Implementation of algorithms from "Boolean grammars" and "An Introduction to the Theory of Groups" |
74 |
| - second_a |
75 |
| - Modifications of `second` approach with modified algorithm from "An Introduction to the Theory of Groups" |
76 |
| - second_b |
77 |
| - Modifications of `second` approach with modified algorithm from "An Introduction to the Theory of Groups" |
78 |
| -
|
79 |
| -Objects: |
80 |
| - grammar |
| 56 | +### Options |
| 57 | + * `-i file_path` `--input=file_path` |
| 58 | + Full path to file with grammar definition |
| 59 | + * `-o file_path` `--output=file_path` |
| 60 | + Full path to file for printing results |
| 61 | + * `-e file_path` `--error=file_path` |
| 62 | + Full path to file, where errors should be recorded during parsing |
| 63 | + * `-a approach` `--approach=approach` |
| 64 | + Used approach (see section [Approaches](#approaches)) |
| 65 | + * `-I objects` `--info=objects` |
| 66 | + Print useful information about objects (see section [Objects](#objects)) |
| 67 | + * `-h` `--help` |
| 68 | + Print help and exit |
| 69 | + |
| 70 | +### Approaches |
| 71 | + * `first` |
| 72 | + Implementation of algorithm from [Isoperimetric and Isodiametric Functions of Groups](https://arxiv.org/abs/math/9811105) |
| 73 | + * `second` |
| 74 | + Implementation of algorithms from [Boolean grammars](https://doi.org/10.1016/j.ic.2004.03.006) and [An Introduction to the Theory of Groups](https://doi.org/10.1007/978-1-4612-4176-8) |
| 75 | + * `second_a` |
| 76 | + Modifications of `second` approach with modified algorithm from [An Introduction to the Theory of Groups](https://doi.org/10.1007/978-1-4612-4176-8) |
| 77 | + * `second_b` |
| 78 | + Modifications of `second` approach with modified algorithm from [An Introduction to the Theory of Groups](https://doi.org/10.1007/978-1-4612-4176-8) |
| 79 | + |
| 80 | +### Objects |
| 81 | + * `grammar` |
81 | 82 | Input grammar (context-free, conjunctive or boolean)
|
82 |
| - turing_machine, tm |
| 83 | + * `turing_machine`, `tm` |
83 | 84 | Produced Turing machine (its type depends on used approach)
|
84 |
| - group_presentation, gp |
| 85 | + * `group_presentation`, `gp` |
85 | 86 | Produced group presentation
|
86 |
| -Note: When enumerating objects, they must be separated by commas WITHOUT SPACES! |
87 | 87 |
|
88 |
| -For more information see https://github.com/YaccConstructor/LangToGroup/blob/master/README.md |
89 |
| -``` |
| 88 | +> **NOTE**: When enumerating objects, they must be separated by commas WITHOUT SPACES! |
90 | 89 |
|
91 |
| -For example, if you want build presentation of grammar via second modification of the second approach and get metrics of produced group presentation and Turing machine, you should type options: |
92 |
| -`-i grammar.txt -a second_b -I tm,gp` |
| 90 | +### Examples |
93 | 91 |
|
94 |
| -And if you want to build presentation of grammar via first approach and save produced group presentation to file, you should type options: |
95 |
| -`-i grammar.txt -o group_presentation.txt -a first` |
| 92 | + * ```bash |
| 93 | + stack run -- LangToGroup-cli -i grammar.txt -a second_b -I tm,gp |
| 94 | + ``` |
| 95 | + If you want build presentation of grammar via second modification of the second approach and get metrics of produced group presentation and Turing machine |
96 | 96 |
|
97 |
| -Examples of grammar files given below. |
| 97 | + * ```bash |
| 98 | + stack run -- LangToGroup-cli -i grammar.txt -o group_presentation.txt -a first |
| 99 | + ``` |
| 100 | + If you want to build presentation of grammar via first approach and save produced group presentation to file |
| 101 | + |
| 102 | +### Examples of grammar |
98 | 103 |
|
99 | 104 | **Boolean grammar**
|
100 | 105 |
|
@@ -168,3 +173,45 @@ Here are the tables with some examples of building group presentations by differ
|
168 | 173 | | <img src="https://render.githubusercontent.com/render/math?math=\{ww \mid w \in \{a,b\}*\}">| Boolean| 14 | 2498 | 20200 | 455220 |
|
169 | 174 | | <img src="https://render.githubusercontent.com/render/math?math=\{a^{m} b^{n} c^{n} \mid (m != n), m, n \in N\}"> | Boolean | 14 | 3461 | 27655 | 683100 |
|
170 | 175 |
|
| 176 | +## Execution (old version) |
| 177 | + |
| 178 | +> **NOTE**: Old CLI was saved because some of posibilities aren't available in new CLI. |
| 179 | +
|
| 180 | +For run experiments and print its numerical results you can use `is_det <bool>` flag. |
| 181 | +
|
| 182 | +So, for print experiments' results using deterministic symmetrization: |
| 183 | + |
| 184 | +```bash |
| 185 | +stack exec -- LangToGroup-printer --is_det true |
| 186 | +``` |
| 187 | + |
| 188 | +using nondeterministic symmetrization: |
| 189 | + |
| 190 | +```bash |
| 191 | +stack exec -- LangToGroup-printer --is_det false |
| 192 | +``` |
| 193 | + |
| 194 | + |
| 195 | +### Printing example transformations in LaTeX |
| 196 | +Grammar's transformations also can be printed in LaTeX. For this should be used `--print_example <grammar>` flag. |
| 197 | +The following grammars can be used as print examples: "one\" --- one rule grammar, \"a*\" --- grammar for regular language |
| 198 | +<img src="https://render.githubusercontent.com/render/math?math=L = \{a*\}"> |
| 199 | +, \"dyck\" --- Dyck language grammar. |
| 200 | +
|
| 201 | +For example, |
| 202 | +
|
| 203 | +```bash |
| 204 | +stack exec -- LangToGroup-printer --is_det true --print_example one |
| 205 | +``` |
| 206 | +
|
| 207 | +Output filename can be specified by ``-o <filename>`` flag. |
| 208 | +
|
| 209 | +### Printing example group presentation in Gap-format file |
| 210 | +For this you can use `-G` flag without a parameter, but with `--is_det <bool>` and `--print_example <grammar>` flags. |
| 211 | +Also, output filename can be specified by `-o <filename>` flag, if it does not speccified it been printing with default filename "out.txt". |
| 212 | +
|
| 213 | +For example, following prints in "out.txt" a group presentation, which obtained from Dyck language grammar using nondeterministic symmetrization: |
| 214 | +
|
| 215 | +```bash |
| 216 | +stack exec -- LangToGroup-printer -G --is_det false --print_example dyck |
| 217 | +``` |
0 commit comments