\documentclass[12pt,a4paper,openany]{book}
\usepackage{amsthm,amssymb,amsmath}
\usepackage{graphicx}
\usepackage{xepersian}
\settextfont[Scale=1.2]{XB Niloofar}
\setlatintextfont[ExternalLocation,BoldFont={lmroman10-bold},BoldItalicFont={lmroman10-bolditalic},ItalicFont={lmroman10-italic}]{lmroman10-regular}
\theoremstyle{definition}
\newtheorem{definition}{تعریف}[section]
\theoremstyle{theorem}
\newtheorem{theorem}[definition]{قضیه}
\newtheorem{lemma}[definition]{لم}
\newtheorem{proposition}[definition]{گزاره}
\newtheorem{corollary}[definition]{نتیجه}
\newtheorem*{rem}{ملاحظه}
\theoremstyle{definition}
\newtheorem{example}[definition]{مثال}
\begin{document}
\chapter{سلام}
\section{بخش اول}
سلام
\begin{theorem}
این اولین قضیه است که باهاش کاری نداریم.
\end{theorem}
\begin{example}
این هم اولین مثال  است که درست شماره خورده است و باهاش کاری نداریم.
\end{example}
\begin{figure}[!h]
\centerline{\includegraphics[height=5cm]{Knuth}}
\caption{
این اولین عکس است. اما می‌خوام شماره‌ش بجای ۱.۱، به صورت ۳.۱.۱ باشه. یعنی از شماره قضیه و مثال قبلش، پیروی کنه.}
\end{figure}
\begin{definition}
این هم یه تعریف بعد از شکل قبلی است که باز می‌خوام شماره‌ش بجای ۳.۱.۱، بصورت ۴.۱.۱ باشه. یعنی از شماره شکل قبلش، پیروی کنه.
\end{definition}
\end{document}