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

Improve the extraction and the Lean backend #429

Merged
merged 10 commits into from
Feb 3, 2025
Merged

Improve the extraction and the Lean backend #429

merged 10 commits into from
Feb 3, 2025

Conversation

sonmarcho
Copy link
Member

@sonmarcho sonmarcho commented Feb 3, 2025

This PR adds various improvements:

  1. It improves the Lean backend, by modifying some tactics like extract_goal (which I use to extract the current goal as an auxiliary lemma) and tweaking some definitions of the Standard library.

  2. It improves the quality of the extracted code in two ways:

  • code which uses array index/update operations is now a lot cleaner (micro-pass simplify_array_slice_update)
  • it adds a micro-pass simplify_duplicate_calls. The reason is that when writing code we often naturally write duplicate expressions. For instance, below we duplicate expression i + j:
let x = a[i + j];
let y = b[i + j];

In the generated code, this leads to:

let i1 <- i + j
let x <- a.index i1
let i2 <- i + j
let y <- b.index i2

In this code, we have to reason about the fact that i + j doesn't overflow twice. The simplify_duplicate_calls micro-pass deduplicates those expression in the pure model, leading to the following code:

let i1 <- i + j
let x <- a.index i1
let y <- b.index i1

@sonmarcho sonmarcho changed the title Merge Son/lean2 into main Improve the extraction and the Lean backend Feb 3, 2025
@sonmarcho sonmarcho marked this pull request as ready for review February 3, 2025 16:40
@sonmarcho sonmarcho merged commit c69e986 into main Feb 3, 2025
6 checks passed
@sonmarcho sonmarcho deleted the son/lean2 branch February 3, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant