{-# OPTIONS -w -O0 #-}
{-# LANGUAGE CPP, StandaloneDeriving, DeriveDataTypeable, DeriveGeneric #-}
module ATC.ProofTree () where
import ATerm.Lib
import Common.Json.Instances
import Common.ProofTree
import Data.Aeson(ToJSON, FromJSON)
import Data.Data
import Data.Graph.Inductive.Graph
import Data.Graph.Inductive.PatriciaTree (Gr)
import Data.List (intercalate)
import GHC.Generics(Generic)
import Text.Printf
deriving instance GHC.Generics.Generic Common.ProofTree.ProofTree
instance Data.Aeson.ToJSON Common.ProofTree.ProofTree where
instance Data.Aeson.FromJSON Common.ProofTree.ProofTree where
instance ShATermConvertible Common.ProofTree.ProofTree where
toShATermAux :: ATermTable -> ProofTree -> IO (ATermTable, Int)
toShATermAux att0 :: ATermTable
att0 xv :: ProofTree
xv = case ProofTree
xv of
ProofTree a :: String
a -> do
(att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> String -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 String
a
(ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "ProofTree" [Int
a'] []) ATermTable
att1
ProofGraph a :: Gr ProofGraphNode Int
a -> do
(att1 :: ATermTable
att1, a' :: Int
a') <- ATermTable -> Gr ProofGraphNode Int -> IO (ATermTable, Int)
forall t.
ShATermConvertible t =>
ATermTable -> t -> IO (ATermTable, Int)
toShATerm' ATermTable
att0 Gr ProofGraphNode Int
a
(ATermTable, Int) -> IO (ATermTable, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return ((ATermTable, Int) -> IO (ATermTable, Int))
-> (ATermTable, Int) -> IO (ATermTable, Int)
forall a b. (a -> b) -> a -> b
$ ShATerm -> ATermTable -> (ATermTable, Int)
addATerm (String -> [Int] -> [Int] -> ShATerm
ShAAppl "ProofGraph" [Int
a'] []) ATermTable
att1
fromShATermAux :: Int -> ATermTable -> (ATermTable, ProofTree)
fromShATermAux ix :: Int
ix att0 :: ATermTable
att0 = case Int -> ATermTable -> ShATerm
getShATerm Int
ix ATermTable
att0 of
ShAAppl "ProofTree" [a :: Int
a] _ ->
case Int -> ATermTable -> (ATermTable, String)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
{ (att1 :: ATermTable
att1, a' :: String
a') ->
(ATermTable
att1, String -> ProofTree
ProofTree String
a') }
ShAAppl "ProofGraph" [a :: Int
a] _ ->
case Int -> ATermTable -> (ATermTable, Gr ProofGraphNode Int)
forall t.
ShATermConvertible t =>
Int -> ATermTable -> (ATermTable, t)
fromShATerm' Int
a ATermTable
att0 of
{ (att1 :: ATermTable
att1, a' :: Gr ProofGraphNode Int
a') ->
(ATermTable
att1, Gr ProofGraphNode Int -> ProofTree
ProofGraph Gr ProofGraphNode Int
a') }
u :: ShATerm
u -> String -> ShATerm -> (ATermTable, ProofTree)
forall a. String -> ShATerm -> a
fromShATermError "Common.ProofTree.ProofTree" ShATerm
u