
// standard 
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cassert>
#include <cstdlib>
#include <unordered_map>
#include <string>

// spot 
#include <spot/twaalgos/hoa.hh>
#include <spot/twaalgos/translate.hh>
#include <spot/twaalgos/isdet.hh>
#include <spot/twaalgos/product.hh>
#include <spot/twaalgos/word.hh>
#include <spot/twaalgos/degen.hh>
#include <spot/twaalgos/remprop.hh>

#include <spot/twa/twagraph.hh>
#include <spot/twa/twagraph.hh>

#include <spot/tl/formula.hh>
#include <spot/tl/print.hh>
#include <spot/tl/parse.hh>
#include <spot/tl/relabel.hh>
#include <spot/tl/print.hh>
#include <spot/tl/ltlf.hh>

#include <spot/misc/optionmap.hh>
#include <spot/misc/timer.hh>

using namespace spot;
using namespace std;

int 
main(int argc, char** argv)
{
    if(argc < 1 || argc > 2)
        std::cout << "please input one formula string" << std::endl;
    auto pf1 = spot::parse_infix_psl(argv[1]);
    if (pf1.format_errors(std::cerr))
    {
      std::cerr << "error: " << argv[1] << std::endl;
      return -1;
    }
    // formula 
    auto f1 = pf1.f;
    std::cout << f1 << std::endl;
    // translate to ltlf
    //auto ltlf = spot::from_ltlf(f1, "alive");
    spot::translator trans;
    //trans.set_type(spot::postprocessor::BA);
    trans.set_pref(spot::postprocessor::Small);
    trans.set_level(spot::postprocessor::High);
    spot::twa_graph_ptr aut = trans.run(spot::from_ltlf(pf1.f));

    spot::remove_ap rem;
    rem.add_ap("alive");
    aut = rem.strip(aut);

    spot::postprocessor post;
    post.set_type(spot::postprocessor::BA);
    post.set_pref(spot::postprocessor::Small); // or ::Deterministic
    post.set_pref(spot::postprocessor::High); // or ::Deterministic
    aut = post.run(aut);
    
    cout << "#states=" << aut->num_states() << endl;
    
}
