souffle  2.0.2-371-g6315b36
MaterializeSingletonAggregation.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2020, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file MaterializeSingletonAggregation.h
12  *
13  * Replaces literals containing single-valued aggregates with
14  * a synthesised relation
15  *
16  ***********************************************************************/
17 
18 #pragma once
19 
20 #include "ast/Aggregator.h"
21 #include "ast/Clause.h"
22 #include "ast/Program.h"
23 #include "ast/TranslationUnit.h"
25 #include <string>
26 
27 namespace souffle::ast::transform {
28 
29 /**
30  * Replaces literals containing single-valued aggregates with
31  * a synthesised relation
32  */
33 class MaterializeSingletonAggregationTransformer : public Transformer {
34 public:
35  std::string getName() const override {
36  return "MaterializeSingletonAggregationTransformer";
37  }
38 
39  MaterializeSingletonAggregationTransformer* clone() const override {
41  }
42 
43 private:
44  bool transform(TranslationUnit& translationUnit) override;
45  /**
46  * Determines whether an aggregate is single-valued,
47  * ie the aggregate does not depend on the outer scope.
48  */
49  static bool isSingleValued(const TranslationUnit& tu, const Aggregator& agg, const Clause& clause);
50  /**
51  * Modify the aggClause by adding in grounding literals for every
52  * variable that appears in the clause ungrounded. The source of literals
53  * to copy from is the originalClause.
54  **/
56  const TranslationUnit& translationUnit, Clause& aggClause, const Clause& originalClause);
57 };
58 
59 } // namespace souffle::ast::transform
souffle::ast::transform::MaterializeSingletonAggregationTransformer::transform
bool transform(TranslationUnit &translationUnit) override
Definition: MaterializeSingletonAggregation.cpp:49
TranslationUnit.h
Transformer.h
souffle::ast::Clause
Intermediate representation of a horn clause.
Definition: Clause.h:51
souffle::ast::transform::MaterializeSingletonAggregationTransformer::isSingleValued
static bool isSingleValued(const TranslationUnit &tu, const Aggregator &agg, const Clause &clause)
Determines whether an aggregate is single-valued, ie the aggregate does not depend on the outer scope...
Definition: MaterializeSingletonAggregation.cpp:141
souffle::ast::transform::MaterializeSingletonAggregationTransformer::clone
MaterializeSingletonAggregationTransformer * clone() const override
Definition: MaterializeSingletonAggregation.h:53
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::transform
Definition: Program.h:45
souffle::ast::transform::MaterializeSingletonAggregationTransformer::groundInjectedParameters
void groundInjectedParameters(const TranslationUnit &translationUnit, Clause &aggClause, const Clause &originalClause)
Modify the aggClause by adding in grounding literals for every variable that appears in the clause un...
Aggregator.h
souffle::ast::Aggregator
Defines the aggregator class.
Definition: Aggregator.h:53
Program.h
Clause.h
souffle::ast::transform::MaterializeSingletonAggregationTransformer
Replaces literals containing single-valued aggregates with a synthesised relation.
Definition: MaterializeSingletonAggregation.h:40
souffle::ast::transform::MaterializeSingletonAggregationTransformer::getName
std::string getName() const override
Definition: MaterializeSingletonAggregation.h:49