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

Translate Coq recursion that does not directly pattern matches #24

Open
pedrotst opened this issue Feb 24, 2020 · 2 comments
Open

Translate Coq recursion that does not directly pattern matches #24

pedrotst opened this issue Feb 24, 2020 · 2 comments

Comments

@pedrotst
Copy link
Owner

pedrotst commented Feb 24, 2020

Cedille recursion is tied with recursion, which is not necessarily the case with Coq.
This brings us to the question of how to deal functions like f bellow.

Fixpoint f (x y : nat): nat :=
S ((fix g (a b: nat) := match a with
             | O => b
             | S a' => g a' b + f a' b
              end) x y).
@pedrotst
Copy link
Owner Author

A follow up question to this is how does coq figures out the decreasing argument here

@cwjnkins
Copy link

cwjnkins commented Jul 5, 2020

The following (somewhat involved) implementation of f in Cedille might provide at least some help in figuring out how to translate such examples: https://gist.github.com/cwjnkins/c0ca1553adaf0252494e9d36c117a7ed

The definition works like this: one must have f use pattern matching, and probably would require a local definition of g for each clause (or have this factored out). g must be given knowledge that, if its argument a is non-zero, then pred a has the type Type/f, by explicitly using the derived View family (for internalized typing derivations). That way, when you case-analyze a to get the predecessor a', you know that this has type Type/g for the first call and Type/f for the second call.

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