src/Pure/IsaPlanner/isaplib.ML
author wenzelm
Tue, 14 Jun 2005 22:08:53 +0200
changeset 16392 7212040b71f2
parent 16179 fa7e70be26b0
child 17796 86daafee72d6
permissions -rw-r--r--
discontinued polyml-3.x; made cygwin functionality less intrusive; more quoting of expressions;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
     1
(* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *) 
16179
fa7e70be26b0 header;
wenzelm
parents: 16004
diff changeset
     2
(*  Title:      Pure/IsaPlanner/isaplib.ML
fa7e70be26b0 header;
wenzelm
parents: 16004
diff changeset
     3
    ID:		$Id$
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
     4
    Author:     Lucas Dixon, University of Edinburgh
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
     5
                lucasd@dai.ed.ac.uk
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
     6
*)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
     7
(* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *) 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
     8
(*  DESCRIPTION:
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
     9
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    10
    A few useful system-independent utilities.
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    11
*)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    12
(* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- *) 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    13
signature ISAP_LIB =
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    14
sig
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    15
  (* ints *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    16
  val max : int * int -> int
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    17
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    18
  (* seq operations *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    19
  val ALL_BUT_LAST : ('a -> 'b Seq.seq) -> 'a -> 'b Seq.seq
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    20
  val FST : ('a -> 'b Seq.seq) -> 'a -> 'b Seq.seq
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    21
  val NTH : int -> ('a -> 'b Seq.seq) -> 'a -> 'b Seq.seq
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    22
  val all_but_last_of_seq : 'a Seq.seq -> 'a Seq.seq
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    23
  val nat_seq : int Seq.seq
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    24
  val nth_of_seq : int -> 'a Seq.seq -> 'a option
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    25
  val pair_seq : 'a Seq.seq -> 'b Seq.seq -> ('a * 'b) Seq.seq
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    26
  val seq_is_empty : 'a Seq.seq -> bool
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    27
  val number_seq : 'a Seq.seq -> (int * 'a) Seq.seq
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    28
16004
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
    29
  datatype 'a skipseqT = 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
    30
           skipmore of int
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
    31
         | skipseq of 'a Seq.seq Seq.seq;
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
    32
  val skipto_seqseq : int -> 'a Seq.seq Seq.seq -> 'a skipseqT
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
    33
  val seqflat_seq : 'a Seq.seq Seq.seq -> 'a Seq.seq 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
    34
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    35
  (* lists *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    36
  val mk_num_list : int -> int list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    37
  val number_list : int -> 'a list -> (int * 'a) list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    38
  val repeated_list : int -> 'a -> 'a list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    39
  val all_pairs : 'a list -> 'b list -> ('a * 'b) list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    40
	val get_ends_of : ('a * 'a -> bool) ->
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    41
										('a * 'a) -> 'a list -> ('a * 'a)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    42
  val flatmap : ('a -> 'b list) -> 'a list -> 'b list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    43
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    44
	val lrem : ('a * 'b -> bool) -> 'a list -> 'b list -> 'b list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    45
  val forall_list : ('a -> bool) -> 'a list -> bool
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    46
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    47
  (* the list of lists with one of each of the original sublists *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    48
  val one_of_each : 'a list list -> 'a list list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    49
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    50
  (* type changing *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    51
  exception NOT_A_DIGIT of string
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    52
  val int_of_string : string -> int
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    53
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    54
  (* string manipulations *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    55
  val remove_end_spaces : string -> string
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    56
  val str_indent : string -> string
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    57
  val string_of_intlist : int list -> string
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    58
  val string_of_list : ('a -> string) -> 'a list -> string
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    59
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    60
  (* options *)
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    61
  val aptosome : 'a option -> ('a -> 'b) -> 'b option
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    62
  val seq_mapfilter : ('a -> 'b option) -> 'a Seq.seq -> 'b Seq.seq
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    63
  val seq_map_to_some_filter : ('a -> 'b) -> 'a option Seq.seq 
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    64
                               -> 'b Seq.seq
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    65
end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    66
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    67
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    68
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    69
structure IsaPLib :> ISAP_LIB = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    70
struct
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    71
 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    72
(* Int *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    73
fun max (x,y) = if x > y then x else y;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    74
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    75
(* Seq *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    76
fun seq_map_to_some_filter f s0 =
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    77
    let 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    78
      fun recf s () = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    79
          case (Seq.pull s) of 
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    80
            NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    81
          | SOME (NONE,s') => recf s' ()
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    82
          | SOME (SOME d, s') => 
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    83
            SOME (f d, Seq.make (recf s'))
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    84
    in Seq.make (recf s0) end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    85
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    86
fun seq_mapfilter f s0 =
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    87
    let 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    88
      fun recf s () = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    89
          case (Seq.pull s) of 
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    90
            NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    91
          | SOME (a,s') => 
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    92
            (case f a of NONE => recf s' ()
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
    93
                       | SOME b => SOME (b, Seq.make (recf s')))
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    94
    in Seq.make (recf s0) end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    95
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    96
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    97
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    98
(* a simple function to pair with each element of a list, a number *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
    99
fun number_list i [] = []
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   100
	| number_list i (h::t) = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   101
		(i,h)::(number_list (i+1) t)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   102
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   103
(* check to see if a sequence is empty *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   104
fun seq_is_empty s = is_none (Seq.pull s);
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   105
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   106
(* the sequence of natural numbers *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   107
val nat_seq = 
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   108
      let fun nseq i () = SOME (i, Seq.make (nseq (i+1)))
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   109
      in Seq.make (nseq 1)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   110
      end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   111
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   112
(* create a sequence of pairs of the elements of the two sequences
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   113
   If one sequence becomes empty, then so does the pairing of them. 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   114
   
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   115
   This is particularly useful if you wish to perform counting or
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   116
   other repeated operations on a sequence and you want to combvine
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   117
   this infinite sequence with a possibly finite one.
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   118
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   119
   behaviour: 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   120
   s1: a1, a2, ... an
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   121
   s2: b1, b2, ... bn ...
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   122
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   123
   pair_seq s1 s2: (a1,b1), (a2,b2), ... (an,bn)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   124
*)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   125
fun pair_seq seq1 seq2 = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   126
    let
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   127
      fun pseq s1 s2 () = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   128
	        case Seq.pull s1 of 
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   129
	          NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   130
	        | SOME (s1h, s1t) => 
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   131
	          case Seq.pull s2 of 
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   132
		          NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   133
	          | SOME (s2h, s2t) =>
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   134
		          SOME ((s1h, s2h), Seq.make (pseq s1t s2t))
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   135
    in
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   136
      Seq.make (pseq seq1 seq2)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   137
    end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   138
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   139
(* number a sequence *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   140
fun number_seq s = pair_seq nat_seq s;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   141
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   142
(* cuts off the last element of a sequence *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   143
fun all_but_last_of_seq s = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   144
    let 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   145
      fun f () = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   146
	  case Seq.pull s of
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   147
	    NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   148
	  | SOME (a, s2) => 
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   149
	    (case Seq.pull s2 of 
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   150
	       NONE => NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   151
	     | SOME (a2,s3) => 
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   152
	       SOME (a, all_but_last_of_seq (Seq.cons (a2,s3))))
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   153
    in
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   154
      Seq.make f
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   155
    end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   156
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   157
 fun ALL_BUT_LAST r st = all_but_last_of_seq (r st);
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   158
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   159
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   160
  (* nth elem for sequenes, return none if out of bounds *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   161
  fun nth_of_seq i l = 
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   162
           if (seq_is_empty l) then NONE 
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   163
           else if i <= 1 then SOME (Seq.hd l)
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   164
           else nth_of_seq (i-1) (Seq.tl l);
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   165
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   166
  (* for use with tactics... gives no_tac if element isn't there *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   167
  fun NTH n f st = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   168
      let val r = nth_of_seq n (f st) in 
15570
8d8c70b41bab Move towards standard functions.
skalberg
parents: 15531
diff changeset
   169
        if (is_none r) then Seq.empty else (Seq.single (valOf r))
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   170
      end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   171
 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   172
  (* First result of a tactic... uses NTH, so if there is no elements,
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   173
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   174
     then no_tac is returned. *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   175
  fun FST f = NTH 1 f;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   176
16004
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   177
datatype 'a skipseqT = skipmore of int
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   178
  | skipseq of 'a Seq.seq Seq.seq;
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   179
(* given a seqseq, skip the first m non-empty seq's *)
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   180
fun skipto_seqseq m s = 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   181
    let 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   182
      fun skip_occs n sq = 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   183
          case Seq.pull sq of 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   184
            NONE => skipmore n
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   185
          | SOME (h,t) => 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   186
            (case Seq.pull h of NONE => skip_occs n t
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   187
             | SOME _ => if n <= 1 then skipseq (Seq.cons (h, t))
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   188
                         else skip_occs (n - 1) t)
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   189
    in (skip_occs m s) end;
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   190
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   191
(* handy function for re-arranging Sequence operations *)
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   192
(* [[a,b,c],[d,e],...] => flatten [[a,d,...], [b,e,...], [c, ...]] *)
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   193
fun seqflat_seq ss = 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   194
    let 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   195
      fun pulltl LL () = 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   196
          (case Seq.pull LL of 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   197
             NONE => NONE
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   198
           | SOME (hL,tLL) => 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   199
             (case Seq.pull hL of 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   200
                NONE => pulltl tLL ()
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   201
              | SOME (h,tL) => 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   202
                SOME (h, Seq.make (recf (tLL, (Seq.single tL))))))
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   203
      and recf (fstLL,sndLL) () = 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   204
          (case Seq.pull fstLL of 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   205
             NONE => pulltl sndLL ()
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   206
           | SOME (hL, tLL) => 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   207
             (case Seq.pull hL of 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   208
                NONE => recf (tLL, sndLL) ()
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   209
              | SOME (h,tL) => 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   210
                SOME (h, Seq.make (recf (tLL, Seq.append (sndLL, Seq.single tL))))))
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   211
    in Seq.make (pulltl ss) end;
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   212
(* tested with: 
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   213
val ss = Seq.of_list [Seq.of_list [1,2,3], Seq.of_list [4,5], Seq.of_list [7,8,9,10]];
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   214
Seq.list_of (seqflat_seq ss);
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   215
val it = [1, 4, 7, 2, 5, 8, 3, 9, 10] : int list
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   216
*)
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   217
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   218
031f56012483 lucas - fixed subst in assumptions to count redexes from left to right.
dixon
parents: 15570
diff changeset
   219
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   220
  (* create a list opf the form (n, n-1, n-2, ... ) *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   221
  fun mk_num_list n =  
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   222
      if n < 1 then [] else (n :: (mk_num_list (n-1))); 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   223
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   224
  fun repeated_list n a =  
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   225
      if n < 1 then [] else (a :: (repeated_list (n-1) a)); 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   226
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   227
  (* create all possible pairs with fst element from the first list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   228
     and snd element from teh second list *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   229
  fun all_pairs xs ys = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   230
      let 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   231
        fun all_pairs_aux yss [] _ acc = acc
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   232
          | all_pairs_aux yss (x::xs) [] acc = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   233
            all_pairs_aux yss xs yss acc
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   234
          | all_pairs_aux yss (xs as (x1::x1s)) (y::ys) acc = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   235
                               all_pairs_aux yss xs ys ((x1,y)::acc)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   236
      in
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   237
        all_pairs_aux ys xs ys []
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   238
      end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   239
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   240
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   241
  (* create all possible pairs with fst element from the first list
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   242
     and snd element from teh second list *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   243
  (* FIXME: make tail recursive and quick *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   244
  fun one_of_each [] = []
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   245
    | one_of_each [[]] = []
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   246
    | one_of_each [(h::t)] = [h] :: (one_of_each [t])
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   247
    | one_of_each ([] :: xs) = []
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   248
    | one_of_each ((h :: t) :: xs) = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   249
      (map (fn z => h :: z) (one_of_each xs)) 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   250
      @ (one_of_each (t :: xs));
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   251
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   252
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   253
(* function to get the upper/lower bounds of a list 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   254
given: 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   255
gr : 'a * 'a -> bool  = greater than check
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   256
e as (u,l) : ('a * 'a) = upper and lower bits
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   257
l : 'a list = the list to get the upper and lower bounds of
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   258
returns a pair ('a * 'a) of the biggest and lowest value w.r.t "gr"
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   259
*)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   260
fun get_ends_of gr (e as (u,l)) [] = e
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   261
  | get_ends_of gr (e as (u,l)) (h :: t) = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   262
    if gr(h,u) then get_ends_of gr (h,l) t
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   263
    else if gr(l,h) then get_ends_of gr (u,h) t
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   264
    else get_ends_of gr (u,l) t;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   265
15570
8d8c70b41bab Move towards standard functions.
skalberg
parents: 15531
diff changeset
   266
fun flatmap f = List.concat o map f;
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   267
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   268
  (* quick removal of "rs" elements from "ls" when (eqf (r,l)) is true 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   269
		 Ignores ordering. *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   270
  fun lrem eqf rs ls = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   271
			let fun list_remove rs ([],[]) = []
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   272
						| list_remove [] (xs,_) = xs
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   273
						| list_remove (r::rs) ([],leftovers) = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   274
							list_remove rs (leftovers,[])
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   275
						| list_remove (r1::rs) ((x::xs),leftovers) = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   276
							if eqf (r1, x) then list_remove (r1::rs) (xs,leftovers)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   277
							else list_remove (r1::rs) (xs, x::leftovers)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   278
			in
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   279
				list_remove rs (ls,[])
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   280
			end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   281
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   282
fun forall_list f [] = true
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   283
  | forall_list f (a::t) = f a orelse forall_list f t;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   284
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   285
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   286
  (* crappy string indeter *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   287
  fun str_indent s = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   288
    implode (map (fn s => if s = "\n" then "\n  " else s) (explode s));
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   289
      
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   290
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   291
  fun remove_end_spaces s = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   292
      let 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   293
				fun rem_starts [] = [] 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   294
					| rem_starts (" " :: t) = rem_starts t
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   295
					| rem_starts ("\t" :: t) = rem_starts t
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   296
					| rem_starts ("\n" :: t) = rem_starts t
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   297
					| rem_starts l = l
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   298
				fun rem_ends l = rev (rem_starts (rev l))
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   299
      in
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   300
				implode (rem_ends (rem_starts (explode s)))
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   301
      end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   302
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   303
(* convert a string to an integer *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   304
  exception NOT_A_DIGIT of string;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   305
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   306
  fun int_of_string s = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   307
      let 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   308
				fun digits_to_int [] x = x
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   309
					| digits_to_int (h :: t) x = digits_to_int t (x * 10 + h);
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   310
	
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   311
				fun char_to_digit c = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   312
						case c of 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   313
							"0" => 0
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   314
						| "1" => 1
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   315
						| "2" => 2
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   316
						| "3" => 3
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   317
						| "4" => 4
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   318
						| "5" => 5
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   319
						| "6" => 6
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   320
						| "7" => 7
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   321
						| "8" => 8
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   322
						| "9" => 9
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   323
						| _ => raise NOT_A_DIGIT c
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   324
      in
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   325
				digits_to_int (map char_to_digit (explode (remove_end_spaces s))) 0
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   326
      end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   327
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   328
  (* Debugging/printing code for this datatype *)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   329
  fun string_of_list f l = 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   330
      let 
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   331
				fun auxf [] = ""
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   332
					| auxf [a] = (f a)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   333
					| auxf (h :: (t as (h2 :: t2))) = (f h) ^ ", " ^ (auxf t)
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   334
      in
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   335
				"[" ^ (auxf l) ^ "]"
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   336
      end;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   337
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   338
   val string_of_intlist = string_of_list string_of_int;
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   339
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   340
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   341
  (* options *)
15531
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   342
  fun aptosome NONE f = NONE
08c8dad8e399 Deleted Library.option type.
skalberg
parents: 15481
diff changeset
   343
    | aptosome (SOME x) f = SOME (f x);
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   344
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents:
diff changeset
   345
end;