souffle  2.0.2-371-g6315b36
GroundWitnesses.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 GroundWitnesses.h
12  *
13  * Transformation pass to ground witnesses of an aggregate so that
14  * they can be transferred to the head.
15  *
16  ***********************************************************************/
17 
18 #pragma once
19 
20 #include "ast/TranslationUnit.h"
22 
23 #include <string>
24 
25 namespace souffle::ast::transform {
26 
27 /**
28  * Apply a grounding so that the witness of a selection aggregate (min/max)
29  * can be transferred to the outer scope. Here is an example:
30  *
31  * Tallest(student) :- _ = max height : { Student(student, height) }.
32  *
33  * student occurs ungrounded in the outer scope, but we can fix this by using the
34  * aggregate result to figure out which students satisfy this aggregate.
35  *
36  * Tallest(student) :- n = max height : { Student(student0, height) },
37  * Student(student, n).
38  *
39  * This transformation is really just syntactic sugar.
40  *
41  */
42 class GroundWitnessesTransformer : public Transformer {
43 public:
44  std::string getName() const override {
45  return "GroundWitnessesTransformer";
46  }
47 
48  GroundWitnessesTransformer* clone() const override {
50  }
51 
52 private:
53  bool transform(TranslationUnit& translationUnit) override;
54 };
55 
56 } // namespace souffle::ast::transform
TranslationUnit.h
Transformer.h
souffle::ast::transform::GroundWitnessesTransformer::clone
GroundWitnessesTransformer * clone() const override
Definition: GroundWitnesses.h:62
souffle::ast::transform::GroundWitnessesTransformer::getName
std::string getName() const override
Definition: GroundWitnesses.h:58
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::transform::GroundWitnessesTransformer::transform
bool transform(TranslationUnit &translationUnit) override
Definition: GroundWitnesses.cpp:31
souffle::ast::transform
Definition: Program.h:45
souffle::ast::transform::GroundWitnessesTransformer
Apply a grounding so that the witness of a selection aggregate (min/max) can be transferred to the ou...
Definition: GroundWitnesses.h:49