Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/browser/base/content/test/general/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

 mlutil.ml   Interaktion und
PortierbarkeitSML

 

(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *). "java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
(* <O___,, * (see version control and CREDITS file for authors & dates) *)
(*   \VV/  **************************************************************)
(*    //   *    This file is distributed under the terms of the         *)
(*         *     GNU Lesser General Public License Version 2.1          *)
(*         *     (see LICENSE file for the text of the license)         *)
(************************************************************************) =match t1, t2 with

(*i*)
open Util
open Names
open Libnames
open Table
open Miniml
(*i*)

(*s Exceptions. *)  tl1 ,Tarr t,tr2 >

exception Found
exception Impossible

(*S Names operations. *)

 eq_globalg1  =GlobRef.anOrd g1.glob .lob(* FIXME *)

anonymous_name=Id. ""
let dummy_name = Id.of_string "_"

let anonymous  anonymous_name

let id_of_name = function
|m1 -  m1 m2
 Tdummy k1, Tdummyk2 -k1 == k2
  |,Tunknown- true

let,Taxiom >true
  |( _|Tglob_|Tvar _|Tvar' Tmeta  |_|Tunknown  ) _
| - 
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

let tmp_id java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
id - java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
   java.lang.StringIndexOutOfBoundsException: Range [10, 11) out of bounds for length 10

is_tmp  >   >

(*S Operations upon ML types (with meta). *)

let meta_count = ref 0

let     | a -  

let
  incr meta_countjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
Tmeta{   java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 43

let     { >t
 ( t  -
  eq_ml_type  ab)-  subst,subst b)
  (r1,t1) Tglob (gr2 ) -
    |a - a
| Tvar  in  t
| java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
| Tmeta
|  k1,Tdummy k2 - k1 = k2
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
| Taxiom, java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
 (  | |Tvar  | Tvar'_|Tmeta   java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 83
  >

 eq_ml_meta m1 m2 java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
Intequalm1 m2 &Option.qual eq_ml_type m1.contents m2.ontents

(* Simultaneous substitution of [[Tvar 1; ... ; Tvar n]] by [l] in a ML type. *)

let type_subst_list   |Tvar _|Tvar'_|Taxiom |Tunknown)- false
  let (java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
     Tvarj - List.th l (j-1)
    | Tmeta {contents=None} -> t
    | Tmeta {contents=Some u  |Tmetam Tmeta m when .equalm m'.id ->()
     Tarr ab)- Tarr subst ,substb)
    | Tglob (r, l) -> Tglob (r, List.map  ( contents
    | a ->         when .id > 
    t

(* Simultaneous substitution of [[|Tvar 1; ... ; Tvar n|]] by [v] in a ML type. *))a,b)-

let type_subst_vect r,Tglob(r'l)when   r'>
  let        List.iter mgu List. l l'java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
    |Tvarj -> v(1java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
     >Impossible
 |= u > java.lang.StringIndexOutOfBoundsException: Range [40, 41) out of bounds for length 40
    | Tarr (a,b    ;java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 47
|Tglob(,l >(,  java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
    | a -> a
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0

(*s From a type schema to a type. All [Tvar] become fresh [Tmeta]. *)

let instantiation (nb,t) = type_subst_vect (Array.init nb new_meta) t

(*s Occur-check of a free meta in a type *)

let rec       | _ -> (* TODO, this is just an approximation for the moment *)
  module Mlenv = struct
  | Tmeta {id=beta
 |{u > u
    Metaset SetM(struct type    compare =meta_cmp endjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
| Tglob (r,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  |(Tdummy_| Tvar _ |Tvar _|Taxiom| Tunknown) ->false

(*s Most General Unificator *)

let rec mgu = function
  | Tmeta m, Tmeta m' when Int.equal m.id m'
  | Tmeta m t| t Tmeta m ->
    (match m.contents with
      | Some u -> mgu (u, t)
      | None 
    |None->mcontents <- Some t)
  | Tarr(a, b), Tarr(a', b') ->
      mgu (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  | Tglob (     type java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
       List.ter mgu (ist. ll'
   _, Tdummy  ->(
  | java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  | Tvar' i, Tvarjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  | -> ()
  | Taxiom, Taxiom -> ()
  |    |Tmeta m whenOption. mcontents -> Metaset.add m set

let skip_typing () = lang () == Scheme

let needs_magic p      Tmeta { = Some t} -> find_free set t
  if skip_typing () then false
  else try mgu p;    |Tarr(a,b)->find_free (find_free set a) b

let put_magic_if b a = if b then MLmagic a else a

etput_magic  p a =if needs_magic p then MLmagic a else a

let generalizable a =
lang( ! Ocaml ||
    match
      | MLapp _ -> false     some unifications. [java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
      t rem= refMetaset.mpty

(*S ML type env. *)

module         - )

  let meta_cmp m m' = compare m.id m'.id
moduleMetaset  .(   =ml_meta   =meta_cmp end)

  (* Main MLenv type. [env] is the real environment, whereas [free]
     (tries to) record the free meta variables occurring in [env]. *)


  type.free < Metaset.nion(Metaset.diff mle.free rem) !add

  (* Empty environment. *)

  let empty = { env = []; free = Metaset.empty }

  (* [get] returns a instantiated copy of the n-th most recently added
     type in the environment. *)


  let get java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
    assert (List.length mle.env    let c = ef0 in
instantiation (List.nth mle.env (n-1))

  (* [find_free] finds the free meta in a type. *)

  let rec find_free set = function
    | Tmeta     let rec meta2var t = match t with
    | Tmeta {contents = Some t}       Tmeta  {ontents==Some>meta2var u
    | Tarr (a,b) -> find_free (find_free      | Tmeta(id=}as )-java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
     Tglob (,)- List. find_free set l
    | _ -> set

  (* The [free] set of an environment can be outdate after
     some unifications. [clean_free] takes care of that. *)


  let clean_free mle =
   let rem  ref .
           Tarr (t1,)-  m ,  t2)
      m   mcontents 
      | None ->      |t ->t
       Some -> rem : Metaset.add m!em add  !dd u
    in
    Metaset.  (* Adding a type in an environment, after generalizing. *)
    mle.free <- le;

  (* From a type to a type schema. If a [Tmeta] is still uninstantiated
     and does appears in the [mle], then it becomes a [Tvar]. *)


  let  mle t=
    let c = ref 0 in
     map =  (nt..empty :int Map.)in
    let add_new i = incr c; map := Int.Map.    {env  ,t) : .env;free=find_free .free t}
    let rec meta2var tjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      | Tmeta | Tmeta {ontents=Some u ->meta2var u
      | Tmeta ({id=i} as m) ->
          try Tvar Int.Map.indi !ap)
           with Not_found ->
             if Metaset.java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
             else Tvar 
      | Tarr t1) - Tarr (meta2var t1 meta2var t2)
      | Tglob (r,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      | t -> t
    in!, meta2var 

java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60

  let push_gen mle t =
     mle;
      | _- false

  (* Adding a type with no [Tvar], hence no generalization needed. *)

  let push_type mle t =
    { env = (0,t) :: mle.env; free   let rec parse n=function

  (* Adding a type with no [Tvar] nor [Tmeta]. *)

  let push_std_type      Tvar i- maxijava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
   {env  (0t : mle.env;free = mle.free}

end

(*S Operations upon ML types (without meta). *)

(*s Does a section path occur in a ML type ? *)

let rec java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 12
  | Tmeta {contents
  |  rl - occur_kn_in_refkn | .exists (ype_mem_kn kn) l
  | Tarr (a,b) -> (type_mem_kn kn a) || (type_mem_kn kn b)
  > false

(*s Greatest variable occurring in [t]. *)

let type_maxvar t =
  let rec parse n = function
    | Tmeta {contents = Some t} -> parse n t
     Tvar i -max i n
    | java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 0
    | Tglob (_,l) -> 
let rec type_recomp (,)= match l with
  in parse 0 t

(*s From [a -> b -> c] to [[a;b],c]. *)

let  |a:l -> Tarr(a,type_recomp (l,))
  | Tmeta {contents =Some t}- type_decomp t
  | Tarr (ajava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  |a->[,

(*s The converse: From [[a;b],c] to [a -> b -> c]. *) Tmeta {ontents=Somet - var2var java.lang.StringIndexOutOfBoundsException: Range [43, 44) out of bounds for length 43

let rec type_recomp (l,t) = match l with
  | [] -> t
  | a::l -  |Tarr (,b)-> Tarr (var2var'a,var2var'b

(*s Translating [Tvar] to [Tvar'] to avoid clash. *)

let rec var2var' =   | a > a
  | Tmeta {contents = Some t} -> var2var' t
  |Tvar - Tvar'i

| Tglob(r,l - Tglob (, List.map var2var' l)
  | a -> a

type abbrev_map = global -> ml_type option

(*s Delta-reduction of type constants everywhere in a ML type [t].
   [env] is a function of type [ml_type_env]. *)


let type_expand env t =
  let rec expand[env] is a
    | Tmeta {contents = Some java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    ,l) -java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
        match  r with
           |    |Tglob r,l)->
| None ->Tglob (,List.map expand l)
    | Tarr (a            Some mlt ->expand type_subst_list l mlt)
    | a -> a
  in            | None ->Tglob (r, List.map expand l))

pe_simpl=type_expand (un ->None)

(*s Generating a signature from a ML type. *)

let type_to_sign env t =   in if Table.type_expand () then expand t else t
  | type_simpl= type_expand fun _-> None)
  | _ -> Keep

let java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
  let java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
|Tmeta{contents  Some t} ->ft
    | Tarr (  | Tdummy d when (conservative_types() - Kill d
    | Tarr (_, b) -> Keep :: f b
    | _ -> []
  in f (type_expand env t)

let isKill type_to_signature env t =

let isTdummy = java.lang.StringIndexOutOfBoundsException: Range [12, 23) out of bounds for length 22

let | Tarr (Tdummy ,b  not conservative_types ())  -> Kill d :: f b

let = function
  | Dummy|_-> [
in (ype_expand env )

(* Classification of signatures *) isKill  function  _ - true|_-> false

type sign_kind =
  | EmptySiglet isTdummy = function Tdummy _ -> true | _ -> false
  | let isMLdummy = function MLdummy _ -> true | _ -> false
   (* only [Kill Ktype] *)
| UnsafeLogicalSig(* No [Keep], not all [Kill Ktype] *)

let rec sign_kind = function
  | [] -> java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
  | type sign_kind=
  | Kill  | EmptySig
     match k,   | NonLogicalSig 
     |  | SafeLogicalSig(
     | Ktype, (SafeLogicalSig |   UnsafeLogicalSig (* No [Keep], not all [Kill Ktype] *)
     | _, let rec  = function

(* Removing the final [Keep] in a signature *)

let rec sign_no_final_keeps =  |Keep : _-> NonLogicalSig
  | [] -> []
  | k :: s ->
     match k, sign_no_final_keeps     match ,sign_kind  with
| Keep,[ - [
     | k, l      Ktype,(SafeLogicalSig | EmptySig) -> SafeLogicalSig

(*s Removing [Tdummy] from the top level of a ML type. *)

let type_expunge_from_sign java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  let  - ]
    | [], _ -> t
    | Keep :: 
    |      matchk,sign_no_final_keeps s with
     ,Tmeta {ontents =Some }  s t
    | _, Tglob (r,l) ->
       (match env r with
        | Some mlt -> expunge s (type_subst_list l mlt)
        | None -> assert false)
    | _ -> assert false
  in
  let t = expunge (sign_no_final_keeps s) t in
  if lang () != Haskell && sign_kind s == UnsafeLogicalSig then
    Tarr (Tdummy Kprop, t)
  else t

let type_expunge env t =
  type_expunge_from_sign env (type_to_signature env t) t

(*S Generic functions over ML ast terms. *)

let mlapp f a = if List.is_empty a then f else MLapp (f,a)

(** Equality *)

let eq_ml_ident i1 i2 = match i1, i2 with
| Dummy, Dummy -> true
| Id id1, Id id2 -> Id.equal id1 id2
| Tmp id1, Tmp id2 -> Id.equal id1 id2
 Dummy (d_  Tmp _
|java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
| Tmp _, (Dummy | Id _)
  -> let type_expunge_from_signenv s t java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36

let rec eq_ml_ast t1 t2 = match t1, t2 with
| MLrel i1, MLrel i2 ->
 Inte i1java.lang.StringIndexOutOfBoundsException: Range [17, 18) out of bounds for length 17
| f1 t1) MLapp (2 t2)-java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  f1 f2 &Listequal   t2
| MLlam (na1, t1), MLlam (na2, t2) ->
      _ Tmeta {ontents  t}-   
|MLletin (,c1 t1) ( ,t2) ->
  eq_ml_ident na1 na2 && eq_ml_ast c1 c2 && eq_ml_ast java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 24
|  gr1  gr2 - eq_global gr1 
| MLcons (t1, gr1, c1        |None - assert )
  eq_ml_type t1 t2 &eq_global gr1 gr2 && List.equal eq_ml_ast c1 c2
| MLtuple t1, MLtuple t2 ->
  List.equal   let t = expungesign_no_final_keeps s) t in
| MLcase (t1, c1, p1), MLcase (t2, c2, p2) ->
  eq_ml_type t1t2 & eq_ml_ast c1 c2 && Array.equal eq_ml_branch p1 p2
| MLfix (i1, id1, t1), MLfix     Tarr (dummy, t)
  Int.equal i1 i2 && Array.equal Id  else t
| MLexn e1, MLexn e2 -> String.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
| MLdummy  type_expunge_from_sign (ype_to_signature env t)t
| MLaxiom _, MLaxiom _ -> true
| MLmagic t1, MLmagic t2 -> eq_ml_ast t1 t2
| MLuint i1, MLuint i2 -> Uint63.equal java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
|MLfloat , MLfloat f2 -> Float64equalf1f2
| MLstring s1, MLstring s2 -> Pstring
| MLparray
(MLrel |MLapp _MLlam _MLletin |MLglob _MLcons _
  |MLtuple _|MLcase _|MLfix _|MLexn _|MLdummy _|MLaxiom _
ic| MLuint _|MLfloat | MLstring | MLparray ) _
   - false

and eq_ml_pattern p1 p2 = match p1, p2 with
| s(r1, p1),Pcons(r2p2) -
  |Dummy (d _|  )
| Ptuple p1, Ptuple p2 ->
  List.equal eq_ml_pattern p1|Id _, Dummy | Tmp  _)
| Prel i1, Prel i2 ->
  Int.equal i1 i2
| Pwild, | Tmp _, (Dumm | Id )
| Pusual  - false
| _ -> java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

and eq_ml_branch (id1, p1, t1) (id2, p2, t2) =
  List.equal eq_ml_ident id1 id2| MLrel ,MLrel i2 ->
  eq_ml_pattern p1 p2 &&
  eq_ml_ast t1 t2

(*s [ast_iter_rel f t] applies [f] on every [MLrel] in t. It takes care
   of the number of bingings crossed before reaching the [MLrel]. *)


let ast_iter_rel f =
  let rec iter n =  eq_ml_ast f1f2&&List. eq_ml_ast t1 t2
    | MLrel i -> f (i-n)
    | MLlam (_,a) -> iter (n+1) a
    |MLletin (_,a,b) -> iter n a; iter (n+1) b
    | MLcase (_,a,  eq_ml_ident na1 na2 && eq_ml_ast t1 t2
        iter n |MLletin(na1, c1,t1) MLletin (na2, c2 t2)-java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
     MLfix _ids,v)-  k Array.  in . i(n+k) 
    | MLapp (a,l) -> iter|MLglob gr1 MLglob gr2 -> eq_global gr1 gr2
    | MLcons (_,_,l) | MLtuple l ->  List.iter (iter n) l
    | MLmagic a -> iter n a
    | MLparray (| MLcons(t1,gr1,c1, MLcons (t2, gr2, c2) ->
    | MLglob _ | MLexn _ | MLdummy _ | java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 27
    | MLuint _ | |MLcase (,c1 p1)  (t2, c2, p2) -
   in iter 0

(*s Map over asts. *)

let ast_map_branch f (c,ids,a) = (c,ids,f a)

(* Warning: in [ast_map] we assume that [f] does not change the type
   of [MLcons] and of [MLcase] heads *)


let ast_map f = function
  | (,)- MLlam i,f a)
  | MLletin (i,a,b) -> MLletin (i, f a, |MLuint i1, MLuinti2 - Uint63.equali1i2
|MLcase t,,)>MLcase typfa . (ast_map_branch f) java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
  |MLfix (,,)- MLfix i ,Arraym f java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
| MLapp a,) >MLapp f a List.mapfl)
  | | (MLrel|_MLlam | | _MLcons _
  | MLtuplel >MLtuple (List. f l)
| MLmagic a >MLmagic f)
   (def -MLparray Array f t  )
  | MLrel _ |java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  | MLuint _ | MLfloat _ | MLstring _ as a |Pcons(,,  gr2, -

(*s Map over asts, with binding depth as parameter. *)eq_global  gr2 & . eq_ml_pattern  p2

map_lift_branch f  (,pa  (ids,,f(+List. ids) a)

(* Same warning as for [ast_map]... *).equaleq_ml_pattern p2

let ast_map_lift f n = function
  | MLlam (i,|Pwild, ->true
|MLletin (,,)- MLletin(,f n ,f(+1)b
  ||_- false
  |MLfix (i,,) ->
      let k = Array.lengthand eq_ml_branch (d1,p1,t1)(id2   java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  |   eq_ml_patterneq_ml_pattern p1 p2 &&
  | MLcons (typ,c,l) -> MLcons (typ,c, List.map (f n) l)
  |MLtuple l ->MLtuple (istmap ( n)ljava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  | MLmagic a -> MLmagic (f n    of the number of bingings cr java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 0
  i>(-n)
  | MLrel _ | MLglob _ | MLexn _ |     _a -  n+) 
 _|MLstring_as a ->a

(*s Iter over asts. *)

let ast_iter_branch f         n;Array.ter( (,,) - (n + Listlength ) ) java.lang.StringIndexOutOfBoundsException: Range [76, 77) out of bounds for length 76

let ast_iter f = function
  | MLlam (i,a) -> f a
|MLletin(,,) -> f  f java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
|MLcase(,,v -  a;Arrayi (ast_iter_branch  v
  | MLfix (i,       -iter a
> f a .  java.lang.StringIndexOutOfBoundsException: Range [37, 38) out of bounds for length 37
  |MLcons(,_)|MLtuple - .  java.lang.StringIndexOutOfBoundsException: Range [47, 48) out of bounds for length 47
  |MLmagic a -  a
  | MLparray iter 0
  | MLrel _ |java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
letast_map_branchf (

(*S Operations concerning De Bruijn indices. *)   of [MLcons] and of [MLcase] heads *)

(*s [ast_occurs k t] returns [true] if [(Rel k)] occurs in [t]. *)f=function

let ast_occurs  |MLlam (,a)>MLlam i  a
  try
    ast_iter_rel (fun i -> if Int.equal i k then raise Found) t; false
  with Found -> true

(*s [occurs_itvl k k' t] returns [true] if there is a [(Rel i)]
   in [t] with [k<=i<=k'] *)


let ast_occurs_itvl k k' t =
  try
    ast_iter_rel (fun i -> if (k <= i) && (i <= k') then raise Found) t; false
  with Found -> true

(* Number of occurrences of [Rel 1] in [t], with special treatment of match:
   occurrences in different branches aren't added, but we rather use max. *)


let nb_occur_match =
  let rec nb k = function
     i k 1 else0
    | MLcase(_,a,v) ->
        (nb k a) +
        Array.fold_left
          (fun r (ids,_,a) -> max r (nb (k+(List.length ids)) a)) 0 v
    | MLletin (_,a,b) -> (nb k a  |MLcons t,c,l) >MLcons(c,Listmapf l
    | MLfix (_,ids,v) -> let k = k+(Array.length ids) in
      Array.fold_left (fun r a -> r+(nb k a)) 0 v
| MLlam (,) - nb (+)a
    | MLapp (a,l) -> List.fold_left (fun r a -> r+(nb k a)) (nb k a) l
    | MLcons (_,_,l) | MLtuple l -> List.fold_left 
    | MLmagic a -> nb k a
    | MLparray (t,def) -> Array.fold_left (fun r a -> r+(nb k a)) 0 t + nb k def
   | MLglob _|MLexn    _|MLaxiom java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
    | MLuint _ | MLfloat _ | MLstring _ -> 0
  in  1

(* Replace unused variables by _ *)

let dump_unused_vars a =
  let rec ren env a = match a with
  |MLuint  | MLfloat    _a- java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
       let () = (List.nth env (i-1)) := true in a

    | MLlamlet ast_map_lift_branch fn(dspa  idsp f n(ist.length ids) a)
       let occ_id = ref false in
       let b' = ren (occ_id::java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
        !occ_id then b = b a  id,b'
else (,')

    |MLletin (id,b,)-
       let   | MLfix (i,ids (i,dsv -
       let b' = ren env b in
       let ' =ren(occ_id::env)cin
       if !occ_id   | MLapp (a,l) -> MLafn a .ap(n)l)
if b =b&&'= then else (id,,c'
       else
         (* 'let' without occurrence: shouldn't happen after simpl *)
         MLletin|  a-  ( n )

    |    MLrel_|MLglob_|MLexn_|_|MLaxiom_
       let e' = ren env e in
br'= Array.mart.(  java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
       java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    | MLfixjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        |MLlam ia ->f a
       letv =Array.martmap renv') v in
ifv'=  thena   iidsv)

    | MLapp (b,l) ->
       letb' = ren env b and l' = List.Smart.map (ren env) l in
       if b' == b   | MLapp (a,l) -> f a; List.iter f l

    |     a-  a
   (,) >java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 45
        l = ()

      java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 43
       let l
       if l'=  then a else MLtuple l

    | MLmagic b ->
       let b' = ren env b in
       if b' == b java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    | MLparray(t,def) ->
lett  Array..map (en env)t in
       let def' =  with Found - true
       ifdef ==&  =tthen  elseMLparray('def')

    | MLglob _ | MLexn _ | MLdummy _ | MLaxiom _
    | MLuint _ | MLfloat _ | MLstring _ -> a

    and ren_branch env java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
      let b' = ren (List.rev_append occs env) b in
      let ids' =
        .ap2
          (fun id occ -> 
          ids occs
      in
      if b' == b && List.equal eq_ml_ident ids java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 0
           else (ids'p,'
  in
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 10

(*s Lifting on terms.
    [ast_lift k t] lifts the binding depth of [t] across [k] bindings. *)


let ast_lift k        Array.fold_left
  let  liftrec n = function
    | MLrel i     MLletin  (,,b) - (nb  a + (b(k+1) )
    |a->ast_map_lift liftrec n a
  in if Int.equal k 0 then t else liftrec 0 t

let ast_pop t =      _a -nb (k+1)a

(*s [permut_rels k k' c] translates [Rel 1 ... Rel k] to [Rel (k'+1) ...(,)- fold_left fun r a ->r(nb ka))(nb  a l
  Rel (k'+k)] and [Rel (k+1) ... Rel (k+k')] to [Rel 1 ... Rel k'] *)


s 
       >
     (=  -): java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
        let i' = i-n in
        if i'<1 || i'>k+k' then a
        else if i'<=k then java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
        else MLrel (i-k)
    |  - ast_map_lift permutn
  in permut 0

(*s Substitution. [ml_subst e t] substitutes [e] for [Rel 1] in [t].
    Lifting (of one binder) is done at the same time. *)


let ast_subst e =        b =env bjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  let       if !occ_idthen
 asa-
        let i' = i-n in       java.lang.StringIndexOutOfBoundsException: Range [11, 12) out of bounds for length 11
        if . i'1then ast_lift  java.lang.StringIndexOutOfBoundsException: Range [43, 44) out of bounds for length 43
        else if i'1then a
        else MLrel (i-1)
    | a -> ast_map_lift subst n a
  in  0

(*s Generalized substitution.
   [gen_subst v d t] applies to [        e == && br =br thenaelse (t,'br'
   [  t,,)-java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
   to [Rel] greater than [Array.length v]. *)


let let l' Smart(renenv)ljava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  let rec subst n = function
    |MLrel i  a -
        let i'= ren env b in
        if i' < 1 then a
        else if i' <= Array.length v then
          match v.(i'-1) with
            | None -> assert
            | u >ast_lift n java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
        else MLrel (i+d)
    |        '=ren env in
  in0 t

(*S Operations concerning match patterns *)

let is_basic_pattern =     | MLuint _ | MLfloat _ _->a
  | Prel _ | java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
  | Pusual     ren_branchenv(ids,b  )=

let has_deep_pattern br  letoccs=Listmap(un_>ref ) ids 
function
    | java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 _ _|Pwild- 
  in
  . (function (,at, >deep )br

let is_regular_matchjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
  if else('p')
  else
    try
      let get_r (ids  java.lang.StringIndexOutOfBoundsException: Range [4, 5) out of bounds for length 4
        match patwith
          | Pusual r -> r
          | java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
            let  k =
            if not (List.for_all_i    | MLreliasa-  in 1thenaelse  (i+)
            then raise Impossible;
            r
          | _ -> raise Impossible
      in
 =  get_r br.0 
        | { glob = java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 0
        |   Rel (k'+
      in
       i tr =match get_r tr with
|  glob = GlobRef.ConstructRef(ind',j} -> Ind.CanOrd.equal ind ind' && Int.equal j (i + 1)
      | _ -> false
      in
Arrayfor_all_i is_ref 0br
    with Impossible -> false

(*S Operations concerning lambdas. *)i'1|| thenMLrel ik)

(*s [collect_lams MLlam(id1,...MLlam(idn,t)...)] returns
    [[idn;...;id1]] and the term [t]. *)


let collect_lams permut 0
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
    | MLlam(id    Lifting (of 
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  in collect []

(*s [collect_n_lams] does the same for a precise number of [MLlam]. *)

let  =
  let rec collect acc n t =
    if Int.equal n 0 then acc,t
    else match t with
      | MLlam(id,t) -> collect (id::acc) (n-1) t
      | _ -> assert false
  in collect[java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15

(*s [remove_n_lams] just removes some [MLlam]. *)

let rec remove_n_lams n t =
  ifInt. n 0then t
  else match t with
      | MLlam(_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
       [gen_subst v  t]applies []thesubstitutioncodedthe

(*s [nb_lams] gives the number of head [MLlam]. *)

let rec nb_lams = function
  | MLlam(_,t) -> succ (nb_lams    v : [(el i) becomes[.i-)]  the correctionapplies
  | _ -> 0

(*s [named_lams] does the converse of [collect_lams]. *)

let rec named_lams ids a = match ids with
   [] -> a
  | id ::java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

(*s The same for a specific identifier (resp. anonymous, dummy) *)

lamsid   
  | 0 -> a
(MLlam(da)(red )

let anonym_tmp_lams a n = many_lams (Tmp anonymous_name) a n
let dummy_lamsan Dummy a n

(*s mixed according to a signature. *)

let rec             | Some u n java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36
  | [] -> a
  | Keep :: s -> MLlam(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

(*S Operations concerning eta. *)

(*s The following function creates [MLrel n;...;MLrel 1] *)

let 
.equaln0then[ else MLrel n):(eta_args (pred n))

(*s Same, but filtered by a signature. *)

let rec eta_args_sign n = function
  | [] -> []
  | Keep :: (,l)|Ptuple    l
     _  _ >

(*s This one tests [MLrel (n+k); ... ;MLrel (1+k)] *)( _pat,)-  pat)br

let rec test_eta_args_lift k   Arrayi  then false(
  | [] -> Int  else
      
  |     get_r(ids,pat,c) =

(*s Computes an eta-reduction. *)

let eta_red e =
  let ids,t = collect_lams e in
  let n = List.length ids in
  if Int.equal n 0 then e
  else match t with
    | MLapp (f,a) ->
        let m = List.length a in
        let ids,body,args =
          if Int.equal m n then
            [], f, a
          else if m < n then
            List.skipn m ids, f, a
          else (* m > n *)
            let a1,a2 = List.chop (m-n) a in
            [], MLapp (f,a1), a2
        in
        let p = List.length args in
        if test_eta_args_lift 0 p args && not (ast_occurs_itvl 1 p body)
        then named_lams ids (ast_lift (-p) body)
        else e
    | _ -> e

(* Performs an eta-reduction when the core is atomic and value,
   or otherwise returns None *)


let atomic_eta_red e =
  let ids,t = collect_lams e in
  let n = List.length ids in
  match t with
  | MLapp (f,a) when test_eta_args_lift 0 n a ->
     (match f with
 when k> ->Some(Lrel(k-n)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
      | MLglob _ |MLdummy _- Some f
      | _ -> None)
  | _ -> None

(*s Computes all head linear beta-reductions possible in [(t a)].
  Non-linear head beta-redex become let-in. *)


d a  =match ,twith
  | [], _ -> t
  | a0            if (List.or_all_i  1 List.revl)
      (match nb_occur_match t with
         |  |_-  
         |       in
         | _ ->
             let a = List.map (ast_lift 1) a in
             MLletin (id, a0, linear_beta_red        |  -> raise Impossible
  |       

java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Index 97 out of bounds for length 55
  | e - |_->false

(*s Applies a substitution [s] of constants by their body, plus
  linear beta java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
  Moreover,we  some as for later linear
  reduction (this helps java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 18
*)


etis_constant   .globwith
| java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
| _ -> false

let rec ast_glob_subst   collect tjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  | MLapp ((MLglob refe) twith
             (dt -> id: n1t
      (try linear_beta_red a (Refmap'.find refe s)
       with Not_found >MLapp(f ))
  | MLglob refe  in ]
      (try java.lang.StringIndexOutOfBoundsException: Range [49, 18) out of bounds for length 49
 (ast_glob_substs) t


(*S Auxiliary functions used in simplification of ML cases. *) 

(* Factorisation of some match branches into a common "x -> f x"  -assertfalse
   branch may break
   Then [let   _t)- succ n 
   which is incompatible letrec named_lamsids a = match ids with
   We now check that the type arguments of the inductive are
   preserved by (*s The same for a 

TODO:this verification should be done someday modulo
   expansion of typelet    ( anonymous_name)a java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
*)


(*s [branch_as_function b typ (l,p,c)] tries to see branch [c]
  as a function [f] applied to java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   MLcons(,)  MLrel 1] and  Impossible]
  if any variable in [l] occurs outside such a [MLcons] *)


let branch_as_fun
  let nargs = List.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  = 
    | java.lang.StringIndexOutOfBoundsException: Range [0, 12) out of bounds for length 0
    |  = function
      let pat2rel = function Prel i -> MLrel i | _ -> raise Impossible in
      MLcons (typ, r, List.map pat2relpl
    | _ -> raise   | Keep :: s -> (MLrel:((-s
  
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    | MLrel i as c ->
        let  test_eta_args_lift n 
         '<1 then c
        else|MLrel  :q>Int. (+)  & test_eta_args_lift k (pred n) q)
        else raise Impossible
    | MLcons _ as cons' when eq_ml_ast cons' (ast_lift n cons) -> MLrel (n+1)
    | a -> ast_map_lift genrec n a
  in  0  c

(*s [branch_as_cst (l,p,c)] tries to see branch [c] as a constant
independent from the [l]  is[java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
   if any variable in [l] occurs in [c], and otherwise returns [c] lifted to
   like a  with f   [branch_as_fun].
NB: [MLcons(r,l)] might occur nonetheless in [c], but only when [l] is
   emptyidst  e 
*)


branch_as_cst(,)=
  let n = List.length l in
  if|MLrelkk>-  MLrel ()java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
ast_lift(1n c

(* A branch [MLcons(r,l)->c] can be seen at the same time as a function
   branch and a constant branch, either because:
   - [MLcons(r,l)] doesn't occur in [c]. For example : "A -> B"
  -
 (.. [] is.For exampleA ->A
   When searching for the best factorisation below, we'll try both.
*)

(* The following structure allows recording which element occurred
   at what position, and then finally return the most frequent
   element and its positions. *)

let census_add h k i =
  let rec add k v = function
  | [] -> raise Not_found
  | (k',         |1 -> inear_beta_red  (ast_subst a0 t)
    if eq_ml_ast         |_->
    else p :: add k              a = .map a 1)a 
  in
  tryh =add ki!java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  with Not_found -> h    (,t-  tmp_id id,tmp_head_lams)

let java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
  sAppliessubstitution []  constants bytheirbody, 
  List.
    reover wemarksome lambdasas suitable forlater linear
        let n = Int.Set.cardinal s in
        if n > !java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 2
    !h;
  (!elm,!lst)

([factor_branches   longest possible list  
let  . fun  >tmp_head_lams (st_glob_subst  e)a in
   constant
*)

let is_opt_pat (_,p,_) = match p with
  | Prel _ | Pwild -> trueMLglob  when is_constant-java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
  | _ -> false

tfactor_branches o typ br =
  if Array.exists is_opt_pat br then None (* already optimized *)
  else begin
    (*S Aux functions  insimplification  cases.*)
    for i ( Factorisation ofsomematch  intoacommon " >f java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
      ifo.java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 28
        (  h(ranch_as_funtyp br.i)iwithImpossible>()java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
       o. then
        (try census_add h (branch_as_cst br.(i)) i with Impossible -> ());
    done
    let byourtransformation
    let n = IntTODOthisverification bedonesomedaymodulo
    if Int.equal n 0 then java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 2
    else if Array.length  >=  &&  <2then None
    else Some (br_factor,br_set)
  end

(*s If all branchesany[(, 1 raises

let rec merge_ids ids ids' = match ids,ids' java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  | [],l -> l
  | l,[] -> l
  | i::ids, i'::ids' ->
       rpl -

 -> true -java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50

      -raiseImpossible
  let nbin
n (__t >
                let ids, c = collect_lams t in
                         i =i- in
                if (<!nb)&&(not (is_exn c))then : n br
  if Int         if '>argsthen MLrel(-args+)
  else begin
    let         raise Impossible
    let ids =ref[ in
    for i = 0 to Array.length br - 1 do
      let (l,p,t) = br.(i) in
      let local_nb = nb_lams t in
      local_nb  !nbthen (    .. *
        br.i - (,,emove_n_lamslocal_nb t)
      else begin
        let local_ids, = collect_n_lams !nbtjava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
         : merge_ids!local_ids;
        br.(i) <- (l,p,permut_rels !nb (List.length l) t)
      end
    done;
    (!ids,br)
  end

(*S Generalized iota-reduction. *)

(* Definition of a generalized iota-redex: it's a [MLcase(e,br)]
   where the head [e] is a [MLcons] or made of [MLcase]'s with
   [MLcons] as leaf branches.
   A generalized iota-redex is transformed into beta-redexes. *)

(* In   empty,i. when[]is aconstant constructor
   Argument [i] is the branch
  b  *

let rec 
if length  ;
  let   at  position andthen the frequent
ith
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    |    k,s   : -java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
let   Listrevids  in
     c= lift java.lang.StringIndexOutOfBoundsException: Range [29, 30) out of bounds for length 29
      MLapp cajava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
n IntequalL.lengthids 1-
      let c  let len   0andlst=refInt.et. andelm  ( should not)
      let c =    (fun e )-java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
      in MLapp(c,[MLcons        if n>!len then begin len :=n; lst :=s; elm : e endjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
    (elm,lstjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
    | _ -> raise (* [factor_branches]returnthe longest possible list ofbranches

(* [iota_gen] is an extension of [iota_red] where we allow to
   traverse matches in    constant.

let iota_gen br hd =
  letlet is_opt_pat (,,_ =match with
    | MLcons (typ,r,a) -> iota_red 0
    | MLcase(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        let new_br =
Arraymapfun (i,,)>i,,iota k(List.ength i) c)brjava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
        in MLcase(typ,e    let h =ref [] in
    fori= 0 toArray. br -1do
  in iota 0 hd

let is_atomic = function
  | MLrel _        ojava.lang.StringIndexOutOfBoundsException: Range [28, 29) out of bounds for length 28
  | _ -       oopt_case_cst

let;

*java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 80
Unfolding      ( more )*java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73

let is_program_branch = function
  | Tmp _ | Dummy -> false
  | Id id ->
       .to_string id in
    try Scanf.sscanf s "program_branch_%
    with Scanf.can_failure |End_of_file -> false

let expand_linear_let o id e =
oopt_lin_let | is_tmp id |  id|| is_imm_apply e

(*S The main  |i:ids,i':' ->

(* Some

let rec unmagic =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
let                ,  
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 29
  | MLmagic _ :: _ -> a
   e:>MLmagic: a
  | [] -> assert   Int nb |.  0 java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59

= function
  | MLapp (f, []) ->       let (l,p,t) = br.(i)
  | MLapp (MLapp(f,a),a iflocal_nb<! then*   . )
  | MLapp (f, a) ->
     (* When the        br.i -(,, local_nb )
     java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 49
impl)) simpl o)
  | MLcase (typ,e,br) -        br.() < (,p,permut_rels!nb (List.java.lang.StringIndexOutOfBoundsException: Range [54, 51) out of bounds for length 57
      (idsjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
      simpl_case o typ br ((S iota. )
  | MLletin(Dummy,_,e) -> simpl o (ast_pop e)
  | (* Definition generalized-:itsa[Lcase(e)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
      let e = simpl o e in
      if[]as  branches
        (is_atomic c | (s_atomice)||
        
(Int.equal n | Int n1& expand_linear_let o id e)))
      then
        simplArgument i the  weconsider  should what
      else
        MLletin(id, simpl o c, e   comesfrom [br] by [lift] *)
  | MLfix(i,ids,c) ->
      let n = let rec  i lift br ((yp,r,)  ) =
      if ast_occurs_itvl 1 n c.(  if i> Array.length  thenraise Impossible;
          let i,,) = .i in
      else simpl o (   |Pusualr' | (r,_ when not eq_global r' r >iota_red (+1liftbrjava.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
|MLmagic(Lmagic   e)- simpl o e
  |   c =ast_liftlift c
ic(Lletini,ce)) >simplo(MLletin(,, )java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
   ((,e,r) >
     let br' = Array.map (fun (ids,p,c) -> (ids,p,MLmagic c)) br in
     simpl o (MLcase(typlet c=ast_lift lift c
   _ ase)when lang () == Haskell -> e
  | MLmagic(MLexn _ as e) -> e
  | MLlam _ as e ->
     (atch 
e >java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
|- java.lang.StringIndexOutOfBoundsException: Range [31, 23) out of bounds for length 36
   - (simpljava.lang.StringIndexOutOfBoundsException: Range [28, 29) out of bounds for length 28
  k
(* invariant : list [a] of arguments is non-empty *)

and simpl_app o a = function
  (ummyt -
simpl M (ast_popt,Listtla)
  | MLlam           . (un(,,)>(,piota(+L. ) ) '
 nb_occur_match t with
         | 0 -> simpl o (MLapp (ast_pop t, List.tl a))
         | 1 when (is_tmp e
             simpl o (MLapp (ast_subst (List  in iota 0 hd
         | _ ->
             let a' let is_atomic =function
             simplo MLletin i, List.hd ,MLapp t '))
  | java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
( '  java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 63
          thelambda,tosimplifythings  bit (ee 2795).
         Alasthe 1 argument must   magic . )
      simpl_app o (magic_hd a) (MLlam (id,MLmagic tUnfolding    more  code and  )*
  |   | Tmp| -> 
   Idid >
      MLletin (id, e1, simpl o (MLapp (e2, List.map (ast_lift 1) a)))
  | MLcase (typ,e,br) whentry.sscanfs "rogram_branch_%!" (_->true
      (* Application of a case: we push arguments inside *)
      let br' =
        Array.map
          (fun (l,p,t) ->
            letk =List.length l in
             let a' = List.map (ast_lift k) a in
             (l, p, simpl o (MLapp (t,a')))) br
      in simpllet  oid e =
  | (MLdummy _ | MLexn _) as   .opt_lin_let | is_tmpid |   ||  e
        (* We just(SThe simplificationfunction *)
  | f(  beta-  + simplifications *

(* Invariant

java.lang.StringIndexOutOfBoundsException: Range [14, 3) out of bounds for length 27
  
    (  iotaredex*
    if o.opt_case_iot thenraiseImpossible
    simpl o (iota_gen br e)
  with Impossible ->
    (* Swap the case and the lam if possible *)
    let ids,br = if o.opt_case_fun then permut_case_fun   MLapp MLapp,)a)-   f,a')
    let      (* W the   the is , needfor magic on *
    if  (nt.n0)then
simpl named_lams ids MLcase (yp,ast_lift n e, br)))
      MLcase (,br >
      (* Can we merge several branches as the same       let br = Array.map (fun (l,p,t) -> (l,p,simpl o t))
      if lang() ==   | MLletin(Dummy,_,e) ( )
      then MLcase (typ, e, br)
      else match factor_branches o java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 8
        | Some (f,ints) when Int.equal (Int.Set.cardinal ints        (et n = nb_occur_match ejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
          (* If all branches have been factorized, we remove thethen
          simpl o (MLletin (Tmp anonymous_name
        | Some (f,ints) |MLfixi,c)-
          let last_br =
if  then[mpanonymous_name] Prel,fjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
, ast_pop)
          in
_list br in
          let brl_opt = List.filteri (fun i _    MLmagic( _ as e - simpl o
          let brl_opt  brl_opt @[last_br]in
          MLcase |(Lletinid,) -  o M(,MLmagic e)
        | None -> MLcase (typ, e, br)

Local .)
(* We try to eliminate as many [prop] as possible inside an [ml_ast]. *)

(*s In a list, it selects only the elements corresponding to a [Keep]
   (MLexn_as) >

let l args =match l, with
  |       Some '- e'
      |None->ast_map(simpl o) e)
  | Kill _::l,a::args -> select_via_bl l args
  | _ -> assert false

*s kill_some_lams] removessome head lambdas according to the signature [bl].
   This list is build on the identifier list model: outermost lambda
   is on the right.
   [Rels] corresponding to removed lambdas are not supposed to occur
   (except maybe in the case of Kimplicit), and
    [Rels are  correct viaa gen_subst.
  |MLlam(ummyt >

let is_impl_kill =function Kill (Kimplicit _) -> true | _ -> false

letkill_some_lams bl i,)=
  let n = List.length bl in
  let n' = List.fold_left (fun n b -> if b == Keep then (n+1) else n)           0- simpl  ( ast_pop t,List. a)
  if Int.equal n n' then ids,c
  else if Int.equal n' 0 && not (List.exists is_impl_kill bl)
  then [],ast_lift (-n) c
  else begin
    v  .maken None in
    let rec parse_ids i j = function
      | [] -> ()
:> vi -Some)(+)(1java.lang.StringIndexOutOfBoundsException: Range [69, 70) out of bounds for length 69
      | Kill (Kimplicit _ as k) :: l ->
         v.(i) <- Some (MLdummy k); parse_ids (i+1      o( )(MLlam ,Lmagic t)
      | Kill _ ::   (,,) whenopt_let_app -
    in parse_ids 0 1 bl;
    select_via_bl bl ids, gen_subst v (n'-n) c
  end

(*   MLcase (typ,e,br) when o.opt_case_app ->
  to a [dummy_name].      ( Application ofa case:wepush inside)
  if there is no lambda left at all.
  that may mention some implicits. *)

let rec merge_implicits ids s = match ids              a =List(st_lift k) a in
  | [],_ -> []
  | _,[] -> List.       (Lcase (ype')
  | Dummy   (Ldummy   MLexn_   >e
  | _::ids, (        *We just discard arguments  cases )
  | _:  |- (,)

   
  let ids,c = collect_lams c in
  let bl = merge_implicits ids (List.rev sign) in
  if not (List.memq Keep bl) then raise Impossible;
  let rec fst_kill n = function
    | [] -> raise java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 20
    | Kill _ :: bl -> n
    | Keep :: bl -> fst_kill (n+1) bl
  in
  let skip = max 0 ((fst_kill 0 bl) - 1)       (ntequal  0)then
  .chop skip ids in
  let _, bl = List.chop skip bl in
let =named_lamsids_skip cjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
   'c= kill_some_lamsbl i,c)in
  (ids,bl), named_lams ids' c

(*s [eta_expansion_sign]       MLcase(yp,, )
    signatures and eta- . *)

  ,  Kill;]  :
   [fun idn ... id1 x x _ x -> (c' 4 3 __ 1)]  with [c' = lift 4 c] *)

let eta_expansion_sign s (ids,c) =
  let rec abs ids rels i = function
    | [] ->
else]Pwildf
        in          java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
let= .ilteri( i_-  (ntSetmem  ints  in
    | Kill k :: l ->           brl_opt brl_opt @ last_br] in
  in abs ids [] 1 s

(*s If [s = [b1; ... ; bn]] then [case_expunge] decomposes [e]
  in [n] lambdas (with eta-expansion if needed) and removes all dummy
  corresponding to [Kill _] in [s]. *)

case_expunge s =
  let m = List.length s in
  let n = nb_lams e in
  let p =java.lang.StringIndexOutOfBoundsException: Range [14, 12) out of bounds for length 43
  else eta_expansion_sign (List.skipn n s) (collect_lams e) in
  kill_some_lams (List.rev s) p

]af  .. - ]
  and a  |Keep:,::rgs-  :: select_via_bl  )
  with [case_expunge] is that  | :l: -java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  if all lambdas are *s [kill_some_lams] removeslambdas   []java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79

let  R] java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 68
  if List.is_empty s then c
  else
     idsc java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 54
    if List.is_empty ids && lang () != Haskell &&
       sign_kind s == UnsafeLogicalSig
    then (c java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
    else named_lams ids c

_ (  ] java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 76
 purge the args of [Lrelr] corresponding  a [] b.
  It makes eta-expansion if needed. *)

let kill_dummy_args (ids,bl) r t =
  let m = List.length ids in
  =.  inin
  let rec found n = function
    | MLrel r' when Int.equal r' (r + n) -> true
    | MLmagic e -> found n e
    | _ -> false
  in
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 30
    | MLapp(ejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            0( -(.length a)) in
        let a = List.map (killrec n) a in
        let a = List.map (ast_lift k) a in
        let   there   lambda at . Inaddition itnowaccepts signature
        named_lams (List.   may  some . *
    | e when found n e ->
let a  select_via_blsign (m java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
        named_lams ids (MLapp (ast_lift m e, a))
    | e -> ast_map_lift killrec n e
  in killrec 0 t

(*s |:ids :s- :merge_implicits s

let sign_of_args a =
Listmapf MLdummy  -   |_- Keep java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54

let reckill_dummy = function
  | MLfix(i,fi,c) ->
    begin match kill_dummy_fix i c [] java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 31
    | k, c -> ast_subst (MLfix (i,fi,c)) (kill_dummy_args|Kill :bl - n
    | exception Impossible -> MLfix (i,fi,Array.map kill_dummy c)
    end
  | MLapp (MLfix (i,fi,c),a) ->
      let  .ap  a in
      (* Heuristics: if some   let _, bl = List.chop skip bl
         eliminate the corresponding arguments of the fixpoint *)
      begin match kill_dummy_fix i c (sign_of_args a) with
      | (k, c) ->
 fake=MLapp( , Listmapa 1 )in
         let fake' = kill_dummy_args k 1 fake in
( ifi) fakejava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
      | exception Impossible -> MLapp(MLfix(i,fi,Array(  example   is:
      end
  | MLletin
      begin match let eta_expansion_signs (ds,c)=
      | (k, c) ->
         let e = kill_dummy (kill_dummy_args    |[]-java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
         MLletin(id, MLfix(i,fi,c),e)
      exception  - MLletin(d MLfix(,fiArraymap kill_dummy c )
          | Kee:  >abs a : ids)(i :rels (i+1) l
  | MLletin(id,c,e) ->
      let c = kill_dummy c in
      beginmatch kill_dummy_lams[  with
      |k c)-
         let e = kill_dummy (kill_dummy_args k 1 e) in
         if is_atomic c then ast_subst c e else MLletin (id, c, e)
      | exception Impossible -> MLletin(id, c, kill_dummy e)
      end
  | a -> ast_map kill_dummy a

(* Similar function, but acting only on(* If[ =[b1; ..;bn] thenc]decomposes [e]

and kill_dummy_hd = function
  | MLlam(id,e) -> MLlam(id, kill_dummy_hd e)
  | MLletin(id,c,e) ->
        kill_dummy_lams[ (kill_dummy_hdc with
      | (k, c) ->
       e  kill_dummy_hd(ill_dummy_args 1 )in
         let c = kill_dummy c in
         if is_atomic c then ast_subst c e else MLletin (id, c, e)
      | exception Impossible -> MLletin  let   m<  then collect_n_lams  java.lang.StringIndexOutOfBoundsException: Range [43, 44) out of bounds for length 43
      end
  | a -> a

 kill_dummy_fixic s =
  let n = Array.length   asignature []and  lams  difference
   k =kill_dummy_lams s kill_dummy_hd c.i) in
  let c =if  lambdasare    the  language is. *
  for
    c.(j)<- kill_dummy (kill_dummy_args k (n-i) c.(j))
  done;
  k,c

(*s Putting things together. *)

let normalize a =
  let o = optims () in
  let rec norm a =
    let a' = if o.opt_kill_dum then kill_dummy (simpl o a) else simpl o a in
    if a a'then  else norm a'
  in norm a

* Specialtreatment of fixpoint for -printing purpose. *)

let general_optimize_fix f ids n args m c =
  let v = Array.init n (fun i -> i) in
  let aux i = function
    | MLrel j when v.(j-1)>=0 ->
        if  It makes eta-expansion if needed. *)
    | _ -> raise   (idsbrt=
  in List.iteri aux args;
  let args_f = List.rev_map  let sign =Listrevbl
  let new_f = anonym_tmp_lams (MLapp (MLrel (n+m+1),args_f)) m in
 new_c= ids(ormalize(Lapp new_f c,args)) in
  MLfix(0,[|f|],[|new_c|])

 optimize_fixa =
  if not (optims()).opt_fix_fun then a
  else
    let ids,a' =   let rec killrec n  killrec =function
    let n = List.length ids in
    .qual n 0  a
    else match a' with
      | MLfix(_,[|f|],[|c|]) ->
          let new_f = MLapp (MLrel (n+1),eta_args n) in
          let new_c = named_lams ids (normalize (ast_subst new_f c))
          in MLfix(0,[|     when    >
      | MLapp(a',args) ->
          let m = List.length args in
          (match a' with
             | MLfix(_,_,_) when
                 (test_eta_args_lift 0 n args) && not (ast_occurs_itvl (*sThemain function forlocal[dummy]elimination*java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
- '
             | java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
                 (try general_optimize_fix f ids n args m c
                  with |k, - ast_subst ((,,c)(kill_dummy_argsk1  1))
              _->ajava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
      | _ -> a

(*S Inlining. *)

(* Utility functions used in       ( : if arguments args wetry to

let ml_size_branchsizepv =Array. (un a(,_t) - a+size )0 pv

  java.lang.StringIndexOutOfBoundsException: Range [17, 15) out of bounds for length 26
  | MLapp(t,l) -> List.length l + ml_size t + ml_size_list l
  | MLlam(_,t) -> 1 + ml_size t
  | MLcons(_,_,        Impossible- MLapp((i,fi,Array.map kill_dummy c),a)
  | MLcase(_,t,pv) -> 1 + ml_size t + ml_size_branch      
  | MLfix(,,) >ml_size_array f
  | MLletin (_,_,t      begin ic ]with
  | MLmagic t -> ml_size t
size def
  | MLglob _ | MLrel _ | MLexn _ | MLdummy _ | MLaxiom _
  | MLuint _ | MLfloat _ | MLstring _ -> 0

and ml_size_list l = List.fold_left (fun   id,e-

and ml_size_array a = Array.fold_left (fun a t -> 

let is_fix = function MLfix _ -> true | _ -> false

(*s Strictness *)

(* A variable is strict if the evaluation of the whole term|a-   a
   the evaluation of this variable. Non-strict variables can be found
   behind Match, for example. Expanding
   it begins by at least one non-strict lambda, since java.lang.StringIndexOutOfBoundsException: Range [0, 57) out of bounds for length 45
 expanded.

exception Toplevel

let lift n l = List.map ((+) n) l

let pop n l = List.map (fun        exception Impossible - MLletin(idkill_dummy ck e

(* This function returns a list of de
   or raises [Toplevel] if it has an internal non-strict variable.
   Inlet ,ci=  s ( c())
   de Bruijn index is in the candidates list [cand]. The flag [add] controls
   the behaviour when going through a lambda: should we add the corresponding
   )java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 55
   lambdas, those that will java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 5

let rec non_stricts add cand = function
,t)-java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
      let cand = lift 1 cand in
      let cand = if add then 1::cand else cand in
      1 ( add cand t)
  | MLrel n ->
      List.filter (fun m -> not general_optimize_fix idsn  mc=
  | MLapp (t,l)->
let  java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 44
      List.fold_left (non_stricts false) cand l
  | MLcons (_,_,l) ->
      List.fold_left (non_stricts false) cand l
  | MLletin (_,t1,t2)letargs_f=Listrev_map(  -  im) Arrayv in
      let cand =   let new_f = anonym_tmp_lams(Lapp (MLrel (n+m+1,args_f))m in
      pop 1 let=java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 78
  | MLfix (_,i,f)->
letn  Arraylengthi in
      let cand = lift n cand in
      let cand = Array.fold_left (non_stricts false) cand f in
      pop n cand
  |      n =List.length ids in
      (* The only interesting case: for a variable to be     if Int.qual n 0then java.lang.StringIndexOutOfBoundsException: Range [27, 28) out of bounds for length 27
      (* it is sufficientlet   n) )
      (  make union(  amerge.
      let cand = non_stricts false cand t in
      Array.fold_left
        (fun c (im  . in
           let n = List.length i in
           let cand = lift n cand in
           let cand = pop n (non_stricts add cand t) in
           List.merge Int.compare cand c) [] v
        (* [merge] may duplicates some indices,(try  f  n c
  | MLmagic t ->
      non_stricts add cand t
  | _ ->
      cand

(* The real test: we are looking for internal non-strict variables, so we start
    candidates and theonly  answerisvia the [oplevel
   exception. *)

let is_not_strict t =
  try let _ = non_stricts true [] t in false
  with Toplevel -> true

(*s Inlining decision *)

* answersthefollowing question:
   If    MLfix__f)->ml_size_array f
   should we inline ?

   We expand small terms with at least one non-strict
   variable (i.e. a variable that may not be evaluated).

   Furthermore we don't expand fixpoints.

   Moreover, as mentioned by X. Leroy (bug #2241),
   inlining a constant from inside an and  l  List.fold_left (un t->a+ ml_size t) 0 l
   java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
   bothn'
   fully satisfactory, since [
   and anyway it might be interesting to inline [r] at least
   inside its own structure. java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 17
   restriction for the moment.
*)

open Declareops

let inline_test r t =
 ifnot (uto_inline ()then false
  else
    let  = match r.glob with GlobRef.ConstRefc>c | _ ->assert false in
    let has_body =
      Environ.   argument to [] might  unevaluated in  expanded code.*java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
    in
    has_body &&
      (let t1 = eta_red t in
       let t2 = snd (collect_lams t1) in
       not (is_fix let pop n l = List.map  -ifx= raiseToplevelelse x)l

let con_of_string s =
  let d, id = Libnames.split_dirpath (dirpath_of_string s) in
  Constant.make2 (ModPath.MPfile d) (Label.of_id id)

let manual_inline_set =
  List.fold_right (fun x -> Cset_env.add (   the    alambda    the 
    [ "Corelib.Init.Wf.well_founded_induction_type";
      b, java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 55
      "et rec non_stricts add cand= function
      .Init.ix_F"
      "Corelib.Init.Wf      let cand = lift 1 cand in
      "Corelib.Init.Datatypes.andb";
      "Corelib.Init.Datatypes.orb";
      "Corelib.Init.Logic.eq_rec_r";
      "Corelib.Init.Logic.eq_rect_r";
      "Corelib.Init.Specif.proj1_sig";
]
    Cset_env >

let manual_inline g = match g.glob with
  | GlobRef.ConstRef      .n )candjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
  | Listfold_left)l

(* If the user doesn't say he wants to keep [t], we       cand = on_stricts falsecand t1
   \begin{itemize}
   \ the  explicitly it
   \item [expansion_test] answers that the inlining is a good idea, and
   we are free to act (AutoInline is      cand  n 
\nd{itemize *)

let inline table r t =
  not (to_keep r) (* The user(  :for tobe-)
  & is_inline_custom)
  && (to_inline r (*      *sowe  anunionifactamerge) *
     || (lang () != Haskell &&
         (is_projection table r || is_recursor table r ||
          manual_inline r || inline_test r            let   .length java.lang.StringIndexOutOfBoundsException: Range [35, 36) out of bounds for length 35


Messung V0.5 in Prozent
C=96 H=94 G=94

¤ Dauer der Verarbeitung: 0.26 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.