Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Python/Sympy/sympy/physics/quantum/tests/     Datei vom 6.10.2026 mit Größe 1 kB image not shown  

Quelle  cClosure.ml   Sprache: SML

 

(************************************************************************)
(*         *      The Rocq Prover / The Rocq Development Team           *)
(*  v      *         Copyright INRIA, CNRS and contributors             *)
(* <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)         *)
************************************java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74

(* Created by Bruno Barras with Benjamin Werner's account to implement
   a call-by-value conversion 
   with sharing, Nov 1996 *)

(* Addition of zeta-reduction (let-in contraction) by Hugo Herbelin, Oct 2000 *)
(* Call-by-value machine moved to cbv.ml, Mar 01 *)
(* Additional tools for module subtyping by Jacek Chrzaszcz, Aug 2002 *)
(* Extension with closure optimization by Bruno Barras, Aug 2003 *)
(* Support for evar reduction by Bruno Barras, Feb 2009 *)
(* Miscellaneous other improvements by Bruno Barras, 1997-2009 *)

(* This file implements a lazy reduction for the Calculus of Inductive
   Constructions *)


[@@@ocaml.warning "+4"]

open CErrors
open Util
open Names
open Constr
open Declarations
open Context
open Environ
open Vars
open Esubst
open RedFlags

module RelDecl = Context.Rel.Declaration
module NamedDecl = Context.Named.Declaration

type mode = Conversion | Reduction
(* In conversion mode we can introduce FIrrelevant terms.
   Invariants of the conversion mode:
   - the only irrelevant terms as returned by [knr] are either [FIrrelevant],
     [FLambda], [FFlex] or [FRel].
   - the stack never contains irrelevant-producing nodes i.e. [Zproj], [ZFix]
     and [ZcaseT] are all relevant
*)


(**********************************************************************)
(* Lazy reduction: the one used in kernel operations                  *)

(* type of shared terms. fconstr and frterm are mutually recursive.
 * Clone of the constr structure, but completely mutable, and
*annotated with reduction state (reducible or not).
 *  - FLIFT is a delayed shift; allows sharing java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 71
 *    of a given term.
 *  - FCLOS is a delayed substitution applied to a constr
 *  - FLOCKED is used to erase the content of a reference that must
 *    be updated. This is to allow the garbage collector to work
 *    if          if check_native_args term
 *)


(* Ntrl means the term is in βιδζ head normal form and cannot create a redex
     when substituted   iserasejava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 67
   Cstr     means  termin ι normal formthat it
     create a redex when substituted (i.e. constructor, fix, lambda)
   Red is used for terms that might be reduced
*)

    red_knit java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28

let neutr = function Ntrl| functionNtrl >|Red| -Red
is_red =  - |    - 

type   java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0

typefconstr{

type fconstr = {
  mutable mark : red_state;
  mutable term: fterm;
}

and   utable term: fterm;
  |      java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
   FAtom constr(* Metas and Sorts *)
  | FFlex of     ofpinductive
  |of 
  | FConstruct of pconstructor * fconstr array
  |   of fconstr ,_:_) >assert  
 ofProjection*java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 53
  | FFix of   |FCoFix of assert(c>;
   of  (* instance on the case and instance on the constructor are compatible by typing *)
    UVars*constr array*java.lang.StringIndexOutOfBoundsException: Range [77, 76) out of bounds for length 124
   FCaseInvertof  knit info tab ~pat_state ejava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  | FLambda  |java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 49
    FEvar ofEvar.*constr list * * evar_repack
  | letstk @|rg|] s in
  | FEvar of Evar.t |java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 24
    Uint63.t
  | FFloat of Float64.t
  | FString of Pstring.t
  | | FLIFT of *fconstr
|FLIFT   
  | |FIrrelevant
  |  |
  |   subs puniverses

and   subs p

strarray

 fiv=

let java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
let set_ntrl v = v.java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 14

(* Could issue a warning if no is still Red, pointing out that we loose<mark;v1.<- t
   sharing. *)

let update v1 mark t =
           m,java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 47

type  var_irrelevant : constr pexistential  if  info
| of '
| EvarUndefined of Evar.t * '
  evar_expand = (fun _ -> assemk_irrelevant,skip_irrelevant_stack stk

typeqvar_irrelevant= (un q -java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
falsejava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
   :Evar. *constr  java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 47
  evar_irrelevant : constr pexistential -> bool;
  qvar_irrelevant : Sorts java.lang.StringIndexOutOfBoundsException: Range [50, 38) out of bounds for length 50
}

let default_evar_handler env = {
  = ( _ >assert )
  evar_repack  i_relevancesjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 9
  evar_irrelevant = (fun _let info_flags info = info.i_flags
  let info_env info  = infoi..i_env
       info_univs info = info.i_cache.i_univs
      false);
 |FCoFix,lna,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

(** Reduction cache *)
type infos_cache = {
  i_env : env;
  i_sigma relevances=
  ol
  _:UGrapht;
  i_mode : mode;
}

type clos_infos = {
  java.lang.StringIndexOutOfBoundsException: Range [11, 9) out of bounds for length 17
  i_relevances :Sorts.relevance Range.t;
  i_cache : java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

java.lang.StringIndexOutOfBoundsException: Range [72, 3) out of bounds for length 72
let info_env info t'( 
let info_univs java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 42

let    =
  { infos with i_relevances = if Int.equal (Array.length v) 0

let push_relevancesinfos  java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
  { infos with
     _ Zproj_|Zfix |Zshift _ _|Zprimitive_ :_ |  java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
      java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
_elevances}

let set_info_relevances info r = { info with i_relevances = r }

match (n,s) with

(**********************************************************************)
(* The type of (machine) stacks (= lambda-bar-calculus' contexts)     *),) -> s
pe '
a,Zshift):)>Zshift(n+):s

type stack_member =
  | Zapp of fconstr array
  trec stack_args_size = function
  | Zapp : s(match[arning -"  stkwith
  |Zshift():s - s
 of(op,_, as c,, |( _ |Zproj_|Zfix_ _::_|[ - 
       (* operator, constr def, arguments already seen (in rev order), next arguments *)
  | Zshift of int
  | Zupdate of fconstr

and stack stack_memberlist

let lft_fconstralways  new_argsm:rargsn injava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
end_stack vs java.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22
  if     |FRel >{markft
  match java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 14
  | Zapp l {mark           let  args = r with
  ZcaseT _|  _ |    Zshift _| _|java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 23
    Zapp v :: s

(* Collapse the shifts in the stack *)mark=Cstr;term           | [-]
let zshift n    | FLIFT(km  (nk) m
  match(,s) with
      (0,     FLOCKED -assert           [; bc]  |;b |]
    | (_,Zshift(k)::s) -> Zshift(n+k)::s
    | (_,(ZcaseT _ | Zproj _ | Zfix _           | [; ;c ]->[|; ;b;a|     FFlex(RelKey )|  _   _   FProj _  FCaseT _|FCaseInvert  | _

let rec stack_args_size = function
  | Zapp v :: s -> let lift_fconstr k f =
  |  if.qual  0 then else f
           java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 76
  | (ZcaseT_| Zproj _| Zfix _  Zprimitive_):: _ [             Some - infopat_state m 

let usubs_shft (n,    |Inlnmt >lift_fconstr|None > assert

(* Lifting. Preserves sharing (useful only for cell with norm=Red).    |Inr,one) >{Ntrl; term= FRel k}
   lft_fconstr  anew cell, while   
   when   when  (kp){mark=Red;=Rp}
let rec lft_fconstr n ft =
  match ft.term java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 0
|((,[||(java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 105
    |FReli >{markfth  function
>
| ,)-
{=;=(x,(  else ,. u'
    | FCoFix(cfxlet  _u)
if UVarsjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 37

    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    |
 |  |java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 88
      |   | FLambda(njava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 16
let lift_fconstr k f =
if   if Intjava.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 76

let clos_rel e i =
  match expand_rel i 
java.lang.StringIndexOutOfBoundsException: Range [55, 3) out of bounds for length 55
-{= termFjava.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 46
    | Inr(k,Some p e ijava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 22
        lift_fconstr (k        red_ret mark=Cstr;term FInt }

(* since the head may be reducible, we might introduce lifts of 0 *)
let      in
  let rec strip_rec depth = function
     (k)::s ->  d+) java.lang.StringIndexOutOfBoundsException: Range [43, 44) out of bounds for length 43
    Zupdatem::s->
        (* Be sure to create a new cell otherwise sharing would be
           lost by the let injectu c u = mk_clos (subs_id 0, u) c
        let c=injectucUVars.nstancee
        (** The stack contains [Zupdate] marks only if in sharing mode *)  
        java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 28
        shortcut_irrelevant r
|(   |Zfix _ | Zapp _ | Zprimitive _) :: _ | []) as stk -> zshift depth stk
  in
  strip_recjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

(* Put an update mark in the stack, only if needed *)
let zupdate info m s =
  let share      NamedDecl.LocalDef (_, c, _) -> inject c
  if share && is_red m.mark then
    java.lang.StringIndexOutOfBoundsException: Range [26, 7) out of bounds for length 33
    let _ = m.term <- FLOCKED java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
    Zupdate(m)::s'    |Def b- injectu bu
   s

(* We use empty as a special identity value, if we don't check
   subst_instance_instance will raise array out of bounds.|Primitive  -raise(otEvaluableConst( (,p))
let usubst_instance (,u u =
  if   |RedPatternNil b -java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  else UVars.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

let usubst_punivs (_,u) (v,u'
 as origtry
  UVars. u orig
  java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 0

let usubst_sort (_,u) s =
        match ef kni:' _- _ >pat_state:  -_ -_ -'a =
  else UVars.subst_instance_sortlet     in

let usubst_relevance (_,u) r =
  if UVarsI.java.lang.StringIndexOutOfBoundsException: Range [35, 28) out of bounds for length 37
  else UVars.subst_instance_relevance u r

let knr info tabshortcut_irrelevant  (.get_relevance)
java.lang.StringIndexOutOfBoundsException: Range [31, 28) out of bounds for length 31
     let r' 
  if r =  |RelDecl  >raise Not_found

bdaenv ijava.lang.StringIndexOutOfBoundsException: Range [10, 11) out of bounds for length 10
  let (rvars,t') = Term.decompose_lambda  let (rvars,t') = Term.decompose_lambda 
FLambda(.length rvars List.ev t,java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 53

let (eu)= nfo tab pat_state ht s

let usubs_liftn         letts=RedFlags.red_transparent info.i_flags in

(* t must be a FLambda and binding list cannot be empty *)
let java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   [@java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 41
,,)->
    (usubst_binder e na,clos_fun e ty,java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 12
  |[|] >None|(,) -
    ( cb=java.lang.StringIndexOutOfBoundsException: Range [37, 32) out of bounds for length 43
          let ts =RedFlags. info.i

(* Optimization: do not enclose variables in a closure.
   Makes variable access much faster *)
k_clos(e:usubs) t =
  match         ifTransparentState.is_transparent_constant ts cst then match cb.const_body with
    | Rel i ->         | Undef _ | Def _| OpaqueDef _|Primitive _ ->
    | let mask=match cbconst_body_code 
    | Const c ->          | None |Some(.BCalias _ | Vmemitcodes.BCconstant) -> [||]
    |            (Vmemitcodes.Cdefined (mask _, _ -mask
      let s          in
      { = ;term = (s) java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
om}
    | Ind kn -> {mark 
    | Construct kn -> {mark
    | Int i -> {mark = let subst_context env ctx 
    |v'
=push_relevance'tabusubs_lift e)vin
    | String s -> {mark = Cstr; term = FString s}
    | (CoFix_|Lambda _|Fix _| subst_instance_context (snd env) ctx
        {mark = Red; term = FCLOS(t,e)}

let injectu c  else

let inject c = injectu c       java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 37

 ={ mark = Cstr term=FIrrelevant }

let is_irrelevant info r = match info..i_mode with
|   match List.rev ctx with
| Conversion -> match r with
  | Sorts.| [ -t
  | Sorts.RelevanceVar|LocalAssum ( ):ctx -
  |       let,=.(java.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 112

(************************************************************************)l assums  (,ty):assums in

type table_val = (fconstr * bool array, Empty.t, java.lang.StringIndexOutOfBoundsException: Range [0, 54) out of bounds for length 22

module Table : sig
  type      (ubs_idMeta |Sort_|Ind _  Construct_|nt_Float  |String _>
  val create : unit -> t
  val lookup : clos_infos -> t -> table_key -> table_val
end = struct
  module Table = Hashtbl. java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 64
    type t = table_key
java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
    let hash = hash_table_key (fun (java.lang.StringIndexOutOfBoundsException: Range [2, 37) out of bounds for length 2
  )

  ype t =java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 28

  let create () = Table.let args = if CArrayis_emptyargs0 then args  .a ijava.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83

  exception_-

  s info  
    if is_irrelevant infom=java.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 44

  let assoc_defined d =
    match d with
    | (_,
    | NamedDecl.LocalAssum (_, _) -> raise Not_found

  let constant_value_in u = function
    | |,u,pms,p br,e:s->
     java.lang.StringIndexOutOfBoundsException: Range [11, 1) out of bounds for length 50
    | Undef _ -> raise        letmark  .java.lang.StringIndexOutOfBoundsException: Range [34, 32) out of bounds for length 36
    | p-raise NotEvaluableConst ( (,))java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
    | _ ;termProjPp,,)s
    (*  Should already be dealt with *)

  let value_of info ref =
    try
      let env = info.i_cachestack[m] s )
      match ref with
      ||Zshiftn):sjava.lang.StringIndexOutOfBoundsException: Range [19, 10) out of bounds for length 10
              e, info rvtys)=List. fold(e,,[ tysin
        let d =
          Rangeget(java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 71
           ) = update rfm.ark .term in
        in
        shortcut_irrelevant info (RelDecl.get_relevance d);
        let body =
          match d with
          | RelDecl.LocalAssum _ -> raise Not_found
          | RelDecl.LocalDef (_, t, _) ->       letargs       FLetIn(,,b,fe)-
        in
        let f = {ark = Red;  = FFlex (ConstKey c)} in
      | VarKey id ->
        let def = Environ.lookup_named      (* don't need to mkFApp because not a constructor *)
        shortcut_irrelevant info
          (binder_relevance (NamedDecl.get_annot def));
         = RedFlags.          letn=usubst_binder  e iin
        if TransparentState.is_transparent_variable ts id then
          Def (assoc_defined java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
        else
          raise Not_found
      | ConstKey (cst,u) ->
        let cb = lookup_constant cst env in
        shortcut_irrelevant info (UVars.subst_instance_relevance u cb.const_relevance);
        let ts = RedFlags.red_transparent info.i_flags in
        if.is_transparent_constant ts cst then match cb.const_body with
        | Undef _ | Def _ | OpaqueDef _ | Primitive _ ->
           with
          | None | Some (Vmemitcodes.java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 30
           (* The assertions in the functions below are granted because they are
          in
          Def (constant_value_incalled only    alet rng = klt (push_relevance usubs_lift )rng 
        | Symbol b ->
          let r = match lookup_rewrite_rules cst env with
          | exception Not_found -> assert false
            > r
          in
          raise ((strip_update_shift_app),a fix get_nth_arg) or 
        else
          raise Not_found
    with
    | Irrelevant ->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  (IsPrimitive (_u,op)) (* Const *) -> Primitive op
    | NotEvaluableConst (HasRules (u let infobd   infoi
    | Not_found
    | NotEvaluableConst _ (* Const *) -> Undef None

  let lookupjava.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 32
     java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 44
    let v = value_of info ref in
    Table.add tab ref v; v
end

type clos_tab = Table.t

let create_tab = | Zupdate(m)::s >

(************************************************************************)

(** Hand-unrolling of the map function to bypass the call to the generic array( = mh.ark .term in
    allocation *)
let mk_clos_vect env v = match v        strip_rec  s
|[|] >[|java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
| [|v0|] -> [|mk_clos env v0|]
|[v0 v1|(,stk)
| [|v0; v1; v2|] -> [|mk_clos env v0; mk_clos env v1; java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 4
| [|v0; v1; v2; v3|] ->
  [|mk_clos env v0java.lang.StringIndexOutOfBoundsException: Range [57, 58) out of bounds for length 57
| v -> Array.Fun1.map mk_clos env v

let rec subst_constr (subst,usubst as e) c =
  let  =Vars.java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 61
   4 ind cwith
| Rel i ->
  begin     args :  -
  | Inl (k, lazy v) -> Vars.lift_substituend  strip_recZapp args :rstk)(mkFApp  argsargs  s
  | Inr (    | Zupd(m:s-
  end
|Const _   _   _ Sort_- subst_instance_constr  c
| Case (ci, u, pms, p, iv, discr, br) ->
  let '
 usubst_instance
  let
  Constr    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
|(uelemsdef,y -
  let u'         let () = update r Cstr (FLambda(n,tys,f,e)) in
  let c = if u == u'
 then cget_args tys f s
  Constr.map_with_binders|Zshiftk::s >
| _ ->
  Constrmap_with_bindersusubs_liftsubst_constr c

let subst_context e ctx =
  let open Context.Rel.Declaration in
  let rec subst_context ctx = match ctx with
   |        (p, rkl tab c
  | LocalAssum (na, ty) :        else n<najava.lang.StringIndexOutOfBoundsException: Range [27, 23) out of bounds for length 48
          | FArray (u, a, ty) ->
    let  =ety in
    usubs_lift e, LocalAssum java.lang.StringIndexOutOfBoundsException: Range [31, 32) out of bounds for length 31
  | LocalDef (na, ty,          get_argsn-na)etys f usubs_consn l na java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    let e, ctx = subst_context ctx in
    let ty = ty in
    let bdy = subst_constr e bdy in
    usubs_lift e, LocalDef (na, ty,
in
  snd @@ subst_context ctx

(* The inverse of mk_clos: move back to constr *)
let rec to_constr lfts v =
   |Zshift _|Zupdate _ |        mkArray (u, java.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 31
    | FRel i -> mkRel (reloc_rel i lfts)
    | FFlex (RelKey p) -> mkRel (reloc_rel p lfts)
    | FFlex (VarKey x) -> mkVar x
    | FAtom c      e  FConstruct cargs-> kApp(,Array. (kl tab args
    | FFlex (ConstKey op) -> mkConstU op
    | FInd op -> mkIndU op
    | FConstruct (op,args) -> mkApp (mkConstructU op, Array.Fun1.map to_constr lfts args)
    | FCaseT (ci, u, pms, p, c, ve, env) ->
      to_constr_case lfts ciupms p NoInvert c ve env
    | FCaseInvert ci u, pms p, indicesc,ve,env)->
      let iv = CaseInvert {indices=Array.Fun1.map to_constr lfts indices} in
      to_constr_case lfts ci u pms p iv c ve env
    | FFix ((op,(lna,tys,bds)) as      |FApp |FCaseT   java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 70
      if is_subs_id (fst e) && is_lift_id lfts then
        subst_instance_constr (snd e) (mkFix fx)
      else
in
        let subs_ty = comp_subs[1 [|]java.lang.StringIndexOutOfBoundsException: Range [28, 29) out of bounds for length 28
                
        let
        let tys = Array.Fun1.let rec skip_native_args rargs n =
        Array.Fun1.mapjava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 60
        mkFix||FIrrelevant      
    | FCoFix ((op,(lna,tys,bds)) as cfx, e) ->
      if is_subs_id (fst e) &if      
        subst_instance_constr (snd )java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 45
      else
        let n = Array.length bds in
        let   let rec get_args >m
        =  e | : >
        let lna = Arrayjava.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 64
        let tys = Array.Fun1.map java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 24
        let bds = Array.Fun1.map subst_constr  (java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 44
        mkCoFix (op, (lna, tys, bds))
      fv      let e = usu Array.length ) java.lang.StringIndexOutOfBoundsException: Range [49, 50) out of bounds for length 49
        mkApp (to_constr lfts f|rnargs, ] -
               .un1map(  info tabe )
    | FProj (p,r,c) ->
            

    | FLambda (len, tys, f, e) -(kip_native_args [ List.
      if is_subs_id (fst e) && is_lift_id lfts then
        subst_instance_constr (snd e) (Term.compose_lam (List.rev tys) f)
      
        let subs =          
        tys  . (na c 
            usubst_binder subs najava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 9
            tys

        let f = subst_constrstrip_rec  depthkargsZproj,s-
        Term.compose_lam (List.rev tys) f
        mkProj (Projection.ptrue, r,m java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
      if is_subs_id (fst e)instrip_rec [ mark= zip_term info t
        mkProd (n, to_constr lfts t, subst_instance_constr (snd e) c)
      else
          matchop  with
        mkProd (usubst_binder subs' n,
                    ab ( java.lang.StringIndexOutOfBoundsException: Range [49, 44) out of bounds for length 66
                subst_constr( '
)c)
     (,bjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 27
      =comp_subs(n) >
      mkLetIn (usubst_binder subs n,
               lftsb,
               to_constr lfts t,
               subst_constr subs f)
     ev,args env,repack) ->
      let subs = comp_subs lfts env in
      repack (evzip_term   
    | FLIFT (k,a) -> to_constrjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    | FInt i ->
       Constr.mkInt i
    |FFloat -
        Constr.mkFloat f
    | FString s ->
        Constr.mkString s


      let def elsejava.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 27
      let t =      sub    let=java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 62
          to_constr  >assert false
      in
      let ty java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      mkArray(u, t, let java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 53

    | FCLOS java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
       java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 53
        java.lang.StringIndexOutOfBoundsException: Range [34, 29) out of bounds for length 41

        let subs


 !.);(java.lang.StringIndexOutOfBoundsException: Range [69, 68) out of bounds for length 83
    |java.lang.StringIndexOutOfBoundsException: Range [14, 12) out of bounds for length 30

and to_constr_caselfts java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 4
  let subs = comp_subs lfts env in
  let r = usubst_relevance subs r 
  if is_subs_id (fstlet get_branchinfos cinorm_term nfotab info tabet
    mkCase (ci, usubst_instance subs u, pms, (p,r), iv, to_constr   let ((java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  else
    let f_ctx (nas, c) =
          
      let args =drop_parameters.ci_nparctermin
      ,)
    in
    java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
            usubst_instance subs u,
            Array.map (environment to know the      every java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 0
            (f_ctx     let=usubs_consvargsein
            iv,
            
            Array.map f_ctx ve)


letk = infos tab  

(* This function defines the correspondence between constr and
 
   then we directly return the constr to avoid possibly huge
   reallocation. *)

let term_of_fconstr c = to_constr el_id c

let subst_context env ctx =if ( = (tx, _=mipind_nf_lc(iin
  if is_subs_id (    let ctx, _ = List mind_consnrealdecls( ctx
    subst_instance_context    java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 72
  else
    let subs = comp_subs el_id env      >]
     ctx

let it_mkLambda_or_LetIn infos ctx t =
  let l =let ans=push(red  java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 66
xtRel. let=Optiondefault(nvironuniverses)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
  |RelDeclLocalDef(_,,_)  ctxlet=(i_envjava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 76
  |[ - 
  | LocalAssum (n, ty) :: ctx ->
      p_until(function LocalAssum (n, ty) -> Some (n, ty) | LocalDef _ -> None) ctx in
       assums=(n, ):: assumsin
      { term = FLambda( s = Array.rev_of_list
  | LocalDef _ ::      lete=usubs_consvsjava.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 40
      mk_clos(ubs_idl,UVars..java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0

(* fstrong applies unfreeze_fun recursively on the (freeze) term and
 * yieldsletcreate_conv_infos =java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 6
 * FCLOS term.
let rec fstrong unfreeze_fun lfts v =
  to conversion    java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 76
*)


let mkFApp h args =
  if CArray.the constructor term [c]
  else java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
    | FConstruct (c, args0) ->
      =ifCArray.s_empty  thenargs java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 32
      {mark=Cstr; *)
    | _ ->
      (* don't bother collapsing FApp nodes *)
      {mark=neutr h.mark; term=FApp(h,args)}

let reclet openDeclarations in
   stkjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 13
    | Zapp args :: s -> zip (mkFApp m args if(.mind_finite==BiFinite)
    | ZcaseT(ci, u, pms, p, br matchDeclareops.inductive_make_projectionsmib with
          unfold_ref_with_args infos tab fl v =
        let mark = *Given aanda   thecorresponding
       zip{ark;termt java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
    | Zproj  FCLOS(ixFi{: T0. Fn-=Tn1} )
        let mark = (neutr m.mark) in
        zip {mark; term    >(S.FCLOSF0,S)  ..FCLOS(1S,Ti)
    | Zfix(fx,par)::s ->
        zip fx (par @ append_stack [|m|] s)
    | Zshift(n)::s ->
        (thisbody, ,nfix) =
    | Zupdate(rf)::s ->
      (** The stack contains [Zupdate] marks only if in sharing mode *)with
        ) =updaterf .mark .termin
        zip rf          (.()
    |           fun  >{   Cstr;
      let args = List.rev_append rargstjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 60
      let f = {mark = Red; term FCoFix(i(_ rdcl)),nv) >
      (* don't need to mkFApp because not a constructor *)
zip{=neutrmmark);term   (,oargs) 

let fapp_stack mstk zip  java.lang.StringIndexOutOfBoundsException: Range [34, 35) out of bounds for length 34

let term_of_processletrec mk_subs i 

(*********************************************************************)

(* The assertions in the functions below are granted because they are
   java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
   s,a( an abstraction
   (strip_update_shift, through get_arg). *)


(* when we don't need to return the depth & initial part of the stack,
   with only the rebuilt term sufficing
   (typically head is a fconstruct so we return a fconstruct with added args) *)

let strip_update_shift_absorb_app head stk =
  let rec strip_rec h = function
    | (******
        strip_rec (* Reduction of Native operators                                        *)
    | (Zapp args :: s) ->
        elem =fconstr
    | Zupdate(m)    =java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
      (** The stack contains [Zupdate] marks only if in sharing mode *)

        let ()  l  match ocaml.""with   - c| _- assertfalsein
        strip_rec m s
    | ((ZcaseT _ |       java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
      
      (h, stk)

  strip_rec head stk

(* optimised for the case where there are no shifts... *)
let strip_update_shift_app_red head stk =
  lets depth  function
ft( as ejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        strip_rec (ejava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 45
    | (ZappRedPattern.tch_symbolknred (infos_with_redsinfos ) p:edPattern. Yes)   r v
        strip_rec (Zapp java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 25
    | Zupdate(m)::s ->
      (** The stack contains [Zupdate] marks only if in sharing mode *)
        let () = update m h.mark h.term in
        strip_rec rstk m depth s
|_- assert false
      (* depth and rstk only matter for cofix *)
      (depth,h,List.    letget_parray ()e=
  in
  strip_rec [] head 0 stk

 head  java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  assert 
  strip_update_shift_app_red head stack

let get_nth_arg head n stk =
  assert (not (is_red head.mark));
  let rec strip_rec rstk h n = function
    | Zshift(k) as e :: s ->
        strip_rec (e::rstk) (lift_fconstr k h) n s
    | Zapp args::s' ->
        let q = Array.length args in
        if n >= q
        then
          strip_rec (Zapp args::rstk) (mkFApp h args) (n-q) s'
        else
          let bef = Array.sub args 0 n in
aft =.1 q--1 
          let stk' =
            List.rev java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          (Some (stk', args.(n)), append_stack java.lang.StringIndexOutOfBoundsException: Range [0, 50) out of bounds for length 31
    | Zupdate(m)::s ->
        (** The stack contains [Zupdate] mark only if in sharing mode *)
        let () = update m h.mark h.term in
        strip_rec rstk m n s
    | ((ZcaseT _ | Zproj _ | Zfix _ | Zprimitive _)
java.lang.StringIndexOutOfBoundsException: Range [21, 7) out of bounds for length 32

let letjava.lang.StringIndexOutOfBoundsException: Range [25, 17) out of bounds for length 25

let rec subs_consn v i n s =
  if Int.equal i n then s
  else subs_consn v (i + 1) n (subs_cons v.(i) s)

let usubs_consn v i n s = on_fst (subs_consn v i n) s

let usubs_consv v s =
  usubs_consn v 0 (Array.length    let fC1 =ref dummy

(* Beta reduction: look for an applied argument in the stack.     java.lang.StringIndexOutOfBoundsException: Range [25, 18) out of bounds for length 26
   Since the encountered update marks are java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 30
let rec get_args n tys f e = function
    |java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 23
        (** The stack contains [Zupdate] mark only if in sharing mode *) java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 38
        let () =  let defined_pair = java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 32
         n tys f  s
    | Zshift k :: s ->
        get_args n tys f (usubs_shft (k,e)) s
    | Zapp l :
        let na =r  =
        if n == na      Retroknowledge.retro_pairwith
        else if n < na       Somec -java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
          let eargs =      | >java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 37
          (Inl (usubs_consn l fEq =djava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
        else (* more lambdas *)
          let etys = List.skipn let  = ref dummy
          get_args (n-na) etys f (usubs_consn l 0 na e) s
    | ((match retro.Retroknowledge.retro_cmp with
({;=ntys,f,e)},stkjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

(* Eta expansion: add a reference to implicit surrounding lambda at end of stack *)
let rec eta_expand_stack info fLt := mk_construct cLt;
  | (Zapp _ | Zfix _         java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 32
java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 59
: java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 37
  | []
        java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 33
      is_irrelevant info . m
      else {mark = Ntrl; term = 
    in
; Zapp |]

(* Get the arguments of a native operator *)
 skip_native_argsnargs =
  match nargs with
| kd a :  >
      if kd = CPrimitives.Kwhnf then rargs, nargs
            skip_native_args(a:rargs)nargs'
  | [] -> rargs, []

let get_native_args op c        defined_f_cmp: truejava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
  let kargs = CPrimitives.kind op in
  let rec get_args rnargs kargs args =
    match kargs, args with
    | kd::kargs, a::args -java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 56
    ,_ >rnargs,kargs,argsin
  let rec strip_rec rnargs h depth kargs = function
    | Zshift k :: s ->
 (java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 69
        (lift_fconstr k h) (depth+k) kargs s
    | Zapp argsjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 28
      t_args java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 65
        | rnargs, [], [] ->
          (skip_native_args [] ( java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 25
        | assert (!defined_carry && !defined_int)
          (skip_native_args [] (List.rev rnargs),
           Zapp (Array.of_list eargs) :: s')
        | rnargs,    let check_pairenv =
          (* head of h is not constructor -> no need to mkFApp *)
          strip_rec rnargs {mark = h.mark;term=FApp(h, args)} depth kargs s'
      end
    | Zupdate(m) :: s ->
      let () = update java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      strip_rec rnargs m depth  kargs s
     _   _ |Zproj_|Zfix) :   ]-
  in strip_rec [] {mark = Red; term = FFlex      (defined_f_cmp

let get_native_args1 op c java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 27
  java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 31
  | ((rargs, (kd,a):: nargs), stk) ->
      assert (kd = CPrimitives.Kwhnf);
      (rargs, a, nargs, stk)
  |       (defined_array

let check_native_args op stk =
 CPrimitives.  
  let rargs = stack_args_size stk java.lang.StringIndexOutOfBoundsException: Range [0, 36) out of bounds for length 20
  nargs <= rargs


java.lang.StringIndexOutOfBoundsException: Range [29, 23) out of bounds for length 62
  | FConstruct (_, args) ->
    let q = Array.length args in
    if ;
    else if q  java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 51
    else .java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 33
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21

java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 25
  try try_drop_parameters n m
  with  -
  (* we know that n < stack_args_size(argstk) (if well-typed term) *)
  anomaly (Pp.str l mkLt env =

let inductive_subst mib u pms =
  let rec mk_pms i ctx = match ctx with
  | [] -> subs_id 0
  | RelDecl.LocalAssum _ :: ctx ->
    ejava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
    java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
  | RelDecl.LocalDef (_, c, _) :: env;
    let subs = mk_pms i       
    subs_cons (mk_clos (subs,u) c)     java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 19
  in
  mk_pms (Array.length pms - 1)java.lang.StringIndexOutOfBoundsException: Range [18, 13) out of bounds for length 19

(* Iota-reduction: feed the arguments of the constructor to the branch *)
let mkFGtenv =
  let ((ind java.lang.StringIndexOutOfBoundsException: Range [22, 17) out of bounds for length 22
    | FConstruct (c, _) -> c
    | _ -> assert false
  in
  let i = c -!
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  let (_nas, br) = br.(java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
  if Int.equal ci.ci_cstr_ndecls.(i) ci.ci_cstr_nargs.(i) then
    (* No let-bindings in the constructor, we don't have to fetch the
      environment to know the value of the branch. *)
    let e = usubs_consv 
    (br, e)
  else
    (* The constructor contains let-bindings, but they are not physically
        present in the match, so we fetch them in the environment. *)
    let let mkNSubn=
    let mib = Environ.lookup_mind 
    let   mind_packets.(snd.(sndind in
    let (ctx, _) = mip.mind_nf_lc.(i) in
    let ctx, _ = List.    let mkPZero env=
    let ind_subst = inductive_subst mib u (Array.map (mk_clos e) pms) in
    let rec push i e = function
    | [] -> []
     _:: -
      let ans = push (pred i) e ctx in
      args.(i) :: ans
    | RelDecl.LocalDef (_, b, _) :: ctx ->
      let ans = push i e ctx in
      let b = subst_instance_constr!fPInf
      let s =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      lete = s  
      let v = mk_clos e b in
      v :: ans
    in
    let ext = push (Array.length args - 1)     let e=
    (br, usubs_consv (Array.rev_of_list ext) e)

(** [eta_expand_ind_stack env ind c s t] computes stacks corresponding
    to the conversion of the eta expansion      check_f_class ;
    of       !NaN
    s.
    @assumes [t]   java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 28
    the c
    @raise Not_found if the inductive is not a primitive record, or if the
    java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 5
 *)
let  (indu  f s)=
  let open Declarations in
  let mib = lookup_mind (fst ind) env in
  (* disallow eta-exp for non-primitive records *) skip_irrelevant_stack stk=match stk 
  if not (mib.java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 10
  match Declareops.inductive_make_projectionsZ |java.lang.StringIndexOutOfBoundsException: Range [19, 17) out of bounds for length 28
  | Some projs ->
    (* (Construct, pars1 .. parsm :: arg1...argn :: []) ~= (f, s') ->
..argn ~= (proj1 t...projn t) where t = zip (f,s') *)
    let pars = mib.Declarations.mind_nparams in
    let right = fapp_stack (f|  :_-assert false (* no irrelevant primitives so far *)
   (** Try to drop the params, might fail on partially applied constructors. *)
    let argss = try_drop_parameters pars m in
    let () = if not @@ Int.equal (Array.length projs) (  let ( =updatemmk_irrelevant.mark mk_irrelevant.term in
      then raise Not_found (* partially applied constructor (missing non-param arguments) *)
    in
    let hstack = Array.map (fun (p,r) ->
        { mark = Redlet  infos(_, =
            FProj Projection.ptrue,UVars.ubst_instance_relevance r,right)}java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
        projs

    [Zapp argss], [Zapp hstack]
  | Noneatom or  subterm  mayproduce aredexabstraction,

(* Iota reduction: expansion of a fixpoint.
, returns thecorresponding
 * fixpoint body, and the substitution in 
 * evaluated: its first variables are the fixpoint java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 19
 *
 * FCLOS(fix Fi {F0 := T0      FCLOSt,)- i  (im )
 *    -> (S     -  
 *    (,b>knhinfo a (append_stack b (zupdate  mstk)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
(* does not deal with FLIFT *)
let let r' = usubst_relevusubst_relevance e r in
  let (thisbody, make_body, env, nfix) =
    match [@ocaml.warning "
-4java.lang.StringIndexOutOfBoundsException: Range [30, 22) out of bounds for length 35
      | FFix (((reci,i),        java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 64
          (bds.(i) |FFix((,n,( ,_) ) -
      if java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 80
                       term = FFix ((( skip_irrelevant_stackstk
           else
      | FCoFix  (atch et_nth_arg m.n with
          (bds.)
           (fun| java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 38
                       term = FCoFix ((j,rdcl),env) }),
           env, Array.length bds)
      | _ -> | Some s  cs :: zupdate info m stk))
  in
  let rec mk_subs   FConstruct > strip_update_shift_absorb_appmstk
    if Int.equal i nfix then env
    else mk_subs java.lang.StringIndexOutOfBoundsException: Range [23, 21) out of bounds for length 58
  in
  (on_fst (fun env -> java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 16

let unfold_projection info p r =
  if red_projection info.i_flags p
  then
    Some (Zproj (Projection.repr p, r))
  else None

(************************************************************************)
(* Reduction of Native operators                                        *)

open Primred

module java.lang.StringIndexOutOfBoundsException: Range [38, 18) out of bounds for length 42
  struct
    type elem = fconstr
    type args = fconstr array
    type evd = unit
    type uinstance = UVars.Instance.t

    let mk_construct c =
      (* All constructors used in primitive functions are relevant *)Proj pr, )-
      { mark = Cstr; term = java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

    let get = Array.get

    let get_int () e =
      match [@ocaml.warning "-4"] e.term with
      | FInt i -> i
      | _ -> assert false

    let get_float () e =
      match [@ocaml.warning "-4"] e.term with
      | FFloat f -> f
      | _ -> assert false

    let get_string () e =
      match [@ocaml.warning "-4"] e.term with
      | FString s -> s
      | _ -> assert false

    let get_parray () e =
      match [@ocaml.warning "-4"] e.term with
      | FArray (_u,t,_ty) -> t
      | _ -> assert false

    let dummy =     Lambda  >{mark =;  et} stk

    let current_retro = ref Retroknowledge.empty
    let defined_int = ref false
    let   dummy

    java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 24
      matchretro.retro_int63 with
      | Some c ->
        defined_int := true;
        fint := { mark = Ntrl; term = FFlex (ConstKey (UVars.in_punivs c)) }
      | None -> defined_int := false

    let defined_float = ref false
    let ffloat = ref dummy

    let init_float retro =
      match retro.Retroknowledge.retro_float64 with
      | Some c ->
        java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 30
        ffloat := { mark = Ntrl; term = FFlex (ConstKey (UVars.in_punivsinfoi_cacheimode   &info..evar_irrelevantev 
      | None -> defined_float := false

    let defined_string = ref false
    let fstring = ref dummy

    let init_string retro =
      match retro.Retroknowledge.retro_string with
      | Some c ->
                  (k_irrelevant infostk
        java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
      | None -> {  =   =FEvar evk   )} stk

    let defined_bool = ref false
    let ftrue = ref dummy
    let ffalse = ref dummy

    let init_bool retro =
      match retro.Retroknowledge.retro_bool with
      | Some (ct,cf) ->
        defined_bool := true;
        ftrue := mk_construct ct;
        ffalse := mk_construct cf;
      | None -> defined_bool :=false

    let defined_carry = ref false
    let fC0 = ref dummy
    let fC1 = ref dummy

    let init_carry retro =
      match retro.Retroknowledge.retro_carry with
      | Some(c0,c1) ->
        defined_carry := true;
        fC0 := mk_construct c0;
        fC1 := mk_construct c1;
      | None -> defined_carry := false

    let defined_pair = ref false
    let fPair = ref dummy

    let       letlen=Array.tjava.lang.StringIndexOutOfBoundsException: Range [33, 31) out of bounds for length 33
      match retro.Retroknowledge.retro_pair with
      | Some c ->
        defined_pair := true;
        fPair := mk_construct c;
      | None -> defined_pair :mk_clos e t.(i)) (mk_clos e def) in

    let defined_cmp = ref false
    let fEq = ref dummy
    let fLt = ref dummy
    let fGt = ref dummy
    let fcmp = ref dummy

    let init_cmp       let term = FArray term =FArray(,tty)in
      matchRetroknowledge.retro_cmpwith
      | Some (cEq, cLt, cGt) ->
        defined_cmp := true;
        fEq := mk_construct cEq;
        fLt := mk_construct ;
        fGt := mk_construct cGt;
         (icmp,_  cEqjava.lang.StringIndexOutOfBoundsException: Range [30, 31) out of bounds for length 30
        fcmp := {java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      | None -> defined_cmp := false

    let defined_f_cmp = ref false
    let fFEq = ref dummy
    letfFLt =ref dummy
    fFGt  ref dummy
    let fFNotComparable = ref dummy

    let init_f_cmp retro =
      match retro.Retroknowledge.retro_f_cmp with
|Some (cFEq java.lang.StringIndexOutOfBoundsException: Range [51, 47) out of bounds for length 51
        : true
        fFEq := mk_construct cFEq;
        fFLt := mk_construct cFLt;
        fFGt := mk_construct cFGt;
        fFNotComparable :=
      | None ->type a patstate=(fconstr,stack,rel_context a depth

    let defined_f_class = refval :(a 'patstate) >clos_infos >Table. -
    let fPNormal   
    let fNNormal = ref dummy
    let fPSubn = ref dummy
    let fNSubn = ref dummy
    let fPZero = ref dummy
    let fNZero = ref dummy
     fPInf=ref ummy
    let java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
    let fNaN

    let init_f_class type'
= 
      match   cjava.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 66
      | Some (cPNormal, cNNormal, cPSubn, java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 1
              cPInf,   >
        defined_f_class := true;
        java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
        fNNormal := mk_construct cNNormal;
        fPSubn := mk_construct cPSubn;
        fNSubn := mk_construct cNSubn;
        fPZero := mk_construct cPZero;
        =java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 38
        fPInf   >initn fun i- (.unsafe_get a))
        fNInf    asp- Arraymake  
        fNaN
      | None -> defined_f_class :=  letfold_leftf a=function Check - fa  Ignore> a

    let defined_array = java.lang.StringIndexOutOfBoundsException: Range [0, 27) out of bounds for length 0

    let init_array retro =
      defined_array := Option.has_some retro.Retroknowledge.retro_array

    let init env =
      current_retro := Environ.retroknowledge env;
      init_int !  |LocStartof elims: pattern_elimination list statusarray;context: 'context; head:'constr stack: 'stack; next: ('constr, 'stack, 'context) state_next }
      init_float !current_retro;
      init_string !current_retro;
       !java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
      init_carry !current_retro;
      init_pair !current_retro;
      | Some  rhs->
      init_f_cmp !current_retro java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 68
       !urrent_retro;
      init_array !current_retro

    let check_env env =
      if not (!current_retro == Environ.retroknowledge env) then init env

    let check_int         | Nil Yes -> Nil es -> Some m',stackjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
      check_env env;
      rt !defined_int)

    let check_float env =
      check_env env;
      assert (!defined_float)

    letcheck_string env=
      check_env env;
      assert (!| LocStart { elims; context stack;next } >

    let check_bool env =
      java.lang.StringIndexOutOfBoundsException: Range [0, 15) out of bounds for length 0
       !efined_bool)

    let check_carry env =
      heck_env env;
      assert (!| LocArg { next; _ } -> match_kill info  ~next

    let check_pair env =
      check_env env;
      assert (defined_pair && !defined_int)

    let check_cmp env =
      check_env env;
      assert (!defined_cmp)

lcheck_f_cmp  =
      check_env env;
assert (defined_f_cmp

    let check_f_class env =
java.lang.StringIndexOutOfBoundsException: Range [19, 15) out of bounds for length 20
      assert (!defined_f_class)

    let check_array env =
      check_env env;
      assert (!defined_array)

     envi java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
      check_int env;
      { mark = Cstr; term = p java.lang.StringIndexOutOfBoundsException: Range [53, 51) out of bounds for length 107

    menv  =
      check_float env;
      { mark = Cstr; term = FFloat f }

    let mkString env s =
      check_string let rarg, stack   m stkjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
      { mark = Cstr; term = FString s }

    let mkBool env b =
          let stk' = p @append_stack |]sjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
      if b then !ftrue else !ffalse

    let mkCarry env b e =
      | _ -> redinfo~true ( )
      java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

    let mkIntPair env e1 e2 =
      check_pair env  fun red info  pat_state  context states  head  -java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
      mkFApp !fPair [|!fint;!fint;e1;e2|]

    let mkFloatIntPair env f i =
      check_pair env;
      check_float env;
Pair[|!ffloat;fint;f;i|]

    let mkLt env =
       env;
      !fLt

    let mkEq env =
      check_cmp env;
      !fEq

    let mkGt env =
      check_cmp env;
           fGt

    let mkFLt env 
      check_f_cmp env;
      java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

    menv java.lang.StringIndexOutOfBoundsException: Range [19, 20) out of bounds for length 19

      !fFEq

    let mkFGt env =
      check_f_cmp env;
      !fFGt

    let mkFNotComparable env =
      check_f_cmp env;
      !fFNotComparable

    let mkPNormal env =
      check_f_class env;
      !fPNormal

    let mkNNormal env =
      check_f_class env;
      !fNNormal

     mkPSubn env =
      check_f_class env;
     

java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 21
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 24
      !fNSubn

    let mkPZero env =
      check_f_classenv
      !fPZero

     mkNZero env =
      check_f_class env;
      !fNZero =Environ.expand_arityspecif ci.,u pms (st )in

    let mkPInf env =
      check_f_class env;
      !fPInf

    let mkNInf env =
      check_f_class env;
       ifnot@ Ind.anOrd.pind cici_ind else

    let env java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
      check_f_class envjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
      !fNaN

    let mkArray env u t ty =
      check_array env;
      { mark = Cstr; term = FArray (u,t,ty)}

  end

module FredNative = RedNative(FNativeEntries)

let rec skip_irrelevant_stack info stk      in
| [] -> []
| (Zshift _ | Zapp _) :: { elims ; head; stack=s;next  in
| (Zfix  lntys_ret  subst_context entys_retin
  (* Typing rules ensure that fix / proj over SProp is irrelevant *)
  skip_irrelevant_stackinfo s
| ZcaseT (_, _, _, (_,r), _, e) :: s ->
  let r = usubst_relevance e r in
 if is_irrelevant info rthenskip_irrelevant_stack info s
  else stk
| Zprimitive _ :: _ -> assert false (* no irrelevant primitives so far *)
| Zupdate m :: s       let loc =Array (fun patterns ctx arg)next- LocArg  patterns;context =   context;arg; next )(Array. (Array. (.plit_array Array. brs) pbrss)) brs loc in
  (** The stack contains [Zupdate] marks only if in sharing mode *)
  let ) =update m mk_irrelevant.mark mk_irrelevant.term in
  skip_irrelevant_stack info s

let match_mainred info tab ~pat_state states loc
  is_irrelevant infos @@ UVars.subst_instance_relevance u @@ ind_relevance ind (info_env infos)

(*********************************************************************)
(* A machine that inspects the head of a term until it finds an
    or  subterm that may  aredex (abstraction
   constructor, cofix, letin, constant), or a neutral term (      let elims, states = extract_or_kill2 (function [@ocaml.warning states =extract_or_kill2 (function [ocaml."4"java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
   inductive) *)
let rec knh info mstk =
  match m.term with
    | FLIFT(k,a) -> knh info a (zshift k stk)
    | FCLOS(t,e) -> {  java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 67
    | ->assert 
    | FApp(a,b) -java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 38
    |FCaseT(ci,u,pms,(_,r as p),t,br,e) ->
           r'
=  rin
      if| [] >
        (      let states = extract_or_kill states=extract_or_kill([, subst- subst |_>Nonestates n
      else
        knh info java.lang.StringIndexOutOfBoundsException: Range [110, 18) out of bounds for length 139
    | FFix (((ri, n), (lna, _, _)), e) ->
       is_irrelevantinfo (subst_relevancee(.n)binder_relevance)
        (mk_irrelevant, skip_irrelevant_stack,u)-java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
      else
        (match get_nth_arg m ri.(n)    |(PHInd(,pu) elims,psubst ->
             (Some(pars       not@@Indequal indind'  None else
           | (None, stk'
) -> (m,stk'))
    | FProj (p,rc -java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
           ifis_irrelevant info r then
        (mk_irrelevant, skip_irrelevant_stack info stk)
      else
      (match java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 6
       | None -> (m stk)
       | Some s -> knh info c (s :: zupdate info m stk))
    | FConstruct _ -> strip_update_shift_absorb_app m stk

(* cases where knh stops *)
    | (FFlex   |FConstruct ( u), args) ->
       FCoFix _FLambda | _FAtom | ||Int |_|
       FString _|FArray _) ->
        (m, let elims,states   ( @.warning -4]

(* The same for pure terms *)
 knht  e  stk =
  match kind t with
    | App(a,b) ->
        knht info e a (append_stack      if  @@Construct.CanOrd.equal constr constr'thenNone else
    | Case(ci,u,subst= java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 67
          |_ >None patterns states
        (    in
      else
knhtinfoe  ZcaseT(,u, p,br,e):stk)
    | Case(ci,u,pms,(_,r as p),CaseInvert{indices},t,br    match_main  infotab ~ loc
      if is_irrelevantinfo(usubst_relevance r then
        (| Sort s -
      else
          = (,u,pms p,(.(mk_clos)indices) mk_clos et br e java.lang.StringIndexOutOfBoundsException: Index 102 out of bounds for length 102
        { mark = Red; term }, stk
    |Fix((_ , lna, ,_) as >
      if         map fsubst >elims,{ java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 68
_irrelevant_stackinfo stk
      else
        knh info { mark = java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 85
    | Cast(a,_,_) -> knht info e a stk
    |Rel
    | Proj (p, r, c) ->
      let r = usubst_relevance e r in
      if is_irrelevant info r then
        (k_irrelevant, skip_irrelevant_stack info stk)
      else begin match unfold_projection info p r with
|None- ({mark  Red;term=FProj(p ,mk_clos e c) }, stk)
      | Some s -> knht info e c (s :: stk)
      end
    | Construct _ -> knh info (mk_clos e t) stk
    | (Ind _|Const _|Var _|Meta _ | Sort _ | Int _|Float _|String _)end
    | CoFix cfx ->
      mark = Cstr;term = FCoFix cfx,) },stk
    | Lambda _ -> { mark = Cstr ; term = mk_lambda e t }, stk
    let elims,states= extract_or_kill2 (function [@ocamlwarning "-4"]
      { mark = Ntrl; term = FProd (n, mk_clos e     |(PHSymbol (,pu, elims),psubst ->
    | LetIn (n,b,t,c) ->
      , mk_clos e b, mk_clos e t, c, e) }, stk
    | Evar ev ->
      begin match info.i_cache.i_sigma.evar_expand ev with
      | EvarDefined c -> knht info e c stk
       EvarUndefined e, args)->
        assert (UVars.Instance.is_empty (snd e));
        if info.i_cache.    |_- None) patterns states
          (mk_irrelevant, skip_irrelevant_stack
        else
          let repack = info.i_cache.i_sigma.evar_repack in
 args, e,repack) ,stk
      end
 ut) -java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
      let len = Array.length t in
      letty=  e  
      let t = Parray.init (Uint63.of_int len) (fun i -> mk_clos e t if  @ equal '
then 
      let term =FArray java.lang.StringIndexOutOfBoundsException: Range [74, 73) out of bounds for length 83
      knh info { mark =|  '>

(************************************************************************)

let conv : (clos_infos -> clos_tab -> fconstr -> fconstr -> bool) ref
  =ref fun    _->( bool)
let set_conv f = conv := f

type ('a, '          =na java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 63
  red_ret : clos_infos -> Table.t -> pat_state:'b -> ) tysbodyelims 
  red_kni : clos_infos -> Table.t -> pat_state:'
b 
  let ,=.decompose_prod_n(na1 body in


type(_ )escape=
  | No:  ('i, 'i) escape
  | Yes: ('a, 'a option) escape

module RedPattern :
sig

type 'constr, ' context)

type constr, stack context,)depth=
  | Nil: ('constr * 'stack, '    let loc = LocStart { elimsloc=LocStart{elims;context;head=t stack=;next=ontinue   in
xtresume_stater) >('
constr ', 'context,ret)

type 'a patstate = (      let np = Array.length np = Array.length ptys in

val match_symbol : ('
a, 'a patstate) reduction -> clos_infos -> Table.t ->
  :(fconstr, stack,rel_context, a) depth >table_key -> UVars.Instance.t * bool * rewrite_rule list -> stack -> '
a

val java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 42
  tysbodyelims

end =
struct

type 'constr partial_subst = {
  subst: ('
constr, Sorts.Quality.t, Univ.     =Term.ompose_lam(.tys'  
   constr;
}

type '
constr subst_status = Dead | Live of  let=mapi(fun  _ t >mk_clos ne)t)tysin

type 'a status =
        =LocStart{elims;context;head=;stack=;next=Continue next } in
  | Ignore

    let    {patterns   =   ;arg  mk_clos(usubs_liftn  )body;next =}in
  let split_array n = function
  |Check a when. a < n >invalid_arg Status."

  | Check a -> Array.init n (fun i -> Check (Array.unsafe_get a i))
  | Ignore as p -> Array.make n p

  let fold_left f a = function |_ ->
end

type ('a, 'b) next =    (iptjava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 23
    ofa
'java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16

 (constr'
 context)state=
  | LocStart       let pu, es = r.lhs_pat in
  | LocArg of { patterns: pattern_argument status array; context: ' let subst  Partial_substmake r.in

'
,' context)  ((constr stack,'  bool constr *'stack)

type ('
constr, 'stack, 'java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 22
  { states: 'constr subst_status array; context: 'context; patterns: head_elimination status array; next: ('constr, 'stack, 'java.lang.StringIndexOutOfBoundsException: Index 127 out of bounds for length 28

type ('
constr lam,s-> infotab ~lams)
  | Nil: ('constr * 'stack, 'ret) escape -> ('constr, 'stack, 'context, 'ret) depth
  | Cons: ('
constr, 'stack, 'context) resume_state * ('constr, 'stack, 'context, 'ret) depth -> ('constr, 'stack, 

type 'a patstate = (fconstr, stack, rel_context, 'a) depth

let extract_or_kill filter a status =
  let step elim status =
    elim, with
    | Ignore, s -> s
    | _, Dead -> Dead
| Live  - filter e )
      | None -> Dead
      | Some s -> Live s
  in
  Array.map2 step a statusjava.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 48

let extract_or_kill2 filter a status =
  let step elim status =
    match elim, status with
   | Ignore,rjava.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 30
   | _, Deadjava.lang.StringIndexOutOfBoundsException: Range [37, 33) out of bounds for length 74
   | Check e, Live          |OpaqueDef _ >set_ntrlm infotab ~pat_state (mstk))
      | None -> Ignore, Dead
      | Some (p, s)letjava.lang.StringIndexOutOfBoundsException: Range [20, 18) out of bounds for length 51
  in
 a status

  filterstatus=
  let step elim status =
    match elim, status with
    | Ignore, s -> Ignore, Ignore, s
    | _, Dead -> Ignore, Ignore, Dead
    | Check e, Live s -> match filter (e, s) with
      | None -> Ignore, Ignore, Dead
       Some(p1 , s)- Check p1,Check p2,Live s
  in
  .split3 @@Arraymap2 a status

let extract_or_kill4filter a status=
  let step elim status =
s
    | Ignore, s -> Ignore, Ignore, | (m, Zproj (p,_)::s) when use_match
 ,Dead >java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 45
  ,Lives  filter( s)with
      | None -> Ignore, Ignore, Ignore, Dead
      | Some (p1, p2, p3, s) -> Check p1, Check p2, Check p3, Live s
  in
  Array.split4 @@ Array.map2 step a status

let recjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
  fun red info tab ~pat_state states loc ->
 ArrayffunctionDead >true Live _-  then  red tab~at_stateloc 
  match [@ocaml.warning "-4"] loc with
  | LocStart { elims; context; head; stack; next = Return _ as next } ->
    begin match Arrayknr_ret infot~ (stk)
    | Some { subst; rhs } ->
        let subst, qsubst (i,( ,))  ->
        let subst = Array.fold_right subs_cons subst (java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 44
matchstrip_update_shift_appm stkwith
        let m' = mk_clos (subst        _ , ,(( | _:_ asstk)-
        begin match             let (fxe,fxbd) =fxe,   .term in
        | Nil Yes -> Some (m'
, stack)
        | _ -> red.red_kni info tab ~pat_state            knit info tab~at_statefxe (stk)
        end
    | None -> match_elim red info tab ~pat_state next context states elims head stack
    end
  | LocArg { patterns; context; arg; next } ->
      match_arg red info     else knr_ret info tab ~pat_state (m, stk)
  | LocStart { elims; context; head;infoi>
      match_elim red info tab ~pat_state next context states elims head stack

and    |FFloat_|java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 47

  | LocArg { next; _ } -> match_kill red info tab ~pat_state next
  |      | (_, ,_, Zprimitive(op(,uasc,rargs,nargs):s) -java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
      ignore (zip head stack);
      match with
      | Continue next -> match_kill red info tab ~pat_state next
      | Return k -> java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 16

and match_endstack : 'a. ('a,           |] -[||]
            a]->[a|
  match next with
  | Continue next -> match_main red info tab ~pat_state states next
  | Return k ->
      (rray.or_all( Dead-   Live_- false );
      try_unfoldfix red info tab ~pat_state k

and try_unfoldfix : 'a. ('a, 'a patstate) reduction -> _ -> _ -> pat_state:(_, _, _, 'a) depth -> _ -> 'a =
  fun red info tab ~pat_state (b, m, stk) ->
  if not b then red.red_ret info tab ~pat_state ~failed:true (m, stk) else
  let rarg, stack = strip_update_shift_absorb_app m stk in
  match [@ocaml.warning "-4"] stack with
  | java.lang.StringIndexOutOfBoundsException: Range [9, 7) out of bounds for length 27
    let stk  par @java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 47
f,=contract_fix_vect fx.term in
    red.red_knit info tab ~pat_state fxe fxbd stk'

  | _ -> red.      d  , stk)->java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 78

and match_elim : 'a. ('a, 'a patstate) reduction -> _ -> _ -> pat_state:(fconstr, stack, _, 'java.lang.StringIndexOutOfBoundsException: Range [0, 94) out of bounds for length 80
  fun red info tab ~pat_state next context states elims head    letpms= mk_clos_vect   java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
  match stk  begin matchinfo tab ci  pmsiv vwith
  | Zapp args :: s ->
letpargselimsstates  (function [@. -4]pargs :es subst->Some((pargs,es, )| _>None) lims  
      let na = Array.length args in
una(pargs, _) -> min a (Array.length pargs))) na pargselims in
      _java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 19
        extract_or_kill3java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
          let npp = Array.length pargs in
          if npp == np then Some (pargs, elims, subst) else
          let fst, lst = Array.chopjava.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 54
          Some (fst, PEApp lst :: elims(********************************************)
          pargselims states
      in
      let args, rest = Array.chop np args in
      let head = mkFApp head args in
      let stack = if Array.length rest > 0 then Zapp rest :: s else s in
      let loc = LocStart { java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
      let loc| FAtom   _|FInd_ (,||)|FInt  FFloat _ | > true
      match_main red info tab ~pat_state states loc
  | Zshift k :: s -> match_elim red info tab ~pat_state next FConstruct _ | FApp _ | FProj _ | FFix _ | FCoFix _ | FCaseT _ | FCaseInvert
  | Zupdate m :: s ->
      let () = update m head.mark head.term in
      match_elim red info tab ~pat_state next context states elims head s
  | ZcaseT (ci, u, pms,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      let t = FCaseT(ci, u   java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 37
       in
      let head = {mark; term=t} in
      let specif =    let (nm,s =kniinfo tabm[ in
      letspecif=( mind_packets(c.ci_ind) java.lang.StringIndexOutOfBoundsException: Range [67, 68) out of bounds for length 67
      ntys_ret=Environ. specif(ici_ind, u ( p)in
      let ntys_brs = Environ.java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
         elims, states= extract_or_kill4 (function [@ocaml.warning "-4"]
      | PECase (pind, pu, pret, pbrs) :: es, psubst ->
        if not @@ Ind.  java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 39
          let subst =     )>java.lang.StringIndexOutOfBoundsException: Range [35, 33) out of bounds for length 57
          Option.map (  |Inr k Somep)-  @ (-){markR;termRp}
      | _ -> None)
          elims states
      in
      let loc = LocStart { elims; context; head; stack=s; next } in
      let ntys_ret = subst_contextjava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 26
      letret  mk_clos usubs_liftnContext.lntys_ret e snd p 
      let brs = Array.map2 (fun     let hd' subst_instance_constr (snd e) hd n
      let loc = Array.fold_right2 (fun patterns (ctx, arg) next -> LocArg { patterns; context = ctx @ context; arg; next }) (Array.transpose (java.lang.StringIndexOutOfBoundsException: Range [0, 147) out of bounds for length 40
       loc=LocArg {patterns  prets;context  ntys_ret @ context;  = ;next = in
      match_main red info tab ~| Var _ | Const _ | CoFix _ | Lambda     |Case 
  | Zproj  |Cast    _ | Proj _ | Array _|Rel  Meta_|_|Int 
      let mark = (neutr head.mark)| Float _ |String _ -
      let head    let share = info._cache. in
      let elims, states = extract_or_kill2 (java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 40
      | PEProj proj :: es, subst ->
        if not @@ Projection.Repr.CanOrd.equal proj proj'
 then None else
        Some (es, subst)
      |_- None)elims states
      in
      let loc = LocStart { elims; context; head; stack=s; next } in
      zip_terminfo tab java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  |   =usubst_binderenain
      =extract_or_killf_- None  inin
         c = kltpush_relevanceinfo na)tab (e)c  =  &u =  & '== cjava.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 43
      match_endstack red info tab ~pat_state java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 20
  |[]>
      let states = extract_or_kill (function [], subst -> Some subst | _ -> None) elims states in
      match_endstack red info tab ~pat_state states next

and match_arg : '
a. ('a, 'a patstate) reduction -> _ -> _ -> pat_state:(java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 43
  fun red info tab ~pat_state next context states patterns  mkProd(a,u, v'
  match_deeper f 
  let t'
 = |Var    CoFix  _     Case _ |LetIn |    java.lang.StringIndexOutOfBoundsException: Range [82, 80) out of bounds for length 85
   let patterns,=split@ java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
    (Dead >fun  - ,Dead |Live({ subst; _ as as java.lang.StringIndexOutOfBoundsException: Range [88, 85) out of bounds for length 98
      | Ignore -> Ignore, state
      | Check EHole i -> Ignore, Live { java.lang.StringIndexOutOfBoundsException: Range [0, 46) out of bounds for length 33
      | Check java.lang.StringIndexOutOfBoundsException: Range [66, 28) out of bounds for length 66
      | Check ERigid p -> match_deeper := true; Check p, state
    ) states patterns in
  if !match_deeper then
    let pat_state = Cons (         na java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 38
    red.red_kni info tab ~pat_state t []
  else
    match_main ((java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 37

and   a ',apatstate     pat_state(,,_,'  >_->_ -_ -   - >=
  fun red info tab ~pat_state next context states patterns t stk ->
  match [@ocaml.warning "-4"] t.term with
  | FInd (ind', u) ->
    let elims, states = extract_or_kill2 (function [@ocaml.warning "-4"]
     PHInd ind ,,java.lang.StringIndexOutOfBoundsException: Range [40, 38) out of bounds for length 41
      if not @       |        _
      let subst = UVars.Instance.pattern_match pu u psubst.subst   _   java.lang.StringIndexOutOfBoundsException: Range [41, 39) out of bounds for length 70
      Option.map (fun subst -> elims      java.lang.StringIndexOutOfBoundsException: Range [21, 19) out of bounds for length 73
    | _ -> None) patterns states
    in
let   java.lang.StringIndexOutOfBoundsException: Range [24, 22) out of bounds for length 83
    match_main red info tab ~pat_state states loc
  | FConstruct ((constr zip_term  (java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
   java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 72
    | (PHConstr (constr, pu),         c 
      zip_termtab s
      let
      Option.(
    | _ -> None) patterns states
    in
    java.lang.StringIndexOutOfBoundsException: Range [20, 7) out of bounds for length 20
    match_main red info tab ~pat_state states
  | FAtom t' -> begin match [@ocaml.warning "
-4"njava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 39
    | Sort java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
|-java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
      |  (** No need to perform [kni] nor to unlock updates because
        let subst = Sorts.pattern_match ps s       everyjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        Option.map (fun subst -> elims, { psubst with subst }) subst
      | _ -> None) patterns states
      in
      let loc = LocStart { elims; context; head=t;    )=
      match_main red info re 
    | Meta _ ->
      let elims, states = extract_or_kill2 (fun _ -> None) patterns states in
      let loc = LocStart { elims; context; head=t; stack=stk; next=Continue next } in
tates
    | _ -> assert false
    end  
  | FFlex (ConstKey (c'
, u)) ->  
    let elims, states = extract_or_kill2 (function [@ocaml
    | (PHSymbol (c, pu), elimslet create_infos i_mode?nivs ejava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 53
t @ .java.lang.StringIndexOutOfBoundsException: Range [39, 37) out of bounds for length 57
      let subst = UVars.Instance   i_univs = Option.default (nvironuniverses ) univs
      Option.map (fun subst -> elims, { psubst with subst }) subst
    | _ -> None) patterns states
    in
    let loc = LocStart { elims; context; head=t; stack=stk; next{java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 48
    match_main red info tab ~pat_state states loc
  | FRel n ->
    let elims, states = extract_or_kill2 (let create_clos_infos Reduction
    | (PHRel n
      if not @@ fos  .java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 62
      Some (elims, psubst)
    | _ -letjava.lang.StringIndexOutOfBoundsException: Range [26, 19) out of bounds for length 32
    in
    let loc = LocStart { elims; context; head=t; stack=stkletunfold_ref_with_args infos tab fl v =
    match_main red info tab ~pat_state states loc
  | FInt i' ->
    let elims, states = extract_or_kill2 (function [@ocaml.warning "-4"]
    | (PHInt i, elims), psubst ->
      if not @@ Uint63.equal i i'
 then  Defjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 33
      Some (elims, psubst)
    | _    =java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 86
    in
    let loc = LocStart { elims; context; head=     a a:java.lang.StringIndexOutOfBoundsException: Range [39, 36) out of bounds for length 60
states loc
  | FFloat f' ->
    let elims, states = extract_or_kill2 (function [@ocaml.warning "-4"]
    | (PHFloat f, elims), psubst ->
     java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 49
      Some (elims, psubst)
|_- None) patterns states
    in
    let  { ;head;stk =  } in
    match_main red info tab ~pat_state states loc
  | FString s'
 ->
    let elims, states = extract_or_kill2 (function [@ocaml.warning "-4"]
    | (PHString s, elims), psubst ->
      if not @@ Pstring.equal s s' then None else
      Some (elims, psubst)
    | _ -> None) patterns states
    in
    let loc = LocStart { elims; context; head=t; stack=stk; next=Continue next } in
    match_main red info tab ~pat_state states loc
  | FProd (n, ty, body, e) ->
    let ntys, _ = Term.decompose_prod body in
    let na = 1 + List.length ntys in
    let tysbodyelims, states = extract_or_kill2 (function [@ocaml.warning "-4"] (PHProd (ptys, pbod), es), psubst when Array.length ptys <= na -> Some ((ptys, pbod, es), psubst) | _ -> None) patterns states in
    let na = Array.fold_left (Status.fold_left (fun a (p1, _, _) -> min a (Array.length p1))) na tysbodyelims in
    assert (na > 0);
    let ptys, pbody, elims, states = extract_or_kill4 (fun ((ptys, pbod, elims), psubst) ->
        let npp = Array.length ptys in
        if npp == na then Some (ptys, pbod, elims, psubst) else
        let fst, lst = Array.chop na ptys in
        Some (fst, ERigid (PHProd (lst, pbod), []), elims, psubst)
      ) tysbodyelims states
    in

    let ntys, body = Term.decompose_prod_n (na-1) body in
    let ctx1 = List.map (fun (n, ty) -> Context.Rel.Declaration.LocalAssum (n, ty)) ntys |> subst_context e in
    let ctx = ctx1 @ [Context.Rel.Declaration.LocalAssum (n, term_of_fconstr ty)] in
    let ntys'
' = List.mapi (fun n (_, t) -> mk_clos (usubs_liftn n e) t) (List.rev ntys) in
    let tys = Array.of_list (ty :: ntys'
') in
    let contexts_upto = Array.init na (fun i -> List.lastn i ctx @ context) in
    let loc = LocStart { elims; context; head=t; stack=stk; next=Continue next } in
    let loc = LocArg { patterns = pbody; context = ctx @ context; arg = mk_clos (usubs_liftn na e) body; next = loc } in
    let loc = Array.fold_right3 (fun patterns arg context next -> LocArg { patterns; context; arg; next }) (Array.transpose (Array.map (Status.split_array na) ptys)) tys contexts_upto loc in
    match_main red info tab ~pat_state states loc
  | FLambda (na, ntys, body, e) ->
    let tysbodyelims, states = extract_or_kill2 (function [@ocaml.warning "-4"] (PHLambda (ptys, pbod), es), psubst when Array.length ptys <= na -> Some ((ptys, pbod, es), psubst) | _ -> None) patterns states in
    let na = Array.fold_left (Status.fold_left (fun a (p1, _, _) -> min a (Array.length p1))) na tysbodyelims in
    assert (na > 0);
    let ptys, pbody, elims, states = extract_or_kill4 (fun ((ptys, pbod, elims), psubst) ->
      let np = Array.length ptys in
      if np == na then Some (ptys, pbod, elims, psubst) else
      let fst, lst = Array.chop na ptys in
      Some (fst, ERigid (PHLambda (lst, pbod), []), elims, psubst)
      ) tysbodyelims states
    in
    let ntys, tys'
 = List.chop na ntys in
    let body = Term.compose_lam (List.rev tys') body in
    let ctx = List.rev_map (fun (n, ty) -> Context.Rel.Declaration.LocalAssum (n, ty)) ntys |> subst_context e in
    let tys = Array.of_list ntys in
    let tys = Array.mapi (fun n (_, t) -> mk_clos (usubs_liftn n e) t) tys in
    let contexts_upto = Array.init na (fun i -> List.lastn i ctx @ context) in
    let loc = LocStart { elims; context; head=t; stack=stk; next=Continue next } in
    let loc = LocArg { patterns = pbody; context = ctx @ context; arg = mk_clos (usubs_liftn na e) body; next = loc } in
    let loc = Array.fold_right3 (fun patterns arg context next -> LocArg { patterns; context; arg; next }) (Array.transpose (Array.map (Status.split_array na) ptys)) tys contexts_upto loc in
    match_main red info tab ~pat_state states loc
  | _ ->
    let states = extract_or_kill (fun _ -> None) patterns states in
    ignore (zip t stk);
    match_main red info tab ~pat_state states next

let match_symbol red info tab ~pat_state fl (u, b, r) stk =
  let unfold_fix = b && red_set info.i_flags fFIX in
  let states, elims = Array.split @@ Array.map
    (fun r ->
      let pu, es = r.lhs_pat in
      let subst = Partial_subst.make r.nvars in
      let subst = UVars.Instance.pattern_match pu u subst in
      match subst with
      | Some subst -> Live { subst; rhs = r.Declarations.rhs }, Check es
      | None -> Dead, Ignore
    ) (Array.of_list r)
  in
  let m = { mark = Red; term = FFlex fl } in
  let loc = LocStart { elims; context=[]; head = m; stack = stk; next = Return (unfold_fix, m, stk) } in
  match_main red info tab ~pat_state states loc

let match_head red info tab ~pat_state { states; context; patterns; next } m stk =
  match_head red info tab ~pat_state next context states patterns m stk

end

type '
a depth = 'a RedPattern.patstate

(* Computes a weak head normal form from the result of knh. *)
let rec knr : '
a. _ -> _ -> pat_state: 'a depth -> _ -> _ -> 'a =
  fun info tab ~pat_state m stk ->
  match m.term with
  | FLambda(n,tys,f,e) when red_set info.i_flags fBETA ->
      (match get_args n tys f e stk with
          Inl e', s -> knit info tab ~pat_state e' f s
        | Inr lam, s -> knr_ret info tab ~pat_state (lam,s))
  | FFlex fl when red_set info.i_flags fDELTA ->
      (match Table.lookup info tab fl with
        | Def (v, _) -> kni info tab ~pat_state v stk
        | Primitive op ->
          if check_native_args op stk then
            let c = match fl with ConstKey c -> c | RelKey _ | VarKey _ -> assert false in
            let rargs, a, nargs, stk = get_native_args1 op c stk in
            kni info tab ~pat_state a (Zprimitive(op,c,rargs,nargs)::stk)
          else
            (* Similarly to fix, partially applied primitives are not Ntrl! *)
            knr_ret info tab ~pat_state (m, stk)
        | Symbol (u, b, r) ->
          let red = {
            red_kni = kni;
            red_knit = knit;
            red_ret = knr_ret;
          } in
          RedPattern.match_symbol red info tab ~pat_state fl (u, b, r) stk
        | Undef _ | OpaqueDef _ -> (set_ntrl m; knr_ret info tab ~pat_state (m,stk)))
  | FConstruct (c,_) ->
     let use_match = red_set info.i_flags fMATCH in
     let use_fix = red_set info.i_flags fFIX in
     if use_match || use_fix then
      (match [@ocaml.warning "-4"] m,  stk with
        | (_, Zapp _ :: _) -> assert false (* knh *)
        | (c, ZcaseT(ci,_,pms,_,br,e)::s) when use_match ->
            assert (ci.ci_npar>=0);
            (* instance on the case and instance on the constructor are compatible by typing *)
            let (br, e) = get_branch info ci pms c br e in
            knit info tab ~pat_state e br s
        | (rarg, Zfix(fx,par)::s) when use_fix ->
            let stk' = par @ append_stack [|rarg|] s in
            let (fxe,fxbd) = contract_fix_vect fx.term in
            knit info tab ~pat_state fxe fxbd stk'

        | (m, Zproj (p,_)::s) when use_match ->
            let rargs = drop_parameters (Projection.Repr.npars p) m in
            let rarg = rargs.(Projection.Repr.arg p) in
            kni info tab ~pat_state rarg s
        | (m, s) ->
          if is_irrelevant_constructor info c then
            knr_ret info tab ~pat_state (mk_irrelevant, skip_irrelevant_stack info stk)
          else
            knr_ret info tab ~pat_state (m,s))
     else if is_irrelevant_constructor info c then
      knr_ret info tab ~pat_state (mk_irrelevant, skip_irrelevant_stack info stk)
     else
      knr_ret info tab ~pat_state (m, stk)
  | FCoFix ((i, (lna, _, _)), e) ->
    if is_irrelevant info (usubst_relevance e (lna.(i)).binder_relevance) then
      knr_ret info tab ~pat_state (mk_irrelevant, skip_irrelevant_stack
    else if red_set info.i_flags fCOFIX then
      (match strip_update_shift_app m stk with
        | (_, _, args, (((ZcaseT _|Zproj _)::_) as stk')) ->
            let (fxe,fxbd) = contract_fix_vect m.term in
            knit info tab ~pat_state fxe fxbd (args@stk'
)
        | (_, _, args, ((Zapp _ | Zfix _ | Zshift _ | Zupdate _ | Zprimitive _) :: _ | [] as s)) ->
            knr_ret info tab ~pat_state (m,args@s))
    else knr_ret info tab ~pat_state (m, stk)
  | FLetIn (_,v,_,bd,e) when red_set info.i_flags fZETA ->
      knit info tab ~pat_state (on_fst (subs_cons v) e) bd stk
  | FInt _ | FFloat _ | FString _ | FArray _ ->
    (match [@ocaml.warning "-4"] strip_update_shift_app m stk with
     | (_, _, _, Zprimitive(op,(_,u as c),rargs,nargs)::s) ->
       let (rargs, nargs) = skip_native_args (m::rargs) nargs in
       begin match nargs with
         | [] ->
           let args = match rargs with
           | [] -> [||]
           | [a] -> [|a|]
           | [a; b] -> [|b; a|]
           | [a; b; c] -> [|c; b; a|]
           | [a; b; c; d] -> [|d; c; b; a|]
           | _ -> Array.rev_of_list rargs
           in
           begin match FredNative.red_prim (info_env info) () op u args with
            | Some m -> kni info tab ~pat_state m s
            | None -> assert false
           end
         | (kd,a)::nargs ->
           assert (kd = CPrimitives.Kwhnf);
           kni info tab ~pat_state a (Zprimitive(op,c,rargs,nargs)::s)
             end
     | (depth, _, _, stk) -> knr_ret info tab ~pat_state (m,zshift depth stk))
  | FCaseInvert (ci, u, pms, _p,iv,_c,v,env) when red_set info.i_flags fMATCH ->
    let pms = mk_clos_vect env pms in
    let u = usubst_instance env u in
    begin match case_inversion info tab ci u pms iv v with
      | Some c -> knit info tab ~pat_state env c stk
      | None -> knr_ret info tab ~pat_state (m, stk)
    end
  | FIrrelevant ->
    let stk = skip_irrelevant_stack info stk in
    knr_ret info tab ~pat_state (m, stk)
  | FProd _ | FAtom _ | FInd _ (* relevant statically *)
  | FCaseInvert _ | FProj _ | FFix _ | FEvar _ (* relevant because of knh(t) *)
  | FLambda _ | FFlex _ | FRel _ (* irrelevance handled by conversion *)
  | FLetIn _ (* only happens in reduction mode *) ->
    knr_ret info tab ~pat_state (m, stk)
  | FLOCKED | FCLOS _ | FApp _ | FCaseT _ | FLIFT _ ->
    (* ruled out by knh(t) *)
    assert false

and knr_ret : type a. _ -> _ -> pat_state: a depth -> ?failed: _ -> _ -> a =
  fun info tab ~pat_state ?(failed=false) i ->
  match pat_state with
  | RedPattern.Cons (patt, pat_state) ->
      let m, stk = i in
      let red = {
        red_kni = kni;
        red_knit = knit;
        red_ret = knr_ret;
      } in
      RedPattern.match_head red info tab ~pat_state patt m stk
  | RedPattern.Nil b ->
      match b with No -> i | Yes -> if failed then None else Some i

(* Computes the weak head normal form of a term *)
and kni : 'a. _ -> _ -> pat_state: 'a depth -> _ -> _ -> 'a =
  fun info tab ~pat_state m stk ->
  let (hm,s) = knh info m stk in
  knr info tab ~pat_state hm s
and knit : '
a. _ -> _ -> pat_state: 'a depth -> _ -> _ -> _ -> 'a =
  fun info tab ~pat_state e t stk ->
  let (ht,s) = knht info e t stk in
  knr info tab ~pat_state ht s

and case_inversion info tab ci u params indices v = match v with
| [||] -> None (* empty type *)
| [| [||], v |] ->
  (* No binders / lets at all in the unique branch *)
  let open Declarations in
  if Array.is_empty indices then Some v
  else
    let env = info_env info in
    let ind = ci.ci_ind in
    let psubst = subs_consn params 0 ci.ci_npar (subs_id 0) in
    let mib = Environ.lookup_mind (fst ind) env in
    let mip = mib.mind_packets.(snd ind) in
    (* indtyping enforces 1 ctor with no letins in the context *)
    let _, expect = mip.mind_nf_lc.(0) in
    let _ind, expect_args = destApp expect in
    let tab = if info.i_cache.i_mode == Conversion then tab else Table.create () in
    let info = {info with i_cache = { info.i_cache with i_mode = Conversion}; i_flags=all} in
    let check_index i index =
      let expected = expect_args.(ci.ci_npar + i) in
      let expected = mk_clos (psubst,u) expected in
      !conv info tab expected index
    in
    if Array.for_all_i check_index 0 indices
    then Some v else None
| _ -> assert false

let knred = {
  red_kni = kni;
  red_knit = knit;
  red_ret = knr_ret;
}

let kni info tab v stk = kni info tab ~pat_state:(RedPattern.Nil No) v stk
let knit info tab v stk = knit info tab ~pat_state:(RedPattern.Nil No) v stk
let kh info tab v stk = fapp_stack(kni info tab v stk)

(************************************************************************)

(* Computes the strong normal form of a term.
   1- Calls kni
   2- tries to rebuild the term. If a closure still has to be computed,
      calls itself recursively. *)


let is_val v = match v.term with
| FAtom _ | FRel _   | FInd _ | FConstruct (_,[||]) | FInt _ | FFloat _ | FString _ -> true
| FFlex _ -> v.mark == Ntrl
| FConstruct _ | FApp _ | FProj _ | FFix _ | FCoFix _ | FCaseT _ | FCaseInvert _ | FLambda _
| FProd _ | FLetIn _ | FEvar _ | FArray _ | FLIFT _ | FCLOS _ -> false
| FIrrelevant | FLOCKED -> assert false

let rec kl info tab m =
  let share = info.i_cache.i_share in
  if is_val m then term_of_fconstr m
  else
    let (nm,s) = kni info tab m [] in
    let () = if share then ignore (fapp_stack (nm, s)) in (* to unlock Zupdates! *)
    zip_term info tab (norm_head info tab nm) s

and klt info tab e t = match kind t with
| Rel i ->
  begin match expand_rel i (fst e) with
  | Inl (n, mt) -> kl info tab @@ lift_fconstr n mt
  | Inr (k, None) -> if Int.equal k i then t else mkRel k
  | Inr (k, Some p) -> kl info tab @@ lift_fconstr (k-p) {mark=Red;term=FFlex(RelKey p)}
  end
| App (hd, args) ->
  begin match kind hd with
  | Ind _ | Construct _ ->
    let args' = Array.Smart.map (fun c -> klt info tab e c) args in
    let hd'
 = subst_instance_constr (snd e) hd in
    if hd' == hd && args' == args then t
    else mkApp (hd', args')
  | Var _ | Const _ | CoFix _ | Lambda _ | Fix _ | Prod _ | Evar _ | Case _
  | Cast _ | LetIn _ | Proj _ | Array _ | Rel _ | Meta _ | Sort _ | Int _
  | Float _ | String _ ->
    let share = info.i_cache.i_share in
    let (nm,s) = knit info tab e t [] in
    let () = if share then ignore (fapp_stack (nm, s)) in (* to unlock Zupdates! *)
    zip_term info tab (norm_head info tab nm) s
  | App _ -> assert false
  end
| Lambda (na, u, c) ->
  let na' = usubst_binder e na in
  let u'
 = klt info tab e u in
  let c' = klt (push_relevance info na') tab (usubs_lift e) c in
  if na' == na && u' == u && c' == c then t
  else mkLambda (na'
, u', c')
| Prod (na, u, v) ->
  let na' = usubst_binder e na in
  let u'
 = klt info tab e u in
  let v' = klt (push_relevance info na') tab (usubs_lift e) v in
  if na' == na && u' == u && v' == v then t
  else mkProd (na'
, u', v')
| Cast (t, _, _) -> klt info tab e t
| Var _ | Const _ | CoFix _ | Fix _ | Evar _ | Case _ | LetIn _ | Proj _ | Array _ ->
  let share = info.i_cache.i_share in
  let (nm,s) = knit info tab e t [] in
  let () = if share then ignore (fapp_stack (nm, s)) in (* to unlock Zupdates! *)
  zip_term info tab (norm_head info tab nm) s
| Meta _ | Sort _ | Ind _ | Construct _ | Int _ | Float _ | String _ ->
  subst_instance_constr (snd e) t

(* no redex: go up for atoms and already normalized terms, go down
   otherwise. *)

and norm_head info tab m =
  if is_val m then term_of_fconstr m else
    match m.term with
      | FLambda(_n,tys,f,e) ->
        let fold (e, info, ctxt) (na, ty) =
          let na = usubst_binder e na in
          let ty = klt info tab e ty in
          let info = push_relevance info na in
          (usubs_lift e, info, (na, ty) :: ctxt)
        in
        let (e', info, rvtys) = List.fold_left fold (e,info,[]) tys in
        let bd = klt info tab e'
 f in
        List.fold_left (fun b (na,ty) -> mkLambda(na,ty,b)) bd rvtys
      | FLetIn(na,a,b,f,e) ->
          let na = usubst_binder e na in
          let c = klt (push_relevance info na) tab (usubs_lift e) f in
          mkLetIn(na, kl info tab a, kl info tab b, c)
      | FProd(na,dom,rng,e) ->
        let na = usubst_binder e na in
        let rng = klt (push_relevance info na) tab (usubs_lift e) rng in
          mkProd(na, kl info tab dom, rng)
      | FCoFix((n,(na,tys,bds)),e) ->
          let na = Array.Smart.map (usubst_binder e) na in
          let infobd = push_relevances info na in
          let ftys = Array.map (fun ty -> klt info tab e ty) tys in
          let fbds = Array.map (fun bd -> klt infobd tab (usubs_liftn (Array.length na) e) bd) bds in
          mkCoFix (n, (na, ftys, fbds))
      | FFix((n,(na,tys,bds)),e) ->
          let na = Array.Smart.map (usubst_binder e) na in
          let infobd = push_relevances info na in
          let ftys = Array.map (fun ty -> klt info tab e ty) tys in
          let fbds = Array.map (fun bd -> klt infobd tab (usubs_liftn (Array.length na) e) bd) bds in
          mkFix (n, (na, ftys, fbds))
      | FEvar(ev, args, env, repack) ->
          repack (ev, List.map (fun a -> klt info tab env a) args)
      | FProj (p,r,c) ->
        mkProj (p, r, kl info tab c)
      | FArray (u, a, ty) ->
        let a, def = Parray.to_array a in
        let a = Array.map (kl info tab) a in
        let def = kl info tab def in
        let ty = kl info tab ty in
        mkArray (u, a, def, ty)
      | FConstruct (c,args) -> mkApp (mkConstructU c, Array.map (kl info tab) args)
      | FLOCKED | FRel _ | FAtom _ | FFlex _ | FInd _
      | FApp _ | FCaseT _ | FCaseInvert _ | FLIFT _ | FCLOS _ | FInt _
      | FFloat _ | FString _ -> term_of_fconstr m
      | FIrrelevant -> assert false (* only introduced when converting *)

and zip_term info tab m stk = match stk with
| [] -> m
| Zapp args :: s ->
    zip_term info tab (mkApp(m, Array.map (kl info tab) args)) s
| ZcaseT(ci, u, pms, (p,r), br, e) :: s ->
  let zip_ctx (nas, c) =
      let nas = Array.map (usubst_binder e) nas in
      let e = usubs_liftn (Array.length nas) e in
      (nas, klt info tab e c)
    in
    let r = usubst_relevance e r in
    let u = usubst_instance e u in
    let t = mkCase(ci, u, Array.map (fun c -> klt info tab e c) pms, (zip_ctx p, r),
      NoInvert, m, Array.map zip_ctx br) in
    zip_term info tab t s
| Zproj (p,r)::s ->
    let t = mkProj (Projection.make p true, r, m) in
    zip_term info tab t s
| Zfix(fx,par)::s ->
    let h = mkApp(zip_term info tab (kl info tab fx) par,[|m|]) in
    zip_term info tab h s
| Zshift(n)::s ->
    zip_term info tab (lift n m) s
| Zupdate(_rf)::s ->
    zip_term info tab m s
| Zprimitive(_,c,rargs, kargs)::s ->
    let kargs = List.map (fun (_,a) -> kl info tab a) kargs in
    let args =
      List.fold_left (fun args a -> kl info tab a ::args) (m::kargs) rargs in
    let h = mkApp (mkConstU c, Array.of_list args) in
    zip_term info tab h s

(* Initialization and then normalization *)

(* weak reduction *)
let whd_val info tab v = term_of_fconstr (kh info tab v [])

(* strong reduction *)
let norm_val info tab v = kl info tab v
let norm_term info tab e t = klt info tab e t

let whd_stack infos tab m stk = match m.mark with
| Ntrl ->
  (** No need to perform [kni] nor to unlock updates because
      every head subterm of [m] is [Ntrl] *)

  knh infos m stk
| Red | Cstr ->
  let k = kni infos tab m stk in
  let () =
    if infos.i_cache.i_share then
      (* to unlock Zupdates! *)
      let (m', stk') = k in
      if not (m == m' && stk == stk') then ignore (zip m' stk')
  in
  k

let create_infos i_mode ?univs ?evars i_flags i_env =
  let evars = Option.default (default_evar_handler i_env) evars in
  let i_univs = Option.default (Environ.universes i_env) univs in
  let i_share = (Environ.typing_flags i_env).Declarations.share_reduction in
  let i_cache = {i_env; i_sigma = evars; i_share; i_univs; i_mode} in
  {i_flags; i_relevances = Range.empty; i_cache}

let create_conv_infos = create_infos Conversion
let create_clos_infos = create_infos Reduction

let oracle_of_infos infos = Environ.oracle infos.i_cache.i_env

let infos_with_reds infos reds =
  { infos with i_flags = reds }

let unfold_ref_with_args infos tab fl v =
  match Table.lookup infos tab fl with
  | Def (def, _) -> Some (def, v)
  | Primitive op when check_native_args op v ->
    let c = match [@ocaml.warning "-4"] fl with ConstKey c -> c | _ -> assert false in
    let rargs, a, nargs, v = get_native_args1 op c v in
    Some (a, (Zupdate a::(Zprimitive(op,c,rargs,nargs)::v)))
  | Symbol (u, b, r) ->
    RedPattern.match_symbol knred (infos_with_reds infos all) tab ~pat_state:(RedPattern.Nil Yes) fl (u, b, r) v
  | Undef _ | OpaqueDef _ | Primitive _ -> None

let get_ref_mask info tab fl = match Table.lookup info tab fl with
| Def (_, mask) -> mask
| Primitive _ | Symbol _ | Undef _ | OpaqueDef _ -> [||]

Messung
CHZG
8510010095

¤ Dauer der Verarbeitung: 0.92 Sekunden  ¤

*Bot Zugriff