LatexListNil @ latexlist(nil, nil) <-; LatexListCons @ latexlist(cons(?x, ?xs), cons(?l_x, ?l_s)) <- latex(?x, ?l_x), latexlist(?xs, ?l_s); IntercalateNil @ intercalate(?sep, nil, nil) <-; IntercalateConsCons @ intercalate(?sep, cons(?x_1, cons(?x_2, ?xs)), cons(?x_1, cons(?sep, ?ys))) <- intercalate(?sep, cons(?x_2, ?xs), ?ys); IntercalateConsNil @ intercalate(?sep, cons(?x, nil), cons(?x, nil)) <-; NonEmpty @ nonempty(cons(?x, ?xs)) <-; LatexInt @ latex(?i, ?l) <- int(?i), tostring(?i, ?l); LatexFloat @ latex(?f, ?l) <- float(?f), tostring(?f, ?l); LatexStr @ latex(?s, ?l) <- str(?s), escapestring(?s, ?l_1), latexifystring(?s, ?l_2), join(["\\texttt{\"", ?l_2, "\"}"], ?l); LatexMeta @ latex(metavariable(?l), ?l) <-; LatexLit @ latex(lit(?i), ?l) <- latex(?i, ?l); LatexVar @ latex(var(?s), ?l) <- latex(?s, ?l); LatexIsInt @ latex(int(?e), ?l) <- latex(?e, ?l_e), join([?l_e, " \\in \\texttt{Int}"], ?l); LatexIsFloat @ latex(float(?e), ?l) <- latex(?e, ?l_e), join([?l_e, " \\in \\texttt{Float}"], ?l); LatexIsNum @ latex(num(?e), ?l) <- latex(?e, ?l_e), join([?l_e, " \\in \\texttt{Num}"], ?l); LatexIsStr @ latex(str(?e), ?l) <- latex(?e, ?l_e), join([?l_e, " \\in \\texttt{Str}"], ?l); LatexSym @ latex(?s, ?l) <- sym(?s), tostring(?s, ?l_1), join(["\\text{", ?l_1,"}"], ?l); LatexCall @ latex(?c, ?l) <- call(?c, ?n, ?ts), nonempty(?ts), latexlist(?ts, ?lts_1), intercalate(", ", ?lts_1, ?lts_2), join(?lts_2, ?lts_3), join(["\\text{", ?n, "}", "(", ?lts_3, ")"], ?l);