Possible truth function in $n$ truth values and $m$ variables. I am trying to do this problem but I am not that good with combinatorics . But I still tried and here is what I came up with so far:
for $1$ variable there are $n$ assignment.
for $2$ variable there are $n^2$ assignment.
for $3$ variable there are $n^3$ assignment.
. 
. 
. 
for $m$ variable there are $n^m$ assignment.
On the other hand ,
for $1$ assignment there are $n$ possible truth values.
for $2$ assignments there are $n^2$ possible truth values.
for $3$ assignments there are $n^3$ possible truth values.
. 
. 
. 
for $n^m$ assignments there are $n^{n^m}$ possible truth values.
So there are $n^{n^m}$ possible truth functions.
Is this correct?And if this is correct then is there a way to make this more rigorous?
 A: You are correct, and your way of doing things is also correct.
The barrier that naturally arises when we think of counting functions , is that we seem to count them using heuristics like : for each choice of xyz, there's these many choices of abc etc. which is what you have done. Probably  because it is still a bit handwavy and there isn't enough mathematical notation to back up words such as "choice" and "assignment", we must strive to make this more rigorous.
The point is, that functions themselves make up a set. So to rigorously express the argument made, we must create a set, assert that the given set represents what we want to count, and then count the number of elements of that set.

To see how we can do this, let's take a finite set $A = \{a_1,...,a_{|A|}\}$ and a finite set $B$. What is the set of functions from $A$ to $B$? We claim that it is in one-to-one bijection with the set $\underbrace{B \times B \times B \times ... \times B}_{|A| \mathrm{\ times}}$. Indeed, note that for each element from $A$, we have a choice of an element from $B$, so for example if $a_1$ goes to $b_1$, $a_2$ goes to $b_2$ and so on, then a function is nothing but the tuple $(b_1,b_2,...,b_{|A|})$, and similarly from a tuple you can get a function by mapping $a_1$ to the first element of the tuple, $a_2$ to the second element of the tuple and so on.
Therefore, the set of functions from $A$ to $B$, has cardinality equal to the cardinality of $\underbrace{B \times B \times B \times ... \times B}_{|A| \mathrm{\ times}}$, and by the definition of the cartesian product (and using a simple induction) the answer is $|B|^{|A|}$.

Now, we identity each function in $m$ variables with $n$ truth values as follows : basically, an assignment of variables is a function from $\{1,...,m\} \to \{1,...,n\}$ because we give variable $1$ the value the function assigns it, variable $2$ the value the function assigns it, and so on. Let us call this set $S$, then realize that $|S| = n^m$ from the previous argument.
Next, note that the set we want, is the set of functions from $S$ to $\{1,...,n\}$, because for each such assignment we want a truth value to be assigned. Therefore, the set we are looking for, has cardinality $n^{|S|} = n^{(n^m)}$, as desired.

The takeaway from this , is that the rigorous way of describing "free choice"  is using the cartesian product to express a set of functions in terms of another easy-to-describe set which is counted using the rules for Cartesian products.
Having said that, I would still be very surprised if you did not get partial credit for your explanation in an exam, because it pretty much contains the entire thinking behind the problem, if not the rigour.
