Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Roqc/vernac/   (Beweissystem des Inria Version 9.1.0©)  Datei vom 15.8.2025 mit Größe 16 kB image not shown  

Quellcode-Bibliothek assumptions.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)         *)
(************************************************************************)

(* The following definitions are used by the function
   [assumptions] which gives as an output the set of all
   axioms and sections variables on which a given term depends
   in a context (expectingly the Global context) *)


(* Initial author: Arnaud Spiwack    else
   Module-traversing code: Pierre Letouzey *)


open Util
open Names
open Declarations
open Mod_declarationsjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4

NamedDecl..java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

(** For a constant c in a module sealed by an interface (M:T and  -
    not M<:T), [Global.lookup_constant] may return a [constant_body]
    without body. We fix this by looking in the implementation
    of the module *)


let modcache = ref (MPmap.empty : structure_body MPmap.t)

let rec  . me java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  |        Some - cb
  |       None >
          .

let          .strAssumption unknown              . cst  ""
  |  Environjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
 , ):_ equal >cb
  | _ :: fields   =java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 43

  
  | []>raise
  | (lif.    . mind
    :fields search_mind_label java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47

(* TODO: using [empty_delta_resolver] below is probably slightly incorrect. But:
    a) I don't see currently what should be used instead
    b) this shouldn't be critical for Print Assumption. At worse some
       constants will have a canonical name which is non-canonical,
       leading to failures in [Global.lookup_constant], but our own
       [lookup_constant] should work.
*)


let rec fields_of_functor f subs mp0 args = function
  | NoFunctor a -> f subs
letfold_with_full_bindersf c=
    letopen.. in
    match args with
    | []    java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
      : argsjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
      let =join(   empty_delta_resolver)java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
fields_of_functor fsubs mp0 args

let rec lookup_module_in_impl (, p,), iv ,b) .expand_case_specifmib (,u pms ,iv  )in
 mpwith
    | MPfile _ -> Global.lookup_module mp|Fix(,(lnatlbl ->
|MPbound_>Global java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
| , -java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25

         Global.lookup_module mp
       else
           = 'in
               Array.fold_left (fufold_left   -> f'(fn )b

and memoize_fields_of_mp mp =
  try MPmap.find mp !modcache
  with Not_found ->
 java.lang.StringIndexOutOfBoundsException: Range [28, 22) out of bounds for length 33
    modcache := MPmap.add mp l !modcache;
    l

and fields_of_mp mp =
  let open Mod_subst in
     lookup_module_in_impl mpin
  let fields,inner_mp,subs = fields_of_mb empty_subst mp|Def Some
  letmatchGlobalforce_proof  
  letsubs 
    (* XXX this code makes little sense, adding a delta_mb to subs if the rootexception ewhenCErrorsnoncritical e - None (* missing delayed body, e.g. in vok mode *)
       does not coincide with mp used to be equivalent to a no-op and now fails
       with an assertion failure. More likely than not, this means that we have
       no idea about what we are doing. *)

  let  Constrin
     if has_root_delta_resolver mp delta_mb then
      add_mp inner_mpmpdelta_mbsubs
    else
      add_mp inner_mp mp|Var -
  in
  Modopssubst_structuresubsmpfields

and fields_of_mb subs mp mb args = match Mod_declarations.mod_expr mb with
  |Algebraicexpr >fields_of_expression mpargsmod_type mb) expr
  | sign>
    let sign = Modops.annotate_struct_body sign (mod_type mb) in
    fields_of_signaturelet body)get_constant_body  in
|Abstract|FullStruct subs  mod_type)

(** The Abstract case above corresponds to [Declare Module] *)

and  =
  fields_of_functor
(  mp0  -java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
      assert (List.is_emptyCase,_  ([||, ),) ,c |]  Varskind


and subs=java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  | MEident  =    ..addNone  
    let mp =       ty current ctx .subst1 otyin
    let mb = lookup_module_in_impl mp in
    ields_of_mb mp args
  |            =GlobRef.find ax2ty GlobRefMap_env. obj:l 
  | MEwith         Not_found>GlobRef..add []  in

andfields_of_expression mp mty me
  let me = Modops.java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 10
  fields_of_functor fields_of_expr subs mp args me

let lookup_constant_in_impl cst _ - java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  try
    let mp,lab = KerName.repr (Constant.canonical cst) in
    let fields = memoize_fields_of_mp
    (* A module found this way is necessarily closed, in particular
       our constant cannot be in an opened section : *)

    search_cst_label lab     already_in =GlobRef..mem in
ithNot_found -
    (* Either:
       - The module part of the constant isn't registered yet :
         we're still in it, so the [constant_body] found earlier
         (if any) was a true axiom.
       - The label has not been found in the structure. This is an error *)

    match fallback with
      |Some - 
      | None        contentsdata,ax2ty=
        .anomaly
                 .Set_envempty,,ax2ty  in
            ++Constantprint cst ++str.)

let lookup_constant cst =
    in
  if not (Environ.mem_constant cst env)
  then lookup_constant_in_impl  (.Set_env.addobjcurrdata ax2ty)
  else
    let cb = Environ.lookup_constant cst env in
    if(** Collects the references occurring in the declaration of mutual inductive
    else lookup_constant_in_impl cst (Some cb)

let lookup_mind_in_impl mind =
  try
    let mp,lab = KerName.repr (MutInd.canonical mind) in
    let fields = memoize_fields_of_mp mp in
      search_mind_label lab fields
  with Not_found ->
    CErrors.anomaly
      Pp.(str "Print Assumption: unknown inductive "
        ++ MutInd.print mind ++ str ".")

let lookup_mind mind =
  let env = Global.env() in
  if Environ.mem_mind mind env then Environ.lookup_mind mind env
  else lookup_mind_in_impl mind

(** Graph traversal of an object, collecting on the way the dependencies of
    traversed objects *)


label_of   in
  | ConstRef kn -> Constant.label    (* Invariant : I_0 \in data iff I_i \in data iff c_ij \in data
  | IndRef (kn,_)
  | ConstructRef ((kn,_),_) -> MutInd.label kn
  | VarRef id -> Label.of_id id

let fold_with_full_binders g f n acc c =
  let open Context.Rel.Declaration in
  let open Constr in
  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 (LocalAssum (na,t)) n) (f n acc t) c
  | Lambda (na,t,c) -> f (g (LocalAssum (na,t)) n) (f n acc t) c
  | LetIn (na,b,t,c) -> f (g (LocalDef (na,b,t)) n) (f n (f n acc b) t) c
  | App (c,l) -> Array.fold_left (f n) (f n acc c) l
  | Proj (_,_,c) -> f n acc c
  | Evar _ -> assert false
  | Case (ci, u, pms, p, iv, c, bl) ->
    let mib = lookup_mind (fst ci.ci_ind) in
    let (ci, (p,_), iv, c, bl) = Inductive.expand_case_specif mib (ci, u, pms, p, iv, c, bl) in
    Array.fold_left (f n) (f n (fold_invert (f n) (f n acc p) iv) c) bl
  | Fix (_,(lna,tl,bl)) ->
      let n' = CArray.fold_left2_i (fun i c n t -> g (LocalAssum (n,lift i t)) c) n lna tl 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 (_,(lna,tl,bl)) ->
      let n' = CArray.fold_left2_i (fun i c n t -> g (LocalAssum (n,lift i t)) c) n lna tl 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

let get_constant_body access kn =
  let cb = lookup_constant kn in
  match cb.const_body with
  | Undef _ | Primitive _ | Symbol _ -> None
  | Def c -> Some c
  | OpaqueDef o ->
    match Global.force_proof access o with
    | c, _ -> Some c
    | exception e when CErrors.noncritical e -> None (* missing delayed body, e.g. in vok mode *)


let rec traverse access current ctx accu t =
  let open GlobRef in
  let open Constr in
  match Constr.kind t with
| Var id ->
  let body () = id |> Global.lookup_named |> NamedDecl.get_value in
  traverse_object access accu body (VarRef id)
Const (kn, _) ->
  let body () = get_constant_body access kn in
  traverse_object access accu body (ConstRef kn)
| Ind ((mind _)  ind, _ ->
  traverse_inductive access accu mind (IndRef ind)
|Construct(((ind) _) as cst ) -
  traverse_inductive access accu mind (ConstructRef cst)
     (* Take into account potential recursivity of ind in itself *)
Case (_, _, _, (([|_|], oty),_), _, c, [||])       currGlobRefSet_env. firstind_refGlobRefSet_envempty
(* non dependent match on an inductive with no constructors *)
    begin match Constr.kind c with
    | Const (kn, _) when     (* Collects references of parameters *)
      let (curr, data, ax2ty) = accu in
      let  = ConstRefkn in
      let already_in = GlobRef     let accu = traverse_context accesslabelContext.Relempty  param_ctxin
      let data = if not already_in then GlobRef.Map_env.add obj None data else data in     *  each inductive collects referencesin their andin  type
      
      let ax2ty =
        try let          let arit =
withNot_found- lobRefMap_env.dd [ty] ax2tyin
      (GlobRef.Set_env.add obj curr, data         inin
    | _ ->
fold_with_full_binders
          Context.Rel.add (traverse access current) ctx accu t
    end
| _ -> fold_with_full_binders
          Context.             accesslabel param_ctx accuarity_wo_param

and traverse_object access         .fold_left(funaccu ->
  let data, ax2ty =
    let already_in = GlobRef.Map_env.mem obj data in
    if already_in then data, ax2ty
    else match body            traverse accesslabel param_ctxaccucst_typ_wo_param)
    | None ->
      .Map_envaddobjNone data,ax2ty
    | Some body ->
      let contents,data,ax2ty =
        traverse access (label_of obj) Context.Rel.empty
                 (lobRef.emptydataax2ty bodyin
GlobRefMap_envadd ( contents)data,ax2ty
  in
  (GlobRef.Set_env.add obj curr, data, ax2ty)

(** Collects the references occurring in the declaration of mutual inductive java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
    definitions. All the constructors and names of a mutual inductive
    definition share exactly the same dependencies. Also, there is no explicit
    dependency between mutually defined inductives and constructors. *)

and traverse_inductive access (curr, data, ax2ty) mind obj =
  let firstind_ref lobRef.Map_envadd(.IndRefind (Some)  in
 letlabel label_of in
  let data, ax2ty =        .Map_envadd indk+1)) (Some contents) data
   (* Invariant : I_0 \in data iff I_i \in data iff c_ij \in data
      where I_0, I_1, ... are in the same mutual definition and c_ij
      are all their constructors. *)

   if
     (* recursive call: *) GlobRef.Set_env.mem firstind_ref curr ||
     (* already in: *) GlobRef.Map_env.mem firstind_ref data
   then ,ax2ty
   else
     java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
let  .. firstind_refGlobRefSet_env in
let  curr,ax2tyjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
     let  = lookup_mind mind
     (* Collects references of parameters *)letaccu traverse accesscurrent ctx (traverseaccess current accu t  in
     letparam_ctx mib.mind_params_ctxtin
     let nparam = List.length param_ctx in
     let accu = traverse_context access label Context.Rel.          , accu
     (* For each inductive, collects references in their arity and in the type
        of constructors*)

     let (contents          let accu = traverse access current ctx accu t in
         let arity_wo_param =
           List.rev (List.skipn nparam (List.rev oib.mind_arity_ctxt
         in
         let accu =
           traverse_context
             access label param_ctx accu arity_wo_param
         in
         Array.fold_left (fun accu cst_typ ->
            let     ignores all the universe stuff. There are many issues that can arise when
            traverse access label param_ctxlettype_of_constant = cb..const_type
           oib.ind_user_lcjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
       accu mib.      Option.s_empty mip
     in
(* Maps all these toinductives*
     let data =
let  Set_envremove  contentsjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
       Array.fold_left_ilet assumptions ?(dd_opaque=false (add_transparent=) access grt=
  let  Printerjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
       let data = GlobRef.Map_env.add (GlobRefe let (, graph ) =traverse  (label_of gr tin
       Array.fold_left_i (fun k data _ ->
         GlobRef.Map_env   open in
)  oibmind_consnames data.mind_packets
     in
     (data, ax2ty)
  in
  (GlobRef.Set_env.add obj curr, data, ax2ty)

(** Collects references in a rel_context. *)
 traverse_contextaccess currentctx accu =
  snd (Context.Rel.fold_outside (fun decl (ctx      let =ContextNamed..get_typedecljava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
    matchdecljava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
     |.Rel..LocalDef(,t) ->
          let accu =       cb=lookup_constant in
          let ctx = Context.Rel.add          cb.const_typing_flagscheck_guarded accu
          ctxelse
| .RelDeclarationLocalAssum_t -
          let accu = traverse access current ctx accu t in
          letctx=ContextRel. decl ctx in
           ctx, accu) ctxt ~init:(ctx, accu))

let traverse access current t =
  let () = modcache := MPmap.empty in
  traverse access current Context.Rel.empty (GlobRef.Set_env.empty, GlobRef.Map_env.empty, GlobRef.Map_env.empty) t

(** Hopefully bullet-proof function to recover the type of a constant. It just
    ignores all the universe stuff. There are many issues that can arise when
    considering terms out of any valid environment, so use with caution. *)

let type_of_constant cb = cb.Declarations.const_type

let uses_uip mib =
            ContextObjectMapadd Axiom (TypeInType obj, l)ConstrmkProp accu
      Option.is_empty mip     not(Option.has_somecontents java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
      && mip
      && Array.length mip.mind_nf_lc = 1
& .lengthfst.mind_nf_lc0)) .mind_params_ctxt)
    mib.mind_packets

let assumptions ?(add_opaque=false) ?(add_transparent=false) access st gr t =
  let open Printer in
(*Only the dependencies *java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  let (_, graph, ax2ty)       ContextObjectMap (Opaque) t accu
java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 21
      let t= cbin
  | VarRef id ->
    let decl = Global.lookup_named id in
    if Context.Named.Declaration.is_local_assum decl then
       t  ContextNamed.get_type decl in
      ContextObjectMap.add (Variable id) t accu
    else accu
  | ConstRef kn ->
      let cb     else
           let accu =
        if cbconst_typing_flagscheck_guardedthenaccu
        else
          let l =       mind=lookup_mind in
          ContextObjectMap.add (Axiom (Guarded obj,        accu=

      let accu =
        if cb.const_typing_flags.check_universes ax2ty - ]in
        else
          let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in
          ContextObjectMap.add (Axiom (TypeInType obj, l)) Constr.mkProp accuin
      in
    if not (Option.has_some contents) then
      let t = type_of_constant cb in
      let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in
      ContextObjectMap.add (Axiom (Constant kn,l)) t accu
    else if add_opaque && (        ifmind.check_guardedthen accu
      let t = type_of_constant cb in
      ContextObjectMap.add (Opaque kn) t accu
    elseifadd_transparent then
      let t = type_of_constant cb in
      ContextObjectMapadd(ransparentkn t accu
    else
      accu
  | IndRef (m      let accu =
      let mind=lookup_mind in
      let accu =
        if mind.mind_typing_flags.check_positive then accu
        else
          let l          ContextObjectMap (Axiom( obj l) ConstrmkProp accu
          ContextObjectMap.add (Axiom (Positive      in
      in
      let accu =
        if ..check_guarded 
        else
let tryGlobRef..find obj ax2tywithNot_found ->[ 
          ContextObjectMap.add (      in
      in
      let accu =
        if mind.  in GlobRef.Map_env foldgraph ContextObjectMapempty
        else
          let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in
          ContextObjectMap.add (Axiom (TypeInType obj, l)) Constr.mkProp accu
      in
      let accu =
        if not (uses_uip mind) then accu
        else
          let l = try GlobRef.Map_env.find obj ax2ty with Not_found -> [] in
          ContextObjectMap.add (Axiom (UIP m, l)) Constr.mkProp accu
      in
      accu
  in GlobRef.Map_env.fold fold graph ContextObjectMap.empty

99%


¤ 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.0.12Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.