lean4-htt/extras/latex/sample.tex
2017-01-03 11:22:04 -08:00

71 lines
1.8 KiB
TeX
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{amssymb}
\usepackage{color}
\definecolor{keywordcolor}{rgb}{0.7, 0.1, 0.1} % red
\definecolor{commentcolor}{rgb}{0.4, 0.4, 0.4} % grey
\definecolor{symbolcolor}{rgb}{0.0, 0.1, 0.6} % blue
\definecolor{sortcolor}{rgb}{0.1, 0.5, 0.1} % green
\usepackage{listings}
\def\lstlanguagefiles{lstlean.tex}
\lstset{language=lean}
\title{The Lean listing style}
\author{Jeremy Avigad}
\begin{document}
\maketitle
This is an example of how to use \verb=lstlean.tex= to typeset your Lean code. Here is some code: \lstinline{theorem foo (x y : ), x + y = y + x}. Here are the translations of some unicode symbols:
\begin{lstlisting}
Some symbols: ∩ ⊂ ∀ ∃ Π α β γ ∈ ⦃ ⦄
\end{lstlisting}
Here is a block of code:
\begin{lstlisting}
/-
Basic properties of lists.
-/
inductive list (α : Type) : Type
| nil {} : list
| cons : α → list → list
namespace list
notation h :: t := cons h t
notation `[` l:(foldr `,` (h t, cons h t) nil `]`) := l
variable {α : Type}
/- append -/
def append : list α → list α → list α
| [] l := l
| (h :: s) t := h :: (append s t)
notation l₁ ++ l₂ := append l₁ l₂
theorem nil_append (t : list α) : [] ++ t = t := rfl
theorem append_cons (x : α) (s t : list α) : (x::s) ++ t = x::(s ++ t) := rfl
theorem append_nil : ∀ (t : list α), t ++ [] = t
| [] := rfl
| (a :: l) := calc
(a :: l) ++ [] = a :: (l ++ []) : rfl
... = a :: l : by rw append_nil l
theorem append.assoc : ∀ (s t u : list α), s ++ t ++ u = s ++ (t ++ u)
| [] t u := rfl
| (a :: l) t u :=
show a :: (l ++ t ++ u) = (a :: l) ++ (t ++ u),
begin rw (append.assoc l t u), reflexivity end
end list
\end{lstlisting}
\end{document}