feat: Collect holes in Lean file and put them into a GoalState #99

Merged
aniva merged 14 commits from frontend/collect-holes into dev 2024-10-03 15:43:01 -07:00
Owner
  • refactor: Moved all FrontendM functions into Frontend/.
  • feat: Export frontend functions
  • feat: Add frontend.process (refactored from compile.unit) command, which runs the frontend on a file.
  • doc: Updated documentation
  • chore: Version bump to 0.2.19 (major command modification)
* refactor: Moved all `FrontendM` functions into `Frontend/`. * feat: Export frontend functions * feat: Add `frontend.process` (refactored from `compile.unit`) command, which runs the frontend on a file. * doc: Updated documentation * chore: Version bump to 0.2.19 (major command modification)
aniva self-assigned this 2024-09-08 13:47:29 -07:00
aniva added this to the TACAS '25 milestone 2024-09-08 13:48:41 -07:00
Author
Owner

We need to think about what the interface should look like. IMO the user should input a theorem name or line number, and the repl generates a goal state for the theorem/example/etc. on that line number. This requires traversing the entire file every time.

The current best solution is to write all the tests into one file, compile it, and load it as the environment.

I don't think there's a very nice meet in the middle solution given Lean's convoluted type system and possible theorem inter-dependencies.

The simplest solution is to extract data from only the first compilation unit that has holes. This avoids the problematic inter-dependency issue.

We need to think about what the interface should look like. IMO the user should input a theorem name or line number, and the repl generates a goal state for the theorem/example/etc. on that line number. This requires traversing the entire file every time. The current best solution is to write all the tests into one file, compile it, and load it as the environment. I don't think there's a very nice meet in the middle solution given Lean's convoluted type system and possible theorem inter-dependencies. The simplest solution is to extract data from only the first compilation unit that has holes. This avoids the problematic inter-dependency issue.
Author
Owner

We should probably assign the root variable when there's just one goal to avoid surprises for our users.

We should probably assign the root variable when there's just one goal to avoid surprises for our users.
Author
Owner

https://github.com/lenianiva/PyPantograph/pull/13

Seems fine. Testing has passed.

https://github.com/lenianiva/PyPantograph/pull/13 Seems fine. Testing has passed.
Author
Owner

Fixed #103

Fixed #103
Author
Owner

Currently there's a variable duplication issue in coupled goals; It seems like every binder gets duplicated in the w goal.

def test_sorry_in_coupled: TestT MetaM Unit := do
  let sketch := "
example : ∀ (y: Nat), ∃ (x: Nat), y + 1 = x := by
  intro y
  apply Exists.intro
  case h => sorry
  case w => sorry
  "
  let goalStates  (collectSorrysFromSource sketch).run' {}
  let [goalState] := goalStates | panic! s!"Incorrect number of states: {goalStates.length}"
  addTest $ LSpec.check "goals" (( goalState.serializeGoals (options := {})).map (·.devolatilize) = #[
    {
      target := { pp? := "y + 1 = ?w" },
      vars := #[{
           userName := "y",
           type? := .some { pp? := "Nat" },
        }
      ],
    },
    {
      userName? := .some "w",
      target := { pp? := "Nat" },
      vars := #[{
           userName := "y✝",
           isInaccessible := true,
           type? := .some { pp? := "Nat" },
        }, {
           userName := "y",
           type? := .some { pp? := "Nat" },
        }
      ],
    }
  ])

Currently there's a variable duplication issue in coupled goals; It seems like every binder gets duplicated in the `w` goal. ```lean def test_sorry_in_coupled: TestT MetaM Unit := do let sketch := " example : ∀ (y: Nat), ∃ (x: Nat), y + 1 = x := by intro y apply Exists.intro case h => sorry case w => sorry " let goalStates ← (collectSorrysFromSource sketch).run' {} let [goalState] := goalStates | panic! s!"Incorrect number of states: {goalStates.length}" addTest $ LSpec.check "goals" ((← goalState.serializeGoals (options := {})).map (·.devolatilize) = #[ { target := { pp? := "y + 1 = ?w" }, vars := #[{ userName := "y", type? := .some { pp? := "Nat" }, } ], }, { userName? := .some "w", target := { pp? := "Nat" }, vars := #[{ userName := "y✝", isInaccessible := true, type? := .some { pp? := "Nat" }, }, { userName := "y", type? := .some { pp? := "Nat" }, } ], } ]) ```
aniva deleted branch frontend/collect-holes 2024-10-03 15:43:01 -07:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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#99
No description provided.