IMAGE_CONV : conv -> conv -> conv
|- IMAGE f {t1;...;tn} = {r1;...;rn}
Given appropriate conversions conv1 and conv2, the function IMAGE_CONV returns a conversion that maps a term of the form IMAGE f {t1;...;tn} to the theorem
|- IMAGE f {t1;...;tn} = {rj;...;rk}
- IMAGE_CONV REFL NO_CONV ``IMAGE (f:num->num) {1; 2; 1; 4}``; > val it = |- IMAGE f {1; 2; 1; 4} = {f 2; f 1; f 4} : thm
For the next example, we construct a conversion that maps SUC n for any numeral n to the numeral standing for the successor of n.
- fun SUC_CONV tm = let open numLib Arbnum val n = dest_numeral (rand tm) val sucn = mk_numeral (n + one) in SYM (num_CONV sucn) end; > val SUC_CONV = fn : term -> thm
- numLib.num_CONV ``4``; > val it = |- 4 = SUC 3 : thm - SUC_CONV ``SUC 3``; > val it = |- SUC 3 = 4 : thm
- IMAGE_CONV SUC_CONV NO_CONV ``IMAGE SUC {1; 2; 1; 4}``; > val it = |- IMAGE SUC {1; 2; 1; 4} = {3; 2; 5} : thm
Finally, here is an example of using IMAGE_CONV to compute the image of a paired addition function on a set of pairs of numbers:
- IMAGE_CONV (pairLib.PAIRED_BETA_CONV THENC reduceLib.ADD_CONV) numLib.REDUCE_CONV ``IMAGE (\(n,m).n+m) {{(1,2), (3,4), (0,3), (1,3)}}``; > val it = |- IMAGE (\(n,m). n + m) {(1,2); (3,4); (0,3); (1,3)} = {7; 3; 4}