Halliday & Matthiessen (2014: 637):
Corresponding in meaning to yes and no are the clause substitutes so and not. (Etymologically the word yes contains the substitute so; it is a fusion of (earlier forms of) aye and so.) In certain contexts these substitute forms are used: (i) following if – if so, if not; (ii) as a reported clause – he said so, he said not; (iii) in the context of modality – perhaps so, perhaps not. Examples:
||| Better than The Rainbow? ||| – ||| I think || so [∅: that it is better than The Rainbow], yes, || because I think || it shows Lawrence as a man more Lawrence in his life. |||
||| Well, do I have to do more in the afternoon? ||| – ||| No, [∅: you] probably [∅: do] not [∅: have to do more in the afternoon]. ||| Just do half an hour now. |||
The general principle is that a substitute is required if the clause is projected, as a report; with modality (perhaps) and hypothesis (if) being interpreted as kinds of projection, along the lines of:
he said so–I thought so–I think so–it may be so–perhaps so–let us say so–if so