Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Universe scope

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Universe scope


Chronological Thread 
  • From: CREGUT Pierre IMT/OLN <pierre.cregut AT orange.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Universe scope
  • Date: Thu, 23 Apr 2020 19:19:43 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=pierre.cregut AT orange.com; spf=Fail smtp.mailfrom=pierre.cregut AT orange.com; spf=None smtp.helo=postmaster AT p-mail-ext.rd.orange.com
  • Ironport-phdr: 9a23:Dn839hAompLxyokpPw8cUyQJP3N1i/DPJgcQr6AfoPdwSPvypMbcNUDSrc9gkEXOFd2Cra4d1qyK4uuwAyQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagYb5+Nhq7oAHeusQVn4dpN7o8xAbOrnZUYepd2HlmJUiUnxby58ew+IBs/iFNsP8/9MBOTLv3cb0gQbNXEDopPWY15Nb2tRbYVguA+mEcUmQNnRVWBQXO8Qz3UY3wsiv+sep9xTWaMMjrRr06RTiu86FmQwLuhSwaNTA27XvXh9RtgqxFrhKvpx9xzYDab46aNvVxYqzTcMgGRWdCRMtdSzBND42+YoYJEuEPPfxYr474p1YWsxawGQaiCuLhxTFWm3T4x6w63Po7EQHcwgMrAtEAvnPKotnuLakcV/i7x7TPwDXbbvNZxy396JLWfRw7vf6MR6x/ccXMyUkzDA7FiU+QppbjPzOayOsBqXSU7+1lVe+2jWMstg9/oj+qxsg2i4nJgJoYxU3e+iVl2ok1Od25SFZlbt6/CpdQrzuaN4xrTc4kXmpmuz46x6UbtZO6YSQG0okrywLeZvCdboSE+BbuWeCMKjlinn1lYqiwhxOq/Eig1OL8Us603U5SriZcl9nDrHEN1xjK5seZRfp94l2t2SyS2AzJ7eFEO1o7lazUK5E/2LI/ip0TsUHbEi/3nkX5krOWe1059uWp9ujreKjqqoOdOoNulw3yKKAjltS6AesiMwgOW2ab+f671L3m5UD5WLRKgeMskqnDrp/WP9gUprSnDA9az4Yj9w2yDzC80NsCm3kHI0xKdAibgIjuPlHCOOr4Auung1SwjDdrwOjLMaHmApXUN3TMjLPhfatm5ENH0woyzdVf54pOBb0bIfLzXFXxtN3CARMjPQy02bWvNNIo3YQHHGmLH6WxMaXIsFbO6Ph8DfOLYdo+ghvSFsRt3//jl2U00X44Qe6O+b1fPGi5E+58LgOSe3fjn8spFn0DuAUzCuftjQvRAnZoe3+uUvdktXkAA4W8ANKbH93/sPm6xC6+W6ZuSCVGB1SLSym6b8CBUvYILS+CPol7nnoDT7GnRIJn3har5lejmuhXa9HM8yhdjqrNkd185undjxY3rGYmCN6U1W6ACWpzmzFUHmNk7OVEuUV4j2y7/+1gmfUBT45U/fpPXQp8PpnZnbR3

I reply to my own question. It is missing a typing pass that will solve the constraints.

  let sigma, typ = Typing.type_of env sigma def in
  Simple_declare.declare_definition ~poly:true (Names.Id.of_string "foo") sigma def

It could be emphasized more in the plugin tutorial as this pass is not necessary when fully defined terms without dangling universe are used and one may expect simple_declare to use the same typing algorithm again.

Pierre

On 23/04/2020 10:59, CREGUT Pierre IMT/OLN wrote:
It is probably belonging to the FAQ level questions but I have not figured out where it is explained.

I am trying to create a very simple coq term in ml and make a top level definition :

    Definition foo := fun A:Type => prod A A.

I am using the Simple_declare.declare of plugin_tutorials/tuto1 (version 8.11)

    let foo () =
      let env = Global.env() in
      let sigma = Evd.from_env env in
      let qprod = Libnames.qualid_of_string "Coq.Init.Datatypes.prod" in
      let sigma, sort = Evd.new_sort_variable Evd.univ_flexible sigma in
      let ty = EConstr.mkSort sort in
      let bd = Context.nameR (Names.Id.of_string "A") in
      let env = EConstr.push_rel (Context.Rel.Declaration.LocalAssum(bd,ty)) env in
      let sigma, prod =  EConstr.fresh_global env sigma (Constrintern.intern_reference qprod) in
      let def =  EConstr.mkLambda(bd, ty, EConstr.mkApp(prod, [|EConstr.mkRel 1; EConstr.mkRel 1|])) in
      Simple_declare.declare_definition ~poly:true (Names.Id.of_string "foo") sigma def

Clearly I am missing something A is of type Type@{Top.1}and it cannot be unified with Type@{prod.u0} from prod. How can I have a new universe scope in a few lines of code (for the standard 8.11 version, it seems the API is changing quickly). Is it in this part that I am missing something or in the use of UState.default_univ_decl in declare_definition ?

Best regards,

Pierre Crégut


simple_declare.ml:

let edeclare ?hook ~name ~poly ~scope ~kind ~opaque sigma udecl body tyopt imps =
  let sigma, ce = DeclareDef.prepare_definition ~allow_evars:false
      ~opaque ~poly sigma udecl ~types:tyopt ~body in
  let uctx = Evd.evar_universe_context sigma in
  let ubinders = Evd.universe_binders sigma in
  let hook_data = Option.map (fun hook -> hook, uctx, []) hook in
  DeclareDef.declare_definition ~name ~scope ~kind ubinders ce imps ?hook_data

let declare_definition ~poly name sigma body =
  let udecl = UState.default_univ_decl in
  edeclare ~name ~poly ~scope:(DeclareDef.Global Declare.ImportDefaultBehavior)
    ~kind:Decls.(IsDefinition Definition) ~opaque:false sigma udecl body None []



  • [Coq-Club] Universe scope, CREGUT Pierre IMT/OLN, 04/23/2020
    • Re: [Coq-Club] Universe scope, CREGUT Pierre IMT/OLN, 04/23/2020

Archive powered by MHonArc 2.6.18.

Top of Page