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

TC solver 2 #529

Merged
merged 65 commits into from
Nov 7, 2023
Merged

TC solver 2 #529

merged 65 commits into from
Nov 7, 2023

Conversation

gares
Copy link
Contributor

@gares gares commented Oct 30, 2023

TODO (before/after merge):

  • toposort tests and ML api
  • header in all files (with license)
  • README (what works, commands available)
  • maybe add an option to disable TC and instance event register
  • in tests/patternFragment.v we have Unshelved goals (example at line 15)
  • find a way to encode modes: since classes are compiled at their creation, we should set modes modes before their creation or we should be able to dinamically modify the modes of the parameters of a predicate in elpi after its creation.

Need of elpi and/or coq update:

apps/tc/theories/tc.v Outdated Show resolved Hide resolved
apps/tc/theories/tc.v Outdated Show resolved Hide resolved
apps/tc/theories/tc.v Outdated Show resolved Hide resolved
apps/tc/theories/tc.v Outdated Show resolved Hide resolved
apps/tc/theories/tc.v Outdated Show resolved Hide resolved
Comment on lines 92 to 110
Elpi Command AddInstances.
Elpi Accumulate Db tc.db.
Elpi Accumulate File base.
Elpi Accumulate File tc_aux.
Elpi Accumulate File modes.
Elpi Accumulate File compiler.
Elpi Accumulate File parser_addInstances.
Elpi Accumulate lp:{{
% The main of the Command
main Arguments :-
std.time (parse Arguments Res, run-command Res) T,
if (coq.option.get ["TimeAddInstances"] (coq.option.bool tt))
(coq.say "Add instance all Time" T) true.
}}.
(* Elpi Typecheck. *)
Elpi Query lp:{{
coq.option.add ["TimeAddInstances"] (coq.option.bool ff) ff.
}}.
(* Elpi Typecheck. *)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

comment: needed if we don't want to also declare the instance in Coq

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AddAllInstances class logpath eg AddAllInstances Decidable Coq.stdpp.file..

apps/tc/theories/tc.v Outdated Show resolved Hide resolved
apps/tc/theories/tc.v Outdated Show resolved Hide resolved
apps/tc/theories/tc.v Outdated Show resolved Hide resolved
apps/tc/theories/tc.v Outdated Show resolved Hide resolved
.vscode/settings.json Outdated Show resolved Hide resolved
_CoqProject Show resolved Hide resolved
_CoqProject Outdated Show resolved Hide resolved
apps/tc/Makefile.coq.local Outdated Show resolved Hide resolved
apps/tc/elpi/base.elpi Outdated Show resolved Hide resolved
apps/tc/elpi/compiler.elpi Outdated Show resolved Hide resolved
std.forall {coq.TC.db-tc} (x\ add-tc-or-inst-gr [] L1 [x])) T,
if (coq.option.get ["TimeAddInstances"] (coq.option.bool tt))
(coq.say "Add instance Time" T) true.
}}.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

idealli (or TODO) add #[local] AddAllInstances ...

Comment on lines 171 to 198
% [add-inst->db IgnoreClassDepL ForceAdd Inst] add the Inst to
% the database except those depending on at least one
% inside IgnoreClassDepL
pred add-inst->db i:list gref, i:bool, i:gref.
:name "add-inst->db:start"
add-inst->db IgnoreClassDepL ForceAdd Inst :-
coq.env.current-section-path SectionPath,
get-sub-classes Inst Dep,
warn-multiple-deps Inst Dep,
if ((ForceAdd = tt; not (instance _ Inst _)),
not (std.exists Dep (std.mem IgnoreClassDepL)), not (banned Inst))
(
compile Inst _IsLeaf TC-of-Inst Clause,
% TODO: a clause is flexible if an instance is polimorphic (pglobal)
not (var Clause),
Graft is after (int_to_string {get-inst-prio Inst}),
get-full-path Inst ClauseName,
if (is-local) (Visibility = [@local!])
(if (has-context-deps Inst)
(@local! => add-tc-db _ Graft (instance SectionPath Inst TC-of-Inst))
(@global! => add-tc-db _ Graft (instance [] Inst TC-of-Inst)), Visibility = [@global!]),
Visibility => add-tc-db ClauseName Graft Clause
)
true; @global! => add-tc-db _ _ (banned Inst),
coq.warning "Not-added" "TC_solver" "Warning : Cannot compile " Inst "since it is pglobal".
Copy link
Contributor Author

Choose a reason for hiding this comment

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

simplify assuming one calls #[local] AddAllInstances, call add-inst

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (get-option "local" tt) (P = @local!) true, P =>

apps/tc/elpi/compiler.elpi Outdated Show resolved Hide resolved
Comment on lines +205 to +211
add-tc-or-inst-gr IgnoreDepClass IgnoreInsts Names :-
std.map IgnoreDepClass coq.locate IgnoreDepClassGR,
std.map IgnoreInsts coq.locate IgnoreInstsGR,
std.forall Names (GR\
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe we can remove these blacklists, since there is a global one already

apps/tc/elpi/modes.elpi Outdated Show resolved Hide resolved
apps/tc/elpi/solver.elpi Outdated Show resolved Hide resolved
apps/tc/elpi/tc_aux.elpi Outdated Show resolved Hide resolved
@gares gares merged commit 36b6281 into master Nov 7, 2023
5 checks passed
@gares gares deleted the master-tc branch November 7, 2023 11:35
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.

2 participants