We have discovered that the current syntax for expressions that we use in the parse* functions is not flexible enough as it doesn't allow to distinguish operators from tensors.
Hence, I would like to suggest to re-design the input format from scratch in order to tackle this issue without being tied to the current syntax.
Proposition
I would propose the following syntax rules:
| Kind |
Syntax |
Comment |
Examples |
| Constant |
constant -> complex | real;
complex -> signed_real ('+' | '-') real 'i';
signed_real -> ('-' | '+') real;
real -> fraction | float | integer;
fraction -> integer '/' integer;
float -> integer? '.' integer;
integer -> [0-9]+;
|
|
|
| Variable |
variable -> id;
id -> letter (letter | digit)*
|
|
|
| Index |
index -> id '_'? integer;
|
|
|
| Tensor |
tensor -> id '[' index_groups ']' (':' symmetry (',' symmetry))?;
index_groups -> ';'* group (';' group)*;
group -> index (',' index)*;
symmetry -> symm_name | cycle;
symm_name -> 'A' | 'S' | 'N' | 'bkS' | 'bkC' | 'bkN' | 'pS' |'pN' ;
cycle -> side_effect? '(' (integer (',' integer)* )? ')' ;
side_effect -> '+' | '-' | '*'
|
- Using `[]` instead of `{}` as index delimiter due to array-like nature of tensors
- Scalar "tensors" are not allowed as one should use a `Variable` instead
- Symmetry specification as (disjoint) cycles (with side-effect) will only be implemented once we have general symmetry support
|
- t[i1]
- t[i1;a1;u1;p1]:pS
- t[;;i1,i2]
- t[i1, i2 ; a1, a2]:pN,+(1,2)
|
| Operator |
operator -> id '{' index_groups '}' ':' statistic ;
statistic -> 'F' | 'B'
|
- {} to resemble normal ordering
- Symmetry determined via chosen statistic
|
|
| Symmetrizer |
symmetrizer -> 'symm' '(' index_groups ')' ':' symmetry
|
- Using reserved keyword "symm" to never confuse symmetrizer with tensor, etc.
- Use parenthesis as delimiters in resemblance to a function call
- Chosen symmetry determined whether it's an symmetric or antisymmetric symmetrization
|
- symm(i1,i2):A
- symm(a1,a2;i1,i2):S
|
Composite expressions like sums and products just follow regular mathematical syntax.
So the core of the proposed changes is the ability to ensure that we have uniquely different syntax for tensors, (normal-ordered) operators and things like symmetrizers.