2019-08-15 14:09:55 +00:00
|
|
|
(*************************************************************************
|
|
|
|
* Copyright (C)
|
|
|
|
* 2019 The University of Exeter
|
|
|
|
* 2018-2019 The University of Paris-Saclay
|
|
|
|
* 2018 The University of Sheffield
|
|
|
|
*
|
|
|
|
* License:
|
|
|
|
* This program can be redistributed and/or modified under the terms
|
|
|
|
* of the 2-clause BSD-style license.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*************************************************************************)
|
|
|
|
|
2019-07-20 13:54:31 +00:00
|
|
|
theory
|
|
|
|
Attributes
|
2023-02-22 09:52:05 +00:00
|
|
|
imports
|
|
|
|
"Isabelle_DOF-Unit-Tests_document"
|
2023-02-19 16:41:16 +00:00
|
|
|
"Isabelle_DOF-Ontologies.Conceptual"
|
2018-08-28 10:48:07 +00:00
|
|
|
begin
|
2023-03-01 19:47:28 +00:00
|
|
|
ML\<open>@{assert} (1 = 1)\<close>
|
|
|
|
section\<open>Elementar Creation of Doc-items and Access of their Attibutes\<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
|
|
|
text\<open>Current status:\<close>
|
|
|
|
print_doc_classes
|
|
|
|
print_doc_items
|
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
(* this corresponds to low-level accesses : *)
|
2018-08-28 10:48:07 +00:00
|
|
|
ML\<open>
|
2023-02-06 16:09:02 +00:00
|
|
|
val docitem_tab = DOF_core.get_instances \<^context>
|
2023-02-12 14:56:06 +00:00
|
|
|
val isa_transformer_tab = DOF_core.get_isa_transformers \<^context>
|
2023-02-14 16:57:53 +00:00
|
|
|
val docclass_tab = DOF_core.get_onto_classes @{context};
|
2023-03-01 19:47:28 +00:00
|
|
|
\<close>
|
|
|
|
ML\<open>
|
|
|
|
map fst (Name_Space.dest_table docitem_tab);
|
2023-02-14 16:57:53 +00:00
|
|
|
Name_Space.dest_table docclass_tab;
|
2023-03-01 19:47:28 +00:00
|
|
|
|
2018-08-28 10:48:07 +00:00
|
|
|
\<close>
|
2023-03-01 19:47:28 +00:00
|
|
|
|
2021-10-08 14:00:57 +00:00
|
|
|
ML\<open>
|
2023-02-06 16:09:02 +00:00
|
|
|
val (oid, DOF_core.Instance {value, ...}) =
|
|
|
|
Name_Space.check (Context.Proof \<^context>) (DOF_core.get_instances \<^context>) ("aaa", Position.none)
|
2021-10-08 14:00:57 +00:00
|
|
|
\<close>
|
|
|
|
|
|
|
|
find_theorems (60) name:"Conceptual.M."
|
|
|
|
|
2022-11-28 08:58:58 +00:00
|
|
|
value [simp]"M.trace(M.make undefined [] ())"
|
|
|
|
value "M.ok(M.make undefined_AAA [] ())"
|
|
|
|
value "M.trace(M.make undefined_AAA [] ())"
|
|
|
|
value "M.tag_attribute(M.make undefined_AAA [] ())"
|
2021-10-08 14:00:57 +00:00
|
|
|
|
|
|
|
|
2022-11-28 08:58:58 +00:00
|
|
|
value "M.ok(M.make 0 [] ())"
|
2021-10-08 14:00:57 +00:00
|
|
|
(*
|
2021-10-14 18:31:21 +00:00
|
|
|
value "ok(M.make undefined [] ())"
|
2021-10-08 14:00:57 +00:00
|
|
|
value "ok(M.make 0 [] undefined)"
|
|
|
|
*)
|
|
|
|
|
|
|
|
value [simp] \<open> M.ok
|
|
|
|
(Conceptual.M.trace_update (\<lambda>x. [])
|
|
|
|
(Conceptual.M.tag_attribute_update (\<lambda>x. 0)
|
|
|
|
(Conceptual.M.ok_update (\<lambda>x. ())
|
|
|
|
(undefined::M))
|
|
|
|
))\<close>
|
2019-10-01 15:57:26 +00:00
|
|
|
|
2021-12-16 12:49:44 +00:00
|
|
|
value [simp] \<open> M.ok
|
|
|
|
(Conceptual.M.trace_update (\<lambda>x. [])
|
|
|
|
(Conceptual.M.tag_attribute_update (\<lambda>x. 0)
|
|
|
|
(Conceptual.M.ok_update (\<lambda>x. ())
|
|
|
|
(undefined::M))
|
|
|
|
))\<close>
|
2021-10-14 18:31:21 +00:00
|
|
|
value \<open> M.ok
|
|
|
|
(Conceptual.M.trace_update (\<lambda>x. [])
|
|
|
|
(Conceptual.M.tag_attribute_update (\<lambda>x. 0)
|
|
|
|
(Conceptual.M.ok_update (\<lambda>x. ())
|
2021-12-16 12:49:44 +00:00
|
|
|
(AAAA::M))
|
2021-10-14 18:31:21 +00:00
|
|
|
))\<close>
|
|
|
|
|
|
|
|
|
2021-12-16 12:49:44 +00:00
|
|
|
value \<open> M.ok
|
|
|
|
(Conceptual.M.trace_update (\<lambda>x. [])
|
|
|
|
(Conceptual.M.tag_attribute_update (\<lambda>x. 0)
|
|
|
|
(Conceptual.M.ok_update (\<lambda>x. ())
|
|
|
|
(M.make XX1 XX2 XX3::M))
|
|
|
|
))\<close>
|
2019-10-01 15:57:26 +00:00
|
|
|
|
2019-02-08 14:43:49 +00:00
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
text\<open>A text item containing standard theorem antiquotations and complex meta-information.\<close>
|
2019-07-20 13:54:31 +00:00
|
|
|
(* crashes in batch mode ...
|
|
|
|
text*[dfgdfg::B, Conceptual.B.x ="''f''", y = "[''sdf'']"]\<open> Lorem ipsum ... @{thm refl} \<close>
|
|
|
|
*)
|
|
|
|
text*[dfgdfg::B]\<open> Lorem ipsum ... @{thm refl} \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
text\<open>document class declarations lead also HOL-type declarations (relevant for ontological links).\<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
typ "C"
|
|
|
|
typ "D"
|
2018-10-17 10:22:25 +00:00
|
|
|
text\<open> ... as well as HOL-constant declarations (relevant for monitor rexps and tracres.).\<close>
|
2018-10-16 08:44:59 +00:00
|
|
|
term "C"
|
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
text\<open>Voila what happens on the ML level:\<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
ML\<open>val Type("Conceptual.B.B_ext",[Type("Conceptual.C.C_ext",t)]) = @{typ "C"};
|
2022-05-25 15:07:06 +00:00
|
|
|
val @{typ "D"} = Value_Command.Docitem_Parser.cid_2_cidType "Conceptual.D" @{theory};
|
|
|
|
val @{typ "E"} = Value_Command.Docitem_Parser.cid_2_cidType "Conceptual.E" @{theory};
|
2018-08-28 10:48:07 +00:00
|
|
|
\<close>
|
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
text*[dfgdfg2::C, z = "None"]\<open> Lorem ipsum ... @{thm refl} \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
text*[omega::E, x = "''def''"]\<open> Lorem ipsum ... @{thm refl} \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
2020-04-09 21:58:58 +00:00
|
|
|
text\<open> As mentioned in @{docitem \<open>dfgdfg\<close>} \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
text\<open>Here is a simulation what happens on the level of the (HOL)-term representation:\<close>
|
2021-07-18 15:34:52 +00:00
|
|
|
typ \<open>'a A_scheme\<close>
|
|
|
|
typ \<open>A\<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
term "A.x (undefined\<lparr>A.x := 3\<rparr>)"
|
|
|
|
term "B.x ((undefined::C)\<lparr>B.y := [''sdf'']\<rparr>)"
|
|
|
|
term "C.z ((undefined::C)\<lparr>B.y := [''sdf''], z:= Some undefined\<rparr>)"
|
|
|
|
|
|
|
|
ML\<open>
|
|
|
|
val SOME {def_occurrence = "Conceptual.A", long_name = "Conceptual.A.x", typ = t, def_pos}
|
|
|
|
= DOF_core.get_attribute_info "Conceptual.A" "x" @{theory};
|
|
|
|
DOF_core.get_attribute_info "Conceptual.B" "x" @{theory};
|
|
|
|
DOF_core.get_attribute_info "Conceptual.B" "y" @{theory};
|
|
|
|
DOF_core.get_attribute_info "Conceptual.C" "x" @{theory};
|
|
|
|
val SOME {def_occurrence = "Conceptual.C", long_name = "Conceptual.B.y", typ = t', def_pos}
|
|
|
|
= DOF_core.get_attribute_info "Conceptual.C" "y" @{theory};
|
|
|
|
(* this is the situation where an attribute is defined in C, but due to inheritance
|
|
|
|
from B, where it is firstly declared which results in a different long_name. *)
|
|
|
|
DOF_core.get_attribute_info "Conceptual.C" "z" @{theory};
|
|
|
|
\<close>
|
|
|
|
|
|
|
|
|
|
|
|
ML\<open>
|
2023-02-11 21:48:11 +00:00
|
|
|
DOF_core.get_value_local "sdf" @{context};
|
|
|
|
DOF_core.get_value_local "sdfg" @{context};
|
|
|
|
DOF_core.get_value_local "xxxy" @{context};
|
|
|
|
DOF_core.get_value_local "dfgdfg" @{context};
|
|
|
|
DOF_core.get_value_local "omega" @{context};
|
2018-08-28 10:48:07 +00:00
|
|
|
\<close>
|
|
|
|
|
|
|
|
text\<open>A not too trivial test: default y -> [].
|
|
|
|
At creation : x -> "f", y -> "sdf".
|
|
|
|
The latter wins at access time.
|
|
|
|
Then @{term "t"}: creation of a multi inheritance object omega,
|
|
|
|
triple updates, the last one wins.\<close>
|
2018-10-17 10:22:25 +00:00
|
|
|
ML\<open>val s = map HOLogic.dest_string (HOLogic.dest_list @{docitem_attribute y::dfgdfg});
|
|
|
|
val t = HOLogic.dest_string (@{docitem_attribute x::omega}); \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
section\<open>Mutation of Attibutes in DocItems\<close>
|
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
ML\<open> val Const("Groups.zero_class.zero", @{typ "int"}) = @{docitem_attribute a2::omega} \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
|
|
|
update_instance*[omega::E, a2+="1"]
|
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
ML\<open> val (s as Const("Groups.one_class.one", @{typ "int"}))= @{docitem_attribute a2 :: omega} \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
|
|
|
update_instance*[omega::E, a2+="6"]
|
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
ML\<open> @{docitem_attribute a2::omega};
|
|
|
|
val s = HOLogic.dest_number @{docitem_attribute a2::omega} \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
2020-02-21 15:33:28 +00:00
|
|
|
type_synonym ALFACENTAURI = E
|
|
|
|
|
|
|
|
update_instance*[omega::ALFACENTAURI, x+="''inition''"]
|
2018-08-28 10:48:07 +00:00
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
ML\<open> val s = HOLogic.dest_string ( @{docitem_attribute x::omega}) \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
|
|
|
update_instance*[omega::E, y+="[''defini'',''tion'']"]
|
|
|
|
|
|
|
|
update_instance*[omega::E, y+="[''en'']"]
|
|
|
|
|
2018-10-17 10:22:25 +00:00
|
|
|
ML\<open> val s = map HOLogic.dest_string (HOLogic.dest_list @{docitem_attribute y::omega}); \<close>
|
2018-12-07 12:17:39 +00:00
|
|
|
|
|
|
|
subsection\<open> Example text antiquotation:\<close>
|
2022-11-24 09:41:50 +00:00
|
|
|
text\<open> @{docitem_attribute y::omega} \<close>
|
2018-12-07 12:17:39 +00:00
|
|
|
|
|
|
|
|
2018-08-28 10:48:07 +00:00
|
|
|
section\<open>Simulation of a Monitor\<close>
|
|
|
|
|
2022-12-14 11:02:15 +00:00
|
|
|
declare[[free_class_in_monitor_checking]]
|
|
|
|
|
2018-08-28 10:48:07 +00:00
|
|
|
open_monitor*[figs1::figure_group,
|
|
|
|
caption="''Sample ''"]
|
2023-02-09 15:41:32 +00:00
|
|
|
ML\<open>val monitor_infos = DOF_core.get_monitor_infos \<^context>\<close>
|
2022-12-14 11:02:15 +00:00
|
|
|
text*[testFreeA::A]\<open>\<close>
|
2018-10-05 07:45:24 +00:00
|
|
|
figure*[fig_A::figure, spawn_columns=False,
|
|
|
|
relative_width="90",
|
2018-08-28 10:48:07 +00:00
|
|
|
src="''figures/A.png''"]
|
|
|
|
\<open> The A train \ldots \<close>
|
|
|
|
|
2018-10-05 07:45:24 +00:00
|
|
|
figure*[fig_B::figure,
|
|
|
|
spawn_columns=False,relative_width="90",
|
2018-08-28 10:48:07 +00:00
|
|
|
src="''figures/B.png''"]
|
|
|
|
\<open> The B train \ldots \<close>
|
2022-12-14 11:02:15 +00:00
|
|
|
open_monitor*[figs2::figure_group,
|
|
|
|
caption="''Sample ''"]
|
2023-02-09 15:41:32 +00:00
|
|
|
ML\<open>val monitor_infos = DOF_core.get_monitor_infos \<^context>\<close>
|
2022-12-14 11:02:15 +00:00
|
|
|
figure*[fig_C::figure, spawn_columns=False,
|
|
|
|
relative_width="90",
|
|
|
|
src="''figures/A.png''"]
|
|
|
|
\<open> The C train \ldots \<close>
|
|
|
|
open_monitor*[figs3::figure_group,
|
|
|
|
caption="''Sample ''"]
|
2023-02-09 15:41:32 +00:00
|
|
|
ML\<open>val monitor_infos = DOF_core.get_monitor_infos \<^context>\<close>
|
2022-12-14 11:02:15 +00:00
|
|
|
|
|
|
|
figure*[fig_D::figure,
|
|
|
|
spawn_columns=False,relative_width="90",
|
|
|
|
src="''figures/B.png''"]
|
|
|
|
\<open> The D train \ldots \<close>
|
|
|
|
close_monitor*[figs3]
|
|
|
|
|
|
|
|
open_monitor*[figs4::figure_group,
|
|
|
|
caption="''Sample ''"]
|
2023-02-09 15:41:32 +00:00
|
|
|
ML\<open>val monitor_infos = DOF_core.get_monitor_infos \<^context>\<close>
|
2022-12-14 11:02:15 +00:00
|
|
|
|
2023-02-22 09:52:05 +00:00
|
|
|
text*[testRejected1::figure_group, caption="''document/figures/A.png''"]
|
2022-12-14 11:02:15 +00:00
|
|
|
\<open> The A train \ldots \<close>
|
|
|
|
|
|
|
|
figure*[fig_E::figure,
|
|
|
|
spawn_columns=False,relative_width="90",
|
|
|
|
src="''figures/B.png''"]
|
|
|
|
\<open> The E train \ldots \<close>
|
|
|
|
close_monitor*[figs4]
|
|
|
|
close_monitor*[figs2]
|
2023-02-22 09:52:05 +00:00
|
|
|
text*[testRejected2::figure_group, caption="''document/figures/A.png''"]
|
2022-12-14 11:02:15 +00:00
|
|
|
\<open> The A train \ldots \<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
|
2018-10-02 08:28:24 +00:00
|
|
|
close_monitor*[figs1]
|
2018-08-28 10:48:07 +00:00
|
|
|
|
2022-12-22 06:32:37 +00:00
|
|
|
declare[[free_class_in_monitor_checking = false]]
|
|
|
|
|
2018-12-07 12:17:39 +00:00
|
|
|
text\<open>Resulting trace of figs1 as ML antiquotation: \<close>
|
2018-12-11 15:03:01 +00:00
|
|
|
ML \<open>@{trace_attribute figs1}\<close>
|
|
|
|
text\<open>Resulting trace of figs as text antiquotation:\<close>
|
2018-12-07 12:17:39 +00:00
|
|
|
text\<open>@{trace_attribute figs1}\<close>
|
2018-10-17 10:31:17 +00:00
|
|
|
|
2023-02-22 09:52:05 +00:00
|
|
|
text\<open>Test trace\_attribute term antiquotation:\<close>
|
2022-11-24 13:20:29 +00:00
|
|
|
|
2022-11-25 07:57:59 +00:00
|
|
|
term*\<open>map snd @{trace-attribute \<open>figs1\<close>}\<close>
|
|
|
|
value*\<open>map snd @{trace-attribute \<open>figs1\<close>}\<close>
|
|
|
|
term*\<open>map fst @{trace-attribute \<open>aaa\<close>}\<close>
|
|
|
|
value*\<open>map fst @{trace-attribute \<open>aaa\<close>}\<close>
|
2022-12-14 11:02:15 +00:00
|
|
|
term*\<open>map fst @{trace-attribute \<open>test_monitor_M\<close>}\<close>
|
|
|
|
value*\<open>map fst @{trace-attribute \<open>test_monitor_M\<close>}\<close>
|
2022-12-07 15:01:38 +00:00
|
|
|
|
|
|
|
definition example_expression where "example_expression \<equiv> \<lbrace>\<lfloor>''Conceptual.A''\<rfloor> || \<lfloor>''Conceptual.F''\<rfloor>\<rbrace>\<^sup>*"
|
|
|
|
value* \<open> DA.accepts (na2da (rexp2na example_expression)) (map fst @{trace-attribute \<open>aaa\<close>}) \<close>
|
|
|
|
|
2022-12-09 14:12:38 +00:00
|
|
|
definition word_test :: "'a list \<Rightarrow> 'a rexp \<Rightarrow> bool" (infix "is-in" 60)
|
|
|
|
where " w is-in rexp \<equiv> DA.accepts (na2da (rexp2na rexp)) (w)"
|
2022-12-07 15:01:38 +00:00
|
|
|
|
2022-12-09 14:12:38 +00:00
|
|
|
value* \<open> (map fst @{trace-attribute \<open>aaa\<close>}) is-in example_expression \<close>
|
2022-11-28 08:58:58 +00:00
|
|
|
|
2022-11-24 13:20:29 +00:00
|
|
|
|
2018-12-19 11:05:57 +00:00
|
|
|
(*<*)
|
2018-10-17 10:31:17 +00:00
|
|
|
text\<open>Final Status:\<close>
|
2018-08-28 10:48:07 +00:00
|
|
|
print_doc_items
|
2018-10-08 13:13:47 +00:00
|
|
|
print_doc_classes
|
2019-07-20 13:54:31 +00:00
|
|
|
|
2018-12-19 11:05:57 +00:00
|
|
|
end
|
|
|
|
(*>*)
|