How to tell if a transaction is valid? So I have been reading up on bitcoin and blockchain for awhile now, but I have yet to fully understand it. I understand that bitcoin leverage on DLT, which uses cryptography to verify transaction. This is what I have understood so far:


When I make a transaction, this transaction is added to a pool of unconfirmed transactions
This pool of unconfirmed transactions forms a block and miners will solve a mathematical problem as verification
The first miner to solve it will have the block verified and added on to the chain


However, how do they know if my transaction is valid? What if I have 1 BTC but decide to send 2 BTC, how does the solving of mathematical problem verify that I do not have 2 BTC? What if I just purchased 5 BTC from Coinbase using fiat, how will anyone know that I have 5 BTC?

I believe this should not be a very difficult question but I cant seem to understand it fully. Hope someone can point be to the right direction and enlighten me thanks!
When you spend Bitcoin in a transaction, the transaction must reference at least one existing unspent transaction output (UTXO) and provide a valid signature proving that you are authorized to spend it. The transaction then consumes the UTXOs in the inputs, and assigns value to newly created UTXOs in the outputs.
Other network participants running a type of Bitcoin software called &quot;fully validating nodes&quot; have followed along the full history of all Bitcoin transactions (the &quot;blockchain&quot;) to maintain a complete set of all UTXOs in existence (the &quot;UTXO set&quot;). You can think of the blockchain as the journal of all transactions, and the UTXO set as the ledger of all Bitcoin balances.
UTXOs are uniquely identifiable by their &quot;outpoint&quot; which is composed of the transaction id that created the output and their position in the transaction's output list: txid:vout.
This means that each full node can look up whether the UTXOs the transaction spends in the inputs exist in their UTXO set. They also check that the transaction is correctly constructed, including whether the transaction fulfills the locking conditions of the UTXOs, whether the signatures are valid, and that the transaction does not create new money by assigning more to the outputs than the inputs brought in.