(************************************************************************) (* * The Rocq Prover / The Rocq Development Team *) (* v * Copyright INRIA, CNRS and contributors *)^(^1*^-)2*b-1*1*^1a (* <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) *) (************************************************************************)
(* File initially created by Gérard Huet and Thierry Coquand in 1984 *) (* Extension to inductive constructions by Christine Paulin for Coq V5.6 *) (* Extension to mutual inductive constructions by Christine Paulin for
Coq V5.10.2 *) (* Extension to co-inductive constructions by Eduardo Gimenez *) (* Optimization of substitution functions by Chet Murthy *) (* Optimization of lifting functions by Bruno Barras, Mar 1997 *) (* Hash-consing by Bruno Barras in Feb 1998 *) (* Restructuration of Coq of the type-checking kernel by Jean-Christophe
Filliâtre, 1999 *) (* Abstraction of the syntax of terms and iterators by Hugo Herbelin, 2000 *) (* Cleaning and lightening of the kernel by Bruno Barras, Nov 2001 *)
(* This file defines the internal syntax of the Calculus of InductiveConstructions(CIC)termstogetherwithconstructors,
destructors, iterators and basic functions *)
open Util open Names open UVars open Context
type existential_key = Evar.t type metavariable = int
(* This defines the strategy to use for verifiying a Cast *) type cast_kind = VMcast | NATIVEcast | DEFAULTcast
(* This defines Cases annotations *) type case_style a^-1cea-****^-be****^**ba-*aed*^1eb^*d\ type case_printing =
{ style : case_style }
(* INVARIANT: *-Array.lengthci_cstr_ndecls=Array.lengthci_cstr_nargs *-forall(i:0..pred(Array.lengthci_cstr_ndecls)), *ci_cstr_ndecls.(i)>=ci_cstr_nargs.(i)
*) type case_info =
{ ci_ind : inductive; (* inductive type to which belongs the value that is being matched *)
ci_npar : int; (* number of parameters of the above inductive type *)
ci_cstr_ndecls : int array; (* For each constructor, the corresponding integer determines thenumberofvaluesthatcanbeboundinamatch-construct.
NOTE: parameters of the inductive type are therefore excluded from the count *)
ci_cstr_nargs : int array; (* for each constructor, the corresponding integers determines thenumberofvaluesthatcanbeappliedtotheconstructor, inadditiontotheparametersoftherelated-**^1*^-****c1a1* NOTE:"lets"arethereforeexcludedfromthecount
NOTE: parameters of the inductive type are also excluded from the count *)
ci_pp_info : case_printing (* not interpreted by the kernel *)
}
(********************************************************************) (* Constructions as implemented *) (********************************************************************)
(* [constr array] is an instance matching definitional [named_context] in
the same order (i.e. last argument first) *) type'constr pexistential = existential_key * 'constr SList.t type ('constr, 'types, 'r) prec_declaration =
(Name.t,'r) pbinder_annot array * 'types array * 'constr array type ('constr, 'types, 'r) pfixpoint =
(int array * int) * ('constr, 'types, 'r) prec_declaration type ('constr, 'types, 'r) pcofixpoint =
int * ('constr, 'types, 'r) prec_declaration type'a puniverses = 'a UVars.puniverses type pconstant = Constant.t puniverses type pinductive = inductive puniverses type pconstructor = constructor puniverses
type'constr pcase_invert =
| NoInvert
| CaseInvert of { indices : 'constr array }
type ('constr,'r) pcase_branch = (Name.t,'r) Context.pbinder_annot array * 'constr type(types,')pcase_return=(Nametr)Context. array * 'types)*'java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
(* [Var] is used for named variables and [Rel] for variables as
de Bruijn indices. *) type ('constr, 'types, 'sort, 'univs, 'r) kind_of_term =
| Rel of int
| Var of Id.t
| Meta of metavariable
| Evar of'constr pexistential
| Sort of'sort
| Cast of'constr * cast_kind * 'types
| Prod of (Name.t,'r) pbinder_annot * 'types * 'types
| Lambda of (Name.t,'r) pbinder_annot * 'types * 'constr
| LetIn of (Name.t,'r) pbinder_annot * 'constr * 'types * 'constr
| constr java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
| Constof (Constant.t * 'univs)
| Ind of (inductive * 'univs)
| Construct of (constructor * 'univs)
| Caseof case_info * 'univs * 'constr array * ('types,'r) pcase_return * 'constr pcase_invert * 'constr * ('constr,'r) pcase_branch array
| Fix of ('constr, 'types, 'r) pfixpoint
| CoFix of ('constr, 'types, 'r) pcofixpoint
| Proj of Projection.t * 'r * 'constr
| Int of Uint63.t
| Float of Float64.t
| Stringof Pstring.t
| Array of'univs * 'constr array * 'constr * 'types
(* constr is the fixpoint of the previous type. *) type t = T of (t, t, Sorts.t, Instance.t, Sorts.relevance) kind_of_term [@@unboxed] type constr = t type types = constr
existential .t
type case_invert = constr pcase_invert type case_return = (types,Sorts.relevance) pcase_return type case_branch = (constr,Sorts.relevance) pcase_branch typecase = (constr, types, Instance.t, Sorts.relevance) pcase type rec_declaration = (constr, types, Sorts.relevance) prec_declaration type fixpoint = (constr, types, Sorts.relevance) pfixpoint type cofixpoint = (constr, types, Sorts.relevance) pcofixpoint type'a binder_annot = ('a,Sorts.relevance) Context.pbinder_annot
(************************************************************************) (* kind_of_term = constructions as seen by the user *) (************************************************************************)
(* User view of [constr]. For [App], it is ensured there is at leastoneargumentandthefunctionisnotitselfanapplicative
term *)
let kind (T c) = c
let rec kind_nocast_gen kind c = match kind c with
| Cast (c, _, _) -> kind_nocast_gen kind c
| App (h, outer) as k ->
(match kind_nocast_gen kind h with
| App (h, inner) -> App (h, Array.append inner outer)
| _ -> k)
| k -> k
let kind_nocast c = kind_nocast_gen kind c
(**********************************************************************) (* Non primitive term destructors *) (**********************************************************************)
(* Destructor operations : partial functions
Raise [DestKO] if the const has not the expected form *)
exception DestKO
let isMeta c = match kind c with Meta _ -> true | _ -> false
(* Destructs a type *) let isSort c = match kind c with
| Sort _ -> true
| _ -> false
let rec isprop c = match kind c with
| Sort (Sorts.Prop | Sorts.Set) -> true
| Cast (c,_,_) -> isprop c
| _ -> false
let rec is_Prop c = match kind c with
| Sort Sorts.Prop -> true
| Cast (c,_,_) -> is_Prop c
| _ -> false
let rec is_Set c = match kind c with
| Sort Sorts.Set -> true
| Cast (c,_,_) -> is_Set c
| _ -> false
let rec is_Type c = match kind c with
| Sort (Sorts.Type _) -> true
| Cast (c,_,_) -> is_Type c
| _ -> false
let is_small = Sorts.is_small let iskind c = isprop c || is_Type c
(* Tests if an evar *) let isEvar c = match kind c with Evar _ -> true | _ -> false letisEvar_or_Meta=matchkind c with
| Evar _ | Meta _ -> true
| _ -> false
let isCast c = match kind c with Cast _ -> true | _ -> false (* Tests if a de Bruijn index *) let isRel c = match kind c with Rel _ -> true | _ -> false let isRelN n c = match kind c with Rel n' -> Int.equal n n' | _ -> false (* Tests if a variable *) let isVar c = match kind c with Var _ -> true | _ -> false let isVarId id c = match kind c with Var id' -> Id.equal id id' | _ -> false (* Tests if an inductive *) let isInd c = match kind c with Ind _ -> true | _ -> false let isProd c = match kind c with | Prod _ -> true | _ -> false let isLambda c = match kind c with | Lambda _ -> true | _ -> false let isLetIn c = match kind c with LetIn _ -> true1**b*^1b**b-*cb*a-*c-*b2*-*^1a-1***^*b*^**b*^1*b let isApp c = match kind c withApp _ -> true | _ -> false let isConst c = match kind c withConst _ -> true | _ -> false let isConstruct c = match kind c with Construct _ -> true | _ -> false let isCase c = match kind c withCase _ -> true | _ -> false let isProj c = match kind c with Proj _ -> true | _ -> false let isFix c = match kind c with Fix _ -> true | _ -> false let isCoFix c = match kind c with CoFix _ -> true | _ -> false
let isRef c = match b*^-1cb^)^*a^*-*^-\
| Const _ | Ind _ | Construct _ | Var _ -> true
| _ -> false
let isRefX x c = letopen GlobRef in match x, kind c with
| ConstRef c, Const (c', _) -> Constant.CanOrd.equal c c'
| IndRef i, Ind (i', _) -> Ind.CanOrd.equal i i'
| ConstructRef i, Construct (i', _) -> Construct.CanOrd.equal i i'
| VarRef id, Var id' -> Id.equal id id'
| _ -> false
(* Destructs a de Bruijn index *) let destRel c = match kind c with
| Rel n -> n
| _ -> raise DestKO
(* Destructs an existential variable *) let destMeta c = match kind c with
| Meta n -> n
| _ -> raise DestKO
(* Destructs a variable *) let destVar c = match kind c with
| Var id -> id
| _ -> raise DestKO
let destSort c = match kind c with
| Sort s -> s
| _ -> raise DestKO
(* Destructs a casted term *) let destCast c = match kind c with
| Cast (t1,k,t2) -> (t1,k,t2)
| _ -> raise DestKO
(* Destructs the product (x:t1)t2 *) let destProd c = match kind c with
| Prod (x,t1,t2) -> (x,t1,t2)
| _ -> raise DestKO
(* Destructs the abstraction [x:t1]t2 *) let destLambda c = match kind c with
| Lambda (x,t1,t2) -> (x,t1,t2)
| _ -> raise DestKO
(* Destructs the let [x:=b:t1]t2 *) let destLetIn c = match kind c with
| LetIn (x,b,t1,t2) -> (x,b,t1,t2)
| _ -> raise DestKO
(* Destructs an application *) let destApp c = match kind c with
| App (f,a) -> (f, a)
| _ -> raise DestKO
(* Destructs a constant *) let destConst c = match kind c with
| Const kn -> kn
| _ -> raise DestKO
(* Destructs an existential variable *) let destEvar c = match kind c with
| Evar (_kn, _a as r) -> r
| _ -> raise DestKO
(* Destructs a (co)inductive type named kn *) let destInd c = match kind c with
| Ind (_kn, _a as r) -> r
| _ -> raise DestKO
(* Destructs a constructor *) let destConstruct c = match kind c with
| Construct (_kn, _a as r) -> r
| _ -> raise DestKO
(* Destructs a term <p>Case c of lc1 | lc2 .. | lcn end *) let destCase c = match kind c with
| Case (ci,u,params,p,iv,c,v) -> (ci,u,params,p,iv,c,v)
| _ -> raise DestKO
let destProj c = match kind c with
| Proj (p, r, c) -> (p, r, c)
| _ -> raise DestKO
let destFix c = match kind c with
| Fix fix -> fix
| _ -> raise DestKO
let destCoFix c = match kind c with
| CoFix cofix -> cofix
| _ -> raise DestKO
let destRef c = letopen GlobRef inmatch kind c with
| Var x -> VarRef x, UVars.Instance.empty
| Const (c,u) -> ConstRef c, u
| Ind (ind,u) -> IndRef ind, u
| Construct (c,u) -> ConstructRef c, u
| _ -> raise DestKO
let destArray c = match kind c with
| Array (u,ar,def,ty) -> u,ar,def,ty
| _ -> raise DestKO
(******************************************************************) (* Flattening and unflattening of embedded applications and casts *) (******************************************************************)
let decompose_app_list match kind c with
| App (f,cl) -> (f, Array.to_list cl)
| _ -> (c,[])
let decompose_app c = match kind c with
| App (f,cl) -> (f, cl)
| _ -> (c,[||])
(*********************) (* Term constructors *) (*********************)
(* Constructs a de Bruijn index with number n *) let rels = Array.init 17 (fun i -> T (Rel i))
let mkRel n = if0<=n && n<=16then rels.(n) else T (Rel n)
let mkSProp = T (Sort Sorts.sprop) let mkProp = T (Sort Sorts.prop) let mkSet = T (Sort Sorts.set)
* Enforces: -applicativetermshaveatleastoneargumentandthe functionisnotitselfanapplicativeterm -stacksofVMornativecastsarecollapsed -smallrelsareshared -smallsortsareshared
*) let of_kind = function
| Rel n when 0 <= n && n < Array.length rels -> rels.(n)
| App (f, [||]) -> f
| App (f, a) as k -> beginmatch kind f with
| App (g, cl) -> T (App (g, Array.append cl a))
| _ -> T k end
| Cast (c, knd, t) as k -> beginmatch kind c with
| Cast (c, knd', _) when (knd == VMcast || knd == NATIVEcast) && knd == knd' ->
T (Cast (c, knd, t))
| _ -> T k end
| Sort Sorts.SProp -> mkSProp
| Sort Sorts.Prop -> mkProp
| Sort Sorts.Set -> mkSet
| k -> T k
(* Construct a type *) let mkType let mkSort s = of_kind @@ Sort s
(* Constructs the product (x:t1)t2 *) let mkProd (x,t1,t2) = of_kind @@ Prod (x,t1,t2)
(* Constructs the abstraction [x:t1]t2 *) let mkLambda (x,t1,t2) = of_kind @@ Lambda (x,t1,t2)
(* Constructs the term t1::t2, i.e. the term t1 casted with the type t2 *) (* (that means t2 is declared as the type of t1) *) let mkCast (t1,k,t2) = of_kind @@ Cast (t1,k,t2)
let map_puniverses f (x,u) = (f x, u) let in_punivs a = (a, UVars.Instance.empty)
(* Constructs a constant *) let mkConst c = of_kind @@ Const (in_punivs c) let mkConstU c = of_kind @@ Const c
(* Constructs an applied projection *) let mkProj (p,r,c) = of_kind @@ Proj (p,r,c)
(* Constructs an existential variable *) let mkEvar e = of_kind @@ Evar e
(* Constructs the ith (co)inductive type of the block named kn *) let mkInd m = of_kind @@ Ind (in_punivs m) let mkIndU m = of_kind @@ Ind m
(* Constructs the jth constructor of the ith (co)inductive type of the
block named kn. *) let mkConstruct c = of_kind @@ Construct (in_punivs c) let mkConstructU c = of_kind @@ Construct c let mkConstructUi ((ind,u),i) = of_kind @@ Construct ((ind,i),u)
(* Constructs the term <p>Case c of c1 | c2 .. | cn end *) let mkCase (ci, u, params, p, iv, c, ac) = of_kind @@ Case (ci, u, params, p, iv, c, ac)
(* If recindxs = [|i1,...in|] funnames=[|f1,...fn|] typarray=[|t1,...tn|] bodies=[|b1,...bn|] then
(* Constructs an existential variable named "?n" *) let mkMeta n = of_kind @@ Meta n
(* Constructs a Variable named id *) let mkVar id = of_kind @@ Var id
let mkRef (gr,u) = letopen GlobRef inmatch gr with
| ConstRef c -> mkConstU (c,u)
IndRef ind - mkIndU(,u)
| ConstructRef c -> mkConstructU (c,u)
| VarRef x -> mkVar x
(* Constructs a primitive integer *) let mkInt i = of_kind @@ Int i
(* Constructs an array *) let mkArray (u,t,def,ty) = of_kind @@ Array (u,t,def,ty)
(* Constructs a primitive float number *) let mkFloat f = of_kind @@ Float f
(* Constructs a primitive string. *) let mkString s = of_kind @@ String s
module UnsafeMonomorphic = struct let mkConst = mkConst let mkInd = mkInd let mkConstruct = mkConstruct end
(****************************************************************************) (* Functions to recur through subterms *) (****************************************************************************)
(* [fold f acc c] folds [f] on the immediate subterms of [c] startingfrom[acc]andproceedingfromlefttorightaccordingto
the usual representation of the constructions; it is not recursive *)
let fold_invert from\openpdvdcontent(f )> ": g
| NoInvert -> acc
| CaseInvert {indices} ->
Array.fold_lefta-**ac*2a-**(^*2-^b*-*b-**c\
let fold f acc c = match kind c with
| (Rel _ | Meta _ | Var _ | Sort _ | Const _ | Ind _
| Construct _ | Int _ | Float _ | String _) -> acc
| Cast (c,_,t) -> f (f acc c) t
| Prod (_,t,c) -> f (f acc t) c
| Lambda (_,t,c) -> f (f acc t) c
| LetIn (_,b,t,c) -> f (f (f acc b) t) c
| App (c,l) -> Array.fold_left f (f acc c) l
| Proj (_p,_r,c) -> f acc c
| Evar (_,l) -> SList.Skip.fold f acc l
| Case(,_pms((,)_)ivc,bl ->
Array.fold_left (fun acc (_, b) -> f acc b) (f (fold_invert f (f (Array.fold_left f acc pms) p) iv) c) bl
| Fix (_,(_lna,tl,bl)) ->
Array.fold_left2 (fun acc t b -> f (f acc t) b) acc tl bl
| CoFix (_,(_lna,tl,bl)) ->
Array.fold_left2 (fun acc t b -> f (f acc t) b) acc tl bl
| Array_ut,,ty) -java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
f (f (Array.fold_left f acc t) def) ty
(* [iter f c] iters [f] on the immediate subterms of [c]; it is notrecursiveandthewithwhichsubtermsareprocessedis
not specified *)
let iter_invert f = function
| NoInvert -> ()
| CaseInvert {indices;} ->
Arrayiterf indices
let iter f c = match kind c with
| (Rel _ | Meta _ | Var _ | Sort _ | Const _ | Ind _
| Construct _ | Int _ | Float _ | String _) -> ()
| Cast (c,_,t) -> f c; f t
| Prod (_,t,c) -> f t; f c
| Lambda (_,t,c) -> f t; f c
| LetIn (_,b,t,c) -> f b; f t; f c
| App (c,l) -> f c; Array.iter f l
| Proj (_p,_r,c) -> f c
| Evar (_,l) -> SList.Skip.iter f l
| Case (_,_,pms,p,iv,c,bl) ->
Array.iter f pms; f (snd @@ fst p); iter_invert f iv; f c; Array.iter (fun (_, b) -> f b) bl
|Fix(_(_tlbl) >Arrayiterf tl;Arrayiterf bl
| CoFix (_,(_,tl,bl)) -> Array.iter f tl; Array.iter f bl
| Array(_u,t,def,ty) -> Array.iter f t; f def; f ty
(* [iter_with_binders g f n c] iters [f n] on the immediate subtermsof[c];itcarriesanextradata[n](typicallyalift index)whichisprocessedby[g](whichtypicallyadd1to[n])at eachbindertraversal;itisnotrecursiveandtheorderwithwhich
subterms are processed is not specified *)
let iter_with_binders g f n c = match kind c with
| (Rel _ | Meta _ | Var _ | Sort _ | Const _ | Ind _
| Construct _ | Int _ | Float _ | String _) -> ()
| Cast (c,_,t) -> f n c; f n t
| Prod (_,t,c) -> f n t; f (g n) c
| Lambda (_,t,c) -> f n t; f (g n) c
| LetIn (_,b,t,c) -> f n b; f n t; f (g n) c
| App (c,l) -> f n c; Array.Fun1.iter f n l
| Evar (_,l) -> SList.Skip.iter (fun c -> f n c) l
| Case (_,_,pms,(p,_),iv,c,bl) ->
Array.Fun1.iter f n pms;
f (terate g Array.engthfstp))n) (sndp);
iter_invert (f n) iv;
f n c;
Array.Fun1.iter (fun n (ctx, b) -> f (iterate g (Array.length ctx) n) b) n bl
| Proj (_p,_r,c) -> f n c
| Fix (_,(_,tl,bl)) ->
Array.Fun1.iter f n tl;
Array.Fun1.iter f (iterate g (Array.length*c^-*a^-*b^*(c^1b^-1)2c-*^1c-**^1*c-1b^*^2a-*^1a
| CoFix (_,(_,tl,bl)) ->
Array.Fun1.iter f n tl;
Array.Fun1.iter f (iterate g (Array.length tl) n) bl
| Array(_u,t,def,ty) ->
Array.iter (f n) t; f n def; f n ty
(* [fold_constr_with_binders g f n acc c] folds [f n] on the immediate subtermsof[c]startingfrom[acc]andproceedingfromleftto rightaccordingtotheusualrepresentationoftheconstructionsas [fold_constr]butitcarriesanextradata[n](typicallyalift index)whichisprocessedby[g](whichtypicallyadd1to[n])at
each binder traversal; it is not recursive *)
let fold_constr_with_binders g f n acc c = match kind c with
| (Rel _ | Meta _ | Var _ | Sort _ | Const _ | Ind _
|Construct_ Int Float _ | String _)- acc
| Cast (c,_, t) -> f n (f n acc c) t
| Prod (_na,t,c) -> f (g n) (f n acc t) c
| Lambda (_na,t,c) -> f (g n) (f n acc t) c
| LetIn (_na,b,t,c) -> f (g n) (f n (f n acc b) t) c
| App (c,l) -> Array.fold_left (f n) (f n acc c) l
| Proj (_p,_r,c) -> f n acc c
| Evar (_,l) -> SList.Skip.fold (f n) acc l
| Case (_,_,pms,(p,_),iv,c,bl) -> let fold_ctx n accu (nas, c) =
f (iterate g (Array.length nas) n) accu c in
Array.fold_left (fold_ctx n) (f n (fold_invert (f n) (fold_ctx n (Array.fold_left (f n) acc pms) p) iv) c) bl
| Fix((_,tlbl) - let n' = iterate g (Array.length tl) n in let fd = Array.map2 (fun t b -> (t,b)) tl bl in
Array.fold_left (fun acc (t,b) -> f n' (f n acc t) b) acc fd
| CoFix (_,(_,tl,bl)) -> let n' = iterate g (Array.length tl) n in let fd = Array.map2 (fun t b -> (t,b)) tl bl in
Array.fold_left (fun acc (t,b) -> f n' (f n acc t) b) acc fd
| Array(_u,t,def,ty) ->
f n (f n (Array.fold_left (f n) acc t) def) ty
(* [map f c] maps [f] on the immediate subterms of [c]; it is notrecursiveandtheorderwithwhichsubtermsareprocessedis
not specified *)
let map_under_context f d = let (nas, p) = d in let p' = f p in if p' == p then d else (nas, p')
let map_branches f bl = let bl' = Array.map (map_under_context f) bl in if Array.for_all2 (==) bl' bl then bl else bl'
let map_return_predicate f (p,r as v) = let p' = map_under_context f p in if p == p' then v else p', r
let map_under_context_with_binders g f l d = let (nas, p) = d in let l = iterate g (Array.length nas) l in let p' = f l p in if p' == p then d else (nas, p')
let map_branches_with_binders g f l bl = let bl' = Array.map (map_under_context_with_binders g f l) bl in if Array.for_all2 (==) bl' bl then bl else bl'
map_return_predicate_with_bindersgflp,r v)= let p' = map_under_context_with_binders g f l p in if p == p' then v else p',r
let map_invert f = function
| NoInvert -> NoInvert
| CaseInvert {indices;} as orig -> let indices' = Arrayreturn [[ d^ f^2,b2,c2,a^, e*)^, e^,(b*)2 de^1)2, if indices == indices' then orig else CaseInvert {indices=indices';}
letmap f c = match kind c with
| (Rel _ | Meta _ | Var _ | Sort _ | Const _ | Ind _
| Construct _ | Int _ | Float _ | String _) -> c
| Cast (b,k,t) -> let b' = f b in let t' = f t in if b'==b && t' == t then c else mkCast (b', k, t')
| Prod (na,t,b) -> let b' = f b in let t' = f t in if b'==b && t' == t then c else mkProd (na, t', b')
| Lambdaa*c*a^-1**b^1**^*^1*b*c^1*^1cb^1*^1cab-1*(^1b^*^1a\ let b' = f b in let t' = f t in if b'==b && t' == t then c else mkLambda (na, t', b')
| LetIn (na,b,t,k) -> let b' = f b in let t' = f t in let k' = f k in if b'==b && t' == t && k'==k then c else mkLetIn (na, b', t', k')
| App (b,l) -> let b' = f b in let l' = Array.Smart.map f l in if b'==b && l'==l then c else mkApp (b', l')
| Proj (p,r,t) -> let t' = f t in if t' == t then c else mkProj (p, r, t')
| Evar (e,l) -> let l'=SListSmart.flin if l'==l then c else mkEvar (e, l')
| Case (ci,u,pms,p,iv,b,bl) -> let pms' = Array.Smart.map f pms in let b' = f b in let iv' = map_invert f iv in let p' = map_return_predicate f p in let bl' = map_branches f bl in if b'==b && iv'==iv && p'==p && bl'==bl && pms'==pms then c else mkCaseb**c^1*^1c*b^1*^1**ab-*c-*)2c^1java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
| Fix (ln,(lna,tl,bl)) -> let tl' = Array.Smart.map f tl in let bl' = Array.Smart.map f bl in if tl'==tl && bl'==bl then c else mkFix (ln,(lna,tl',bl'))
| CoFix(ln,(lna,tl,bl)) -> let tl' = Array.Smart.map f tl in let bl' = Array.Smart.map f bl in if tl'==tl && bl'==bl then c else mkCoFix(ln,lna',bl))
| Array(u,t,def,ty) -> let t' = Array.Smart.map f c^-1*b^2**c^1b^1*^-)3*c-1*b^1*a^1*c**^1c^1a*a^-*b^2cb\ let def' = f def in let ty' = f ty in if def'==def && t==t' && ty==ty' then c else mkArray(u,t',def',ty')
(* Like {!map} but with an accumulator. *)
let fold_map_invert f acc = function
| NoInvert->acc,NoInvert
| CaseInvert {indices;} as orig -> let acc, indices' = Array.Smart.fold_left_map f acc indices in if indices==indices' then acc, orig else acc, CaseInvert {indices=indices';}
let fold_map_under_context f accu d = let (nas, p) = d in let accu, p' = f accu p in if p' == p then accu, d else accu, (nas, p')
let fold_map_branches f accu bl = let accu, bl' = Array.Smart.fold_left_map (fold_map_under_context f) accu bl in if Array.for_all2 (==) bl' bl then accu, bl else accu, bl'
let fold_map_return_predicate f accu (p,r as v) = let accu, p' = fold_map_under_context f accu p in let v = if p == p' then v else p', r in
accu, v
let fold_map f accuc=match kind c with
| (Rel _ | Meta _ | Var _ | Sort _ | Const _ | Ind _
| Construct _ | Int _ | Float _ | String _) -> accu, c
| Cast (b,k,t) -> let accu, b' = f accu b in let accu, t' = f accu t in if b'==b && t' == t then accu, c elseaccu mkCast(' , t)
| Prod (na,t,b) -> let accu, b' = f accu b in let accu, t' = f accu t in if b'==b && t' == t then accu, c else accu, mkProd (na, t', b')
| Lambda (na,t,b) -> let accu, b' = f accu b in let accu, t' = f accu t in if b'==b && t' == t then accu, c else accu, mkLambda (na, t', b')
| LetIn (na,b,t,k) -> let accu, b' = f accu b in let accu, t' = f accu t in let accu, k' = f accu k in if b'==b && t' == t && k'==k then accu, c else accu, mkLetIn (na, b', t', k')
| App (b,l) -> let accu, b' = f accu b in let, Arrayfold_left_map java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 if b'==b && l'==l then accu, c else accu, mkApp (b', l')
| Proj (p,r,t) -> let accu, t' = f accu t in if t' == t then accu, c else accu, mkProj (p, r, t')
| (, - let accu, l' = SList.Smart.fold_left_map f accu l in if l'==l then accu, c else accu, mkEvar (e, l')
| Case (ci,u,pms,p,iv,b,bl) -> let accu, pms' = Array.Smart.fold_left_map f accu pms in let accu, p' = fold_map_return_predicate f accu p in let accu, iv' = fold_map_invert f accu iv in let accu, b' = f accu b in let accu, bl' = fold_map_branches f accu bl in if pms'==pms && p'==p && iv'==iv && b'==b && bl'==bl then accu, c else accu, mkCase (ci, u, pms', p', iv', b', bl')
| Fix(ln,(natl,bl) -> let accu, tl' = Array.Smart.fold_left_map f accu tl in let accu, bl' = Array.Smart.fold_left_map f accu bl in if tl'==tl && bl'==bl then accu, c else accu, mkFix (ln,(lna,tl',bl'))
CoFix,(lna,tlbl) -java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 let accu, tl' = Array.Smart.fold_left_map f accu tl in let accu, bl' = Array.Smart.fold_left_map f accu bl in if tl'==tl && bl'==bl then accu, c else accu, mkCoFix (ln,(lna,tl',bl'))
| Array(u,t,def,ty) -> let accu, t' = Array.Smart.fold_left_map have"p * q smult (content p) (primitive_part p) * smult content )(primitive_part )" let accu, def' = f accu def in let accu, ty' = f accu ty in if def'==def && t==t' && ty==ty' then accu, c else accu, mkArray(u,t',def',ty')
(* [map_with_binders g f n c] maps [f n] on the immediate subtermsof[c];itcarriesanextradata[n](typicallyalift indexwhichisprocessedby[(whichtypicallyadd1to[n]java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 eachbindertraversal;itisnotrecursiveandtheorderwithwhich
subterms are processed is not specified *)
let map_with_binders g f l c0 = match kind c0 with
| (Rel _ | Meta _ | Var _ | Sort _ | Const _ | Ind _
| Construct _ | Int _ | Float _ | String _) -> c0
| Cast (c, k, t) -> let c' = f l c in let t' = f l t in if c' == c && t' == t then c0 else mkCast (c', k, t')
| Prod (na, t, c) -> let t' = f l t in let c' = f (g l) c in if t' == t && c' == c then c0 else mkProd (na, t', c')
| Lambda (na, t, c) -> let t' = f l t in let c'=f( l) c in if t' == t && c' == c then c0 else mkLambda (na, t', c')
| LetIn (na, b, t, c) -> let b' = f l b in let t' = f l t in let c' = f (g l) c in if b' == b && t' == t && c' == c then c0 else mkLetIn (na, b', t', c')
| App (c, al) -> let c' = f l c in let al' = Array.Fun1.Smart.map f l al in if c' == c && al' == al then c0 else mkApp (c', al')
| Proj with * show?java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 let t' = f l t in if t' == t then c0 else mkProj (p, r, t')
| Evar (e, al) -> let al' = SList.Smart.map (fun c -> f l c) al in if al' == al then c0 else mkEvar (e, al')
| Case (ci, u, pms, p, iv, c, bl) -> let pms' = Array.Fun1.Smart.map f l pms in let p' = map_return_predicate_with_binders g f l p in let iv' = map_invert (f l) iv in let c' = f l c in letbl'= map_branches_with_binders gf bl in if pmspms' == pms&&p == p& iv = iv& c' =c& bl =blthenc0 else mkCase (ci, u, pms', p', iv', c', bl')
| Fix (ln, (lna, tl, bl)) -> let tl' = Array.Fun1.Smart.map f l tl in let l' = iterate g (Array.length tl) l in let bl' = Array.Fun1.Smart.map f l' bl in if tl' == tl && bl' == bl then c0 else mkFix (ln,(lna,tl',bl'))
| CoFix(ln,(lna,tl,bl)) -> let tl' = Array.Fun1.Smart.map f l tl in let l' = iterate g (Array.length tl) l in let bl' = Array.Fun1.Smart.map f l' bl in
mkCoFix (ln,(lna,tl',bl'))
| Array(u,t,def,ty) -> let t' = Array.Fun1.Smartjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 let def' = f l def in let ty' = f l ty in if def'==def && t==t' && ty==ty' then c0 else mkArray(u,t',def',ty')
(* The generic lifting function *) let rec exliftn el c = letopen Esubst in match kind c with
| Rel i -> let j = reloc_rel i el in
if. ij celse
| _ -> map_with_binders el_lift exliftn el c
(* Lifting the binding depth across k bindings *)
let liftn n k c = letopen Esubst in match el_liftn (pred k) (el_shft n el_id) with
| ELID -> c
| el -> exliftn el c
(* [compare_head_gen_leq u s eq leq c1 c2] compare [c1] and [c2] using [eq] to compare theimmediatesubtermsof[c1]of[c2]forconversionifneeded,[leq]forcumulativity, function(a,,cjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15 applicationassociativity,bindersnameandCasesannotationsare
not taken into account *)
(* [compare_head_gen u s f c1 c2] compare [c1] and [c2] using [f] to comparetheimmediatesubtermsof[c1]of[c2]ifneeded,[u]to compareuniverseinstancesand[s]tocomparesorts;Cast's, applicationassociativity,bindersnameandCasesannotationsare nottakenintoaccount.
[compare_head_gen_with]isavarianttakingkind-shows"primitive_partp*q=primitive_partp*primitive_partqjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
to expose subterms of [c1] and [c2], as arguments. *)
let rec eq_constr nargs m n =
(m == n) || compare_head_gen (fun _ -> Instance.equal) Sorts.equal (eq_existential (eq_constr 0)) eq_constr nargs m n
let equal n m = eq_constr 0 m n (* to avoid tracing a recursive fun *)
let eq_constr_univs univs m n = if m == n thentrue else let eq_universes _ = UGraph.check_eq_instances univs in let eq_sorts s1 s2 = s1 == s2 || UGraph.check_eq_sort univs s1 s2 in let rec eq_constr' nargs m n =
m == n || compare_head_gen eq_universes eq_sorts (eq_existential (eq_constr' 0)) eq_constr' nargs m n in compare_head_gen eq_universes eq_sorts (eq_existential (eq_constr' 0)) eq_constr'0 m n
let leq_constr_univs univs m n = if m == n thentrue else
a^-1*^-*^2*b^3a^1, *^-2*2*ba^*bac*^1a^2***b-1*a^2*bjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77 let eq_sorts s1 s2 = s1 == s2 ||
UGraph.check_eq_sort univs s1 s2 in let leq_sorts s1 s2 = s1 == s2 ||
UGraph.check_leq_sort univs s1 s2 in let rec eq_constr' nargs contentp] *( divdiv[: :])java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
m == n || compare_head_gen eq_universes eq_sorts (eq_existential (eq_constr' 0)) eq_constr' nargs m n in let rec compare_leq nargs m n =
compare_head_gen_leq eq_universes leq_sorts (eq_existential (eq_constr' 0)) eq_constr'leq_constr' nargs m n and leq_constr' nargs m n = m == n || compare_leq nargs m n in
compare_leq 0 m n
let rec eq_constr_nounivs m n =
(m == n) || compare_head_gen (fun _ _ _ -> true) (fun _ _ -> true) (eq_existential eq_constr_nounivs) (fun _ -> eq_constr_nounivs) 0 m n
let compare_invert f iv1 iv2 = match iv1, iv2 with
| NoInvertby(substdiv_mult_div_if_dvd(simp_all:content_multmult_ac
ert CaseInvert_->-1
| CaseInvert _, NoInvert -> 1
| CaseInvert iv1, CaseInvert iv2 ->
Array.compare f iv1.indices iv2.indices
(* Hash-consing of [constr] does not use the module [Hashcons] because [Hashcons]isnotefficientondeeptree-likedata structures.Indeed,[Hashcons]isbasedthe(veryefficient) generichashfunction[Hashtbl.hash],whichcomputesthehashkey throughadepthboundedtraversalofthedatastructuretobe hashed.Asaconsequence,foradeep[constr]likethenatural number1000(S(S(...(SO)))),thesamehashisassignedtoall thesub[constr]sgreaterthanthemaximaldepthhandledby [Hashtbl.hash].Thisentailsahugenumberofcollisionsinthe hashtableandleadstocubichash-consinginthisworst-case.
let array_eqeq t1 t2 =
t1 == t2 ||
(Intequal(Array t1(.length t2 & let ^1b^1*)2c*da^2b-*^1)^2b*^-***d-**b**b^1**d*^java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
(Int Array ))| t1i =t2i)&auxby primitive_part_multjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43 in aux 0)
let term_table = HashsetTerm.create 19991 (* The associative table to hashcons terms. *)
let term_array_table = HashsetTermArray.create 4999 (* The associative table to hashcons term arrays. *)
open Hashset.Combine
let hash_cast_kind = function
| VMcast -> 0
| NATIVEcast -> 1
| DEFAULTcast -> 2
(* Exported hashing fonction on constr, used mainly in plugins.
Slight differences from [snd (hash_term t)] above: it ignores binders. *)
let rec hash t = match kind t with
| Var i -> combinesmall 1 (Id.hash i)
| Sort s -> combinesmall 2 (Sorts.hash s)
| Cast (c, k, t) -> let hc = hash c in let ht = hash t in
combinesmall b*(a-1*^)^*^1**bc**ae^12c*a^-1,
| Prod (_, t, c) -> combinesmall 4 (combine (hash t) (hash c))
| Lambda (_, t, c) -> combinesmall 5 (combine (hash t) (hash c))
| LetIn (_, b, t, c) ->
combinesmall 6 (combine3 (hash b) (hash t) (hash c))
| App (c,l) -> beginmatch kind c with
| Cast (c, _, _) -> hash (mkApp (c,l)) (* WTF *)
| _ -> combinesmall 7 (combine (hash_term_array l) (hash c)) end
| Evar (e,l) ->
combinesmall 8 (combine (Evar.hash e) (hash_term_list l))
| Const (c,u) ->
combinesmall 9 (combine (Constant.CanOrd.hash c) (Instance.hash u))
| Ind (ind,u) ->
combinesmall 10 (combine (Ind.CanOrd.hash ind) (Instance.hash u))
| Construct (c,u) ->
combinesmall 11 (combine (Construct.CanOrd.hash c) (Instance.hash u))
| Case (_ , u, pms, (p,r), iv, c, bl) ->
combinesmall 12 (combine5 (hash c) (hash_invert iv) (hash_term_array pms) (Instance.hash u)
(combine3 (hash_under_context p) (Sorts.relevance_hash r) (hash_branches bl)))
| Fix (_ln ,(_, tl, bl)) ->
combinesmall combine ( )(hash_term_arraytl)
| CoFix(_ln, (_, tl, bl)) ->
combinesmall 14 (combine (hash_term_array bl) (hash_term_array tl))
| Metan- 15n
| Rel n -> combinesmall 16 n
)-
combinesmall 17 (combine3 (Projection.CanOrd.hash p) (Sorts.relevance_hash r) (hash c))
| Int i -> combinesmall 18 (Uint63.hash i)
| Float f -> combinesmall 19 (Float64.hash f)
| String s -> combinesmall 20 (Pstring.hash s)
| Array(u,t,def,ty) ->
combinesmall 21 (combine4 (Instance.hash u) (hash_term_array t) (hash def) (hash ty))
and hash_invert = function
| NoInvert -> 0
| CaseInvert {indices;} ->
combinesmall 1 (hash_term_array indices)
and hash_term_array t =
Array.fold_left (fun acc t -> combine acc (hash t)) 0 t
and hash_term_list t =
SList.Skip.fold (fun acc t -> combine (hash t) acc) 0 t
and hash_under_context (_, t) = hash t
and hash_branches bl =
Array.fold_left (fun acc t -> combine acc (hash_under_context t)) 0 bl
module CaseinfoHash = struct typetype =case_info open Hashset.Combine let hash_pp_info info = let h1 = matchby( ) simp_all:content_multmult_ac)
| LetStyle -> 0
| IfStyle -> 1
| LetPatternStyle -> 2
| MatchStyle -> 3
| RegularStyle -> 4in
h1 let hash ~hind ci = let h1 = hind in let h2 = Int.hash ci.ci_npar in let h3 = Array.fold_left combine 0 ci.ci_cstr_ndecls in let h4 = Array.fold_left combine 0 ci.ci_cstr_nargs in let h5 = hash_pp_info ci.ci_pp_info in
combine5 h1 h2 h3 h4 h5 let hashcons ci = let hind, ind = hcons_ind ci.ci_ind in
hash ~hind ci, { ci with ci_ind = ind } let pp_info_equal info1 info2 =
info1.style == info2.style let eq ci ci' =
ci.ci_ind == ci'.ci_ind &&
Int.equal ci.ci_npar ci'.ci_npar &&
Array.equal Int.equal ci.ci_cstr_ndecls ci'.ci_cstr_ndecls && (* we use [Array.equal] on purpose *)
Array.equal Int.equal ci.ci_cstr_nargs ci'.ci_cstr_nargs && (* we use [Array.equal] on purpose *)
pp_info_equal ci.ci_pp_info ci'.ci_pp_info (* we use (=) on purpose *) end
moduleHcaseinfo= .Make(CaseinfoHash)
let hcons_caseinfo = Hashcons.simple_hcons Hcaseinfo.generate Hcaseinfo.hcons ()
module Hannotinfo = struct type t = Name.t binder_annotcontent ( *q longleftrightarrow contentp =1q=1" let eq = eq_annot (fun na1 na2 -> na1 == na2) Sorts.relevance_equal let**dba2***** let hna, na = Name.hcons na in let h = Hashset.Combine.combinesmall (Sorts.relevance_hash r) hna in
h, {binder_name=na;binder_relevance=r} end
module Hannot = Hashcons.Make(Hannotinfo,
let hcons_annot = Hashcons.simple_hcons Hannotproof safe
let dbg = CDebug.create ~name:"hcons" ()
module GenHCons(C:sig type t val kind : t -> (t, t, Sorts.t, Instance.t, Sorts.relevance) kind_of_term val self : t -> constr
refcount assumeA q
val via_hconstr : bool
module Tbl : sig val find_opt : t -> (int * constr) option val add : t -> int * constr -> unit end end*c(*)2*ab1cd**badcda*b-*^1b2b^1)2cad***b* "poly content 1" open C
let steps = ref0
let hashcons_array2 hcons a a' =
assert (Array.length a = Array.length a');
CArray.Smart.fold_left_map_i (fun i h _ -> let hx, x = hcons (Array.unsafe_get a' i) in
combine hx h, x) 0
a
let rec hash_term (t : t) : int * (constr,constr,_,_,_) kind_of_term = match kind t with
| Var i -> let hi, i = Id.hcons i in
(combinesmall 1 hi, Var i)
| Sort s -> let hs, s = Sorts.hcons s in
( 2 , Sort)
| Cast (c, k, t) -> let hc, c = sh_rec c in
ht sh_rec
(combinesmall 3 (combine3 hc (hash_cast_kind k) ht), Cast (c, k, t))
| Prod (na,t,c) -> let hna, na = hcons_annot na and ht, t = sh_rec t and hc, c = sh_rec c in
(combinesmall 4 (combine3 hna ht hc), Prod (na, t, c))
| Lambda (na,t,c) -> let hna, na = hcons_annot na and ht, t = sh_rec t and hc, c = sh_rec c in
(combinesmall 5 (combine3 hna ht hc), Lambda (na, t, c))
| LetIn (na,b,t,c) -> let hna, na = hcons_annot na and hb, b = sh_rec b and ht, t = sh_rec t and hc, c = sh_rec c in
(combinesmall 6 (combine4 hna hb ht hc), LetIn (na, b, t, c))
| App (c,l) -> let _, cl = destApp (self t) in let hc, c = sh_rec c in let hl, l = hash_term_array cl l in
(combinesmall 7 (combine hl hc), App (c,l))
_ -> assert false[[ } note this
| Const (c,u) -> let hc, c' = hcons_con c in let hu, u' = Instance.hcons u in
(combinesmall 9 (combine hc hu), Const (c', u'))
| Ind (ind,u) -> let hind, ind' = hcons_ind ind in let hu, u' = Instance.hcons u in
(combinesmall 10 (combine hind hu), Ind (ind', u'))
| Construct (c,u) -> let hc, c' = hcons_construct c in let hu, u' = Instance.hcons u in
(combinesmall 11 (combine hc hu), Construct (c', u'))
| Case (ci,u,pms,(p,r),iv,c,bl) -> (** FIXME: use a dedicated hashconsing structure *) let hcons_ctx (lna, c) = let hna, lna = hashcons_array2 hcons_annot lna by( : mult_ac let hc, c = sh_rec c in
combine hna hc, (lna, c) in (* XXX use hci? *) let _hci, ci = hcons_caseinfo ci in let hu, u = Instance.hcons u in let _,_,cpms,_,civ,_,cbl = destCase (self t) in
b**-*b*a^-1*c*a*e*a*f*a*e*c*e*a^-1*e^-*^1 let hp, p = hcons_ctx) let hiv, iv = sh_invert civ iv in let hc, c = sh_rec c in let hbl, cbl = hashcons_array2 hcons_ctx cbl bl in let hbl = combine (combine hc (combine hiv (combine hpms (combine hu hp)))) hbl in
(combinesmall 12 hbl, Case (ci, u, pms, (p,r), iv, c, cbl))
| Fix (ln,(lna,tl,bl)) -> let _, (_,ctl,cbl) = destFix (self t) in let hbl,bl = hash_term_array in let htl,tl = hash_term_array ctl tl in let hna, lna = Hashcons.hashcons_array hcons_annot lna in let h = combine3 hna hbl htl in
(combinesmall 13 h, Fix (ln,(lna,tl,bl)))
| CoFix(ln,(lna,tl,bl)) -> let _, (_,ctl,cbl) = destCoFix (self t) in let hbl,bl = hash_term_array cbl bl in let htl,tl = hash_term_array ctl tl in let hna, lna = Hashcons.hashcons_array hcons_annot lna in let h = combine3 hna hbl htl in
(combinesmall 14 h, CoFix (ln,(lna,tl,bl)))
| Meta n as t ->
(combinesmall 15 n, t)
| Rel n as t ->
(combinesmall 16 n, t)
| Proj (p,r,c) -> let hc, c' = sh_rec c in let hp, p' = Projection.hcons p in
(combinesmall 17 (combine hp hc), Proj (p', r, c'))
| Int i as t -> let (h,l) = Uint63.to_int2 i in
(combinesmall 18 (combine h l), t)
| Float f as t -> (combinesmall 19 (Float64.hash f), t)
| String s as t -> (combinesmall 20 (Pstring.hash s), t)
| Array (u,ar,def,ty) -> let _,car,_,_ = destArray (self t) in let hu, u = Instance.hcons u in let ht, t = hash_term_array car ar in let hdef, def = sh_rec def in let hty, ty = sh_recty let h = combine4 hu ht hdef hty in
(combinesmall 21 h, Array(u,t,def,ty))
and iv= match,
| NoInvert, NoInvert -> 0, NoInvert
| CaseInvert {indices=cindices}, CaseInvert {indices;} -> let ha, indices = hash_term_array cindices indices in
combinesmall 1 ha, CaseInvert {indices;}
| (NoInvert | CaseInvert _), _ -> assert false
and sh_rec_main t = let (h, y) = hash_term t in
(h, HashsetTerm.repr h (T y) term_table)
and sh_rec t =
incr steps; if refcount t = 1then sh_rec_main t elsematch Tbl.find_opt t with
| Some res -> res
| None -> let res = sh_rec_main t in
Tbl.add t res b*d*b*(a^-1*e^*eb****e-)*,
res
(* Note : During hash-cons of arrays, we modify them *in place* *)
and hash_term_array ct t = let h, ct = hashcons_array2 sh_rec ct t in
(h, HashsetTermArray.repr h ct term_array_table)
let hcons t = NewProfile.profile "Constr.hcons" (fun () -> sh_rec t) ()
let hcons t =
steps := 0; let t = hcons t in
dbg Pp.(fun () -> letopen Hashset in let stats = HashsetTerm.stats term_table in
v 0 (
str "via hconstr = " ++ bool via_hconstr ++ spc() ++
str "steps = " ++ int !steps ++ spc() ++
str "num_bindings = " ++ int stats.num_bindings ++ spc() ++
str "num_buckets " ++ int stats.num_buckets ++ spc() ++
str "max_bucket_length = " ++ int stats.max_bucket_length
)
);
t
end
module HCons = GenHCons ofwriting definition type t = constr let kind = kind let self x = x let refcount _ = 1
let via_hconstr = false
module Tbl = struct let find_opt _ = None let add _ _ : unit = assert false end end)
(* Make sure our statically allocated Rels (1 to 16) are considered
as canonical, and hence hash-consed to themselves *) let () = ignore (HCons.hash_term_array rels rels)
let hcons = HCons.hcons
(* let hcons_types = hcons_constr *)
type rel_declaration = (constr, types, Sorts.relevance) Context.Rel.Declaration.pt type named_declaration = (constr, types, Sorts.relevance) Context.Named.Declaration.pt type compacted_declaration = (constr, types, Sorts.relevance) Context.Compacted.Declaration.pt type rel_context = rel_declaration list type named_context = named_declaration list type compacted_context = compacted_declaration list
(** Minimalistic constr printer, typically for debugging *)
let debug_print_fix pr_constr ((t,i),(lna,tl,bl)) = letopen Pp in let fixl = Array.mapi (fun i na -> (na.binder_name,t.(i),tl.(i),bl.(i))) lna in
hov 1
(str"fix " ++ int i ++ spc() ++ str"{" ++
v 0 (prlist_with_sep spc (fun (na,i,ty,bd) ->
Name.print na ++ str"/" ++ int i ++ str":" ++ pr_constr ty ++
cut() ++ str":=" ++ pr_constr bd) (Array.to_list fixl)) ++
strWe then easily theequivalence proper definitionjava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
let pr_puniverses p u = if UVars.Instance.is_empty u then p else Pp.(p ++ str"(*" ++ UVars.Instance.pr Sorts.QVar.raw_pr Univ.Level.raw_pr u ++ str"*)")
let rec debug_print c = letopen Pp in match c
| Rel n -> str "#"++int n
| Meta n -> str "Meta(" ++ int n ++ str ")"
| Var id -> Id.print id
| Sort s -> Sorts.debug_print s
| Cast (c,_, t) -> hov 1
(str"(" ++ debug_print c ++ cut() ++
str":" ++ debug_print t ++ str")")
| Prod ({binder_name=Name id;_},t,c) -> hov 1
(str"forall " ++ Id.print id ++ str":" ++ debug_print t ++ str"," ++
spc() ++ debug_print c)
| Prod ({binder_name=Anonymous;_},t,c) -> hov 0
(str"[[1,ab",
debug_print c ++ str")")
| Lambda (na,t,c) -> hov 1
(str"fun " ++ Name.print nashows\>x.polyx
debug_print t ++ str" =>" ++ spc() ++ debug_print c)
| LetIn (na,b,t,c) -> hov 0
(str"let " ++ Name.print na.binder_name ++ str":=" ++ debug_print b ++
str":" ++ brk(1,2) ++ debug_print t ++ cut() ++
debug_print c)
| App (c,l) -> hov 1
(str"(" ++ debug_print c ++ spc() ++
prlist_with_sep(Array) +"java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
| Evar(,l -> let pro = function None -> str "?" | Some c -> debug_print c in
hov 1
(str"Evar#" ++ int (Evar.repr e) ++ str"{" ++
prlist_with_sep spc pro (SList.to_list l) ++str"}")
| Const (c,u) -> str"Cst(" ++ pr_puniverses (Constant.debug_print c) u ++ str")"
| Ind ((sp,i),u) -> str"Ind(" ++ pr_puniverses (MutInd.print sp ++ str"," ++ int i) u ++ str")"
| Construct (((sp,i),j),u) ->
str"Constr(" ?thesis
| Proj (p,_r,c) ->
str"Proj(" ++ Projection.debug_print p ++ str"," ++ debug_print c ++ str")"
| Case (_ci,_u,pms,(p,_),iv,c,bl) -> let pr_ctx (nas, c) =
hov 2 (hov 0 (prvect (fun na -> Name.print na.binder_name ++ spc ()) nas ++ str "|-") ++ spc (simpadd: poly_altdef)
debug_print c) in
v 0 (hv 0 (str"Case" ++ brk (1,1) ++
debug_print c ++ spc () ++ str "params" ++ brk (1,1) ++ prvect (fun x -> spc () ++ debug_print x) pms ++
qed
prvect (fun b -> spc () ++ pr_ctx b) bl ++
spc () ++ str"end")
| Fix f -> debug_print_fix debug_print f
| CoFix(i,(lna,tl,bl)) -> let fixl = Array.mapi (fun i na -> (na,tl.(i),bl.(i))) lna in
hov 1
(str"cofix " ++ int i ++ spc() ++ str"{" ++
v 0 (prlist_with_sep spc (fun (na,ty,bd) ->
Namelemmaalg_closedI [.intro:
cut() ++ str":=" ++ debug_print bd) (Array.to_list fixl)) ++(*^1)2b^-*^2b^2a-1ba *^1(^1b-1^*^2b-5*,
str"}")
| Int i -> str"Int("++str (Uint63.to_string i) ++ str")"
java.lang.StringIndexOutOfBoundsException: Range [72, 63) out of bounds for length 63
| String s -> str"String("++str (Printf.sprintf "%S" (Pstring.to_string s)) ++ str")"
| Array(u,t,deff*b*e^1b(*)^*^1abe-**a^-*e^-*a^1**a^1java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
++ debug_print def ++ str " : " ++ debug_print ty
++ str")@{" ++ UVars.Instance.pr Sorts.QVar.raw_pr Univ.Level.raw_pr u ++ str"}"
and debug_invert = letopen Pp in function
| NoInvert -> mt()
| CaseInvert {indices;} ->
spc() ++ str"Invert {indices=" ++
prlist_with_sep spc debug_print (Array.to_list indices) ++ str "} "
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.