<commit_before>#!/usr/bin/env runhaskell
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}

import Control.Monad
import Data.Maybe
import qualified Language.Prolog.Syntax as Prolog
import Narradar
import Narradar.Types.ArgumentFiltering (AF_, simpleHeu, bestHeu, innermost)
import Narradar.Types.Problem
import Narradar.Types.Problem.Rewriting
import Narradar.Types.Problem.NarrowingGen
import Narradar.Processor.Aprove
import Narradar.Processor.RPO
import Narradar.Processor.FLOPS08
import Narradar.Framework.GraphViz
import Lattice
--import Narradar.Utils

main = narradarMain listToMaybe


-- Missing dispatcher cases
instance (IsProblem typ, Pretty typ) => Dispatch (Problem typ trs) where
    dispatch p = error ("missing dispatcher for problem of type " ++ show (pPrint $ getProblemType p))

instance Dispatch thing where dispatch _ = error "missing dispatcher"

-- Rewriting
instance (Pretty (DPIdentifier a), Ord a) => Dispatch (NProblem Rewriting (DPIdentifier a)) where
  dispatch = mkDispatcher (sc >=> rpoPlusTransforms LPOSAF)

instance (Pretty (DPIdentifier a), Ord a) => Dispatch (NProblem IRewriting (DPIdentifier a)) where
  dispatch = mkDispatcher (sc >=> rpoPlusTransforms LPOSAF)

-- Narrowing Goal

instance (id  ~ DPIdentifier a, Ord a, Lattice (AF_ id), Pretty id) =>
           Dispatch (NProblem (NarrowingGoal (DPIdentifier a)) (DPIdentifier a)) where
  dispatch = mkDispatcher
                (apply (ComputeSafeAF bestHeu) >=> depGraph  >=>
                 apply (NarrowingGoalToRewriting bestHeu) >=>
                 dispatch)


sc = depGraph >=> try(apply SubtermCriterion)

rpoPlusTransforms rpo =  depGraph >=>
                         repeatSolver 5 (apply(RPOProc RPOAF (Yices 60)) .|. apply(RPOProc rpo (Yices 60)) .|. graphTransform >=>
                                         depGraph
                                         )


graphTransform = apply NarrowingP .|. apply FInstantiation .|. apply Instantiation
<commit_msg>Use LPO for the FLOPS08 search heuristic<commit_after>#!/usr/bin/env runhaskell
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE NoMonomorphismRestriction #-}

import Control.Monad
import Data.Maybe
import qualified Language.Prolog.Syntax as Prolog
import Narradar
import Narradar.Types.ArgumentFiltering (AF_, simpleHeu, bestHeu, innermost)
import Narradar.Types.Problem
import Narradar.Types.Problem.Rewriting
import Narradar.Types.Problem.NarrowingGen
import Narradar.Processor.Aprove
import Narradar.Processor.RPO
import Narradar.Processor.FLOPS08
import Narradar.Framework.GraphViz
import Lattice
--import Narradar.Utils

main = narradarMain listToMaybe


-- Missing dispatcher cases
instance (IsProblem typ, Pretty typ) => Dispatch (Problem typ trs) where
    dispatch p = error ("missing dispatcher for problem of type " ++ show (pPrint $ getProblemType p))

instance Dispatch thing where dispatch _ = error "missing dispatcher"

-- Rewriting
instance (Pretty (DPIdentifier a), Ord a) => Dispatch (NProblem Rewriting (DPIdentifier a)) where
  dispatch = mkDispatcher (sc >=> rpoPlusTransforms LPOSAF)

instance (Pretty (DPIdentifier a), Ord a) => Dispatch (NProblem IRewriting (DPIdentifier a)) where
  dispatch = mkDispatcher (sc >=> rpoPlusTransforms LPOSAF)

-- Narrowing Goal

instance (id  ~ DPIdentifier a, Ord a, Lattice (AF_ id), Pretty id) =>
           Dispatch (NProblem (NarrowingGoal (DPIdentifier a)) (DPIdentifier a)) where
  dispatch = mkDispatcher
                (apply (ComputeSafeAF bestHeu) >=> depGraph  >=>
                 apply (NarrowingGoalToRewriting bestHeu) >=>
                 dispatch)


sc = depGraph >=> try(apply SubtermCriterion)

rpoPlusTransforms rpo =  depGraph >=>
                         repeatSolver 5 (apply(RPOProc LPOAF (Yices 60)) .|. apply(RPOProc rpo (Yices 60)) .|. graphTransform >=>
                                         depGraph
                                         )


graphTransform = apply NarrowingP .|. apply FInstantiation .|. apply Instantiation

{'fraction_non_alphanumeric': 0.09636903402603333, 'fraction_numerical': 0.003653802237953871, 'mean_word_length': 3.538860103626943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6512642', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1331, 'n_words': 366}