noir icon indicating copy to clipboard operation
noir copied to clipboard

Deprecation of the Integer Object

Open kevaundray opened this issue 4 years ago • 1 comments

Currently If two integers are added in succession, this will produce a lot more constraints than we desire.

For example:

func main(x : u32) {
  priv a = x + x
  priv b = a + a
  priv c = b + b 
}

This is identical to:

func main(x : u32) {
  priv c = 8 * x 
}

However, since adding two linear expressions returns an arithmetic which is then turned into a linear, we do not have access to this optimisation. Arithmetic -> linear removes all information between the individual witnesses, that the optimiser could use.

@guipublic suggested that instead, we use a Map, somewhat like a table to store this auxiliary information regarding witnesses. This would allow us to have the above optimisation.

In addition, it means that we can remove the Integer object. Furthermore, the information that we store in the map can be collected at the analysis phase, however this is not required at the moment.

Finally this map will also allow us to remove the constants object variant, but this can be done in a separate PR as it might be a bit more involved.

kevaundray avatar Oct 29 '21 11:10 kevaundray

Note, we will still need the ability to compress a linear combination into a single witness, however if we use a map, we can add logic to check the compressed linear combinations

kevaundray avatar Oct 29 '21 11:10 kevaundray

This was an artefact of the interpreter and has since been removed when @guipublic implemented the ssa pass

kevaundray avatar Jan 21 '23 18:01 kevaundray