# Path: hexlite/auxiliary.py
# class Aux:
#   # prefix for all auxiliaries [just rename in case of conflicts in an application]
#   PREFIX = 'aux_'
# 
#   # maxint
#   MAXINT = PREFIX+'maxint'
# 
#   # relevance of external atoms + input tuple grounding
#   EARELV = PREFIX+'r'
#   # truth of external atoms (in the papers "external replacement atoms")
#   EAREPL = PREFIX+'t'
# 
#   # auxiliary for rule heads in explicitflpcheck.RuleActivityProgram
#   RHPRED = PREFIX+'h'
# 
#   # for explicitflpcheck.CheckOptimizedProgram
#   # auxilary for unnamed clasp atoms
#   CLATOM = PREFIX+'C'
#   # auxiliary for atoms in compatible set
#   CSATOM = PREFIX+'c'
#   # auxiliary for atoms in choice heads 
#   CHATOM = PREFIX+'H'
#   # auxiliary for smaller atom
#   SMALLER = PREFIX+'smaller'
# 
#   # for acthex rewriting
#   ACTREPL = PREFIX+'act'


import logging
import sys
import clingo
from .auxiliary import Aux


# assume that the main program has handled possible import problems


# head begin/separator/end sign for key=choice=True (choice rule) or False (disjunction)
HBEG = { True: '{', False: '' }
HSEP = { True: ' ; ', False: ' | ' }
HEND = { True: '}', False: '' }

def formatAssumptions(assumptions):
  return "{} not({})".format(
    repr([a for (a,t) in assumptions if t == True]),
    repr([a for (a,t) in assumptions if t == False]))

def prefixAtom(atom, prefix):
  # prefix without breaking strong negation
  assert(isinstance(atom, str))
  if atom[0] == '-':
    return '-'+prefix+atom[1:]
  else:
    return prefix+atom

def prefixIfNonempty(s, prefix):
  if len(s) == 0:
    return s
  else:
    return prefix+s

def ruleHeadAux(idx):

# Path: hexlite/auxiliary.py
# class Aux:
#   # prefix for all auxiliaries [just rename in case of conflicts in an application]
#   PREFIX = 'aux_'
# 
#   # maxint
#   MAXINT = PREFIX+'maxint'
# 
#   # relevance of external atoms + input tuple grounding
#   EARELV = PREFIX+'r'
#   # truth of external atoms (in the papers "external replacement atoms")
#   EAREPL = PREFIX+'t'
# 
#   # auxiliary for rule heads in explicitflpcheck.RuleActivityProgram
#   RHPRED = PREFIX+'h'
# 
#   # for explicitflpcheck.CheckOptimizedProgram
#   # auxilary for unnamed clasp atoms
#   CLATOM = PREFIX+'C'
#   # auxiliary for atoms in compatible set
#   CSATOM = PREFIX+'c'
#   # auxiliary for atoms in choice heads 
#   CHATOM = PREFIX+'H'
#   # auxiliary for smaller atom
#   SMALLER = PREFIX+'smaller'
# 
#   # for acthex rewriting
#   ACTREPL = PREFIX+'act'


# Path: hexlite/explicitflpcheck.py
import logging
import sys
import clingo
from .auxiliary import Aux



# assume that the main program has handled possible import problems


# head begin/separator/end sign for key=choice=True (choice rule) or False (disjunction)
HBEG = { True: '{', False: '' }
HSEP = { True: ' ; ', False: ' | ' }
HEND = { True: '}', False: '' }

def formatAssumptions(assumptions):
  return "{} not({})".format(
    repr([a for (a,t) in assumptions if t == True]),
    repr([a for (a,t) in assumptions if t == False]))

def prefixAtom(atom, prefix):
  # prefix without breaking strong negation
  assert(isinstance(atom, str))
  if atom[0] == '-':
    return '-'+prefix+atom[1:]
  else:
    return prefix+atom

def prefixIfNonempty(s, prefix):
  if len(s) == 0:
    return s
  else:
    return prefix+s

def ruleHeadAux(idx):

  return Aux.RHPRED+'('+str(idx)+')'