991 fun check_expect outcome_code = |
991 fun check_expect outcome_code = |
992 if expect = "" orelse outcome_code = expect then outcome_code |
992 if expect = "" orelse outcome_code = expect then outcome_code |
993 else error ("Unexpected outcome: " ^ quote outcome_code ^ ".") |
993 else error ("Unexpected outcome: " ^ quote outcome_code ^ ".") |
994 fun wrapper () = |
994 fun wrapper () = |
995 let |
995 let |
996 val timer = Timer.startRealTimer () |
996 val time_start = Time.now () |
997 val t = |
997 val t = |
998 if no_assms then t |
998 if no_assms then t |
999 else if negate then Logic.list_implies (assm_ts, t) |
999 else if negate then Logic.list_implies (assm_ts, t) |
1000 else Logic.mk_conjunction_list (t :: assm_ts) |
1000 else Logic.mk_conjunction_list (t :: assm_ts) |
1001 val u = unfold_defs thy t |
1001 val u = unfold_defs thy t |
1027 if maybe_spurious andalso Context_Position.is_visible ctxt then |
1027 if maybe_spurious andalso Context_Position.is_visible ctxt then |
1028 warning "Term contains a recursive datatype; countermodel(s) may be spurious!" |
1028 warning "Term contains a recursive datatype; countermodel(s) may be spurious!" |
1029 else () |
1029 else () |
1030 fun find_model_loop universe = |
1030 fun find_model_loop universe = |
1031 let |
1031 let |
1032 val msecs_spent = Time.toMilliseconds (Timer.checkRealTimer timer) |
1032 val time_spent = Time.now () - time_start |
1033 val _ = maxtime = 0 orelse msecs_spent < 1000 * maxtime |
1033 val _ = maxtime = 0 orelse time_spent < Timeout.scale_time (Time.fromSeconds maxtime) |
1034 orelse raise Timeout.TIMEOUT (Time.fromMilliseconds msecs_spent) |
1034 orelse raise Timeout.TIMEOUT time_spent |
1035 val init_model = (universe, []) |
1035 val init_model = (universe, []) |
1036 val init_args = {maxvars = maxvars, def_eq = false, next_idx = 1, |
1036 val init_args = {maxvars = maxvars, def_eq = false, next_idx = 1, |
1037 bounds = [], wellformed = True} |
1037 bounds = [], wellformed = True} |
1038 val _ = tracing ("Translating term (sizes: " |
1038 val _ = tracing ("Translating term (sizes: " |
1039 ^ commas (map (fn (_, n) => string_of_int n) universe) ^ ") ...") |
1039 ^ commas (map (fn (_, n) => string_of_int n) universe) ^ ") ...") |
1112 error ("\"maxtime\" is " ^ string_of_int maxtime ^ ", must be at least 0"); |
1112 error ("\"maxtime\" is " ^ string_of_int maxtime ^ ", must be at least 0"); |
1113 (* enter loop with or without time limit *) |
1113 (* enter loop with or without time limit *) |
1114 writeln ("Trying to find a model that " |
1114 writeln ("Trying to find a model that " |
1115 ^ (if negate then "refutes" else "satisfies") ^ ": " |
1115 ^ (if negate then "refutes" else "satisfies") ^ ": " |
1116 ^ Syntax.string_of_term ctxt t); |
1116 ^ Syntax.string_of_term ctxt t); |
1117 if maxtime > 0 then ( |
1117 Timeout.apply (Time.fromSeconds maxtime) |
1118 Timeout.apply (Time.fromSeconds maxtime) |
1118 wrapper () |
1119 wrapper () |
1119 handle Timeout.TIMEOUT _ => |
1120 handle Timeout.TIMEOUT _ => |
1120 (writeln ("Search terminated, time limit (" ^ |
1121 (writeln ("Search terminated, time limit (" ^ |
1121 string_of_int maxtime |
1122 string_of_int maxtime |
1122 ^ (if maxtime=1 then " second" else " seconds") ^ ") exceeded."); |
1123 ^ (if maxtime=1 then " second" else " seconds") ^ ") exceeded."); |
1123 check_expect "unknown") |
1124 check_expect "unknown") |
|
1125 ) else wrapper () |
|
1126 end; |
1124 end; |
1127 |
1125 |
1128 |
1126 |
1129 (* ------------------------------------------------------------------------- *) |
1127 (* ------------------------------------------------------------------------- *) |
1130 (* INTERFACE, PART 2: FINDING A MODEL *) |
1128 (* INTERFACE, PART 2: FINDING A MODEL *) |