I need it to be so as for when the theme is activated, the plugin is automatically activated and deactivated theme =deactivated plugin
If a plugin is essential part of the theme it should be shipped as part of the theme and not as a separate plugin.
In theory, there is no way to do what you want without getting users surprised and upset when they want to use the plugin but not the theme. In practice, you can hack something but this is a bad idea with possible surprising edge cases you will not like to handle.
Best that can be done, is to notify the user that he needs to activate the plugin when the theme is active.