INSERT_CONV : conv -> conv
Given such a conversion, the function INSERT_CONV returns a conversion that maps a term of the form t INSERT {t1;...;tn} to the theorem
|- t INSERT {t1;...;tn} = {t1;...;tn}
- INSERT_CONV REDUCE_CONV ``2 INSERT {1;SUC 1;3}``; > val it = |- {2; 1; SUC 1; 3} = {1; SUC 1; 3} : thm
A call to INSERT_CONV fails when the value being inserted is provably not equal to any of the remaining elements:
- INSERT_CONV REDUCE_CONV ``1 INSERT {2;3}``; ! Uncaught exception: ! HOL_ERR
The behaviour of the supplied conversion is irrelevant when the inserted value is alpha-equivalent to one of the remaining elements:
- INSERT_CONV NO_CONV ``y INSERT {x;y;z}``; > val it = |- {y; x; y; z} = {x; y; z} : thm
Note that DEPTH_CONV(INSERT_CONV conv) can be used to remove duplicate elements from a finite set, but the following conversion is faster:
- fun SETIFY_CONV conv tm = (SUB_CONV (SETIFY_CONV conv) THENC TRY_CONV (INSERT_CONV conv)) tm; > val SETIFY_CONV = fn : conv -> conv - SETIFY_CONV REDUCE_CONV ``{1;2;1;3;2;4;3;5;6}``; > val it = |- {1; 2; 1; 3; 2; 4; 3; 5; 6} = {1; 2; 4; 3; 5; 6} : thm