\input{util/ltl_macros}

\renewcommand{\phi}{\varphi}
\renewcommand{\implies}{\rightarrow}
\newcommand{\imp}{\rightarrow}
\newcommand{\entails}{\enspace \vdash \enspace}
%\newcommand{\model}{\enspace \vDash \enspace}
\newcommand{\ent}{\enspace \vdash \enspace}
\newcommand{\nmodel}{\enspace \nvDash \enspace}
\newcommand{\nent}{\enspace \nvdash \enspace}
\newcommand{\eqv}{\leftrightarrow}
\newcommand{\biimp}{\leftrightarrow}
\newcommand{\lxor}{\oplus}
\newcommand{\nentails}{\nvdash}
\newcommand{\nmodels}{\nvDash}

\newcommand{\Model}{\ensuremath{\mathcal{M}}}

\newcommand{\impi}{\ensuremath{\imp_i}}
\newcommand{\impe}{\ensuremath{\imp_e}}
\newcommand{\andi}{\ensuremath{\land_i}}
\newcommand{\ande}{\ensuremath{\land_e}}
\newcommand{\ori}{\ensuremath{\lor_i}}
\newcommand{\ore}{\ensuremath{\lor_e}}
\newcommand{\negi}{\ensuremath{\neg_i}}
\newcommand{\nege}{\ensuremath{\neg_e}}
\newcommand{\bote}{\ensuremath{\bot_e}\xspace}
\newcommand{\negnege}{\ensuremath{\neg\neg_e}\xspace}
\newcommand{\negnegi}{\ensuremath{\neg\neg_i}\xspace}
\newcommand{\foralli}{\ensuremath{\forall_i}\xspace}
\newcommand{\foralle}{\ensuremath{\forall_e}\xspace}
\newcommand{\existi}{\ensuremath{\exists_i}\xspace}
\newcommand{\existe}{\ensuremath{\exists_e}\xspace}
\newcommand{\prem}{\text{\scriptsize premise}}                %% \prem = premise
\newcommand{\assum}{\text{\scriptsize assumption}}            %% \assum = assumption
\newcommand{\freshVar}[1]{\text{\scriptsize fresh~{#1}}}
\newcommand{\MT}{\text{MT}~}
\newcommand{\PBC}{\text{PBC}~}
\newcommand{\LEM}{\text{LEM}}
\newcommand{\copying}{\text{\scriptsize copy}~}

\newcommand{\true}{\ensuremath{\top}}
\newcommand{\false}{\ensuremath{\bot}}
\newcommand{\F}{\textbf{F}}
\newcommand{\T}{\textbf{T}}

\newcommand{\variableOrder}[1]{
\foreach\variable in {#1}
{\ensuremath{~\variable<}}%% FIXME
}
% multiple choice itemize
\newcommand{\ticked}{\ensuremath{\boxtimes}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TSEITIN rules
\newcommand{\tseitinOr}[3]{
  \def\CHI{#1}%
  \def\PHI{#2}%
  \def\PSI{#3}%
  \ensuremath{(\lnot \PHI \lor \CHI) \land (\lnot \PSI \lor \CHI) \land (\lnot \CHI \lor \PHI \lor \PSI)}%
}
\newcommand{\tseitinAnd}[3]{
  \def\CHI{#1}%
  \def\PHI{#2}%
  \def\PSI{#3}%
  \ensuremath{(\lnot \CHI \lor \PHI) \land (\lnot \CHI \lor \PSI) \land (\lnot \PHI \lor \lnot \PSI \lor \CHI)}%
}
\newcommand{\tseitinNot}[2]{
  \def\CHI{#1}%
  \def\PHI{#2}%
  \ensuremath{(\lnot \CHI \lor \lnot \PHI) \land (\CHI \lor \PHI)}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DPLL helper
\newenvironment{dpllCNFInput}%
  {\begin{enumerate}[leftmargin=2.0em,itemindent=2.45em,label=Clause {\arabic*}:]}%
  {\end{enumerate}}%

\newenvironment{dplltabular}[1]
  {\begin{tabular}{ |l|*{#1}{c|} } \hline}
  {\end{tabular}}

\ExplSyntaxOn
\NewDocumentCommand{\dpllrow}{m}
 {
  \seq_set_split:Nnn \l_row {|} { #1 }
  \seq_use:Nn \l_row { & }
  \\
  \hline
 }
\seq_new:N \l_row % allocate a sequence
\ExplSyntaxOff

\newcommand{\dpllStep}[1]{
  Step & \dpllrow{#1}
}

\newcommand{\dpllDecL}[1]{
  Decision Level & \dpllrow{#1}
}

\newcommand{\dpllAssi}[1]{
  Assignment & \dpllrow{#1}
}

\newcommand{\dpllBCP}[1]{
  BCP & \dpllrow{#1}
}

\newcommand{\dpllPL}[1]{
  PL & \dpllrow{#1}
}

\newcommand{\dpllDeci}[1]{
  Decision & \dpllrow{#1}
}

\newcommand{\dpllClause}[3]{
  \def\ITEM{#1}%
  \def\CLAUSE{#2}%
  Cl. \ITEM: \CLAUSE & \dpllrow{#3}
}

\ExplSyntaxOn
\NewDocumentCommand{\clause}{m}
 {
  \seq_set_split:Nnn \l_clause {;} { #1 }
  \seq_use:Nn \l_clause { \lor }
 }
\seq_new:N \l_clause % allocate a sequence
\ExplSyntaxOff

\ExplSyntaxOn
\NewDocumentCommand{\cube}{m}
 {
  \seq_set_split:Nnn \l_cube {;} { #1 }
  \seq_use:Nn \l_cube { \land }
 }
\seq_new:N \l_cube % allocate a sequence
\ExplSyntaxOff

\newcommand{\cmark}{\ding{51}}
\newcommand{\xmark}{\ding{55}}
\newcommand{\done}{\cmark}
\newcommand{\conflict}{\{\} \xmark}

\NewEnviron{conflictgraph}[1][1.5cm]{%
  \begin{tikzpicture}[->,
                      >=stealth',
                      shorten >=1pt,
                      auto,
                      node distance=#1,
                      thick,
                      base node/.style={circle,draw,minimum size=20pt},
                      real node/.style={double,circle,draw,minimum size=20pt}]
          \BODY
  \end{tikzpicture}
}

\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=1.5pt] (char) {#1};}}

\tikzset{
  line/.style={-},
  dot/.style={decoration={
  markings,
  mark=at position #1 with {\draw circle (2pt);}},postaction={decorate}},
  fulldot/.style={decoration={
  markings,
  mark=at position #1 with {\fill circle (2pt);}},postaction={decorate}},
}

\newenvironment{scprooftree}[1]%
  {\gdef\scalefactor{#1}\begin{center}\proofSkipAmount \leavevmode}%
  {\scalebox{\scalefactor}{\DisplayProof}\proofSkipAmount \end{center} }

\tikzset{
  line/.style={-},
  dot/.style={decoration={
  markings,
  mark=at position #1 with {\draw circle (2pt);}},postaction={decorate}},
  fulldot/.style={decoration={
  markings,
  mark=at position #1 with {\fill circle (2pt);}},postaction={decorate}},
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% BDD helper

\newenvironment{cofactors}
  {\begin{tabbing}}
  {\end{tabbing}}



\NewEnviron{bdd}[1][3em]{%
  \begin{tikzpicture}[node distance=#1,
                      base node/.style={circle,draw,minimum size=20pt},
                      func node/.style={rectangle,draw,minimum size=10pt},
                      cofactor/.style={circle,draw,minimum size=10pt},
                      phantom/.style={circle,draw,inner sep=0pt,minimum size=0pt}]
          \BODY
  \end{tikzpicture}
}

\newcommand{\funcEdge}[3][]{
  \path[] (#2) edge [#1] (#3);
}
\newcommand{\thenEdge}[3][]{
  \path[] (#2) edge [#1] (#3);
}
\newcommand{\elseEdge}[3][]{
  \path[] (#2) edge [#1] node [midway,draw,circle,fill=white,transform shape,inner sep=0pt,minimum size=0.3em] (ref) {} (#3);
}
\newcommand{\negatedEdge}[3][]{
  \path[] (#2) edge [#1] node [midway,draw,circle,fill=black,transform shape,inner sep=0pt,minimum size=0.3em] (ref) {} (#3);
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NewEnviron{egraph}[1][1.5cm]{%
  \begin{tikzpicture}[-,
                      >=stealth',
                      shorten >=1pt,
                      auto,
                      node distance=#1,
                      thick,
                      base node/.style={circle,draw,minimum size=20pt}]
          \BODY
  \end{tikzpicture}
}

\newcommand{\chord}[2]{
  \draw[dashed,red] (#1) -- (#2);
}

\newcommand{\egraphFuncConstraint}[3]{%
  &((e_{#1=#2}~\land~e_{#2=#3})~\imp~e_{#1=#3})~\land\\
  &((e_{#1=#2}~\land~e_{#1=#3})~\imp~e_{#2=#3})~\land\\
  &((e_{#1=#3}~\land~e_{#2=#3})~\imp~e_{#1=#2})
}

\newcommand{\eq}[2]{
  e_{#1=#2}
}

\newcommand{\ackermannFuncConstraint}[3]{%
  (#2=#3~\imp~#1_{#2}=#1_{#3})
}
\newcommand{\DNF}[1]{\ensuremath{\text{DNF}(#1})}
\newcommand{\CNF}[1]{\ensuremath{\text{CNF}(#1})}


\newcommand{\satUnsatAss}[2]{{\color{blue}\ensuremath{#1}}|{\color{red}\ensuremath{#2}}}

