<commit_before>(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2015     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

let map_const_entry_body (f:Term.constr->Term.constr) (x:Entries.const_entry_body)
    : Entries.const_entry_body =
  Future.chain ~pure:true x begin fun ((b,ctx),fx) ->
    (f b , ctx) , fx
  end

(** [start_deriving f suchthat lemma] starts a proof of [suchthat]
    (which can contain references to [f]) in the context extended by
    [f:=?x]. When the proof ends, [f] is defined as the value of [?x]
    and [lemma] as the proof. *)
let start_deriving f suchthat lemma =

  let env = Global.env () in
  let sigma = Evd.from_env env in
  let kind = Decl_kinds.(Global,false,DefinitionBody Definition) in

  (** create a sort variable for the type of [f] *)
  (* spiwack: I don't know what the rigidity flag does, picked the one
     that looked the most general. *)
  let (sigma,f_type_sort) = Evd.new_sort_variable Evd.univ_flexible_alg sigma in
  let f_type_type = Term.mkSort f_type_sort in
  (** create the initial goals for the proof: |- Type ; |- ?1 ; f:=?2 |- suchthat *)
  let goals =
    let open Proofview in
        TCons ( env , sigma , f_type_type , (fun sigma f_type ->
        TCons ( env , sigma , f_type , (fun sigma ef ->
        let env' = Environ.push_named (f , (Some ef) , f_type) env in
        let evdref = ref sigma in
        let suchthat = Constrintern.interp_type_evars env' evdref suchthat in
        TCons ( env' , !evdref , suchthat , (fun sigma _ ->
        TNil sigma))))))
    in

    (** The terminator handles the registering of constants when the proof is closed. *)
    let terminator com =
      let open Proof_global in
      (** Extracts the relevant information from the proof. [Admitted]
          and [Save] result in user errors. [opaque] is [true] if the
          proof was concluded by [Qed], and [false] if [Defined]. [f_def]
          and [lemma_def] correspond to the proof of [f] and of
          [suchthat], respectively. *)
      let (opaque,f_def,lemma_def) =
        match com with
        | Admitted -> Errors.error"Admitted isn't supported in Derive."
        | Proved (_,Some _,_) ->
            Errors.error"Cannot save a proof of Derive with an explicit name."
        | Proved (opaque, None, obj) ->
            match Proof_global.(obj.entries) with
            | [_;f_def;lemma_def] ->
                opaque <> Transparent , f_def , lemma_def
            | _ -> assert false
      in<commit_msg>Fixing OCaml 3.12 compilation.<commit_after>(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2015     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

let map_const_entry_body (f:Term.constr->Term.constr) (x:Entries.const_entry_body)
    : Entries.const_entry_body =
  Future.chain ~pure:true x begin fun ((b,ctx),fx) ->
    (f b , ctx) , fx
  end

(** [start_deriving f suchthat lemma] starts a proof of [suchthat]
    (which can contain references to [f]) in the context extended by
    [f:=?x]. When the proof ends, [f] is defined as the value of [?x]
    and [lemma] as the proof. *)
let start_deriving f suchthat lemma =

  let env = Global.env () in
  let sigma = Evd.from_env env in
  let kind = Decl_kinds.(Global,false,DefinitionBody Definition) in

  (** create a sort variable for the type of [f] *)
  (* spiwack: I don't know what the rigidity flag does, picked the one
     that looked the most general. *)
  let (sigma,f_type_sort) = Evd.new_sort_variable Evd.univ_flexible_alg sigma in
  let f_type_type = Term.mkSort f_type_sort in
  (** create the initial goals for the proof: |- Type ; |- ?1 ; f:=?2 |- suchthat *)
  let goals =
    let open Proofview in
        TCons ( env , sigma , f_type_type , (fun sigma f_type ->
        TCons ( env , sigma , f_type , (fun sigma ef ->
        let env' = Environ.push_named (f , (Some ef) , f_type) env in
        let evdref = ref sigma in
        let suchthat = Constrintern.interp_type_evars env' evdref suchthat in
        TCons ( env' , !evdref , suchthat , (fun sigma _ ->
        TNil sigma))))))
    in

    (** The terminator handles the registering of constants when the proof is closed. *)
    let terminator com =
      let open Proof_global in
      (** Extracts the relevant information from the proof. [Admitted]
          and [Save] result in user errors. [opaque] is [true] if the
          proof was concluded by [Qed], and [false] if [Defined]. [f_def]
          and [lemma_def] correspond to the proof of [f] and of
          [suchthat], respectively. *)
      let (opaque,f_def,lemma_def) =
        match com with
        | Admitted -> Errors.error"Admitted isn't supported in Derive."
        | Proved (_,Some _,_) ->
            Errors.error"Cannot save a proof of Derive with an explicit name."
        | Proved (opaque, None, obj) ->
            match Proof_global.(obj.entries) with
            | [_;f_def;lemma_def] ->
                opaque <> Vernacexpr.Transparent , f_def , lemma_def
            | _ -> assert false
      in
{'fraction_non_alphanumeric': 0.1698663009941721, 'fraction_numerical': 0.004628042509427494, 'mean_word_length': 2.6813880126182967, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1427182', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1703, 'n_words': 610}