feat(serial): Pickle environment delta's #221

Merged
aniva merged 5 commits from serial/delta into dev 2025-06-27 16:02:22 -07:00
Owner

This makes the environments smaller, and also add an option to trust the pickle so we don't need to replay constants.

  • feat(env): Environment merging function
  • feat(repl): Goal state merging function
  • fix(goal): Combine environments in replay
  • fix(goal): Rename aux lemmas during merger
This makes the environments smaller, and also add an option to trust the pickle so we don't need to replay constants. - feat(env): Environment merging function - feat(repl): Goal state merging function - fix(goal): Combine environments in replay - ~~fix(goal): Rename aux lemmas during merger~~
aniva added this to the 0.3.3 milestone 2025-06-26 11:50:36 -07:00
aniva added the
part/Serial
category
optimization
part/Environment
labels 2025-06-26 11:50:36 -07:00
aniva self-assigned this 2025-06-26 11:50:36 -07:00
aniva changed title from feat: Pickle environment delta's to feat(serial): Pickle environment delta's 2025-06-26 11:50:42 -07:00
aniva added a new dependency 2025-06-26 11:50:52 -07:00
aniva modified the milestone from 0.3.3 to 0.4.0 2025-06-26 11:55:59 -07:00
aniva added 1 commit 2025-06-26 15:52:01 -07:00
aniva added 1 commit 2025-06-26 15:52:50 -07:00
Author
Owner

We can store a pristine version of the environment in the main monad, and calculate deltas w.r.t. this environment.

We can store a pristine version of the environment in the main monad, and calculate deltas w.r.t. this environment.
aniva added a new dependency 2025-06-26 15:58:55 -07:00
aniva added 1 commit 2025-06-26 16:23:34 -07:00
aniva added 1 commit 2025-06-26 16:42:12 -07:00
Author
Owner

There is one test case failing corresponding to adding auxiliary lemmata on both branches.

There is one test case failing corresponding to adding auxiliary lemmata on both branches.
Author
Owner

Without the DeclNameGenerator mechanism to be introduced in 4.21.0, we are looking at something like

def merge (dst src src' : Environment) : Environment × Std.HashMap Name Name :=
  let dstLemmas := Meta.auxLemmasExt.getState dst
  let srcLemmas := Meta.auxLemmasExt.getState src
  let srcLemmas' := Meta.auxLemmasExt.getState src'

  let didx := srcLemmas'.idx - srcLemmas.idx
  let nameInfix := .str .anonymous s!"_merge_{dstLemmas.idx}"

  -- Construct the map by finding name collisions
  let map := srcLemmas'.lemmas.foldl (init := Std.HashMap.emptyWithCapacity didx) λ acc _ (name, _) =>
    if src.contains name then
      acc
    else
      let name' := name.modifyBase (· ++ nameInfix)
      acc.insert name name'

  -- Rename the colliding lemmas in `src'`, including occurrences within constants

  let dst := Meta.auxLemmasExt.modifyState dst fun { idx, lemmas } =>
    ⟨idx + 1, lemmas.insert type (auxName, levelParams)⟩

  (dst.replayConsts src src', map)

but Lean's environment is really not conducive to renaming. I think we should wait until we have the name generator.

Without the `DeclNameGenerator` mechanism to be introduced in `4.21.0`, we are looking at something like ```lean def merge (dst src src' : Environment) : Environment × Std.HashMap Name Name := let dstLemmas := Meta.auxLemmasExt.getState dst let srcLemmas := Meta.auxLemmasExt.getState src let srcLemmas' := Meta.auxLemmasExt.getState src' let didx := srcLemmas'.idx - srcLemmas.idx let nameInfix := .str .anonymous s!"_merge_{dstLemmas.idx}" -- Construct the map by finding name collisions let map := srcLemmas'.lemmas.foldl (init := Std.HashMap.emptyWithCapacity didx) λ acc _ (name, _) => if src.contains name then acc else let name' := name.modifyBase (· ++ nameInfix) acc.insert name name' -- Rename the colliding lemmas in `src'`, including occurrences within constants let dst := Meta.auxLemmasExt.modifyState dst fun { idx, lemmas } => ⟨idx + 1, lemmas.insert type (auxName, levelParams)⟩ (dst.replayConsts src src', map) ``` but Lean's environment is really not conducive to renaming. I think we should wait until we have the name generator.
aniva added 1 commit 2025-06-27 16:01:50 -07:00
f4b6996f9e
test: Ignore branch unification test
We'll handle this in Lean v4.21.0
aniva modified the milestone from 0.4.0 to 0.3.3 2025-06-27 16:02:14 -07:00
aniva merged commit 2a87ed2e46 into dev 2025-06-27 16:02:22 -07:00
aniva deleted branch serial/delta 2025-06-27 16:02:22 -07:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: aniva/Pantograph#221
No description provided.