[Tex/LaTex] How to use \theorem

theorems

I don't know why this doesn't work:

I'm a beginner in LaTeX and I'm trying a lot to understand this.

The code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsthm}


\begin{document}
\begin{theorem}
  Given two line segments whose lengths are $a$ and $b$ respectively there 
  is a real number $r$ such that $b=ra$.
\end{theorem}

\begin{proof}
To prove it by contradiction try and assume that the statemenet is false,
proceed from there and at some point you will arrive to a contradiction.
\end{proof}
\end{document}

The log:

! LaTeX Error: Environment theorem undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.8 \begin{theorem}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 9.

Remark 1: I've installed Texmaker and Texlive with sudo apt-get install texlive-full

Remark 2: My OS is Ubuntu and my latex editor is Texmaker.

Remark 3 I'm studying using this site but I used also the documentation of the package amsthm. (in the documentation we should use lem instead of lemma command)

Thanks

Best Answer

amsthm is a package to create theorems and theorem-related environments. It does not do this by default. So, you could issue

\newtheorem{theorem}{Theorem}

to define the theorem environment:

enter image description here

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}
Test
\end{theorem}
\end{document}