Question: Quantum parallelism is usually introduced from CNOT schema, saying that there it results, calling $ |c\rangle $ the control and $|t\rangle$ the target
$$ |0\rangle |t\rangle \implies |0\rangle |t\rangle $$

$$ |1\rangle |t\rangle \implies |1\rangle X|t\rangle $$
Generalizing that for a generic controlled-U gate, it gives
$$
|1\rangle |t\rangle \implies |1\rangle U|t\rangle
$$
To note that the separation of the output is possible only if the control $|c\rangle$ is a pure state (i.e. $|0\rangle$ or $|1\rangle$). 

With a further step it is said that, if $|t\rangle = |0\rangle$, the controlled-$U$ behaves as following
$$
|c\rangle |0\rangle \implies |c\rangle |f(c)\rangle
$$
with $f(x)$ a proper function, non necessarily equal to $U$. More generally 
$$
|c\rangle |t\rangle \implies |c\rangle |t XOR f(c)\rangle 
$$
Now my question: from where above two expressions are derived? And how can we build $f(x)$ from U? Making some examples with $C\_X$, $C\_Z$, $C\_Y$ the unitaries needed for implementing the $f(x)$ are always different, and I couldn't find any clear logic for it.

Any clarification, or a working examples, would be great!

Answer: 
Unfortunately, there is indeed currently no way to generate circuit diagrams from a Q# program. Since this is a feature request, consider making it here: <https://quantum.uservoice.com/forums/906940-debugging-and-simulation>. 

To give a little bit of context, Q# makes a conscious effort to encourage reasoning about quantum algorithms in terms of control flow and transformations rather than circuits, allowing e.g. qubit aliasing. Correspondingly, the kit focuses on tools that are commonly used in software engineering like unit testing instead of circuit diagrams. I can understand that a diagram may come in handy for publications, though it is certainly not unheard of to give pseudo code instead.
Q#'s full state simulator has an `OnOperationStart` and `OnOperationEnd` events that, as the names imply, are triggered every time a quantum operation starts/ends. Thus the easiest way to get and print the sequence of gates would be to attach a handler to the `OnOperationStart`, for example:

```
        using (var qsim = new QuantumSimulator())
        {
            qsim.OnOperationStart += (op, arg) => Console.WriteLine($"{op.Name}:{op.Variant}");

            HelloQ.Run(qsim).Wait();
        }

```

The event sends two parameters:

1. **the operation itself**, exposed via the `ICallable` interface; from it, you can get the `Name` (e.g. `X`), the `FullName` (e.g. `Microsoft.Quantum.Primitive.X`) or the `Variant` (i.e. `Body`, `Adjoint`, `Controlled` or `ControlledAdjoint`).
2. **the argument tuple**, exposed via the `IApplyData` interface; from it you can get the actual values the operation received or just the list of Qubits.

This doesn't produce the circuit diagram, but as you point out, could allow you to print and feed the list of operations to other tools.

We're still actively working on this part of the Quantum Development Kit, which is why it still needs much more documentation. However, we're active monitoring stackoverflow so please let us know if you need any more help.