A function fcan be registered as a dimension function to verify completion by declaring the lemma an is_measure fattribute measure_function. In your case, it looks like this.
lemma is_measure_size2 [measure_function]: "is_measure size2" ..
lexicographic_order, fun, size_change size2 .