Skip to content

Add builtin to the tc app - #1042

Draft
Tragicus wants to merge 7 commits into
LPCIC:masterfrom
Tragicus:mixin-tc
Draft

Add builtin to the tc app#1042
Tragicus wants to merge 7 commits into
LPCIC:masterfrom
Tragicus:mixin-tc

Conversation

@Tragicus

Copy link
Copy Markdown
Contributor

In(Elpi.API.BuiltInData.list Elpi.API.BuiltInData.string, "GR",
Easy("Declares that goals on GR should be solved using elpi's typeclass solver.")),
(fun gr ~depth ->
set_solver_mode AAdd ["TC.Solver"] (List.map Libnames.qualid_of_string gr))),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that the tc solver should not be hardcoded

@gares

gares commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

You should also add the new opam package to the ci job making the release, and add changelog entries

@gares
gares requested a review from FissoreD June 13, 2026 11:13
@gares

gares commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Davide we need a little doc for the filter api, in particular what happens if two tc problems are to be solved and a tc solver only handles one kind.

The use case of Quentin is that HB uses a very specific solver for classes it generates. It is really an ad hoc solver to implement some notations without hacking too much.

@FissoreD

Copy link
Copy Markdown
Collaborator

IIRC when you have a cluster of typeclass goals, the custom solver is used only if it overrides all the class evars in it, otherwise, it uses rocq solver.

@gares

gares commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

cluster means interdependent goals? like ?g1 : C1 ?t + ?g2 : C2 ?t or only if ?g1 occurs as argument of C2?

@FissoreD

Copy link
Copy Markdown
Collaborator

I think the second.
The code is here and is used here.
Each component of the cluster is passed to the first solver whose condition accepts it

@gares

gares commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

So I think it makes sense for this specific application, all classes are generated by HB, hence solved by the same solver.


let tc_builtins = [
Elpi.API.BuiltIn.MLCode(Pred("coq.TC.override-solver",
In(Elpi.API.BuiltInData.string, "GR",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
In(Elpi.API.BuiltInData.string, "GR",
In(Elpi.API.BuiltInData.string, "SolverName",

let tc_builtins = [
Elpi.API.BuiltIn.MLCode(Pred("coq.TC.override-solver",
In(Elpi.API.BuiltInData.string, "GR",
In(Elpi.API.BuiltInData.list Elpi.API.BuiltInData.string, "GR",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
In(Elpi.API.BuiltInData.list Elpi.API.BuiltInData.string, "GR",
In(Elpi.API.BuiltInData.list Elpi.API.BuiltInData.string, "ClassGR",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Or even ClassNames since it is a list of strings.

Elpi.API.BuiltIn.MLCode(Pred("coq.TC.override-solver",
In(Elpi.API.BuiltInData.string, "GR",
In(Elpi.API.BuiltInData.list Elpi.API.BuiltInData.string, "GR",
Easy("Declares that goals on GR should be solved using elpi's typeclass solver."))),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Easy("Declares that goals on GR should be solved using elpi's typeclass solver."))),
Easy("Declares that instances of class ClassGR should be solved using elpi's typeclass solver SolverName."))),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I kept the word goal because of the verb solve.

@FissoreD

Copy link
Copy Markdown
Collaborator

We had a discussion this morning with Yves, is it mandatory to have a doc folder in a plugin?
It seems to me that the pattern used in those files is always the same. Can't it be generated?

Comment thread dune-project Outdated
(package
(name rocq-elpi-typeclasses)
(synopsis "TC bindings for rocq-elpi")
(description "This package provides a typeclass solver written in Elpi for Rocq")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
(description "This package provides a typeclass solver written in Elpi for Rocq")
(description "This package provides a typeclas solver written in Elpi, as well as the infrastructure for writing custom ones")

Also in the .opam file

Comment thread dune-project Outdated

(package
(name rocq-elpi-typeclasses)
(synopsis "TC bindings for rocq-elpi")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
(synopsis "TC bindings for rocq-elpi")
(synopsis "Typeclass solver in rocq-elpi")

@gares

gares commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

We had a discussion this morning with Yves, is it mandatory to have a doc folder in a plugin? It seems to me that the pattern used in those files is always the same. Can't it be generated?

Yes, I guess, but by which tool? It should be documented, that is for sure.

@FissoreD

Copy link
Copy Markdown
Collaborator

We had a discussion this morning with Yves, is it mandatory to have a doc folder in a plugin? It seems to me that the pattern used in those files is always the same. Can't it be generated?

Yes, I guess, but by which tool? It should be documented, that is for sure.

Not sure how it works, but could we label the function declaring builtins with a custom [@@ gen_doc] which creates the few lines of code in gen_doc.ml and then we delagate to dune to build the .elpi with the new builtins?

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

Successfully merging this pull request may close these issues.

3 participants