equal
deleted
inserted
replaced
822 end |
822 end |
823 |
823 |
824 fun top_abduce_candidates max_candidates candidates = |
824 fun top_abduce_candidates max_candidates candidates = |
825 let |
825 let |
826 (* We prefer free variables to other constructs, so that e.g. "x \<le> y" is |
826 (* We prefer free variables to other constructs, so that e.g. "x \<le> y" is |
827 prioritized over "x \<le> 0". *) |
827 prioritized over "x \<le> 5". *) |
828 fun score t = |
828 fun score t = |
829 Term.fold_aterms (fn t => fn score => score + (case t of Free _ => 1 | _ => 2)) t 0 |
829 Term.fold_aterms (fn t => fn score => score + (case t of Free _ => 1 | _ => 2)) t 0 |
830 |
830 |
831 (* Equations of the form "x = ..." or "... = x" or similar are too specific |
831 (* Equations of the form "x = ..." or "... = x" or similar are too specific |
832 to be useful. Quantified formulas are also filtered out. As for "True", |
832 to be useful. Quantified formulas are also filtered out. As for "True", |
847 (@{const less_eq(nat)} $ @{const zero_class.zero(nat)} $ _)) => NONE |
847 (@{const less_eq(nat)} $ @{const zero_class.zero(nat)} $ _)) => NONE |
848 | @{const Trueprop} $ (@{const Not} $ |
848 | @{const Trueprop} $ (@{const Not} $ |
849 (@{const less_eq(nat)} $ @{const one_class.one(nat)} $ _)) => NONE |
849 (@{const less_eq(nat)} $ @{const one_class.one(nat)} $ _)) => NONE |
850 | @{const Trueprop} $ (Const (@{const_name All}, _) $ _) => NONE |
850 | @{const Trueprop} $ (Const (@{const_name All}, _) $ _) => NONE |
851 | @{const Trueprop} $ (Const (@{const_name Ex}, _) $ _) => NONE |
851 | @{const Trueprop} $ (Const (@{const_name Ex}, _) $ _) => NONE |
852 | _ => SOME (score t, t)) |
852 | _ => |
|
853 (* We require the presence of at least one free variable. A "missing |
|
854 assumption" that does not talk about any free variable is likely |
|
855 spurious. *) |
|
856 if exists_subterm (fn Free _ => true | _ => false) t then SOME (score t, t) |
|
857 else NONE) |
853 in |
858 in |
854 sort_top max_candidates (map_filter maybe_score candidates) |
859 sort_top max_candidates (map_filter maybe_score candidates) |
855 end |
860 end |
856 |
861 |
857 end; |
862 end; |