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

Efficient rewriting using decision trees #172

Merged
merged 891 commits into from
Sep 17, 2019
Merged

Conversation

gabrielhdt
Copy link
Member

@gabrielhdt gabrielhdt commented Feb 21, 2019

The content consists in compiling rewriting rules of a symbol to a decision tree to fasten up choice of the rewriting rule to apply.

The trees are output to gv files that can be interpreted by grapviz using

dot -Tpng <symb.gv> > symb.png

if invoked with --write-trees.

Features

  • first order
  • non linearity
  • abstractions
  • performance assessment

src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/eval.ml Outdated Show resolved Hide resolved
src/eval.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/sign.ml Outdated Show resolved Hide resolved
src/eval.ml Outdated Show resolved Hide resolved
src/eval.ml Outdated Show resolved Hide resolved
src/eval.ml Outdated Show resolved Hide resolved
src/terms.ml Outdated Show resolved Hide resolved
src/terms.ml Outdated Show resolved Hide resolved
src/terms.ml Outdated Show resolved Hide resolved
src/terms.ml Outdated Show resolved Hide resolved
@Deducteam Deducteam deleted a comment from gabrielhdt Mar 5, 2019
src/sign.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/eval.ml Outdated Show resolved Hide resolved
src/eval.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
src/dtree.ml Outdated Show resolved Hide resolved
@fblanqui
Copy link
Member

fblanqui commented Aug 5, 2019 via email

@rlepigre
Copy link
Contributor

rlepigre commented Aug 5, 2019

@fblanqui well, I don't see why we could not play with heuristics now. If anything it should actually be simpler now since the code is a lot easier to follow (it used to be a lot more complicated than it needed to be). Anyway, the mechanisms we removed did not really bring anything in my opinion. It's not like it was a very general mean of configuring heuristics.

src/tree.ml Outdated

(** A pool of (convertibility and free variable) conditions. *)
type t =
{ nl_partial : int IntMap.t
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain what exactly is the idea with this map? I'm not completely sure I follow, and the comment is not very helpful to get an intuition (and looking at the code I'm not sure why this should be correct).

Copy link
Member Author

Choose a reason for hiding this comment

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

Since the constraint involve two variables and we inspect one variable at a time, we must memorise which variables have been seen. This mapping allows to remember which variable pointed to which slot in the environment. If the variable inspected points to the same slot as another one in this mapping, then it means it must be convertible with that previous variable

src/tree.ml Outdated Show resolved Hide resolved
@gabrielhdt
Copy link
Member Author

@fblanqui to be honest, we were not able to experiment much before (apart from setting not-so-normalised coefficients); as said Rodolphe, the code is much simpler now and is a good basis to decide of the flexibility of the rewrite engine.

src/tree.ml Outdated
try
(* We obtain the reference slot (if any). *)
let r_slot = IntMap.find i pool.variables in
let cond = if r_slot < slot then (r_slot, slot) else (slot, r_slot) in
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that r_slot = slot here? More generally, I'm wondering if we have the right representation for the convertibility constraints. I think we should merge all constraints tied to a particular environment slot. This means that we would map environment indices to sets of slots in the vars array. This way we would avoid potential normalization issues. Are constraints always checked after all filtering has been done on constructors?

src/tree.ml Outdated
in the pool [pool]. *)
let is_contained : tree_cond -> t -> bool = fun cond pool ->
match cond with
| CondNL(i,j) -> PSet.mem (if i < j then (i,j) else (j,i)) pool.nl_conds
Copy link
Contributor

Choose a reason for hiding this comment

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

When I talked about normalization in my previous comment, I'm a bit concerned here. For instance, we might have a convertibility constraint between i and j, but we might not have (i,j) nor (j,i) in the set of constraints. We may only have (k,i) and (k,j) for some slot k.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we can have this situation ((k, i), (k, j), (i, j)) since the reference slot is given by the pattern in the Patt(Some(s), _, _). Conditions involving slots i, k and j will be added with s as argument (which is unique, otherwise there is no non linearity constraint). First pattern added will create the binding s -> i in pool.variables and other will retrieve the correct slot (here i) using that mapping. Is there something I miss?

@rlepigre
Copy link
Contributor

OK, let's merge.

@rlepigre rlepigre merged commit 33f445e into Deducteam:master Sep 17, 2019
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.

4 participants