393 |
393 |
394 fun count_user_clause user_lemmas (Clause{axiom_name,literals,...}, ct) = |
394 fun count_user_clause user_lemmas (Clause{axiom_name,literals,...}, ct) = |
395 if axiom_name mem_string user_lemmas then foldl count_literal ct literals |
395 if axiom_name mem_string user_lemmas then foldl count_literal ct literals |
396 else ct; |
396 else ct; |
397 |
397 |
398 val cnf_helper_thms = ResAxioms.cnf_rules_pairs o (map ResAxioms.pairname) |
398 fun cnf_helper_thms thy = |
|
399 ResAxioms.cnf_rules_pairs thy o map ResAxioms.pairname |
399 |
400 |
400 fun get_helper_clauses thy isFO (conjectures, axclauses, user_lemmas) = |
401 fun get_helper_clauses thy isFO (conjectures, axclauses, user_lemmas) = |
401 if isFO then [] (*first-order*) |
402 if isFO then [] (*first-order*) |
402 else |
403 else |
403 let val ct0 = foldl count_clause init_counters conjectures |
404 let val ct0 = foldl count_clause init_counters conjectures |
404 val ct = foldl (count_user_clause user_lemmas) ct0 axclauses |
405 val ct = foldl (count_user_clause user_lemmas) ct0 axclauses |
405 fun needed c = valOf (Symtab.lookup ct c) > 0 |
406 fun needed c = valOf (Symtab.lookup ct c) > 0 |
406 val IK = if needed "c_COMBI" orelse needed "c_COMBK" |
407 val IK = if needed "c_COMBI" orelse needed "c_COMBK" |
407 then (Output.debug (fn () => "Include combinator I K"); cnf_helper_thms [comb_I,comb_K]) |
408 then (Output.debug (fn () => "Include combinator I K"); cnf_helper_thms thy [comb_I,comb_K]) |
408 else [] |
409 else [] |
409 val BC = if needed "c_COMBB" orelse needed "c_COMBC" |
410 val BC = if needed "c_COMBB" orelse needed "c_COMBC" |
410 then (Output.debug (fn () => "Include combinator B C"); cnf_helper_thms [comb_B,comb_C]) |
411 then (Output.debug (fn () => "Include combinator B C"); cnf_helper_thms thy [comb_B,comb_C]) |
411 else [] |
412 else [] |
412 val S = if needed "c_COMBS" |
413 val S = if needed "c_COMBS" |
413 then (Output.debug (fn () => "Include combinator S"); cnf_helper_thms [comb_S]) |
414 then (Output.debug (fn () => "Include combinator S"); cnf_helper_thms thy [comb_S]) |
414 else [] |
415 else [] |
415 val other = cnf_helper_thms [ext,fequal_imp_equal,equal_imp_fequal] |
416 val other = cnf_helper_thms thy [ext,fequal_imp_equal,equal_imp_fequal] |
416 in |
417 in |
417 map #2 (make_axiom_clauses thy (other @ IK @ BC @ S)) |
418 map #2 (make_axiom_clauses thy (other @ IK @ BC @ S)) |
418 end; |
419 end; |
419 |
420 |
420 (*Find the minimal arity of each function mentioned in the term. Also, note which uses |
421 (*Find the minimal arity of each function mentioned in the term. Also, note which uses |