Skip to content

How to write a tactic contradiction with Ltac2 #105

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

thomas-lamiaux
Copy link
Collaborator

No description provided.

@thomas-lamiaux thomas-lamiaux force-pushed the how_to_ltac2_contradiction branch from 954c5d6 to 16aed5d Compare May 2, 2025 00:19
@thomas-lamiaux thomas-lamiaux marked this pull request as ready for review May 4, 2025 07:59

(** - [multi_match! goal with] is more complex and subtle. It basically behaves
like [match!] except that it will further backtrack if the choice of a
branch leads to a subsequent failure when linked with another tactic.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the term "linked" is clear enough here. Personally, I find examples clearer than specifications, so giving a code sample where there is a difference between match! goal with (...) end; t () and multi_match! goal with (...) end; t () would be most helpful for me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not supposed to be an intro on match but I have added a bit of text, it can always be moved to a tuto when we will write one

In contrast, if we had a deep embedding, the arguments of [Unsafe.App] would be
recursively converted to [kind], resulting in the type [kind -> kind array -> kind].
The reason for using a shallow embedding is that it is much faster than fully
converting terms to the interal syntax, yet sufficient for most applications.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interal -> internal

I honestly don't think this paragraph is necessary. The distinction between shallow embeddings and deep embeddings doesn't seem relevant to me here.

I don't think you need to call it an "embedding" at all, you can say that it returns the head of the term.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the goal of this how-to is to get that, I would rather like to move all the match content in a real tuto. It should not be in a how-to but I kinda need it as there is no tuto yet.

@thomas-lamiaux
Copy link
Collaborator Author

@patrick-nicodemus thanks. Overall what do you think, it is clear / useful ?

@patrick-nicodemus
Copy link
Contributor

I think it's good overall.

In 2019 in the original Ltac2 paper, Pierre Marie-Pedrot writes:

Ltac2 is still in an active development phase, but the foundations of the language have been settled. More than any-
thing, it is in need of users in order to polish the rough edges.

It seems to me we are still in that stage in 2025 - by using it to write tutorials, you are hitting the need for functions to count the number of constructors and do conversion between terms, and expose more in the Rocq API. This tension will continue to exist for a while but I think the tension is necessary for the language to develop.

@thomas-lamiaux
Copy link
Collaborator Author

@patrick-nicodemus I agree but also if you check out the current dev, a lot have been added since Rocq 9, and there are less and less API missing. Like, it is far from being bad with the shallow embedding etc...

@Villetaneuse
Copy link
Collaborator

Thank you very much @patrick-nicodemus. @thomas-lamiaux, I will wait for comments to be resolved and write a quick review afterwards.

Copy link
Collaborator Author

@thomas-lamiaux thomas-lamiaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @patrick-nicodemus
Sorry for the typos, clearly AI do not catch them all.

To fix typos could use "code suggestion" next time.
It is the +- button in a comment.
It saves me a lot of times, as I can just merge all the typos from the interface rather than having to go back and forth with my file.


(** - [multi_match! goal with] is more complex and subtle. It basically behaves
like [match!] except that it will further backtrack if the choice of a
branch leads to a subsequent failure when linked with another tactic.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not supposed to be an intro on match but I have added a bit of text, it can always be moved to a tuto when we will write one


(** Checking terms up to syntax is not a good notion of equality in type theory.
For instance, [4 + 1] is not syntactically equal to [1].
What we really want here is to compare type semantically, i.e. up to
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you do too much categories, the semantics of a PL language is its operational semantics 😅
Joke aside, I see your point, I'll see what I can do

In contrast, if we had a deep embedding, the arguments of [Unsafe.App] would be
recursively converted to [kind], resulting in the type [kind -> kind array -> kind].
The reason for using a shallow embedding is that it is much faster than fully
converting terms to the interal syntax, yet sufficient for most applications.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the goal of this how-to is to get that, I would rather like to move all the match content in a real tuto. It should not be in a how-to but I kinda need it as there is no tuto yet.

@thomas-lamiaux
Copy link
Collaborator Author

@Villetaneuse I have fixed the issues

@thomas-lamiaux
Copy link
Collaborator Author

@Villetaneuse I'll merge this during the week-end so you have until then. If you don't have time it is fine

@patrick-nicodemus
Copy link
Contributor

patrick-nicodemus commented May 21, 2025

To fix typos could use "code suggestion" next time. It is the +- button in a comment. It saves me a lot of times, as I can just merge all the typos from the interface rather than having to go back and forth with my file.

@thomas-lamiaux
You have mentioned this before. I cannot figure out how to do this. I think you have to give me "permission" to do this.
https://stackoverflow.com/a/45114109/1822018

Actually, the linked post only discusses "Allow edits from maintainers." Since I am not an official Rocq maintainer, it's not clear that I can do this.

@thomas-lamiaux
Copy link
Collaborator Author

@patrick-nicodemus do you not see this button ?

image

@patrick-nicodemus
Copy link
Contributor

@thomas-lamiaux yes, it generates a markdown box:

code change

I guess whatever I put in there is clickable, I see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants