/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * 
 * Author: pgess <v.melnychenko@xreate.org>
 * Created on June 25, 2018, 3:24 PM
 */ 
 
/**
 * \file interpretation.h
 * \brief  Interpretation related functions
 */

#ifndef INTERPRETATION_H
#define INTERPRETATION_H

#include "transcendlayer.h"

namespace xreate{ namespace interpretation{

  /**
   * \brief Converts a Transcend's fact to a Xreate's expression that can be interpreted further. Supports `query` keyword.
   * @param atom Transcend's fact
   * @param schemaT Type of the resulting expression
   * @param transcend Transcend's instance
   * @return converted Transcend' fact in form of Xreate's expression
   */
  Expression representTransExpression(const Gringo::Symbol& atom, ExpandedType schemaT, TranscendLayer* transcend);

  /**
   * \brief Expands slave type.
   * @param t Slave type
   * @param transcend Instance of Transcend
   * @return The expanded slave type
   */  
  ExpandedType dereferenceSlaveType(ExpandedType t, const TranscendLayer* transcend);
  
  TypeAnnotation collapseColumn(const std::list<Gringo::Symbol>& symbols);
  std::list<Expression> generateAllInstancesInDomain2(const ExpandedType& domainT);

}
}
#endif /* INTERPRETATION_H */

