src/Provers/IsaPlanner/zipper.ML
changeset 19975 ecd684d62808
parent 19902 9e5d0df75c98
child 21145 87a03f9b7db2
equal deleted inserted replaced
19974:642b16a049db 19975:ecd684d62808
    89 sig
    89 sig
    90   structure C : TRM_CTXT
    90   structure C : TRM_CTXT
    91   type T
    91   type T
    92 
    92 
    93   val mktop : C.D.Trm.T -> T
    93   val mktop : C.D.Trm.T -> T
    94   val goto_top : T -> T
    94   val mk : (C.D.Trm.T * C.T) -> T
       
    95 
       
    96   val goto_top : T -> T 
    95   val at_top : T -> bool
    97   val at_top : T -> bool
    96   val mk : (C.D.Trm.T * C.T) -> T
    98 
       
    99   val split : T -> T * C.T
       
   100   val add_outerctxt : C.T -> T -> T
       
   101 
    97   val set_trm : C.D.Trm.T -> T -> T
   102   val set_trm : C.D.Trm.T -> T -> T
    98   val set_ctxt : C.T -> T -> T
   103   val set_ctxt : C.T -> T -> T
    99 
   104 
   100   val split : T -> T * C.T
       
   101   val add_outerctxt : C.T -> T -> T
       
   102 
       
   103   val ctxt : T -> C.T
   105   val ctxt : T -> C.T
   104   val trm : T -> C.D.Trm.T
   106   val trm : T -> C.D.Trm.T
       
   107   val top_trm : T -> C.D.Trm.T
       
   108 
       
   109   val zipto : C.T -> T -> T (* follow context down *)
   105 
   110 
   106   val nty_ctxt : T -> (C.D.Trm.aname * C.D.Trm.typ) list;
   111   val nty_ctxt : T -> (C.D.Trm.aname * C.D.Trm.typ) list;
   107   val ty_ctxt : T -> C.D.Trm.typ list;
   112   val ty_ctxt : T -> C.D.Trm.typ list;
   108 
   113 
   109   val depth_of_ctxt : T -> int;
   114   val depth_of_ctxt : T -> int;
   252   fun split (t,c) = ((t,C.empty) : T, c : C.T) 
   257   fun split (t,c) = ((t,C.empty) : T, c : C.T) 
   253   fun add_outerctxt c (t,c2) = (t, C.add_outerctxt c c2) : T
   258   fun add_outerctxt c (t,c2) = (t, C.add_outerctxt c c2) : T
   254 
   259 
   255   val ctxt = snd;
   260   val ctxt = snd;
   256   val trm = fst;
   261   val trm = fst;
       
   262   val top_trm = trm o goto_top;
   257 
   263 
   258   fun nty_ctxt x = C.nty_ctxt (ctxt x);
   264   fun nty_ctxt x = C.nty_ctxt (ctxt x);
   259   fun ty_ctxt x = C.ty_ctxt (ctxt x);
   265   fun ty_ctxt x = C.ty_ctxt (ctxt x);
   260 
   266 
   261   fun depth_of_ctxt x = C.depth (ctxt x);
   267   fun depth_of_ctxt x = C.depth (ctxt x);
   319     | move_down_right z = raise move ("move_down_right",z);
   325     | move_down_right z = raise move ("move_down_right",z);
   320   fun move_down_app (Trm.$(l,r),c) = 
   326   fun move_down_app (Trm.$(l,r),c) = 
   321       ((l,(D.AppR r)::c),(r,(D.AppL l)::c))
   327       ((l,(D.AppR r)::c),(r,(D.AppL l)::c))
   322     | move_down_app z = raise move ("move_down_app",z);
   328     | move_down_app z = raise move ("move_down_app",z);
   323 
   329 
       
   330   (* follow the given path down the given zipper *)
       
   331   (* implicit arguments: C.D.dtrm list, then T *)
       
   332   val zipto = 
       
   333       C.fold (fn C.D.Abs _ => move_down_abs 
       
   334                | C.D.AppL _ => move_down_left
       
   335                | C.D.AppR _ => move_down_right) 
   324 
   336 
   325   (* Note: interpretted as being examined depth first *)
   337   (* Note: interpretted as being examined depth first *)
   326   datatype zsearch = Here of T | LookIn of T;
   338   datatype zsearch = Here of T | LookIn of T;
   327 
   339 
       
   340   (* lazy search *)
   328   fun lzy_search fsearch = 
   341   fun lzy_search fsearch = 
   329       let 
   342       let 
   330         fun lzyl [] () = NONE
   343         fun lzyl [] () = NONE
   331           | lzyl ((Here z) :: more) () = SOME(z, Seq.make (lzyl more))
   344           | lzyl ((Here z) :: more) () = SOME(z, Seq.make (lzyl more))
   332           | lzyl ((LookIn z) :: more) () =
   345           | lzyl ((LookIn z) :: more) () =