Learning program abstractions: Formal model and empirical validation