]> matita.cs.unibo.it Git - helm.git/commitdiff
initial support for LaTeX-defined notatopn
authorFerruccio Guidi <ferruccio.guidi@unibo.it>
Mon, 23 May 2016 20:27:38 +0000 (20:27 +0000)
committerFerruccio Guidi <ferruccio.guidi@unibo.it>
Mon, 23 May 2016 20:27:38 +0000 (20:27 +0000)
14 files changed:
matita/components/binaries/matex/Makefile
matita/components/binaries/matex/alpha.ml
matita/components/binaries/matex/engine.ml
matita/components/binaries/matex/kernel.ml
matita/components/binaries/matex/matex.ml
matita/components/binaries/matex/options.ml
matita/components/binaries/matex/options.mli
matita/components/binaries/matex/test/basic_1.conf.xml
matita/components/binaries/matex/test/basic_1.sty [new file with mode: 0644]
matita/components/binaries/matex/test/ground_1.conf.xml [new file with mode: 0644]
matita/components/binaries/matex/test/ground_1.sty [new file with mode: 0644]
matita/components/binaries/matex/test/legacy_1.conf.xml [new file with mode: 0644]
matita/components/binaries/matex/test/legacy_1.sty [new file with mode: 0644]
matita/components/binaries/matex/test/test.tex

index e177cc077967d375ca860953520d491300444665..c9a7b58ed7155b1a640dde8451431c23e79325ee 100644 (file)
@@ -6,7 +6,8 @@ REQUIRES = helm-ng_library
 include ../Makefile.common
 
 PROBE    = ../probe/probe.native
-REGISTRY = $(RT_BASE_DIR)/matita.conf.xml test/basic_1.conf.xml
+REGISTRY = $(RT_BASE_DIR)/matita.conf.xml \
+           test/legacy_1.conf.xml test/ground_1.conf.xml test/basic_1.conf.xml
 OBJS     = Make.objs
 SRCS     = Make.srcs
 
index 816edd4a54ab14869b0ddeddc1b696ddd2743744..4c4eccef70c0a81fad22842244f41547d10ea80f 100644 (file)
@@ -73,11 +73,9 @@ let get_constant c t = match strip (K.whd c t) with
       P.sprintf "Type[%s]" (U.string_of_uri u)
    | C.Sort (C.Type [`CProp, u]) ->
       P.sprintf "CProp[%s]" (U.string_of_uri u)
-   | C.Const (R.Ref (u, r))      ->
-      let ss = K.segments_of_uri u in
-      let _, _, _, _, obj = E.get_checked_obj G.status u in  
-      let ss, _ = K.name_of_reference ss (obj, r) in
-      X.rev_map_concat X.id "." "type" ss
+   | C.Const c                   ->
+      let s, _ = K.resolve_reference c in
+      s
    | _                           -> ""
 
 let read l s r =
@@ -173,6 +171,7 @@ try
    end;
    tt
 with
+   | E.ObjectNotFound s 
    | T.TypeCheckerFailure s
    | T.AssertFailure s           -> malformed (Lazy.force s)
 
index 7001fb99edd9f11fe62d2d6e001abd0b0f3549eb..e9ec76e86b1198dabbdeaf3179c7eeb4e995af8b 100644 (file)
@@ -43,11 +43,29 @@ let internal s =
 let malformed s =
    X.error ("engine: malformed term: " ^ s)
 
+let missing s =
+   X.log ("engine: missing macro for " ^ s)
+
 (* generic term processing *)
 
 let mk_ptr st name = 
    if G.is_global_id name then P.sprintf "%s.%s" st.i name else ""
 
+let get_macro s =
+   let rec aux = function
+      | []                        -> "", G.nan
+      | (r, m, a) :: _ when r = s -> m, a
+      | _ :: tl                   -> aux tl
+   in
+   aux !G.macro
+
+let get_head = function
+   | C.Const c :: ts ->
+      let s, _ = K.resolve_reference c in
+      let macro, arity = get_macro s in
+      if arity = L.length ts then  Some (macro, ts) else begin missing s; None end 
+   | _               -> None
+
 let proc_sort st is = function
    | C.Prop             -> T.Macro "PROP" :: is
    | C.Type [`Type, u]  -> T.Macro "TYPE" :: T.arg (U.string_of_uri u) :: is
@@ -62,8 +80,12 @@ let rec proc_term st is = function
       let name = K.resolve_lref st.c m in
       T.Macro "LREF" :: T.arg name :: T.free (mk_ptr st name) :: is
    | C.Appl ts              ->
+      let macro, ts = match get_head ts with
+         | Some (macro, ts) -> macro, ts
+         | None             -> "APPL", ts
+      in
       let riss = L.rev_map (proc_term st []) ts in
-      T.Macro "APPL" :: T.mk_rev_args riss is
+      T.Macro macro :: T.mk_rev_args riss is
    | C.Prod (s, w, t)       ->
       let is_w = proc_term st [] w in
       let is_t = proc_term {st with c=K.add_dec s w st.c} is t in
@@ -79,11 +101,9 @@ let rec proc_term st is = function
       T.Macro "ABBR" :: T.arg s :: T.free (mk_ptr st s) :: T.Group is_w :: T.Group is_v :: is_t
    | C.Sort s               ->
       proc_sort st is s
-   | C.Const (R.Ref (u, r)) ->
-      let ss = K.segments_of_uri u in
-      let _, _, _, _, obj = E.get_checked_obj G.status u in  
-      let ss, name = K.name_of_reference ss (obj, r) in
-      T.Macro "GREF" :: T.arg name :: T.free (X.rev_map_concat X.id "." "type" ss) :: is
+   | C.Const c              ->
+      let s, name = K.resolve_reference c in
+      T.Macro "GREF" :: T.arg name :: T.free s :: is
    | C.Match (w, u, v, ts)  ->
       let is_w = proc_term st [] (C.Const w) in
       let is_u = proc_term st [] u in
index 17116677cf6efea62c523bc38709c426dcec9604..8b6a81a3e64d110e40eba37072d2e491054e318d 100644 (file)
@@ -116,7 +116,7 @@ let segments_of_uri u =
    let s = S.sub s (i+2) (l-i-2) in
    X.segments_of_string [] (l-i-2) s
 
-let name_of_reference ss = function
+let names_of_reference ss = function
    | C.Constant (_, name, _, _, _), R.Decl      ->
       ss, name
    | C.Constant (_, name, _, _, _), R.Def _     ->
@@ -136,3 +136,10 @@ let name_of_reference ss = function
       (name :: ss), name
    | _                                          ->
       failwith "name_of_reference"
+
+let resolve_reference = function
+   | R.Ref (u, r) ->
+      let ss = segments_of_uri u in
+      let _, _, _, _, obj = E.get_checked_obj G.status u in  
+      let ss, name = names_of_reference ss (obj, r) in
+      X.rev_map_concat X.id "." "type" ss, name
index 9ca51c1fe8cfe223141b0b25e53b6d797c7c90f7..24775c0a66c02d021308167fbbf2f8c8dd4c07eb 100644 (file)
@@ -36,6 +36,8 @@ let help   = ""
 
 let alpha_decode = R.triple R.string R.string R.string
 
+let macro_decode = R.triple R.string R.string R.int
+
 let init registry =
    R.load_from registry; 
    if !G.no_init then begin
@@ -43,7 +45,8 @@ let init registry =
       G.no_init := false;
    end;
    G.alpha_type := R.get_list alpha_decode "matex.alpha.type";
-   G.alpha_sort := R.get_list alpha_decode "matex.alpha.sort"
+   G.alpha_sort := R.get_list alpha_decode "matex.alpha.sort";
+   G.macro      := R.get_list macro_decode "matex.macro"
 
 let is_registry s =
    F.check_suffix s ".conf.xml"
index da60a79bbe895efb88178da10692ecdbf62d5e7b..3b4c39d418e47a689a4928445dba6cda58c3c44e 100644 (file)
@@ -34,6 +34,8 @@ let default_list_och = None
 
 let default_alpha = []
 
+let default_macro = []
+
 (* interface ****************************************************************)
 
 let dno_id = "_"                            (* identifier for not-occurring premises *)
@@ -58,9 +60,11 @@ let log_alpha = ref default_log_alpha       (* log alpha-unconverted identifiers
 
 let list_och = ref default_list_och         (* output stream for list file *)
 
-let alpha_type = ref default_alpha          (* data of type-based alpha-conversion *)
+let alpha_type = ref default_alpha          (* data for type-based alpha-conversion *)
+
+let alpha_sort = ref default_alpha          (* data for sort-based alpha-conversion *)
 
-let alpha_sort = ref default_alpha          (* data of sort-based alpha-conversion *)
+let macro = ref default_macro               (* data eta-conversion and macro rendering *)
 
 let is_global_id s =
    !global_alpha && s <> dno_id
@@ -80,4 +84,5 @@ let clear () =
    log_alpha := default_log_alpha;
    list_och := default_list_och;
    alpha_type := default_alpha;
-   alpha_sort := default_alpha
+   alpha_sort := default_alpha;
+   macro := default_macro
index b2ad2cf47d4787b26a20f7a2587d5dfc2007f42d..8a7bbb8a22ab9af1c65dd99240970845ae976077 100644 (file)
@@ -35,6 +35,8 @@ val alpha_type: (string * string * string) list ref
 
 val alpha_sort: (string * string * string) list ref
 
+val macro: (string * string * int) list ref
+
 val clear: unit -> unit
 
 val close_list: unit -> unit
index d9d2d67dcaaf5ef77f8e7dc733f5869b762c9ac3..6292ed4ce70beb92efbcea4f43a94432b06a5c72 100644 (file)
 
     <key name="sort">Type[cic:/matita/pts/Type0.univ] f a</key>
   </section>
+<!--
+matita.lambdadelta.basic_1.A.defs.A.AHead.type
+matita.lambdadelta.basic_1.A.defs.A.ASort.type
+matita.lambdadelta.basic_1.A.fwd.A_rect.A_rect.type
+matita.lambdadelta.basic_1.aplus.defs.aplus.aplus.type
+matita.lambdadelta.basic_1.app.defs.app1.app1.type
+matita.lambdadelta.basic_1.app.defs.cbk.cbk.type
+matita.lambdadelta.basic_1.aprem.defs.aprem.aprem.type
+matita.lambdadelta.basic_1.arity.defs.arity.arity.type
+matita.lambdadelta.basic_1.asucc.defs.asucc.asucc.type
+matita.lambdadelta.basic_1.C.defs.C.CHead.type
+matita.lambdadelta.basic_1.C.defs.C.CSort.type
+matita.lambdadelta.basic_1.C.defs.cle.type
+matita.lambdadelta.basic_1.C.defs.clt.type
+matita.lambdadelta.basic_1.C.defs.CTail.CTail.type
+matita.lambdadelta.basic_1.C.defs.cweight.cweight.type
+matita.lambdadelta.basic_1.C.fwd.C_rect.C_rect.type
+matita.lambdadelta.basic_1.cimp.defs.cimp.type
+matita.lambdadelta.basic_1.clear.defs.clear.clear.type
+matita.lambdadelta.basic_1.clen.defs.clen.clen.type
+matita.lambdadelta.basic_1.cnt.defs.cnt.cnt.type
+matita.lambdadelta.basic_1.csuba.defs.csuba.csuba.type
+matita.lambdadelta.basic_1.csubc.defs.csubc.csubc.type
+matita.lambdadelta.basic_1.csubst0.defs.csubst0.csubst0.type
+matita.lambdadelta.basic_1.csubst1.defs.csubst1.csubst1.type
+matita.lambdadelta.basic_1.csubt.defs.csubt.csubt.type
+matita.lambdadelta.basic_1.csubv.defs.csubv.csubv.type
+matita.lambdadelta.basic_1.drop1.defs.drop1.drop1.type
+matita.lambdadelta.basic_1.drop1.defs.ptrans.ptrans.type
+matita.lambdadelta.basic_1.drop.defs.drop.drop.type
+matita.lambdadelta.basic_1.ex0.defs.leqz.leqz.type
+matita.lambdadelta.basic_1.flt.defs.flt.type
+matita.lambdadelta.basic_1.flt.defs.fweight.type
+matita.lambdadelta.basic_1.fsubst0.defs.fsubst0.fsubst0.type
+matita.lambdadelta.basic_1.G.defs.G.mk_G.type
+matita.lambdadelta.basic_1.G.defs.next.next.type
+matita.lambdadelta.basic_1.getl.defs.getl.getl.type
+matita.lambdadelta.basic_1.iso.defs.iso.iso.type
+matita.lambdadelta.basic_1.leq.defs.leq.leq.type
+matita.lambdadelta.basic_1.lift1.defs.lift1.lift1.type
+matita.lambdadelta.basic_1.lift1.defs.lifts1.lifts1.type
+matita.lambdadelta.basic_1.lift1.defs.trans.trans.type
+matita.lambdadelta.basic_1.lift.defs.lifts.lifts.type
+matita.lambdadelta.basic_1.lift.defs.lift.type
+matita.lambdadelta.basic_1.lift.defs.lref_map.lref_map.type
+matita.lambdadelta.basic_1.llt.defs.llt.type
+matita.lambdadelta.basic_1.llt.defs.lweight.lweight.type
+matita.lambdadelta.basic_1.next_plus.defs.next_plus.next_plus.type
+matita.lambdadelta.basic_1.nf2.defs.nf2.type
+matita.lambdadelta.basic_1.nf2.defs.nfs2.nfs2.type
+matita.lambdadelta.basic_1.pc1.defs.pc1.type
+matita.lambdadelta.basic_1.pc3.defs.pc3_left.pc3_left.type
+matita.lambdadelta.basic_1.pc3.defs.pc3.type
+matita.lambdadelta.basic_1.pr0.defs.pr0.pr0.type
+matita.lambdadelta.basic_1.pr1.defs.pr1.pr1.type
+matita.lambdadelta.basic_1.pr2.defs.pr2.pr2.type
+matita.lambdadelta.basic_1.pr3.defs.pr3.pr3.type
+matita.lambdadelta.basic_1.r.defs.r.type
+matita.lambdadelta.basic_1.sc3.defs.sc3.sc3.type
+matita.lambdadelta.basic_1.s.defs.s.type
+matita.lambdadelta.basic_1.sn3.defs.sn3.sn3.type
+matita.lambdadelta.basic_1.sn3.defs.sns3.sns3.type
+matita.lambdadelta.basic_1.sty0.defs.sty0.sty0.type
+matita.lambdadelta.basic_1.sty1.defs.sty1.sty1.type
+matita.lambdadelta.basic_1.subst0.defs.subst0.subst0.type
+matita.lambdadelta.basic_1.subst1.defs.subst1.subst1.type
+matita.lambdadelta.basic_1.subst.defs.subst.subst.type
+matita.lambdadelta.basic_1.T.defs.K.Bind.type
+matita.lambdadelta.basic_1.T.defs.K.Flat.type
+matita.lambdadelta.basic_1.T.defs.tle.type
+matita.lambdadelta.basic_1.T.defs.T.THead.type
+matita.lambdadelta.basic_1.T.defs.T.TLRef.type
+matita.lambdadelta.basic_1.T.defs.T.TSort.type
+matita.lambdadelta.basic_1.T.defs.tweight.tweight.type
+matita.lambdadelta.basic_1.T.fwd.T_rect.T_rect.type
+matita.lambdadelta.basic_1.tlist.defs.TApp.TApp.type
+matita.lambdadelta.basic_1.tlist.defs.THeads.THeads.type
+matita.lambdadelta.basic_1.tlist.defs.TList.TCons.type
+matita.lambdadelta.basic_1.tlist.defs.tslen.tslen.type
+matita.lambdadelta.basic_1.tlist.defs.tslt.type
+matita.lambdadelta.basic_1.tlt.defs.tlt.type
+matita.lambdadelta.basic_1.tlt.defs.wadd.type
+matita.lambdadelta.basic_1.tlt.defs.weight_map.weight_map.type
+matita.lambdadelta.basic_1.tlt.defs.weight.type
+matita.lambdadelta.basic_1.ty3.defs.ty3.ty3.type
+matita.lambdadelta.basic_1.ty3.defs.tys3.tys3.type
+matita.lambdadelta.basic_1.ty3.nf2.ty3_nf2_inv_abst_premise.type
+matita.lambdadelta.basic_1.wcpr0.defs.wcpr0.wcpr0.type
+matita.lambdadelta.basic_1.wf3.defs.wf3.wf3.type
+-->
 </helm_registry>
diff --git a/matita/components/binaries/matex/test/basic_1.sty b/matita/components/binaries/matex/test/basic_1.sty
new file mode 100644 (file)
index 0000000..2706610
--- /dev/null
@@ -0,0 +1,10 @@
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesPackage{basic_1}[2016/05/23 Notation for "cic:/matita/lambdadelta/basic_1/"]
+\ExecuteOptions{}
+\ProcessOptions*
+
+\makeatletter
+
+\makeatother
+
+\endinput
diff --git a/matita/components/binaries/matex/test/ground_1.conf.xml b/matita/components/binaries/matex/test/ground_1.conf.xml
new file mode 100644 (file)
index 0000000..cb5860c
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<helm_registry>
+<!--
+matita.lambdadelta.ground_1.blt.defs.blt.blt.type
+matita.lambdadelta.ground_1.plist.defs.papp.papp.type
+matita.lambdadelta.ground_1.plist.defs.PConsTail.PConsTail.type
+matita.lambdadelta.ground_1.plist.defs.PList.PCons.type
+matita.lambdadelta.ground_1.plist.defs.Ss.Ss.type
+matita.lambdadelta.ground_1.types.defs.and3.and3.type
+matita.lambdadelta.ground_1.types.defs.ex2_2.ex2_2.type
+matita.lambdadelta.ground_1.types.defs.ex2_3.ex2_3.type
+matita.lambdadelta.ground_1.types.defs.ex_2.ex_2.type
+matita.lambdadelta.ground_1.types.defs.ex3_2.ex3_2.type
+matita.lambdadelta.ground_1.types.defs.ex3_3.ex3_3.type
+matita.lambdadelta.ground_1.types.defs.ex3_4.ex3_4.type
+matita.lambdadelta.ground_1.types.defs.ex_3.ex_3.type
+matita.lambdadelta.ground_1.types.defs.ex3.ex3.type
+matita.lambdadelta.ground_1.types.defs.ex4_2.ex4_2.type
+matita.lambdadelta.ground_1.types.defs.ex4_3.ex4_3.type
+matita.lambdadelta.ground_1.types.defs.ex4_4.ex4_4.type
+matita.lambdadelta.ground_1.types.defs.ex4_5.ex4_5.type
+matita.lambdadelta.ground_1.types.defs.ex4.ex4.type
+matita.lambdadelta.ground_1.types.defs.ex5_3.ex5_3.type
+matita.lambdadelta.ground_1.types.defs.ex6_6.ex6_6.type
+matita.lambdadelta.ground_1.types.defs.or3.or3.type
+matita.lambdadelta.ground_1.types.defs.or4.or4.type
+-->
+</helm_registry>
diff --git a/matita/components/binaries/matex/test/ground_1.sty b/matita/components/binaries/matex/test/ground_1.sty
new file mode 100644 (file)
index 0000000..582e49c
--- /dev/null
@@ -0,0 +1,10 @@
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesPackage{ground_1}[2016/05/23 Notation for "cic:/matita/lambdadelta/ground_1/"]
+\ExecuteOptions{}
+\ProcessOptions*
+
+\makeatletter
+
+\makeatother
+
+\endinput
diff --git a/matita/components/binaries/matex/test/legacy_1.conf.xml b/matita/components/binaries/matex/test/legacy_1.conf.xml
new file mode 100644 (file)
index 0000000..056d1dc
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<helm_registry>
+<!--
+matita.lambdadelta.legacy_1.coq.defs.eq.eq.type
+matita.lambdadelta.legacy_1.coq.defs.ex2.ex2.type
+matita.lambdadelta.legacy_1.coq.defs.ex.ex.type
+matita.lambdadelta.legacy_1.coq.defs.land.land.type
+matita.lambdadelta.legacy_1.coq.defs.le.le.type
+matita.lambdadelta.legacy_1.coq.defs.lt.type
+matita.lambdadelta.legacy_1.coq.defs.minus.minus.type
+matita.lambdadelta.legacy_1.coq.defs.nat.S.type
+matita.lambdadelta.legacy_1.coq.defs.not.type
+matita.lambdadelta.legacy_1.coq.defs.or.or.type
+matita.lambdadelta.legacy_1.coq.defs.plus.plus.type
+matita.lambdadelta.legacy_1.coq.defs.pred.type
+-->
+</helm_registry>
diff --git a/matita/components/binaries/matex/test/legacy_1.sty b/matita/components/binaries/matex/test/legacy_1.sty
new file mode 100644 (file)
index 0000000..d33196f
--- /dev/null
@@ -0,0 +1,10 @@
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesPackage{lambdadelta_1}[2016/05/23 Notation for "cic:/matita/lambdadelta/legacy_1/"]
+\ExecuteOptions{}
+\ProcessOptions*
+
+\makeatletter
+
+\makeatother
+
+\endinput
index fe150474c72d6e543cae32db4f2514ad801dae2a..26adf2224ff385a5201954da57a06f817553ddb1 100644 (file)
@@ -3,13 +3,22 @@
 \usepackage[bookmarks=false,ps2pdf]{hyperref}
 \usepackage[american]{babel}
 \usepackage{matex}
+\usepackage{legacy_1}
+\usepackage{ground_1}
+\usepackage{basic_1}
 
 \newcounter{node}
 \renewcommand*\ObjIncNode{\stepcounter{node}}
 \renewcommand*\ObjNode{\arabic{node} }
 
+\title{The Core Theory of the Formal System $\lambda\delta\hbox{-}1$}
+
+\author{Ferruccio Guidi}
+
 \begin{document}
 
+\maketitle
+
 \input{objs}
 
 \end{document}