src/Tools/isac/Specify/refine.sml
author wneuper <Walther.Neuper@jku.at>
Wed, 11 Jan 2023 11:38:01 +0100
changeset 60650 06ec8abfd3bc
parent 60590 35846e25713e
child 60653 fff1c0f0a9e7
permissions -rw-r--r--
eliminate use of Thy_Info 12: TermC partially
walther@59960
     1
(* Title:  Specify/refine.sml
walther@59960
     2
   Author: Walther Neuper 110226
walther@59960
     3
   (c) due to copyright terms
walther@59960
     4
Walther@60555
     5
Refine a problem by a search for a \<open>ML_structure Model_Pattern\<close> 
Walther@60586
     6
better fitting the respective where_-condition.
Walther@60555
     7
Walther@60588
     8
The search on the tree got by @{term Know_Store.get_pbls} is costly such that 
Walther@60588
     9
\<open>ML_structure Know_Store\<close> holds terms in \<open>ML_structure Model_Pattern\<close>, where_-condition (and cas).
Walther@60586
    10
The terms are where_-compiled with the most general \<open>ML_type "'a"\<close> and the type is adapted
Walther@60555
    11
according to the type suggested by the current \<open>ML_structure Context\<close>.
Walther@60555
    12
Walther@60555
    13
Note: From the children of eb89f586b0b2 onwards the old functions (\<open>term TermC.typ_a2real\<close> etc)
Walther@60555
    14
are adapted for "adapt_to_type on the fly" until further clarification.
Walther@60556
    15
Walther@60556
    16
timing (from evaluating imports to use-cases.sml) for Test_Isac_Short
Walther@60556
    17
  before adapt_to_type: 01:05 sec:sec
Walther@60556
    18
  after  adapt_to_type: 
Walther@60556
    19
timing for test/../refine.sml --- equation with CalcTree [ = 6 / 5] for timing: ...
Walther@60556
    20
  before adapt_to_type: 1.5 sec
Walther@60556
    21
  after  adapt_to_type: 
Walther@60556
    22
timing for test/../refine.sml --- refine ad-hoc equation for timing: ...
Walther@60556
    23
  before adapt_to_type: 0.05 sec
Walther@60556
    24
  after  adapt_to_type: 
Walther@60556
    25
*)                          
walther@59960
    26
walther@59960
    27
signature REFINE_PROBLEM =
walther@59960
    28
sig
Walther@60556
    29
(**)
walther@59968
    30
  val problem: theory -> Problem.id -> I_Model.T -> (Problem.id * (I_Model.T * Pre_Conds.T)) option
walther@59968
    31
Walther@60556
    32
(**)
Walther@60559
    33
  val refine_ori : Proof.context -> O_Model.T -> Problem.id -> Problem.id option
Walther@60556
    34
(**)
Walther@60559
    35
  val refine_ori' : Proof.context -> O_Model.T -> Problem.id -> Problem.id
walther@59960
    36
wenzelm@60223
    37
\<^isac_test>\<open>
Walther@60575
    38
(*val test : Formalise.model -> Problem.id -> M_Match.T list*)
Walther@60556
    39
(*val refine : Formalise.model -> Problem.id -> M_Match.T list*)
Walther@60575
    40
  val xxxxx: Proof.context -> Formalise.model -> Problem.id -> M_Match.T list
Walther@60556
    41
(**)
walther@60021
    42
  datatype match_ = Match_ of Problem.id * (( I_Model.T) * (Pre_Conds.T)) | NoMatch_;
Walther@60556
    43
(**)
walther@60021
    44
  val refined_: match_ list -> match_ option
Walther@60556
    45
(**)
Walther@60556
    46
  val refin'': theory -> Problem.id -> I_Model.T -> match_ list -> Problem.T Store.node -> match_ list
Walther@60556
    47
(**)
Walther@60556
    48
  val refins'': theory -> Problem.id -> I_Model.T -> match_ list -> Problem.T Store.node list -> match_ list
Walther@60556
    49
(**)
Walther@60556
    50
(*val refin: Problem.id -> O_Model.T -> Problem.T Store.node -> Problem.id option*)
Walther@60559
    51
  val refin: Proof.context -> Problem.id -> O_Model.T -> Problem.T Store.node -> Problem.id option
wenzelm@60223
    52
\<close>
walther@59960
    53
end
walther@59960
    54
walther@59965
    55
(**)
walther@59960
    56
structure Refine(**) : REFINE_PROBLEM(**) =
walther@59960
    57
struct
walther@59965
    58
(**)
walther@59960
    59
walther@59960
    60
datatype match_ = 
walther@59963
    61
  Match_ of Problem.id * (( I_Model.T) * (Pre_Conds.T))
walther@59960
    62
| NoMatch_;
walther@59960
    63
walther@59960
    64
fun is_matches_ (Match_ _) = true
walther@59960
    65
  | is_matches_ _ = false;
walther@59960
    66
walther@59960
    67
fun refined_ ms = ((find_first is_matches_) o rev) ms;
walther@59960
    68
walther@59960
    69
fun eq1 d (_, (d', _)) = (d = d');
walther@59960
    70
Walther@60478
    71
(*  chk_: theory -> ('a * (term * term)) list -> I_Model.single -> I_Model.single*)
walther@59960
    72
fun chk_ (_: theory) pbt (i, vats, b, f, I_Model.Cor ((d, vs), _)) =
walther@59960
    73
      (case find_first (eq1 d) pbt of 
Walther@60478
    74
        SOME (_, (_, id)) => (i, vats, b, f, I_Model.Cor ((d, vs), (id, [Input_Descript.join'''' (d, vs)])))
walther@59960
    75
      | NONE =>  (i, vats, false, f, I_Model.Sup (d, vs)))
walther@59960
    76
  | chk_ _ pbt (i, vats, b, f, I_Model.Inc ((d, vs), _)) =
walther@59960
    77
      (case find_first (eq1 d) pbt of 
Walther@60478
    78
        SOME (_, (_, id)) => (i, vats, b, f, I_Model.Cor ((d, vs), (id, [Input_Descript.join'''' (d, vs)])))
walther@59960
    79
      | NONE => (i, vats, false, f, I_Model.Sup (d, vs)))
walther@59960
    80
  | chk_ _ _ (itm as (_, _, _, _, I_Model.Syn _)) = itm
walther@59960
    81
  | chk_ _ _ (itm as (_, _, _, _, I_Model.Typ _)) = itm
walther@59960
    82
  | chk_ _ pbt (i, vats, b, f, I_Model.Sup (d, vs)) =
walther@59960
    83
      (case find_first (eq1 d) pbt of 
Walther@60478
    84
        SOME (_, (_, id)) => (i, vats, b, f, I_Model.Cor ((d,vs), (id, [Input_Descript.join'''' (d, vs)])))
walther@59960
    85
      | NONE => (i, vats, false, f, I_Model.Sup (d, vs)))
walther@59960
    86
  | chk_ _ pbt (i, vats, _, f, I_Model.Mis (d, vs)) =
walther@59960
    87
      (case find_first (eq1 d) pbt of
Walther@60478
    88
        SOME _ =>
Walther@60478
    89
          raise ERROR "chk_: ((i,vats,b,f,I_Model.Cor ((d,vs),(id, Input_Descript.join'''' d vs))):itm)"
walther@59960
    90
      | NONE => (i, vats, false, f, I_Model.Sup (d, [vs])))
walther@59960
    91
  | chk_ _ _ _ = raise ERROR "chk_: uncovered fun def.";
walther@59960
    92
Walther@60477
    93
fun eq2 (_, (d, _)) (_, _, _, _, itm_) = d = I_Model.descriptor itm_;
walther@59960
    94
fun eq0 (0, _, _, _, _) = true
walther@59960
    95
  | eq0 _ = false;
walther@59960
    96
fun max_i i [] = i
walther@59960
    97
  | max_i i ((id, _, _, _, _) :: is) = if i > id then max_i i is else max_i id is;
walther@59960
    98
fun max_id [] = 0
walther@59960
    99
  | max_id ((id, _, _, _, _) :: is) = max_i id is;
walther@59960
   100
fun add_idvat itms _ _ [] = itms
walther@59960
   101
  | add_idvat itms i mvat ((_, _, b, f, itm_) :: its) =
walther@59960
   102
    add_idvat (itms @ [(i, [], b, f, itm_)]) (i + 1) mvat its;
walther@59960
   103
walther@59960
   104
(* find elements of pbt not contained in itms;
walther@59960
   105
   if such one is untouched, return this one, otherwise create new itm *)
walther@59960
   106
fun chk_m itms untouched (p as (f, (d, id))) = 
walther@59960
   107
  case find_first (eq2 p) itms of
walther@59960
   108
	  SOME _ => []
walther@59960
   109
  | NONE =>
walther@59960
   110
      (case find_first (eq2 p) untouched of
walther@59960
   111
        SOME itm => [itm]
walther@59960
   112
      | NONE => [(0, [], false, f, I_Model.Mis (d, id))]);
walther@59960
   113
walther@59960
   114
fun chk_mis mvat itms untouched pbt = 
walther@59960
   115
    let val mis = (flat o (map (chk_m itms untouched))) pbt; 
walther@59960
   116
        val mid = max_id itms;
walther@59960
   117
    in add_idvat [] (mid + 1) mvat mis end;
walther@59960
   118
walther@59960
   119
(* check a problem (ie. itm list) for matching a problemtype, 
Walther@60477
   120
   takes the I_Model.max_variant for concluding completeness (could be another!) *)
Walther@60586
   121
fun match_itms thy itms (pbt, where_, where_rls) = 
walther@59960
   122
  let
walther@59960
   123
    fun okv mvat (_, vats, b, _, _) = member op = vats mvat andalso b;
walther@59960
   124
    val itms' = map (chk_ thy pbt) itms; (* all found are #3 true *)
Walther@60477
   125
    val mvat = I_Model.max_variant itms';
walther@59960
   126
	  val itms'' = filter (okv mvat) itms';
walther@59960
   127
	  val untouched = filter eq0 itms; (* i.e. dsc only (from init)*)
walther@59960
   128
	  val mis = chk_mis mvat itms'' untouched pbt;
Walther@60590
   129
	  val (pb, where_')  = Pre_Conds.check (Proof_Context.init_global thy) where_rls where_ itms'' mvat
Walther@60586
   130
  in (length mis = 0 andalso pb, (itms'@ mis, where_')) end;
walther@59960
   131
walther@59960
   132
(* refine a problem; version for tactic Refine_Problem *)
walther@59960
   133
fun refin'' _ (pblRD: Problem.id) itms pbls (Store.Node (pI, [py], [])) =
walther@59960
   134
    let
Walther@60585
   135
	    val {thy, model, where_, where_rls, ...} = py
Walther@60556
   136
	    (*TODO val where_ = map TermC.adapt_to_type where_ ...  adapt to current ctxt*)
Walther@60586
   137
	    val (b, (itms', where_')) = match_itms thy itms (model, where_, where_rls);
walther@59960
   138
    in
walther@59960
   139
      if b
Walther@60586
   140
      then pbls @ [Match_ (rev (pblRD @ [pI]), (itms', where_'))]
walther@59960
   141
      else pbls @ [NoMatch_] 
walther@59960
   142
    end
walther@59960
   143
  | refin'' _ pblRD itms pbls (Store.Node (pI, [py], pys)) =
walther@59960
   144
    let
Walther@60585
   145
      val {thy, model, where_, where_rls, ...} = py 
Walther@60586
   146
      val (b, (itms', where_')) = match_itms thy itms (model, where_, where_rls);
walther@59960
   147
    in if b 
Walther@60586
   148
       then let val pbl = Match_ (rev (pblRD @ [pI]), (itms', where_'))
walther@59960
   149
	    in refins'' thy (pblRD @ [pI]) itms (pbls @ [pbl]) pys end
walther@59960
   150
       else (pbls @ [NoMatch_])
Walther@60556
   151
    end              
walther@59965
   152
  | refin'' _ _ _ _ _ = raise ERROR "refin'': uncovered fun def."
walther@59960
   153
and refins'' _ _ _ pbls [] = pbls
walther@59960
   154
  | refins'' thy pblRD itms pbls ((p as Store.Node _) :: pts) =
walther@59960
   155
    let
walther@59960
   156
      val pbls' = refin'' thy pblRD itms pbls p
walther@59960
   157
    in case last_elem pbls' of
walther@59960
   158
      Match_ _ => pbls'
walther@59960
   159
    | NoMatch_ => refins'' thy pblRD itms pbls' pts
walther@59960
   160
  end;
walther@59960
   161
walther@59960
   162
fun problem thy pblID itms =
Walther@60495
   163
  case refined_ ((Store.apply (get_pbls ())) (refin'' thy ((rev o tl) pblID) itms [])
walther@60324
   164
      pblID (rev pblID)) of
walther@59960
   165
	  NONE => NONE
Walther@60556
   166
  | SOME (Match_ (rfd as (pI', _))) => if pblID = pI' then NONE else SOME rfd;
walther@59960
   167
Walther@60556
   168
(* 
Walther@60556
   169
  refine a problem; construct pblRD while scanning 
Walther@60556
   170
  val refin: Problem.id -> O_Model.T -> Problem.T Store.node -> Problem.id option
Walther@60556
   171
*)
Walther@60556
   172
(** )
walther@59968
   173
fun refin pblRD ori (Store.Node (pI, [py], [])) =
Walther@60585
   174
    if M_Match.match_oris (#thy py) (#where_rls py) ori (#model py, #where_ py) 
walther@59968
   175
    then SOME (pblRD @ [pI])
walther@59968
   176
    else NONE
walther@59968
   177
  | refin pblRD ori (Store.Node (pI, [py], pys)) =
Walther@60585
   178
    if M_Match.match_oris (#thy py) (#where_rls py) ori (#model py, #where_ py) 
walther@59968
   179
    then (case refins (pblRD @ [pI]) ori pys of
walther@59968
   180
	      SOME pblRD' => SOME pblRD'
walther@59968
   181
	    | NONE => SOME (pblRD @ [pI]))
walther@59968
   182
    else NONE
walther@59968
   183
  | refin _ _ _ = raise ERROR "refin: uncovered fun def."
walther@59968
   184
and refins _ _ [] = NONE
walther@59968
   185
  | refins pblRD ori ((p as Store.Node _) :: pts) =
walther@59968
   186
    (case refin pblRD ori p of
walther@59968
   187
      SOME pblRD' => SOME pblRD'
walther@59968
   188
    | NONE => refins pblRD ori pts);
Walther@60556
   189
( ** )TODO clean up after "...  "adapt to current ctxt"( **)
walther@59968
   190
Walther@60556
   191
(*val refin: Problem.id -> O_Model.T -> Problem.T Store.node -> Problem.id option*)
Walther@60559
   192
(*val refin: Proof.context -> Problem.id -> O_Model.T -> Problem.T Store.node -> Problem.id option*)
Walther@60559
   193
fun refin ctxt pblRD ori (Store.Node (pI, [py], [])) =
Walther@60556
   194
    let
Walther@60585
   195
      val {where_rls, model, where_, ...} = py: Problem.T
Walther@60585
   196
      val model = map (Model_Pattern.adapt_to_type ctxt) model
Walther@60556
   197
      val where_ = map (Model_Pattern.adapt_term_to_type ctxt) where_
Walther@60556
   198
    in
Walther@60590
   199
      if M_Match.match_oris ctxt where_rls ori (model, where_) 
Walther@60556
   200
      then SOME (pblRD @ [pI])
Walther@60556
   201
      else NONE
Walther@60556
   202
    end
Walther@60559
   203
  | refin ctxt pblRD ori (Store.Node (pI, [py], pys)) =
Walther@60556
   204
    let
Walther@60585
   205
      val {where_rls, model, where_, ...} = py: Problem.T
Walther@60585
   206
      val model = map (Model_Pattern.adapt_to_type ctxt) model
Walther@60556
   207
      val where_ = map (Model_Pattern.adapt_term_to_type ctxt) where_
Walther@60556
   208
    in
Walther@60590
   209
      if M_Match.match_oris ctxt where_rls ori (model, where_) 
Walther@60575
   210
      then (case refins ctxt (pblRD @ [pI]) ori pys of
Walther@60556
   211
	        SOME pblRD' => SOME pblRD'
Walther@60556
   212
	      | NONE => SOME (pblRD @ [pI]))
Walther@60556
   213
      else NONE
Walther@60556
   214
    end
Walther@60559
   215
  | refin _ _ _ _ = raise ERROR "refin: uncovered fun def."
Walther@60575
   216
and refins _ _ _ [] = NONE
Walther@60575
   217
  | refins ctxt pblRD ori ((p as Store.Node _) :: pts) =
Walther@60559
   218
    (case refin ctxt pblRD ori p of
Walther@60556
   219
      SOME pblRD' => SOME pblRD'
Walther@60575
   220
    | NONE => refins ctxt pblRD ori pts);
Walther@60556
   221
Walther@60556
   222
\<^isac_test>\<open>
walther@59968
   223
(* refine a problem; version providing output for math-experts *)
Walther@60556
   224
(*
walther@60268
   225
fun refin' pblRD fmz pbls (Store.Node (pI, [py: Probl_Def.T], [])) =
walther@59968
   226
    let
walther@59968
   227
      val _ = (tracing o (curry op ^ "*** pass ") o strs2str) (pblRD @ [pI])
Walther@60585
   228
      val {thy, model, where_, where_rls, ...} = py 
Walther@60585
   229
      val oris = O_Model.init thy fmz model(* |> #1*);
walther@59968
   230
      (* WN020803: itms!: oris might _not_ be complete here *)
Walther@60586
   231
      val (b, (itms, where_')) = M_Match.match_oris' thy oris (model, where_, where_rls)
walther@59968
   232
    in
walther@59968
   233
      if b
Walther@60586
   234
      then pbls @ [M_Match.Matches (rev (pblRD @ [pI]), P_Model.from thy itms where_')]
Walther@60586
   235
      else pbls @ [M_Match.NoMatch (rev (pblRD @ [pI]), P_Model.from thy itms where_')]
walther@59968
   236
    end
walther@59968
   237
  | refin' pblRD fmz pbls (Store.Node (pI, [py], pys)) =
walther@59968
   238
    let
walther@59968
   239
      val _ = (tracing o ((curry op ^)"*** pass ") o strs2str) (pblRD @ [pI])
Walther@60585
   240
      val {thy, model, where_, where_rls, ...} = py 
Walther@60585
   241
      val oris = O_Model.init thy fmz model(* |> #1*);
walther@59968
   242
      (* WN020803: itms!: oris might _not_ be complete here *)
Walther@60586
   243
      val(b, (itms, where_')) = M_Match.match_oris' thy oris (model,where_,where_rls);
walther@59968
   244
    in
walther@59968
   245
      if b 
walther@59968
   246
      then
Walther@60586
   247
        let val pbl = M_Match.Matches (rev (pblRD @ [pI]), P_Model.from thy itms where_')
walther@59968
   248
	      in refins' (pblRD @ [pI]) fmz (pbls @ [pbl]) pys end
Walther@60586
   249
      else (pbls @ [M_Match.NoMatch (rev (pblRD @ [pI]), P_Model.from thy itms where_')])
walther@59968
   250
    end
walther@59968
   251
  | refin' _ _ _ _ = raise ERROR "refin': uncovered fun def."
walther@59968
   252
and refins' _ _ pbls [] = pbls
walther@59968
   253
  | refins' pblRD fmz pbls ((p as Store.Node _) :: pts) =
walther@59968
   254
    let
walther@59968
   255
      val pbls' = refin' pblRD fmz pbls p
walther@59968
   256
    in
walther@59968
   257
      case last_elem pbls' of
walther@59984
   258
        M_Match.Matches _ => pbls'
walther@59984
   259
      | M_Match.NoMatch _ => refins' pblRD fmz pbls' pts
walther@59968
   260
    end;
Walther@60556
   261
*)
Walther@60575
   262
(*val refin': Proof.context -> Problem.id -> Formalise.model -> M_Match.T list -> 
Walther@60556
   263
    Probl_Def.T Store.node -> M_Match.T list*)
Walther@60575
   264
fun refin' ctxt pblRD fmz pbls (Store.Node (pI, [py: Probl_Def.T], [])) =
Walther@60556
   265
    let
Walther@60556
   266
      val _ = (tracing o (curry op ^ "*** pass ") o strs2str) (pblRD @ [pI])
Walther@60585
   267
      val {thy, model, where_, where_rls, ...} = py 
Walther@60585
   268
      val model = map (Model_Pattern.adapt_to_type ctxt) model
Walther@60556
   269
      val where_ = map (Model_Pattern.adapt_term_to_type ctxt) where_
Walther@60585
   270
      val oris = O_Model.init thy fmz model; (*WN020803: oris might NOT be complete here*)
Walther@60586
   271
      val (b, (itms, where_')) =
Walther@60585
   272
        M_Match.match_oris' (Proof_Context.theory_of ctxt) oris (model, where_, where_rls)
Walther@60556
   273
    in
Walther@60556
   274
      if b
Walther@60586
   275
      then pbls @ [M_Match.Matches (rev (pblRD @ [pI]), P_Model.from thy itms where_')]
Walther@60586
   276
      else pbls @ [M_Match.NoMatch (rev (pblRD @ [pI]), P_Model.from thy itms where_')]
Walther@60556
   277
    end
Walther@60575
   278
  | refin' ctxt pblRD fmz pbls (Store.Node (pI, [py], pys)) =
Walther@60556
   279
    let
Walther@60556
   280
      val _ = (tracing o ((curry op ^)"*** pass ") o strs2str) (pblRD @ [pI])
Walther@60585
   281
      val {thy, model, where_, where_rls, ...} = py 
Walther@60585
   282
      val model = map (Model_Pattern.adapt_to_type ctxt) model
Walther@60556
   283
      val where_ = map (Model_Pattern.adapt_term_to_type ctxt) where_
Walther@60585
   284
      val oris = O_Model.init thy fmz model; (*WN020803: oris might NOT be complete here*)
Walther@60586
   285
      val (b, (itms, where_')) =
Walther@60585
   286
        M_Match.match_oris' (Proof_Context.theory_of ctxt) oris (model, where_, where_rls)
Walther@60556
   287
    in
Walther@60556
   288
      if b 
Walther@60556
   289
      then
Walther@60586
   290
        let val pbl = M_Match.Matches (rev (pblRD @ [pI]), P_Model.from thy itms where_')
Walther@60575
   291
	      in refins' ctxt (pblRD @ [pI]) fmz (pbls @ [pbl]) pys end
Walther@60586
   292
      else (pbls @ [M_Match.NoMatch (rev (pblRD @ [pI]), P_Model.from thy itms where_')])
Walther@60556
   293
    end
Walther@60575
   294
  | refin' _ _ _ _ _ = raise ERROR "refin': uncovered fun def."
Walther@60575
   295
and refins' _ _ _ pbls [] = pbls
Walther@60575
   296
  | refins' ctxt pblRD fmz pbls ((p as Store.Node _) :: pts) =
Walther@60556
   297
    let
Walther@60575
   298
      val pbls' = refin' ctxt pblRD fmz pbls p
Walther@60556
   299
    in
Walther@60556
   300
      case last_elem pbls' of
Walther@60556
   301
        M_Match.Matches _ => pbls'
Walther@60575
   302
      | M_Match.NoMatch _ => refins' ctxt pblRD fmz pbls' pts
Walther@60556
   303
    end;
walther@60268
   304
\<close>
walther@59968
   305
Walther@60556
   306
(*
Walther@60556
   307
  TODO: rename \<rightarrow> apply_to_node
Walther@60556
   308
  apply a fun to a ptyps node.
Walther@60556
   309
  val app_ptyp: (Probl_Def.T Store.node -> 'a) -> Store.key -> Store.key -> 'a
Walther@60556
   310
*)
Walther@60495
   311
fun app_ptyp x = Store.apply (get_pbls ()) x;
walther@59968
   312
Walther@60556
   313
(* TODO rename \<rightarrow> by_oris
Walther@60556
   314
   for tactic Refine_Tacitly
Walther@60556
   315
   oris are already created wrt. some pbt; ctxt overrides thy in pbt  *)
Walther@60559
   316
fun refine_ori ctxt oris pblID =
walther@59968
   317
  let
Walther@60559
   318
    val opt = app_ptyp (refin ctxt ((rev o tl) pblID) oris) pblID (rev pblID);
Walther@60556
   319
  in case opt of 
walther@59968
   320
      SOME pblRD =>
walther@59968
   321
        let val pblID': Problem.id = rev pblRD
walther@59968
   322
			  in if pblID' = pblID then NONE else SOME pblID' end
walther@59968
   323
	  | NONE => NONE
walther@59968
   324
	end;
Walther@60559
   325
fun refine_ori' ctxt oris pI = perhaps (refine_ori ctxt oris) pI;
walther@59968
   326
walther@60268
   327
\<^isac_test>\<open>
Walther@60575
   328
fun xxxxx ctxt fmz pblID =
Walther@60575
   329
  app_ptyp (refin' ctxt ((rev o tl) pblID) fmz []) pblID (rev pblID);
walther@60268
   330
\<close>
walther@59968
   331
walther@59965
   332
(**)end(**)