]> matita.cs.unibo.it Git - helm.git/blob - helm/software/components/ng_refiner/nCicMetaSubst.ml
b5a4646baba5160bbe940c44d84c38ca8e194b4f
[helm.git] / helm / software / components / ng_refiner / nCicMetaSubst.ml
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.      
9      \ /   This software is distributed as is, NO WARRANTY.     
10       V_______________________________________________________________ *)
11
12 (* $Id$ *)
13
14 exception MetaSubstFailure of string Lazy.t
15 exception Uncertain of string Lazy.t
16
17 (*
18 (*** Functions to apply a substitution ***)
19
20 let apply_subst_gen ~appl_fun subst term =
21  let rec um_aux =
22   let module C = Cic in
23   let module S = CicSubstitution in 
24    function
25       C.Rel _ as t -> t
26     | C.Var (uri,exp_named_subst) ->
27        let exp_named_subst' =
28          List.map (fun (uri, t) -> (uri, um_aux t)) exp_named_subst
29        in
30        C.Var (uri, exp_named_subst')
31     | C.Meta (i, l) -> 
32         (try
33           let (_, t,_) = lookup_subst i subst in
34           um_aux (S.subst_meta l t)
35         with CicUtil.Subst_not_found _ -> 
36           (* unconstrained variable, i.e. free in subst*)
37           let l' =
38             List.map (function None -> None | Some t -> Some (um_aux t)) l
39           in
40            C.Meta (i,l'))
41     | C.Sort _
42     | C.Implicit _ as t -> t
43     | C.Cast (te,ty) -> C.Cast (um_aux te, um_aux ty)
44     | C.Prod (n,s,t) -> C.Prod (n, um_aux s, um_aux t)
45     | C.Lambda (n,s,t) -> C.Lambda (n, um_aux s, um_aux t)
46     | C.LetIn (n,s,ty,t) -> C.LetIn (n, um_aux s, um_aux ty, um_aux t)
47     | C.Appl (hd :: tl) -> appl_fun um_aux hd tl
48     | C.Appl _ -> assert false
49     | C.Const (uri,exp_named_subst) ->
50        let exp_named_subst' =
51          List.map (fun (uri, t) -> (uri, um_aux t)) exp_named_subst
52        in
53        C.Const (uri, exp_named_subst')
54     | C.MutInd (uri,typeno,exp_named_subst) ->
55        let exp_named_subst' =
56          List.map (fun (uri, t) -> (uri, um_aux t)) exp_named_subst
57        in
58        C.MutInd (uri,typeno,exp_named_subst')
59     | C.MutConstruct (uri,typeno,consno,exp_named_subst) ->
60        let exp_named_subst' =
61          List.map (fun (uri, t) -> (uri, um_aux t)) exp_named_subst
62        in
63        C.MutConstruct (uri,typeno,consno,exp_named_subst')
64     | C.MutCase (sp,i,outty,t,pl) ->
65        let pl' = List.map um_aux pl in
66        C.MutCase (sp, i, um_aux outty, um_aux t, pl')
67     | C.Fix (i, fl) ->
68        let fl' =
69          List.map (fun (name, i, ty, bo) -> (name, i, um_aux ty, um_aux bo)) fl
70        in
71        C.Fix (i, fl')
72     | C.CoFix (i, fl) ->
73        let fl' =
74          List.map (fun (name, ty, bo) -> (name, um_aux ty, um_aux bo)) fl
75        in
76        C.CoFix (i, fl')
77  in
78   um_aux term
79 ;;
80
81 let apply_subst =
82   let appl_fun um_aux he tl =
83     let tl' = List.map um_aux tl in
84     let t' =
85      match um_aux he with
86         Cic.Appl l -> Cic.Appl (l@tl')
87       | he' -> Cic.Appl (he'::tl')
88     in
89      begin
90       match he with
91          Cic.Meta (m,_) -> CicReduction.head_beta_reduce t'
92        | _ -> t'
93      end
94   in
95   fun subst t ->
96 (*     incr apply_subst_counter; *)
97 match subst with
98    [] -> t
99  | _ -> apply_subst_gen ~appl_fun subst t
100 ;;
101
102 let profiler = HExtlib.profile "U/CicMetaSubst.apply_subst"
103 let apply_subst s t = 
104   profiler.HExtlib.profile (apply_subst s) t
105
106
107 let apply_subst_context subst context =
108  match subst with
109     [] -> context
110   | _ ->
111 (*
112   incr apply_subst_context_counter;
113   context_length := !context_length + List.length context;
114 *)
115   List.fold_right
116     (fun item context ->
117       match item with
118       | Some (n, Cic.Decl t) ->
119           let t' = apply_subst subst t in
120           Some (n, Cic.Decl t') :: context
121       | Some (n, Cic.Def (t, ty)) ->
122           let ty' = apply_subst subst ty in
123           let t' = apply_subst subst t in
124           Some (n, Cic.Def (t', ty')) :: context
125       | None -> None :: context)
126     context []
127
128 let apply_subst_metasenv subst metasenv =
129 (*
130   incr apply_subst_metasenv_counter;
131   metasenv_length := !metasenv_length + List.length metasenv;
132 *)
133 match subst with
134    [] -> metasenv
135  | _ ->
136   List.map
137     (fun (n, context, ty) ->
138       (n, apply_subst_context subst context, apply_subst subst ty))
139     (List.filter
140       (fun (i, _, _) -> not (List.mem_assoc i subst))
141       metasenv)
142
143 let tempi_type_of_aux_subst = ref 0.0;;
144 let tempi_subst = ref 0.0;;
145 let tempi_type_of_aux = ref 0.0;;
146 *)
147
148 let newmeta = 
149   let maxmeta = ref 0 in
150   fun () -> incr maxmeta; !maxmeta
151 ;;
152
153 exception NotInTheList;;
154
155 let position n (shift, lc) =
156   match lc with
157   | NCic.Irl len when n <= shift || n > shift + len -> raise NotInTheList
158   | NCic.Irl len -> n - shift
159   | NCic.Ctx tl ->
160       let rec aux k = function 
161          | [] -> raise NotInTheList
162          | (NCic.Rel m)::_ when m + shift = n -> k
163          | _::tl -> aux (k+1) tl 
164       in
165        aux 1 tl
166 ;;
167
168 let pack_lc orig = 
169   let rec are_contiguous k = function
170     | [] -> true
171     | (NCic.Rel j) :: tl when j = k+1 -> are_contiguous j tl
172     | _ -> false
173   in
174   match orig with
175   | _, NCic.Ctx [] -> 0, NCic.Irl 0
176   | shift, NCic.Ctx (NCic.Rel k::tl as l) when are_contiguous k tl ->
177       shift+k-1, NCic.Irl (List.length l)
178   | _ -> orig
179 ;;
180
181 let mk_restricted_irl shift len restrictions =
182   let rec aux n =
183     if n = 0 then [] else
184       if List.mem (n+shift) restrictions then aux (n-1)
185       else (NCic.Rel n)::aux (n-1)
186   in
187     pack_lc (shift, NCic.Ctx (List.rev (aux len)))
188 ;;
189
190 exception Occur;;
191
192 let rec force_does_not_occur metasenv subst restrictions t =
193  let rec aux k (metasenv, subst as  ms) = function
194     | NCic.Rel r when List.mem (r - k) restrictions -> raise Occur
195     | NCic.Meta (n, l) as orig ->
196        (* we ignore the subst since restrict will take care of already
197         * instantiated/restricted metavariabels *)
198        let (metasenv,subst as ms), restrictions_for_n, l' =
199          match l with
200          | shift, NCic.Irl len -> 
201              let restrictions = 
202                List.filter 
203                 (fun i -> i > shift && i <= shift + len) restrictions in
204              ms, restrictions, mk_restricted_irl shift len restrictions
205          | shift, NCic.Ctx l ->
206             let ms, _, restrictions_for_n, l =
207              List.fold_right
208                (fun t (ms, i, restrictions_for_n, l) ->
209                  try 
210                    let ms, t = aux (k-shift) ms t in
211                    ms, i-1, restrictions_for_n, t::l
212                  with Occur ->
213                    ms, i-1, i::restrictions_for_n, l)
214                l (ms, List.length l, [], [])
215             in
216              ms, restrictions_for_n, pack_lc (shift, NCic.Ctx l)
217        in
218        if restrictions_for_n = [] then
219          ms, if l = l' then orig else NCic.Meta (n, l')
220        else
221          let metasenv, subst, newmeta = 
222            restrict metasenv subst n restrictions_for_n 
223          in
224            (metasenv, subst), NCic.Meta (newmeta, l')
225     | t -> NCicUtils.map_term_fold_a (fun _ k -> k+1) k aux ms t
226  in
227    aux 0 (metasenv,subst) t 
228
229 and force_does_not_occur_in_context metasenv subst restrictions = function
230   | name, NCic.Decl t as orig ->
231       let (metasenv, subst), t' =
232         force_does_not_occur metasenv subst restrictions t in
233       metasenv, subst, (if t == t' then orig else (name,NCic.Decl t'))
234   | name, NCic.Def (bo, ty) as orig ->
235       let (metasenv, subst), bo' =
236         force_does_not_occur metasenv subst restrictions bo in
237       let (metasenv, subst), ty' =
238         force_does_not_occur metasenv subst restrictions ty in
239       metasenv, subst, 
240        (if bo == bo' && ty == ty' then orig else (name, NCic.Def (bo', ty')))
241
242 and erase_in_context metasenv subst pos restrictions = function
243   | [] -> metasenv, subst, restrictions, []
244   | hd::tl as orig ->
245       let metasenv, subst, restricted, tl' = 
246         erase_in_context metasenv subst (pos+1) restrictions tl in
247       if List.mem pos restricted then
248         metasenv, subst, restricted, tl'
249       else
250         try
251           let metasenv, subst, hd' =
252             let delifted_restricted = 
253               List.map ((+) ~-pos) (List.filter ((<=) pos) restricted) in
254             force_does_not_occur_in_context 
255               metasenv subst delifted_restricted hd
256           in
257            metasenv, subst, restricted, 
258             (if hd' == hd && tl' == tl then orig else (hd' :: tl'))
259         with Occur ->
260             metasenv, subst, (pos :: restricted), tl'
261
262 and restrict metasenv subst i restrictions =
263   assert (restrictions <> []);
264   try 
265     let name, ctx, bo, ty = NCicUtils.lookup_subst i subst in
266       try 
267         let metasenv, subst, restrictions, newctx = 
268           erase_in_context metasenv subst 1 restrictions ctx in
269         let (metasenv, subst), newty =  
270           force_does_not_occur metasenv subst restrictions ty in
271         let (metasenv, subst), newbo =  
272           force_does_not_occur metasenv subst restrictions bo in
273         let j = newmeta () in
274         let subst_entry_j = j, (name, newctx, newty, newbo) in
275         let reloc_irl = mk_restricted_irl 0 (List.length ctx) restrictions in
276         let subst_entry_i = i, (name, ctx, NCic.Meta (j, reloc_irl), ty) in
277         metasenv,
278         subst_entry_j :: List.map 
279           (fun (n,x) as orig -> if i = n then subst_entry_i else orig) subst,
280         j
281       with Occur -> raise (MetaSubstFailure (lazy (Printf.sprintf
282             ("Cannot restrict the context of the metavariable ?%d over "^^
283             "the hypotheses %s since ?%d is already instantiated "^^
284             "with %s and at least one of the hypotheses occurs in "^^
285             "the substituted term") i  (String.concat ", " 
286             (List.map (fun x -> fst (List.nth ctx (x-1))) restrictions)) i
287             (NCicPp.ppterm ~metasenv ~subst ~context:ctx bo))))
288   with NCicUtils.Subst_not_found _ -> 
289     try 
290       let name, ctx, ty = NCicUtils.lookup_meta i metasenv in
291       try
292         let metasenv, subst, restrictions, newctx = 
293           erase_in_context metasenv subst 1 restrictions ctx in
294         let (metasenv, subst), newty =  
295           force_does_not_occur metasenv subst restrictions ty in
296         let j = newmeta () in
297         let metasenv_entry = j, (name, newctx, newty) in
298         let reloc_irl = mk_restricted_irl 0 (List.length ctx) restrictions in
299         let subst_entry = i, (name, ctx, NCic.Meta (j, reloc_irl), ty) in
300         List.map 
301           (fun (n,x) as orig -> if i = n then metasenv_entry else orig) 
302           metasenv,
303         subst_entry :: subst, j
304       with Occur -> raise (MetaSubstFailure (lazy (Printf.sprintf
305           ("Cannot restrict the context of the metavariable ?%d "^^
306           "over the hypotheses %s since metavariable's type depends "^^
307           "on at least one of them") i (String.concat ", " 
308           (List.map (fun x -> fst (List.nth ctx (x-1))) restrictions)))))
309     with 
310     | NCicUtils.Meta_not_found _ -> assert false
311 ;;
312
313 (* INVARIANT: we suppose that t is not another occurrence of Meta(n,_), 
314    otherwise the occur check does not make sense in case of unification
315    of ?n with ?n *)
316 let delift metasenv subst context n l t =
317   let rec aux k (metasenv, subst as ms) = function
318     | NCic.Rel n as t when n <= k -> ms, t
319     | NCic.Rel n -> 
320         (try
321           match List.nth context (n-k-1) with
322           | _,NCic.Def (bo,_) -> 
323                 (try ms, NCic.Rel ((position (n-k) l) + k)
324                  with NotInTheList ->
325                 (* CSC: This bit of reduction hurts performances since it is
326                  * possible to  have an exponential explosion of the size of the
327                  * proof. required for nat/nth_prime.ma *)
328                   aux k ms (NCicSubstitution.lift n bo))
329           | _,NCic.Decl _ -> ms, NCic.Rel ((position (n-k) l) + k)
330         with Failure _ -> assert false) (*Unbound variable found in delift*)
331     | NCic.Meta (i,l1) as orig ->
332         (try
333            let _,_,t,_ = NCicUtils.lookup_subst i subst in
334            aux k ms (NCicSubstitution.subst_meta l1 t)
335          with NCicUtils.Subst_not_found _ ->
336            (* see the top level invariant *)
337            if (i = n) then 
338             raise (MetaSubstFailure (lazy (Printf.sprintf (
339               "Cannot unify the metavariable ?%d with a term that has "^^
340               "as subterm %s in which the same metavariable "^^
341               "occurs (occur check)") i 
342                (NCicPp.ppterm ~context ~metasenv ~subst t))))
343            else
344               let shift1,lc1 = l1 in
345               let shift,lc = l in
346               match lc, lc1 with
347               | NCic.Irl len, NCic.Irl len1 
348                 when shift1 < shift || len1 + shift1 > len + shift ->
349                   let restrictions = 
350                      HExtlib.list_seq 1 (shift - shift1) @
351                      HExtlib.list_seq (shift+len+1) (shift1+len1)
352                   in
353                   let metasenv, subst, newmeta = 
354                      restrict metasenv subst i restrictions 
355                   in
356                   (metasenv, subst), 
357                   NCic.Meta(newmeta, mk_restricted_irl shift1 len1 restrictions)
358               | NCic.Irl len, NCic.Irl len1 when shift = 0 -> ms, orig
359               | NCic.Irl len, NCic.Irl len1 ->
360                    ms, NCic.Meta (i, (shift1 - shift, lc1))
361               | _ -> 
362                   let to_be_restricted = ref [] in
363                   let lc1 = NCicUtils.expand_local_context lc1 in
364                   let rec deliftl tbr j ms = function
365                     | [] -> ms, tbr, []
366                     | t::tl ->
367                         let ms, tbr, tl = deliftl tbr (j+1) ms tl in
368                         try 
369                           let ms, t = aux (k-shift1) ms t in 
370                           ms, tbr, t::tl
371                         with
372                         | NotInTheList | MetaSubstFailure _ -> ms, j::tbr, tl
373                   in
374                   let (metasenv, subst), to_be_r, lc1' = deliftl [] 1 ms lc1 in
375                   let l1 = pack_lc (shift, NCic.Ctx lc1') in
376                   if to_be_r = [] then
377                     (metasenv, subst), 
378                     (if lc1' = lc1 then orig else NCic.Meta (i,l1))
379                   else
380                     let metasenv, subst, newmeta = 
381                       restrict metasenv subst i to_be_r in
382                     (metasenv, subst), NCic.Meta(newmeta,l1))
383     | t -> NCicUtils.map_term_fold_a (fun _ k -> k+1) k aux ms t
384   in
385     aux 0 (metasenv,subst) t
386 ;;
387
388 (*
389   in
390    let res =
391     try
392      deliftaux 0 t
393     with
394      NotInTheList ->
395       (* This is the case where we fail even first order unification. *)
396       (* The reason is that our delift function is weaker than first  *)
397       (* order (in the sense of alpha-conversion). See comment above  *)
398       (* related to the delift function.                              *)
399 (* debug_print (lazy "First Order UnificationFailure during delift") ;
400 debug_print(lazy (sprintf
401         "Error trying to abstract %s over [%s]: the algorithm only tried to abstract over bound variables"
402         (ppterm subst t)
403         (String.concat "; "
404           (List.map
405             (function Some t -> ppterm subst t | None -> "_") l
406           )))); *)
407       let msg = (lazy (sprintf
408         "Error trying to abstract %s over [%s]: the algorithm only tried to abstract over bound variables"
409         (ppterm ~metasenv subst t)
410         (String.concat "; "
411           (List.map
412             (function Some t -> ppterm ~metasenv subst t | None -> "_")
413             l))))
414       in
415        if
416          List.exists
417           (function
418               Some t -> CicUtil.is_meta_closed (apply_subst subst t)
419             | None -> true) l
420        then
421         raise (Uncertain msg)
422        else
423         raise (MetaSubstFailure msg)
424    in
425    let (metasenv, subst) = restrict subst !to_be_restricted metasenv in
426     res, metasenv, subst
427 ;;
428 *)
429
430 (*
431 (* delifts a term t of n levels strating from k, that is changes (Rel m)
432  * to (Rel (m - n)) when m > (k + n). if k <= m < k + n delift fails
433  *)
434 let delift_rels_from subst metasenv k n =
435  let rec liftaux subst metasenv k =
436   let module C = Cic in
437    function
438       C.Rel m as t ->
439        if m < k then
440         t, subst, metasenv
441        else if m < k + n then
442          raise DeliftingARelWouldCaptureAFreeVariable
443        else
444         C.Rel (m - n), subst, metasenv
445     | C.Var (uri,exp_named_subst) ->
446        let exp_named_subst',subst,metasenv = 
447         List.fold_right
448          (fun (uri,t) (l,subst,metasenv) ->
449            let t',subst,metasenv = liftaux subst metasenv k t in
450             (uri,t')::l,subst,metasenv) exp_named_subst ([],subst,metasenv)
451        in
452         C.Var (uri,exp_named_subst'),subst,metasenv
453     | C.Meta (i,l) ->
454         (try
455           let (_, t,_) = lookup_subst i subst in
456            liftaux subst metasenv k (CicSubstitution.subst_meta l t)
457          with CicUtil.Subst_not_found _ -> 
458           let l',to_be_restricted,subst,metasenv =
459            let rec aux con l subst metasenv =
460             match l with
461                [] -> [],[],subst,metasenv
462              | he::tl ->
463                 let tl',to_be_restricted,subst,metasenv =
464                  aux (con + 1) tl subst metasenv in
465                 let he',more_to_be_restricted,subst,metasenv =
466                  match he with
467                     None -> None,[],subst,metasenv
468                   | Some t ->
469                      try
470                       let t',subst,metasenv = liftaux subst metasenv k t in
471                        Some t',[],subst,metasenv
472                      with
473                       DeliftingARelWouldCaptureAFreeVariable ->
474                        None,[i,con],subst,metasenv
475                 in
476                  he'::tl',more_to_be_restricted@to_be_restricted,subst,metasenv
477            in
478             aux 1 l subst metasenv in
479           let metasenv,subst = restrict subst to_be_restricted metasenv in
480            C.Meta(i,l'),subst,metasenv)
481     | C.Sort _ as t -> t,subst,metasenv
482     | C.Implicit _ as t -> t,subst,metasenv
483     | C.Cast (te,ty) ->
484        let te',subst,metasenv = liftaux subst metasenv k te in
485        let ty',subst,metasenv = liftaux subst metasenv k ty in
486         C.Cast (te',ty'),subst,metasenv
487     | C.Prod (n,s,t) ->
488        let s',subst,metasenv = liftaux subst metasenv k s in
489        let t',subst,metasenv = liftaux subst metasenv (k+1) t in
490         C.Prod (n,s',t'),subst,metasenv
491     | C.Lambda (n,s,t) ->
492        let s',subst,metasenv = liftaux subst metasenv k s in
493        let t',subst,metasenv = liftaux subst metasenv (k+1) t in
494         C.Lambda (n,s',t'),subst,metasenv
495     | C.LetIn (n,s,ty,t) ->
496        let s',subst,metasenv = liftaux subst metasenv k s in
497        let ty',subst,metasenv = liftaux subst metasenv k ty in
498        let t',subst,metasenv = liftaux subst metasenv (k+1) t in
499         C.LetIn (n,s',ty',t'),subst,metasenv
500     | C.Appl l ->
501        let l',subst,metasenv =
502         List.fold_right
503          (fun t (l,subst,metasenv) ->
504            let t',subst,metasenv = liftaux subst metasenv k t in
505             t'::l,subst,metasenv) l ([],subst,metasenv) in
506        C.Appl l',subst,metasenv
507     | C.Const (uri,exp_named_subst) ->
508        let exp_named_subst',subst,metasenv = 
509         List.fold_right
510          (fun (uri,t) (l,subst,metasenv) ->
511            let t',subst,metasenv = liftaux subst metasenv k t in
512             (uri,t')::l,subst,metasenv) exp_named_subst ([],subst,metasenv)
513        in
514         C.Const (uri,exp_named_subst'),subst,metasenv
515     | C.MutInd (uri,tyno,exp_named_subst) ->
516        let exp_named_subst',subst,metasenv = 
517         List.fold_right
518          (fun (uri,t) (l,subst,metasenv) ->
519            let t',subst,metasenv = liftaux subst metasenv k t in
520             (uri,t')::l,subst,metasenv) exp_named_subst ([],subst,metasenv)
521        in
522         C.MutInd (uri,tyno,exp_named_subst'),subst,metasenv
523     | C.MutConstruct (uri,tyno,consno,exp_named_subst) ->
524        let exp_named_subst',subst,metasenv = 
525         List.fold_right
526          (fun (uri,t) (l,subst,metasenv) ->
527            let t',subst,metasenv = liftaux subst metasenv k t in
528             (uri,t')::l,subst,metasenv) exp_named_subst ([],subst,metasenv)
529        in
530         C.MutConstruct (uri,tyno,consno,exp_named_subst'),subst,metasenv
531     | C.MutCase (sp,i,outty,t,pl) ->
532        let outty',subst,metasenv = liftaux subst metasenv k outty in
533        let t',subst,metasenv = liftaux subst metasenv k t in
534        let pl',subst,metasenv =
535         List.fold_right
536          (fun t (l,subst,metasenv) ->
537            let t',subst,metasenv = liftaux subst metasenv k t in
538             t'::l,subst,metasenv) pl ([],subst,metasenv)
539        in
540         C.MutCase (sp,i,outty',t',pl'),subst,metasenv
541     | C.Fix (i, fl) ->
542        let len = List.length fl in
543        let liftedfl,subst,metasenv =
544         List.fold_right
545          (fun (name, i, ty, bo) (l,subst,metasenv) ->
546            let ty',subst,metasenv = liftaux subst metasenv k ty in
547            let bo',subst,metasenv = liftaux subst metasenv (k+len) bo in
548             (name,i,ty',bo')::l,subst,metasenv
549          ) fl ([],subst,metasenv)
550        in
551         C.Fix (i, liftedfl),subst,metasenv
552     | C.CoFix (i, fl) ->
553        let len = List.length fl in
554        let liftedfl,subst,metasenv =
555         List.fold_right
556          (fun (name, ty, bo) (l,subst,metasenv) ->
557            let ty',subst,metasenv = liftaux subst metasenv k ty in
558            let bo',subst,metasenv = liftaux subst metasenv (k+len) bo in
559             (name,ty',bo')::l,subst,metasenv
560          ) fl ([],subst,metasenv)
561        in
562         C.CoFix (i, liftedfl),subst,metasenv
563  in
564   liftaux subst metasenv k
565
566 let delift_rels subst metasenv n t =
567   delift_rels_from subst metasenv 1 n t
568 *) 
569