forked from Isabelle_DOF/Isabelle_DOF
Corrections in ontologies (revealed by examples)
- identified problem: accept/reject conflicts were only detected at application time, not at declaration time :-( (leaved as "known problem" for the moment) - new functionality for declaring doc class invariants
This commit is contained in:
parent
4da4434a27
commit
23bc75d08d
|
@ -34,7 +34,7 @@ doc_class figure_group =
|
||||||
(* trace :: "doc_class rexp list" <= "[]" automatically generated since monitor clause *)
|
(* trace :: "doc_class rexp list" <= "[]" automatically generated since monitor clause *)
|
||||||
anchor :: "string"
|
anchor :: "string"
|
||||||
caption :: "string"
|
caption :: "string"
|
||||||
rejects figure, figure_group (* this forbids recursive figure-groups *)
|
rejects figure_group (* this forbids recursive figure-groups *)
|
||||||
accepts "\<lbrace>figure\<rbrace>\<^sup>+"
|
accepts "\<lbrace>figure\<rbrace>\<^sup>+"
|
||||||
|
|
||||||
ML\<open>@{term "side_by_side_figure"};
|
ML\<open>@{term "side_by_side_figure"};
|
||||||
|
|
52
Isa_DOF.thy
52
Isa_DOF.thy
|
@ -66,8 +66,9 @@ section\<open> A HomeGrown Document Type Management (the ''Model'') \<close>
|
||||||
ML\<open>
|
ML\<open>
|
||||||
structure DOF_core =
|
structure DOF_core =
|
||||||
struct
|
struct
|
||||||
type docclass_struct = {params : (string * sort) list, (*currently not used *)
|
type docclass_struct = {params : (string * sort) list, (*currently not used *)
|
||||||
name : binding, thy_name : string, id : serial, (* for pide *)
|
name : binding,
|
||||||
|
thy_name : string, id : serial, (* for pide *)
|
||||||
inherits_from : (typ list * string) option, (* imports *)
|
inherits_from : (typ list * string) option, (* imports *)
|
||||||
attribute_decl : (binding * typ * term option) list, (* class local *)
|
attribute_decl : (binding * typ * term option) list, (* class local *)
|
||||||
rejectS : term list,
|
rejectS : term list,
|
||||||
|
@ -188,7 +189,7 @@ fun upd_monitor_tabs f {docobj_tab,docclass_tab,ISA_transformer_tab, monitor_tab
|
||||||
fun upd_docclass_inv_tab f {docobj_tab,docclass_tab,ISA_transformer_tab, monitor_tab, docclass_inv_tab} =
|
fun upd_docclass_inv_tab f {docobj_tab,docclass_tab,ISA_transformer_tab, monitor_tab, docclass_inv_tab} =
|
||||||
{docobj_tab = docobj_tab,docclass_tab = docclass_tab,
|
{docobj_tab = docobj_tab,docclass_tab = docclass_tab,
|
||||||
ISA_transformer_tab = ISA_transformer_tab, monitor_tab = monitor_tab,
|
ISA_transformer_tab = ISA_transformer_tab, monitor_tab = monitor_tab,
|
||||||
docclass_inv_tab= f docclass_inv_tab};
|
docclass_inv_tab = f docclass_inv_tab};
|
||||||
|
|
||||||
|
|
||||||
fun get_accepted_cids ({accepted_cids, ... } : open_monitor_info) = accepted_cids
|
fun get_accepted_cids ({accepted_cids, ... } : open_monitor_info) = accepted_cids
|
||||||
|
@ -232,12 +233,19 @@ fun is_defined_cid_global cid thy = let val t = #docclass_tab(get_data_global th
|
||||||
Symtab.defined t (name2doc_class_name thy cid)
|
Symtab.defined t (name2doc_class_name thy cid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun is_defined_cid_global' cid_long thy = let val t = #docclass_tab(get_data_global thy)
|
||||||
|
in cid_long=default_cid orelse Symtab.defined t cid_long end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun is_defined_cid_local cid ctxt = let val t = #docclass_tab(get_data ctxt)
|
fun is_defined_cid_local cid ctxt = let val t = #docclass_tab(get_data ctxt)
|
||||||
in cid=default_cid orelse
|
in cid=default_cid orelse
|
||||||
Symtab.defined t (name2doc_class_name_local ctxt cid)
|
Symtab.defined t (name2doc_class_name_local ctxt cid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun is_defined_cid_local' cid_long ctxt = let val t = #docclass_tab(get_data ctxt)
|
||||||
|
in cid_long=default_cid orelse Symtab.defined t cid_long end
|
||||||
|
|
||||||
|
|
||||||
fun is_declared_oid_global oid thy = let val {tab,...} = #docobj_tab(get_data_global thy)
|
fun is_declared_oid_global oid thy = let val {tab,...} = #docobj_tab(get_data_global thy)
|
||||||
in Symtab.defined tab oid end
|
in Symtab.defined tab oid end
|
||||||
|
@ -272,6 +280,24 @@ fun declare_object_local oid ctxt =
|
||||||
handle Symtab.DUP _ => error("multiple declaration of document reference"))
|
handle Symtab.DUP _ => error("multiple declaration of document reference"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
fun update_class_invariant cid_long f thy =
|
||||||
|
let val _ = if is_defined_cid_global' cid_long thy then ()
|
||||||
|
else error("undefined class id : " ^cid_long)
|
||||||
|
in map_data_global (upd_docclass_inv_tab (Symtab.update (cid_long,
|
||||||
|
(fn ctxt => ((writeln("Inv check of :" ^cid_long); f ctxt ))))))
|
||||||
|
thy
|
||||||
|
end
|
||||||
|
|
||||||
|
fun get_class_invariant cid_long thy =
|
||||||
|
let val _ = if is_defined_cid_global' cid_long thy then ()
|
||||||
|
else error("undefined class id : " ^cid_long)
|
||||||
|
val {docclass_inv_tab, ...} = get_data_global thy
|
||||||
|
in case Symtab.lookup docclass_inv_tab cid_long of
|
||||||
|
NONE => K true
|
||||||
|
| SOME f => f
|
||||||
|
end
|
||||||
|
|
||||||
val SPY = Unsynchronized.ref(Bound 0)
|
val SPY = Unsynchronized.ref(Bound 0)
|
||||||
|
|
||||||
fun check_regexps term =
|
fun check_regexps term =
|
||||||
|
@ -464,9 +490,10 @@ fun update_value_global oid upd thy =
|
||||||
|
|
||||||
val ISA_prefix = "Isa_DOF.ISA_" (* ISA's must be declared in Isa_DOF.thy !!! *)
|
val ISA_prefix = "Isa_DOF.ISA_" (* ISA's must be declared in Isa_DOF.thy !!! *)
|
||||||
|
|
||||||
fun get_isa_global isa thy = case Symtab.lookup (#ISA_transformer_tab(get_data_global thy)) (ISA_prefix^isa) of
|
fun get_isa_global isa thy =
|
||||||
NONE => error("undefined inner syntax antiquotation: "^isa)
|
case Symtab.lookup (#ISA_transformer_tab(get_data_global thy)) (ISA_prefix^isa) of
|
||||||
|SOME(bbb) => bbb
|
NONE => error("undefined inner syntax antiquotation: "^isa)
|
||||||
|
| SOME(bbb) => bbb
|
||||||
|
|
||||||
|
|
||||||
fun get_isa_local isa ctxt = case Symtab.lookup (#ISA_transformer_tab(get_data ctxt)) (ISA_prefix^isa) of
|
fun get_isa_local isa ctxt = case Symtab.lookup (#ISA_transformer_tab(get_data ctxt)) (ISA_prefix^isa) of
|
||||||
|
@ -894,13 +921,13 @@ fun calc_update_term thy cid_long (S:(string * Position.T * string * term)list)
|
||||||
val _ = if Long_Name.base_name lhs = lhs orelse ln = lhs then ()
|
val _ = if Long_Name.base_name lhs = lhs orelse ln = lhs then ()
|
||||||
else error("illegal notation for attribute of "^cid_long)
|
else error("illegal notation for attribute of "^cid_long)
|
||||||
fun join (ttt as @{typ "int"})
|
fun join (ttt as @{typ "int"})
|
||||||
= Const (@{const_name "plus"}, ttt --> ttt --> ttt)
|
= Const (@{const_name "Groups.plus"}, ttt --> ttt --> ttt)
|
||||||
|join (ttt as @{typ "string"})
|
|join (ttt as @{typ "string"})
|
||||||
= Const (@{const_name "append"}, ttt --> ttt --> ttt)
|
= Const (@{const_name "List.append"}, ttt --> ttt --> ttt)
|
||||||
|join (ttt as Type(@{type_name "set"},_))
|
|join (ttt as Type(@{type_name "set"},_))
|
||||||
= Const (@{const_name "sup"}, ttt --> ttt --> ttt)
|
= Const (@{const_name "Lattices.sup"}, ttt --> ttt --> ttt)
|
||||||
|join (ttt as Type(@{type_name "list"},_))
|
|join (ttt as Type(@{type_name "list"},_))
|
||||||
= Const (@{const_name "append"}, ttt --> ttt --> ttt)
|
= Const (@{const_name "List.append"}, ttt --> ttt --> ttt)
|
||||||
|join _ = error("implicit fusion operation not defined for attribute: "^ lhs)
|
|join _ = error("implicit fusion operation not defined for attribute: "^ lhs)
|
||||||
(* could be extended to bool, map, multisets, ... *)
|
(* could be extended to bool, map, multisets, ... *)
|
||||||
val rhs' = instantiate_term tyenv' (generalize_term rhs)
|
val rhs' = instantiate_term tyenv' (generalize_term rhs)
|
||||||
|
@ -1491,11 +1518,6 @@ ML\<open>
|
||||||
|
|
||||||
section\<open> Testing and Validation \<close>
|
section\<open> Testing and Validation \<close>
|
||||||
|
|
||||||
text*[sdf] {* f @{thm refl}*}
|
|
||||||
text*[sdfg] {* fg @{thm refl}*}
|
|
||||||
|
|
||||||
text*[xxxy] {* dd @{docitem \<open>sdfg\<close>} @{thm refl}*}
|
|
||||||
|
|
||||||
(* the following test crashes the LaTeX generation - however, without the latter this output is
|
(* the following test crashes the LaTeX generation - however, without the latter this output is
|
||||||
instructive
|
instructive
|
||||||
ML\<open>
|
ML\<open>
|
||||||
|
|
|
@ -70,9 +70,6 @@ paragraph* [sdfk] \<open> just a paragraph - lexical variant \<close>
|
||||||
|
|
||||||
section\<open> Some global inspection commands for the status of docitem and doc-class tables ... \<close>
|
section\<open> Some global inspection commands for the status of docitem and doc-class tables ... \<close>
|
||||||
|
|
||||||
print_doc_classes
|
|
||||||
print_doc_items
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
section\<open> Text Antiquotation Infrastructure ... \<close>
|
section\<open> Text Antiquotation Infrastructure ... \<close>
|
||||||
|
|
|
@ -10,7 +10,7 @@ print_doc_items
|
||||||
|
|
||||||
(* this corresponds to low-level accesses : *)
|
(* this corresponds to low-level accesses : *)
|
||||||
ML\<open>
|
ML\<open>
|
||||||
val {docobj_tab={tab = docitem_tab, ...},docclass_tab, ISA_transformer_tab, monitor_tab}
|
val {docobj_tab={tab = docitem_tab, ...},docclass_tab, ISA_transformer_tab, monitor_tab,...}
|
||||||
= DOF_core.get_data @{context};
|
= DOF_core.get_data @{context};
|
||||||
|
|
||||||
Symtab.dest docitem_tab;
|
Symtab.dest docitem_tab;
|
||||||
|
|
|
@ -41,6 +41,14 @@ close_monitor*[struct]
|
||||||
text\<open>And the trace of the monitor is:\<close>
|
text\<open>And the trace of the monitor is:\<close>
|
||||||
ML\<open>@{trace_attribute struct}\<close>
|
ML\<open>@{trace_attribute struct}\<close>
|
||||||
|
|
||||||
|
print_doc_classes
|
||||||
|
print_doc_items
|
||||||
|
|
||||||
|
ML\<open>
|
||||||
|
|
||||||
|
\<close>
|
||||||
|
|
||||||
|
setup\<open>DOF_core.update_class_invariant "Conceptual.A" (K true)\<close>
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,5 +41,14 @@ doc_class G = C +
|
||||||
doc_class M =
|
doc_class M =
|
||||||
trace :: "(A + C + D + F) list"
|
trace :: "(A + C + D + F) list"
|
||||||
accepts "A ~~ \<lbrace>C || D\<rbrace>\<^sup>* ~~ \<lbrakk>F\<rbrakk>"
|
accepts "A ~~ \<lbrace>C || D\<rbrace>\<^sup>* ~~ \<lbrakk>F\<rbrakk>"
|
||||||
|
|
||||||
|
|
||||||
|
section*[test::A]\<open> Test and Validation\<close>
|
||||||
|
text\<open>Defining some document elements to be referenced in another theory: \<close>
|
||||||
|
text*[sdf] {* f @{thm refl}*}
|
||||||
|
text*[sdfg] {* fg @{thm refl}*}
|
||||||
|
|
||||||
|
text*[xxxy] {* dd @{docitem \<open>sdfg\<close>} @{thm refl}*}
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -32,5 +32,8 @@ doc_class report =
|
||||||
\<lbrace>index\<rbrace>\<^sup>+ ~~
|
\<lbrace>index\<rbrace>\<^sup>+ ~~
|
||||||
bibliography)"
|
bibliography)"
|
||||||
|
|
||||||
|
ML\<open>
|
||||||
|
\<close>
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue