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

Local mutually recursive functions diverge in tactics #2849

Closed
amosr opened this issue Mar 13, 2023 · 3 comments
Closed

Local mutually recursive functions diverge in tactics #2849

amosr opened this issue Mar 13, 2023 · 3 comments
Assignees

Comments

@amosr
Copy link
Contributor

amosr commented Mar 13, 2023

Hi,
I just noticed that using let .. and .. for mutually recursive functions, inside a top-level function, was causing my proof to diverge. It seems OK if I lift them up to top-level mutually recursive functions, or inline the recursion to make it a single locally-recursive definition.

Here is a small example that hangs for me:

module TacticRecursion

module T = FStar.Tactics

let visit_terms (t: T.term): T.Tac unit =
  let rec tm (t: T.term): T.Tac unit = match T.inspect_unascribe t with
    | T.Tv_Match sc _ brs ->
      // do work then recurse...
      T.iter br brs;
      tm sc
    | _ -> ()
  and br (b: T.branch): T.Tac unit = tm (snd b)
  in tm t

let nothing (): unit =
  assert (true) by (
    visit_terms (`true)
  )
@mtzguido
Copy link
Member

Hi Amos, thanks for the report. Something fishy is definitely happening here. See for instance this, that does not fail:

let visit_terms () : T.Tac unit =
  let rec tm (): T.Tac unit =
    T.fail "fail"
  and unused () : T.Tac unit =
    ()
  in tm ()

let nothing (): unit =
  assert (True) by (
    visit_terms ()
  )

Looking into it.

@mtzguido mtzguido self-assigned this Mar 13, 2023
mtzguido added a commit that referenced this issue Mar 13, 2023
mtzguido added a commit that referenced this issue Mar 13, 2023
mtzguido added a commit that referenced this issue Mar 13, 2023
mtzguido added a commit that referenced this issue Mar 13, 2023
Normalizer fix for mutually recursive functions (#2849)
@mtzguido
Copy link
Member

Should be fixed now! Turned out to be a rather scary-looking normalization bug. Thanks again for the clear report!

@amosr
Copy link
Contributor Author

amosr commented Mar 13, 2023

That was quick! Thanks Guido

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

No branches or pull requests

2 participants