souffle-lang / souffle

Soufflé is a variant of Datalog for tool designers crafting analyses in Horn clauses. Soufflé synthesizes a native parallel C++ program from a logic specification.
http://souffle-lang.github.io/
Universal Permissive License v1.0
934 stars 208 forks source link

Refactoring of multi-head rules, disjunctions, and general negations in the parser. #1289

Open azreika opened 4 years ago

azreika commented 4 years ago

It would be nice to have a representation of disjunctions within the AST.

Currently, they are handled entirely in the parser as syntactic sugar, where they are expanded into conjunctions, and so never actually appear at any stage afterwards. Having a representation of disjunctions will make certain transformers, especially inlining, substantially more natural and simple. It also means disjunctions do not have to be specially handled, but are actually described in the AST, and can be introduced or manipulated as needed.

The support could be done partially, in a similar way to how true and false are currently handled, whereby disjunctions can be removed by a specific transformer in the pipeline that can be called at any time. This would mean that existing transformers do not need to be changed to support disjunctions, as long as the disjunction-removing transformer is called beforehand. This would reduce the engineering effort needed.

b-scholz commented 4 years ago

We might want to have a MultiClause as well so that clauses

A(x), B(x) :- C(x). 

are properly reflected in the AST.

b-scholz commented 4 years ago

Class RuleBody converts multi-heads, disjunction, and general negations to our current version of AST. This does not fit well into our current pipeline infrastructure. The class RuleBody should be replaced by proper AST classes for disjunctions, negations, and multi-head rules and lowered to our current AST.