Suppose we have a tree with n keys with values 1 to n.
The inorder of this tree is 1, 2, 3,...,n and we are not sure if this is a BST or not.
We can have a total of n! different pre-order traversals for this tree and if we can prove that for all such preorder traversals, the tree produced is BST then we can effectively claim that if the inorder traversal is sorted, the tree must be BST.
Now for each pre-order traversal, the first element in the traversal will be the root of the tree and in the left sub tree of the root, all the nodes less than root will be present and n the right sub tree, all the nodes greater than root will be present.
For ex - 1,2,3,4,5,6 be the nodes then if 4 is the root then 1,2,3 must be present in left sub tree and 5,6 must be present in right sub tree.
Again, continuing in a generic way, suppose we had chosen k as the root in the first step, then we will have 1 to k-1 elements for the LST and k+1 to n for the RST. Now, the LST has reduced to a smaller problem where the inorder is 1 to k-1 and (k-1)! preorder traversals are possible and similarly, RST has reduced to a problem where inorder is k+1 to n and (n - k)! preorder traversals are possible. Whatever maybe the left child and right child of the root based on above argument, left child<root<right child. We can recursively then show that each node of this tree will follow the same property, i.e. left-child of the node<node<right child of the node because for every node, the inorder traversal is sorted and it will be a smaller subproblem of the initial problem and thus will maintain the binary search property all the way down.
So, it can be said that if the inorder traversal is sorted, the given tree is definitely a BST.