src/Pure/search.ML
changeset 22360 26ead7ed4f4b
parent 22025 7c5896919eb8
child 23178 07ba6b58b3d2
equal deleted inserted replaced
22359:94a794672c8b 22360:26ead7ed4f4b
    62      fun depth used [] = NONE
    62      fun depth used [] = NONE
    63        | depth used (q::qs) =
    63        | depth used (q::qs) =
    64 	  case Seq.pull q of
    64 	  case Seq.pull q of
    65 	      NONE         => depth used qs
    65 	      NONE         => depth used qs
    66 	    | SOME(st,stq) => 
    66 	    | SOME(st,stq) => 
    67 		if satp st andalso not (member eq_thm used st)
    67 		if satp st andalso not (member Thm.eq_thm used st)
    68 		then SOME(st, Seq.make
    68 		then SOME(st, Seq.make
    69 			         (fn()=> depth (st::used) (stq::qs)))
    69 			         (fn()=> depth (st::used) (stq::qs)))
    70 		else depth used (tac st :: stq :: qs)
    70 		else depth used (tac st :: stq :: qs)
    71   in  traced_tac (fn st => depth [] [Seq.single st])  end;
    71   in  traced_tac (fn st => depth [] [Seq.single st])  end;
    72 
    72 
   209   | some_of_list (x::l) = SOME (x, Seq.make (fn () => some_of_list l));
   209   | some_of_list (x::l) = SOME (x, Seq.make (fn () => some_of_list l));
   210 
   210 
   211 (*Check for and delete duplicate proof states*)
   211 (*Check for and delete duplicate proof states*)
   212 fun deleteAllMin prf heap = 
   212 fun deleteAllMin prf heap = 
   213       if ThmHeap.is_empty heap then heap
   213       if ThmHeap.is_empty heap then heap
   214       else if eq_thm (prf, #2 (ThmHeap.min heap))
   214       else if Thm.eq_thm (prf, #2 (ThmHeap.min heap))
   215       then deleteAllMin prf (ThmHeap.delete_min heap)
   215       then deleteAllMin prf (ThmHeap.delete_min heap)
   216       else heap;
   216       else heap;
   217 
   217 
   218 (*Best-first search for a state that satisfies satp (incl initial state)
   218 (*Best-first search for a state that satisfies satp (incl initial state)
   219   Function sizef estimates size of problem remaining (smaller means better).
   219   Function sizef estimates size of problem remaining (smaller means better).
   267 
   267 
   268 (*Insertion into priority queue of states, marked with level *)
   268 (*Insertion into priority queue of states, marked with level *)
   269 fun insert_with_level (lnth: int*int*thm, []) = [lnth]
   269 fun insert_with_level (lnth: int*int*thm, []) = [lnth]
   270   | insert_with_level ((l,m,th), (l',n,th')::nths) = 
   270   | insert_with_level ((l,m,th), (l',n,th')::nths) = 
   271       if  n<m then (l',n,th') :: insert_with_level ((l,m,th), nths)
   271       if  n<m then (l',n,th') :: insert_with_level ((l,m,th), nths)
   272       else if  n=m andalso eq_thm(th,th')
   272       else if  n=m andalso Thm.eq_thm(th,th')
   273               then (l',n,th')::nths
   273               then (l',n,th')::nths
   274               else (l,m,th)::(l',n,th')::nths;
   274               else (l,m,th)::(l',n,th')::nths;
   275 
   275 
   276 (*For creating output sequence*)
   276 (*For creating output sequence*)
   277 fun some_of_list []     = NONE
   277 fun some_of_list []     = NONE