# HG changeset patch # User wenzelm # Date 1122916847 -7200 # Node ID 2ec0b8159e8e6bee0136c16f75c3db3849d5fb77 # Parent 38bb4f03a8877ec0397c5ac84ffaa8fbfa0ee81a tuned; diff -r 38bb4f03a887 -r 2ec0b8159e8e src/HOL/ex/NatSum.thy --- a/src/HOL/ex/NatSum.thy Mon Aug 01 19:20:46 2005 +0200 +++ b/src/HOL/ex/NatSum.thy Mon Aug 01 19:20:47 2005 +0200 @@ -1,4 +1,4 @@ -(* Title: HOL/ex/NatSum.ML +(* Title: HOL/ex/NatSum.thy ID: $Id$ Author: Tobias Nipkow *) @@ -10,9 +10,6 @@ text {* Summing natural numbers, squares, cubes, etc. - Originally demonstrated permutative rewriting, but @{thm [source] - add_ac} is no longer needed thanks to new simprocs. - Thanks to Sloane's On-Line Encyclopedia of Integer Sequences, \url{http://www.research.att.com/~njas/sequences/}. *} @@ -28,7 +25,7 @@ *} lemma sum_of_odds: "(\i=0..i=0..i=0..i=0..n. i) = n * Suc n" - by (induct n, auto) + by (induct n) auto lemma sum_of_squares: "6 * (\i=0..n. i * i) = n * Suc n * Suc (2 * n)" - by (induct n, auto) + by (induct n) auto lemma sum_of_cubes: "4 * (\i=0..n. i * i * i) = n * n * Suc n * Suc n" - by (induct n, auto) + by (induct n) auto text {* @@ -87,13 +84,13 @@ "30 * int (\i=0..i=0..i=0..i=0.. (k - 1) * (\i=0.. " ^ tmp_name); TextIO.openIn -tmp_name); + val is = (Process.system (command ^ " > " ^ tmp_name); TextIO.openIn tmp_name); val result = TextIO.inputAll is; in TextIO.closeIn is; diff -r 38bb4f03a887 -r 2ec0b8159e8e src/Pure/ML-Systems/polyml-time-limit.ML --- a/src/Pure/ML-Systems/polyml-time-limit.ML Mon Aug 01 19:20:46 2005 +0200 +++ b/src/Pure/ML-Systems/polyml-time-limit.ML Mon Aug 01 19:20:47 2005 +0200 @@ -6,29 +6,32 @@ Bounded time execution (similar to SML/NJ's TimeLimit structure) for Poly/ML. *) -structure TimeLimit : sig - exception TimeOut - val timeLimit : Time.time -> ('a -> 'b) -> 'a -> 'b -end = struct - - exception TimeOut +structure TimeLimit: +sig + exception TimeOut + val timeLimit : Time.time -> ('a -> 'b) -> 'a -> 'b +end = +struct + exception TimeOut - fun timeLimit t f x = - let - datatype ('a, 'b) union = - INL of 'a | INR of 'b - val result = Process.channel () - fun workerThread () = - Process.send (result, SOME (INL (f x) handle exn => INR exn)) - val interrupt = Process.console workerThread - val old_handle = Signal.signal (Posix.Signal.alrm, Signal.SIG_HANDLE - (fn _ => ((Process.send (result, NONE)) before (interrupt ())))) - in - Posix.Process.alarm t; - case Process.receive result of - SOME (INL fx) => (Posix.Process.alarm Time.zeroTime; Signal.signal (Posix.Signal.alrm, old_handle); fx) - | SOME (INR exn) => (Posix.Process.alarm Time.zeroTime; Signal.signal (Posix.Signal.alrm, old_handle); raise exn) - | NONE => (Signal.signal (Posix.Signal.alrm, old_handle); raise TimeOut) - end + fun timeLimit t f x = + let + datatype ('a, 'b) union = INL of 'a | INR of 'b + val result = Process.channel () + fun workerThread () = + Process.send (result, SOME (INL (f x) handle exn => INR exn)) + val interrupt = Process.console workerThread + val old_handle = Signal.signal (Posix.Signal.alrm, + Signal.SIG_HANDLE (fn _ => (Process.send (result, NONE)) before (interrupt ()))) + in + Posix.Process.alarm t; + case Process.receive result of + SOME (INL fx) => + (Posix.Process.alarm Time.zeroTime; Signal.signal (Posix.Signal.alrm, old_handle); fx) + | SOME (INR exn) => + (Posix.Process.alarm Time.zeroTime; Signal.signal (Posix.Signal.alrm, old_handle); + raise exn) + | NONE => (Signal.signal (Posix.Signal.alrm, old_handle); raise TimeOut) + end end;