Giter Site home page Giter Site logo

Comments (10)

anton-trunov avatar anton-trunov commented on May 27, 2024

I guess I hit the same issue.

The following works:

Equations foo (n : nat) : nat :=
foo n := bar (S n)
where bar (n : nat) : nat :=
bar n := n.

This snippet

Equations foo (n : nat) : nat :=
foo n := bar (S n)
where bar (n : nat) : nat :=
bar O := O;
bar (S n) := bar n.

produces the following error message:

Error: The variable bar was not found in the current environment.

pointing to the bar (S n) := bar n. clause as the source of the error.

When adding curly braces like so

Equations foo (n : nat) : nat := {
foo n := bar (S n) }
where bar (n : nat) : nat :=
bar O := O;
bar (S n) := bar n.

the error message stays the same, but this time the line that gets marked as the source is foo n := bar (S n) }.

from coq-equations.

mattam82 avatar mattam82 commented on May 27, 2024

from coq-equations.

anton-trunov avatar anton-trunov commented on May 27, 2024

I've tried that, it didn't work:

Equations foo (n : nat) : nat := {
foo n := bar (S n) }
where bar (n : nat) : nat := {
bar O := O;
bar (S n) := bar n }.

from coq-equations.

anton-trunov avatar anton-trunov commented on May 27, 2024

It only works if bar mentiones foo:

Equations foo (n : nat) : nat := {
foo n := bar n }
where bar (n : nat) : nat := {
bar O := O;
bar (S n) := foo n }.

However, if I remove the braces it fails again:

Fail Equations foo (n : nat) : nat := 
foo n := bar n
where bar (n : nat) : nat :=
bar O := O;
bar (S n) := foo n.

from coq-equations.

mattam82 avatar mattam82 commented on May 27, 2024

from coq-equations.

mattam82 avatar mattam82 commented on May 27, 2024

Next on my list, indeed the syntactic check is too crude to determine whether things are mutually recursive or not, I will have to build a dependency graph it seems.

from coq-equations.

mattam82 avatar mattam82 commented on May 27, 2024

Actually, these can't be mutually recursive:

Fixpoint foo (n : nat) : nat := 
  bar n
with bar (n : nat) : nat :=
       match n with 0 => 0 | S n => foo n end.

Fails.

from coq-equations.

mattam82 avatar mattam82 commented on May 27, 2024

So it's rather that foo is recursive while bar isn't (it's just a definition in this case).

from coq-equations.

mattam82 avatar mattam82 commented on May 27, 2024

Also there are examples where you want the where clause itself to be recursive, that requires a few changes as well.

from coq-equations.

mattam82 avatar mattam82 commented on May 27, 2024

This now works by specifying "by struct fs" for both "sum" and "sum_aux". The fix is in master and will be part of the upcoming release.

from coq-equations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.