PyPantograph: Pantograph Error Cases Report

Environment setup

header = """
set_option maxHeartbeats 0
open BigOperators Real Nat Topology Rat
"""
project_path = "<repo>/experiments/minif2f/MiniF2F"
server = Server(imports=['Aesop', 'Mathlib'], project_path=project_path)

Error cases

  • JSONDecodeError for some cases

    theorem amc12_2000_p15 (f : ℂ → ℂ) (h₀ : ∀ x, f (x / 3) = x ^ 2 + x + 1)
        (h₁ : Fintype (f ⁻¹' {7})) : (∑ y in (f ⁻¹' {7}).toFinset, y / 3) = -1 / 9
    
    theorem mathd_numbertheory_552
      (f g h : ℕ+ → ℕ)
      (h₀ : ∀ x, f x = 12 * x + 7)
      (h₁ : ∀ x, g x = 5 * x + 2)
      (h₂ : ∀ x, h x = Nat.gcd (f x) (g x))
      (h₃ : Fintype (Set.range h)) :
      (∑ k in (Set.range h).toFinset, k) = 12
    

    A minimized Case

    theorem mathd_numbertheory_552_min (h : ℕ → ℕ) (h₃ : Fintype (Set.range h)) : true
    
  • Unsolved goals

    theorem sample (p q r x : ℂ)
          (h₀ : (x - p) * (x - q) = (r - p) * (r - q))
       : (x - r) * x = (x - r) * (p + q - r) := by
    linear_combination h₀
    

    The remaining goal state:

    p : ℂ
    q : ℂ
    r : ℂ
    x : ℂ
    h₀ : (x - p) _(x - q) = (r - p)_ (r - q)
    ⊢ ℂ
    

Lean Server Result

The Lean server response can be check here image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

All problems listed here should be solved in https://github.com/stanford-centaur/PyPantograph/pull/60. Please confirm.

Would it be an acceptable solution to remove most of the drafting features (:= sorry will remain) from frontend.process and implement them using the new draft tactic? It is more versatile and requires less hacking into Lean, so it should be more resistant to edge cases like this.

If this is a problem with Lean’s json system we’ll have to wait until the upstream is fixed

The error is raised by the server, not by json-loading. You can reproduce the error by:

Understood. This does seem rather strange as I’ve come across several similar issues that were due to json errors and were resolved by setting ensure_ascii=False.

I was able to successfully reproduce the error you mentioned. Below is a more detailed error backtrace:

PANIC at _private.Pantograph.Frontend.MetaTranslate.0.Pantograph.Frontend.MetaTranslate.translateExpr Pantograph.Frontend.MetaTranslate:71:6: assertion violation: ( __do_lift._@.Pantograph.Frontend.MetaTranslate._hyg.610.0 ).contains fvarId'

      
backtrace:
/path/to/pantograph/pantograph-repl(lean_panic_fn+0x70) [0xaaaad8c6b250]
/path/to/pantograph/pantograph-repl(l_panic___at___private_Pantograph_Frontend_MetaTranslate_0__Pantograph_Frontend_MetaTranslate_translateExpr___spec__1+0x44) [0xaaaad53c26c4]
/path/to/pantograph/pantograph-repl(lean_apply_7+0x460) [0xaaaad8c7a890]
/path/to/pantograph/pantograph-repl(lean_apply_8+0x2fc) [0xaaaad8c7b140]
/path/to/pantograph/pantograph-repl(l_ReaderT_bind___at___private_Pantograph_Frontend_MetaTranslate_0__Pantograph_Frontend_MetaTranslate_translateExpr___spec__8___rarg+0x114) [0xaaaad53c6ba8]
/path/to/pantograph/pantograph-repl(lean_apply_8+0x45c) [0xaaaad8c7b2a0]
/path/to/pantograph/pantograph-repl(l_Lean_Core_withIncRecDepth___at___private_Pantograph_Frontend_MetaTranslate_0__Pantograph_Frontend_MetaTranslate_translateExpr___spec__9+0x464) [0xaaaad53c7534]
/path/to/pantograph/pantograph-repl(l_Lean_Core_transform_visit___at___private_Pantograph_Frontend_MetaTranslate_0__Pantograph_Frontend_MetaTranslate_translateExpr___spec__4+0xa58) [0xaaaad53c40b4]
/path/to/pantograph/pantograph-repl(l_Lean_Core_transform___at___private_Pantograph_Frontend_MetaTranslate_0__Pantograph_Frontend_MetaTranslate_translateExpr___spec__3+0xfc) [0xaaaad53cee5c]
/path/to/pantograph/pantograph-repl(l___private_Pantograph_Frontend_MetaTranslate_0__Pantograph_Frontend_MetaTranslate_translateExpr+0x1dc) [0xaaaad53d1abc]
/path/to/pantograph/pantograph-repl(l_Pantograph_Frontend_MetaTranslate_translateLocalInstance+0x184) [0xaaaad53d26ec]
/path/to/pantograph/pantograph-repl(l_Array_mapMUnsafe_map___at_Pantograph_Frontend_MetaTranslate_translateMVarId___spec__1+0x19c) [0xaaaad53d20b8]
/path/to/pantograph/pantograph-repl(l_Pantograph_Frontend_MetaTranslate_translateMVarId___lambda__3+0x534) [0xaaaad53d6cd4]
/path/to/pantograph/pantograph-repl(lean_apply_8+0x45c) [0xaaaad8c7b2a0]
/path/to/pantograph/pantograph-repl(lean_apply_5+0x444) [0xaaaad8c79338]
/path/to/pantograph/pantograph-repl(l_Lean_Meta_withLCtx___at_Pantograph_Frontend_MetaTranslate_translateMVarId___spec__6___rarg+0x64) [0xaaaad53d4a2c]
/path/to/pantograph/pantograph-repl(l_Pantograph_Frontend_MetaTranslate_translateMVarId___lambda__4+0x19c) [0xaaaad53d78fc]
/path/to/pantograph/pantograph-repl(l_Pantograph_Frontend_MetaTranslate_translateMVarId+0x564) [0xaaaad53d15f4]
/path/to/pantograph/pantograph-repl(l_List_mapM_loop___at_Pantograph_Frontend_MetaTranslate_translateMVarFromTacticInfoBefore___spec__1+0x274) [0xaaaad53dec94]
/path/to/pantograph/pantograph-repl(l_List_mapM_loop___at_Pantograph_Frontend_sorrysToGoalState___spec__3+0x254) [0xaaaad53f1678]
/path/to/pantograph/pantograph-repl(pantograph_frontend_sorrys_to_goal_state_m+0x1b0) [0xaaaad53f2cb0]
/path/to/pantograph/pantograph-repl(lean_apply_5+0x3ac) [0xaaaad8c792a0]
/path/to/pantograph/pantograph-repl(l_Pantograph_Repl_runMetaInMainM___rarg+0x88) [0xaaaad5407528]
/path/to/pantograph/pantograph-repl(l_Pantograph_Repl_runMetaInMainM___rarg___boxed+0x14) [0xaaaad5407c3c]
/path/to/pantograph/pantograph-repl(lean_apply_5+0x3ac) [0xaaaad8c792a0]
/path/to/pantograph/pantograph-repl(l_ReaderT_bind___at_Pantograph_Repl_execute_frontend__process___spec__2___rarg+0x98) [0xaaaad5446a4c]
/path/to/pantograph/pantograph-repl(lean_apply_5+0x3d0) [0xaaaad8c792c4]
/path/to/pantograph/pantograph-repl(l_Lean_withEnv___at_Pantograph_Repl_execute_frontend__process___spec__3+0x1e0) [0xaaaad5446f54]
/path/to/pantograph/pantograph-repl(l_List_mapM_loop___at_Pantograph_Repl_execute_frontend__process___spec__5+0x778) [0xaaaad544923c]
/path/to/pantograph/pantograph-repl(l_Pantograph_Repl_execute_frontend__process___lambda__5+0x510) [0xaaaad544ac04]
/path/to/pantograph/pantograph-repl(l_Pantograph_Repl_execute_frontend__process___lambda__7+0x230) [0xaaaad544be84]
/path/to/pantograph/pantograph-repl(l_Pantograph_Repl_execute_frontend__process+0x180) [0xaaaad544c124]
/path/to/pantograph/pantograph-repl(l_Pantograph_Repl_execute+0x333c) [0xaaaad54507c8]
/path/to/pantograph/pantograph-repl(l_loop___lambda__2+0x264) [0xaaaad53123fc]
/path/to/pantograph/pantograph-repl(l_loop+0x41c) [0xaaaad53117a0]
/path/to/pantograph/pantograph-repl(l_loop___lambda__1___boxed+0x28) [0xaaaad5313758]
/path/to/pantograph/pantograph-repl(lean_apply_6+0x1f8) [0xaaaad8c79bc0]
/path/to/pantograph/pantograph-repl(l_loop+0x41c) [0xaaaad53117a0]
/path/to/pantograph/pantograph-repl(l_main___lambda__1+0xb4) [0xaaaad5313f60]
/path/to/pantograph/pantograph-repl(l_main___lambda__2+0x554) [0xaaaad5314c6c]
/path/to/pantograph/pantograph-repl(+0xfa61e4) [0xaaaad53161e4]
/usr/lib64/libc.so.6(+0x2b040) [0xffffb93cd040]
/usr/lib64/libc.so.6(__libc_start_main+0x94) [0xffffb93cd118]
/path/to/pantograph/pantograph-repl(_start+0x30) [0xaaaad53104b0]

As the error message suggests, commenting out this line can address the aforementioned JSONDecodeErrors. (However, Unsolved goals remains unsolved):

https://github.com/lenianiva/Pantograph/blob/3744cfaa9608cd43e00078283339662b3720949b/Pantograph/Frontend/MetaTranslate.lean#L71C1-L71C43

I’m still not certain why this assertion fails. Perhaps @lenianiva could conduct a more in-depth inspection.

As for the JSONDecodeError in mathd_numbertheory_552 (and the corrsponding MWE), could you please try the following fix?

https://github.com/lenianiva/PyPantograph/blob/f4cc21cc963a9f410b0aec05052d6b4975861321/pantograph/server.py#L177