package rocq-runtime

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file gensubst.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(************************************************************************)
(*         *      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)         *)
(************************************************************************)

open Genarg

(** Substitution functions *)
type 'glb subst_fun = Mod_subst.substitution -> 'glb -> 'glb

module SubstObj =
struct
  type ('raw, 'glb, 'top) obj = 'glb subst_fun
  let name = "subst"
  let default _ = None
end

module Subst = Register (SubstObj)

let substitute = Subst.obj
let register_subst0 = Subst.register0

let generic_substitute subs (GenArg (Glbwit wit, v)) =
  in_gen (glbwit wit) (substitute wit subs v)

module CSubstObj = struct
  type (_, 'g) t = 'g subst_fun
end

module CSubst = GenConstr.Register(CSubstObj)

let register_constr_subst = CSubst.register

let constr_subst subst (GenConstr.Glb (tag, v) as o) =
  let substf = CSubst.get tag in
  let v' = substf subst v in
  if v == v' then o else
  GenConstr.Glb (tag, v')