434 (*Find the minimal arity of each function mentioned in the term. Also, note which uses |
434 (*Find the minimal arity of each function mentioned in the term. Also, note which uses |
435 are not at top level, to see if hBOOL is needed.*) |
435 are not at top level, to see if hBOOL is needed.*) |
436 fun count_constants_term toplev t (const_min_arity, const_needs_hBOOL) = |
436 fun count_constants_term toplev t (const_min_arity, const_needs_hBOOL) = |
437 let val (head, args) = strip_combterm_comb t |
437 let val (head, args) = strip_combterm_comb t |
438 val n = length args |
438 val n = length args |
439 val (const_min_arity, const_needs_hBOOL) = fold (count_constants_term false) args (const_min_arity, const_needs_hBOOL) |
439 val (const_min_arity, const_needs_hBOOL) = |
|
440 (const_min_arity, const_needs_hBOOL) |
|
441 |> fold (count_constants_term false) args |
440 in |
442 in |
441 case head of |
443 case head of |
442 CombConst ((a, _),_,_) => (*predicate or function version of "equal"?*) |
444 CombConst ((a, _),_,_) => (*predicate or function version of "equal"?*) |
443 let val a = if a="equal" andalso not toplev then "c_fequal" else a |
445 let val a = if a="equal" andalso not toplev then "c_fequal" else a |
444 val const_min_arity = Symtab.map_default (a, n) (Integer.min n) const_min_arity |
|
445 in |
446 in |
446 if toplev then (const_min_arity, const_needs_hBOOL) |
447 (const_min_arity |> Symtab.map_default (a, n) (Integer.min n), |
447 else (const_min_arity, Symtab.update (a,true) (const_needs_hBOOL)) |
448 const_needs_hBOOL |> not toplev ? Symtab.update (a, true)) |
448 end |
449 end |
449 | _ => (const_min_arity, const_needs_hBOOL) |
450 | _ => (const_min_arity, const_needs_hBOOL) |
450 end; |
451 end; |
451 |
452 |
452 (*A literal is a top-level term*) |
453 (*A literal is a top-level term*) |