diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2024-04-18 13:44:07 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2024-04-18 13:44:07 +0900 |
| commit | 4c45e86c833fe84a65cb511d6c025745d2dba776 (patch) | |
| tree | 795ac1c691328bf1d257d982014991346c5091d1 | |
| parent | f2188120d8d2ceba51a2136f66f45df86bc0f366 (diff) | |
| download | inpla-4c45e86c833fe84a65cb511d6c025745d2dba776.tar.gz inpla-4c45e86c833fe84a65cb511d6c025745d2dba776.zip | |
v0.12.3
| -rw-r--r-- | Changelog.md | 40 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | src/inpla.y | 38 |
3 files changed, 67 insertions, 13 deletions
diff --git a/Changelog.md b/Changelog.md index 91615f2..9f15d44 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,45 @@ # Change log +### v0.12.3 (released on 18 Apr 2024) + +#### Polished (minor) +- **Substitution optimisation for main active pairs is switched off**: When main active pairs are given, substitution optimisation is applied to them first. Duplicate names are substituted, and then compilation starts. Syntax errors are detected at this compilation step. It works well to remove redundancy of substitutable active pairs from the compilation results. However, for the given active pairs where names occur three times, it causes some strange behaviour. For example, a user expects to have a cyclic net with a connection by the following active pairs: + + ``` + >>> alpha(x)~x, main~x; + ``` + + Of course, it should be rejected, but it can be accepted because `x` is substituted and it becomes `main~alpha(x)`: + + ``` + >>> ifce; + main x + + Connections: + main ->alpha(x) + x -><EMPTY> + ``` + + The problem is that we can have three times occurrences of the same name if it is a variable of attributes, so the occurrence check must be done after the compilation without substitution optimisation: + + ``` + >>> r ~ (a+a+a) where a=1; + ``` + + So, substitution optimisation is now switched off for the main active pairs, although this is an ad hoc fix. The occurrence count check has also been fixed. It now works correctly: + + ``` + Inpla 0.12.3 : Interaction nets as a programming language [built: 18 Apr 2024] + >>> alpha(x)~x, main~x; + 1:ERROR: The name `x' occurs more than twice. + ``` + + Of course, the optimisation is still applied to active pairs in the rule definitions. I think, the effect is quite small because the substitution is only done once and the cost is very small compared to the whole computation. + + + + + ### v0.12.2 (released on 16 Mar 2024) #### New Features @@ -6,7 +6,7 @@ Inpla is a multi-threaded parallel interpreter of interaction nets. Once you write programs for sequential execution, it works also in multi-threaded parallel execution. Each thread is managed on each CPU-core with POSIX-thread library. -* The current version is 0.12.2, released on **16 Mar 2024**. (See [Changelog.md](Changelog.md) for details.) +* The current version is 0.12.3, released on **18 Apr 2024**. (See [Changelog.md](Changelog.md) for details.) * The below graph shows speed-up ratio to threads numbers for programs in the following benchmark table.  diff --git a/src/inpla.y b/src/inpla.y index a337f25..f5da2a8 100644 --- a/src/inpla.y +++ b/src/inpla.y @@ -22,8 +22,8 @@ // ---------------------------------------------- -#define VERSION "0.12.2" -#define BUILT_DATE "16 Mar 2024" +#define VERSION "0.12.3" +#define BUILT_DATE "18 Apr 2024" // ------------------------------------------------------------------ @@ -3726,7 +3726,7 @@ int CmEnv_check_name_reference_times(void) { int i; for (i=0; i<CmEnv.bindPtr; i++) { if (CmEnv.bind[i].type == NB_NAME) { - if (CmEnv.bind[i].refnum > 2) { + if (CmEnv.bind[i].refnum > 1) { printf("%d:ERROR: The name `%s' occurs more than twice.\n", yylineno, CmEnv.bind[i].name); return 0; @@ -6064,8 +6064,19 @@ int Ast_make_annotation_TailCallOptimisation(Ast *mainbody) { return 0; } - - Ast_RewriteOptimisation_eqlist(eqs); + + // DEBUG: 13 Apr 2024 + // Improvement plan: + // To check the syntax, the compilation should be done first. + // Next, if the rewriting deals with at least one ap pair, + // the compilation should be redo. + // But, this rewriting optimisation is really needed? + // This must be required for rules, but this is a top level program, + // and it is executed just one time... + // + // Ast_RewriteOptimisation_eqlist(eqs); + + // ast_puts(eqs);puts(""); if (Ast_eqs_has_agentID(eqs, AST_ANNOTATION_L)) { @@ -6874,11 +6885,11 @@ int check_invalid_occurrence(Ast *ast) { if (ast->id == AST_NAME) { int sym_id = NameTable_get_id(ast->left->sym); - if (IS_GNAMEID(sym_id)) { // already exists as a global VALUE aheap = IdTable_get_heap(sym_id); + /* // it is connected with something. if (NAME(aheap)->port != (VALUE)NULL) { @@ -11132,13 +11143,16 @@ int exec(Ast *at) { // aplist at = at->right; + + /* // for aplists - // puts(""); ast_puts(at); puts(""); - // Ast_RewriteOptimisation_eqlist(at); - // puts(""); ast_puts(at); puts(""); - // // exit(1); - - Ast_RewriteOptimisation_eqlist(at); + puts(""); ast_puts(at); puts(""); + Ast_RewriteOptimisation_eqlist(at); + puts(""); ast_puts(at); puts(""); + exit(1); + */ + + // Ast_RewriteOptimisation_eqlist(at); // Syntax error check { |
