I want my contract to check a given range of blocks and see whether there are any transactions between a given pair of addresses. Is this possible to do in Solidity? Otherwise how would I do it?
No, its not possible the EVM is pretty isolated. Alternative way is to watch the blockchain with a
web3.js script and notify your contract. Of course this is a potential security hole.
The opcodes of the EVM do only have limited access to the current block.
If those two addresses are contracts, they could be coded to inform a "watching" contract of any interactions. Unfortunately, they would have to be specifically programmed to do this.