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

Remove do blocks from generated Lean code when possible #4755

Open
Tracked by #4743
JuanCoRo opened this issue Feb 12, 2025 · 0 comments
Open
Tracked by #4743

Remove do blocks from generated Lean code when possible #4755

JuanCoRo opened this issue Feb 12, 2025 · 0 comments

Comments

@JuanCoRo
Copy link
Member

JuanCoRo commented Feb 12, 2025

The Lean generated code currently uses more do blocks for function definitions than strictly necessary, as an example

def _742a262 : SortScheduleConst → SortSchedule → Option SortInt
  | SortScheduleConst.Rb_SCHEDULE_ScheduleConst, SortSchedule.CONSTANTINOPLE_EVM => do
    let _Val0 <- «_*Int_» 2 1000000000000000000
    return _Val0
  | _, _ => none

could be defined as

def _742a262 : SortScheduleConst → SortSchedule → Option SortInt
  | SortScheduleConst.Rb_SCHEDULE_ScheduleConst, SortSchedule.CONSTANTINOPLE_EVM => «_*Int_» 2 1000000000000000000
  | _, _ => none

In particular, unless the do block is used to chain functions that return an Option type, it can be removed.

Additionally, functions which depend on total functions could be redefined without the do block once their dependencies are stripped of the Option return type. For example

def _432555e : SortWordStack → SortInt → Option SortInt
    | SortWordStack.«_:__EVM-TYPES_WordStack_Int_WordStack» _Gen0 WS, SIZE => do
      let _Val0 <- «_+Int_» SIZE 1
      let _Val1 <- sizeWordStackAux WS _Val0
      return _Val1
    | _, _ => none

Once «_+Int_» and sizeWordStackAux return a SortInt type instead of Option SortInt, it could be redefined as the following or similar

def _432555e : SortWordStack → SortInt → SortInt
    | SortWordStack.«_:__EVM-TYPES_WordStack_Int_WordStack» _Gen0 WS, SIZE =>
      let _Val0 := «_+Int_» SIZE 1
      sizeWordStackAux WS _Val0
    | _, _ => 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant