@problem@
	@problemtype@
		embedded
	@;problemtype@
	@name@
		tutorial_12_assertions
	@endname@
	@preamble@
		x1 = randint(-42,42)
		x2 = randint(-42,42)
		x3 = -x1 -x2
		a = randint(-5,5)
		b = randint(-5,5)
		c = randint(-5,5)
		d = randint(-5,5)
	@;preamble@
	@assert@
		x1 + x2 + x3 == 0
		a*d - c*b != 0
	@endassert@
	@content@
		Some problems involving random values require certain conditions on these values to hold in order to be well posed and non-trivial. For example, if the task is to find $x\in\mathbb{R}$ such that $mx=y$, and if $m,y$ are randomly generated in the preamble, then a unique solution $x$ exists if and only if $m\neq0$. On the other hand, if $y=0$, then the problem might be considered too simple (i.e. trivial).
		@pb;@
		The use of so-called assertions can ensure that such conditions are indeed satisfied for the randomly selected values. During compilation, if any of the conditions listed in the 'assert' block are not fulfilled, the preamble is re-executed (resulting in a new selection of random values) until all assertions are satisfied or until a certain maximum number of attempts has been reached, in which case the compilation will be stopped and an error message will be displayed.
		@pb;@
		Ideally, the random selection of the variable values in the preamble should already contain the necessary relations between the variables. Consider, for example, the following problem:
		@pb;@
		Let $x_1=@x1@$ and $x_2=@x2@$. Find $x_3\in\mathbb{R}$ such that $x_1+x_2+x_3=0$.
		@lb;@
		$x_3=$ @numericalans(100,x3)@
		@pb;@
		In the preamble, "x3" has been assigned the value of the solution to the above problem. In this case, the assertion 'x1 + x2 + x3 == 0', which is necessary and sufficient for 'x3' to be the correct solution, will always be satisfied. However, in more complex problem statements, the assignment of variables in the preamble might change in later revisions of the problem. It should therefore still be considered good practice to ensure important relations via assertions in order to ensure that later changes do not result in unsolvable problems or in wrongly stated solutions.
		@pb;@
		In some situations, on the other hand, a problem might be well posed in all but rather rare situations, i.e. issues occur only for certain rare combinations of random values. Consider the following problem:
		@pb;@
		Let
		\[
			A = \begin{pmatrix}
				@a@ & @b@ \\
				@c@ & @d@
			\end{pmatrix}
			\,.
		\]
		Then $\det(A^{-1})=$ @numericalans(100,1/(a*d-c*b))@.
		@pb;@
		Of course, the problem cannot be solved unless the matrix $A$ is invertible, which is ensured by the assertion 'a*d - c*b != 0'. Note that this assertion can indeed be violated by the randomly assigned values of "a", "b", "c" and "d"; in fact, the determinant of $A$ is indeed equal to zero in every eleventh case (on average). If this situation occurs during compilation, the random assignments will simply be repeated until an invertible matrix is created or until the maximum numer of attempts is reached. Note that by default, at least 100 attempts are made, so the probability of the compilation ending without finding an invertible matrix is less than $\frac{1}{10^{100}}$.
	@;content@
@;problem@