Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABC AST Limitations #37

Closed
Miro-H opened this issue Sep 14, 2021 · 1 comment
Closed

ABC AST Limitations #37

Miro-H opened this issue Sep 14, 2021 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@Miro-H
Copy link
Contributor

Miro-H commented Sep 14, 2021

ABC AST Limitations

This document gathers limitations of our current AST which mainly became apparent while building the Python frontend. Some duplicates with #36 may exist.

Multi-Return Values / Multi-Assignment

What?

The following (Python) syntax is not supported in our AST:

def f():
  return 1, "abc", 2.0 # <- Multi-return

a, b, c = f() # <- Multi-assignment

Something similar is supported though: return values can be ExpressionLists, which contain (a fixed number of) entries of the same type. However, there is no multi-assignment. In fact, those vectors are never changed in size and we always operate on the full vector. All variables are vectors. Thus, assigning variables to parts of the vector is not (straightforward) to support.

Why is this useful?

To efficiently translate higher level languages as Python to our framework.

Type Casting

We do not support type casting yet. I.e., double * int will result in an error and not implicitly cast the int to a double. A real intermediate representation should solve such issues.

No Break Statement / No While Loop

There is no break statement for for-loops. This is an issue for the Python frontend, since Python has limited for-loops. Instead, we often use while-loops to express things.

But without break, some while loops cannot easily be translated, e.g.

i = 1
while True:
  i += i
  if i > 100:
    break

because here, we do an update before checking the condition. This is not the same as

int i;
for (i = 1; i > 100; i += i);

E.g., when we initialize i to 100, the first results in i = 200, the second in i = 100. Detecting how to transform those loops doesn't seem trivial.

Of course, this is only translatable to FHE if i is a non-secret value. We could emulate while loops with for loops (as for(; true; )) but that still requires a break statement for the terminating condition.

Slices

We don't support slices, e.g. v[3:5] to get part of a vector. This is also cumbersome to add, since the vectors used internally never change their size.

Tuple vs List

There is no distinction between tuples and lists in our AST. The main difference in Python is that Tuples are immutable while Lists are mutable. Currently, we use ExpressionLists for Python lists and don't translate Tuples. One of the disadvantages is that we cannot support return statements with multiple values (because they are tuples in Python).

@Miro-H Miro-H added the documentation Improvements or additions to documentation label Sep 14, 2021
@AlexanderViand-Intel
Copy link
Collaborator

Closing this as the old ABC AST structure has been removed for some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants