(************************************************************************* * 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 *************************************************************************) theory Attributes imports "Isabelle_DOF.Conceptual" begin section\Elementary Creation of Doc-items and Access of their Attibutes\ text\Current status:\ print_doc_classes print_doc_items (* this corresponds to low-level accesses : *) ML\ val docitem_tab = DOF_core.get_instances \<^context> val isa_transformer_tab = DOF_core.get_isa_transformers \<^context> val docclass_tab = DOF_core.get_onto_classes @{context}; Name_Space.dest_table docitem_tab; Name_Space.dest_table docclass_tab; \ ML\ val (oid, DOF_core.Instance {value, ...}) = Name_Space.check (Context.Proof \<^context>) (DOF_core.get_instances \<^context>) ("aaa", Position.none) \ find_theorems (60) name:"Conceptual.M." 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 [] ())" value "M.ok(M.make 0 [] ())" (* value "ok(M.make undefined [] ())" value "ok(M.make 0 [] undefined)" *) value [simp] \ M.ok (Conceptual.M.trace_update (\x. []) (Conceptual.M.tag_attribute_update (\x. 0) (Conceptual.M.ok_update (\x. ()) (undefined::M)) ))\ value [simp] \ M.ok (Conceptual.M.trace_update (\x. []) (Conceptual.M.tag_attribute_update (\x. 0) (Conceptual.M.ok_update (\x. ()) (undefined::M)) ))\ value \ M.ok (Conceptual.M.trace_update (\x. []) (Conceptual.M.tag_attribute_update (\x. 0) (Conceptual.M.ok_update (\x. ()) (AAAA::M)) ))\ value \ M.ok (Conceptual.M.trace_update (\x. []) (Conceptual.M.tag_attribute_update (\x. 0) (Conceptual.M.ok_update (\x. ()) (M.make XX1 XX2 XX3::M)) ))\ text\A text item containing standard theorem antiquotations and complex meta-information.\ (* crashes in batch mode ... text*[dfgdfg::B, Conceptual.B.x ="''f''", y = "[''sdf'']"]\ Lorem ipsum ... @{thm refl} \ *) text*[dfgdfg::B]\ Lorem ipsum ... @{thm refl} \ text\document class declarations lead also HOL-type declarations (relevant for ontological links).\ typ "C" typ "D" text\ ... as well as HOL-constant declarations (relevant for monitor rexps and tracres.).\ term "C" text\Voila what happens on the ML level:\ ML\val Type("Conceptual.B.B_ext",[Type("Conceptual.C.C_ext",t)]) = @{typ "C"}; 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}; \ text*[dfgdfg2::C, z = "None"]\ Lorem ipsum ... @{thm refl} \ text*[omega::E, x = "''def''"]\ Lorem ipsum ... @{thm refl} \ text\ As mentioned in @{docitem \dfgdfg\} \ text\Here is a simulation what happens on the level of the (HOL)-term representation:\ typ \'a A_scheme\ typ \A\ term "A.x (undefined\A.x := 3\)" term "B.x ((undefined::C)\B.y := [''sdf'']\)" term "C.z ((undefined::C)\B.y := [''sdf''], z:= Some undefined\)" ML\ 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}; \ ML\ 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}; \ text\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.\ ML\val s = map HOLogic.dest_string (HOLogic.dest_list @{docitem_attribute y::dfgdfg}); val t = HOLogic.dest_string (@{docitem_attribute x::omega}); \ section\Mutation of Attibutes in DocItems\ ML\ val Const("Groups.zero_class.zero", @{typ "int"}) = @{docitem_attribute a2::omega} \ update_instance*[omega::E, a2+="1"] ML\ val (s as Const("Groups.one_class.one", @{typ "int"}))= @{docitem_attribute a2 :: omega} \ update_instance*[omega::E, a2+="6"] ML\ @{docitem_attribute a2::omega}; val s = HOLogic.dest_number @{docitem_attribute a2::omega} \ type_synonym ALFACENTAURI = E update_instance*[omega::ALFACENTAURI, x+="''inition''"] ML\ val s = HOLogic.dest_string ( @{docitem_attribute x::omega}) \ update_instance*[omega::E, y+="[''defini'',''tion'']"] update_instance*[omega::E, y+="[''en'']"] ML\ val s = map HOLogic.dest_string (HOLogic.dest_list @{docitem_attribute y::omega}); \ subsection\ Example text antiquotation:\ text\ @{docitem_attribute y::omega} \ section\Simulation of a Monitor\ declare[[free_class_in_monitor_checking]] open_monitor*[figs1::figure_group, caption="''Sample ''"] ML\val monitor_infos = DOF_core.get_monitor_infos \<^context>\ text*[testFreeA::A]\\ figure*[fig_A::figure, spawn_columns=False, relative_width="90", src="''figures/A.png''"] \ The A train \ldots \ figure*[fig_B::figure, spawn_columns=False,relative_width="90", src="''figures/B.png''"] \ The B train \ldots \ open_monitor*[figs2::figure_group, caption="''Sample ''"] ML\val monitor_infos = DOF_core.get_monitor_infos \<^context>\ figure*[fig_C::figure, spawn_columns=False, relative_width="90", src="''figures/A.png''"] \ The C train \ldots \ open_monitor*[figs3::figure_group, caption="''Sample ''"] ML\val monitor_infos = DOF_core.get_monitor_infos \<^context>\ figure*[fig_D::figure, spawn_columns=False,relative_width="90", src="''figures/B.png''"] \ The D train \ldots \ close_monitor*[figs3] open_monitor*[figs4::figure_group, caption="''Sample ''"] ML\val monitor_infos = DOF_core.get_monitor_infos \<^context>\ text*[testRejected1::figure_group, caption="''figures/A.png''"] \ The A train \ldots \ figure*[fig_E::figure, spawn_columns=False,relative_width="90", src="''figures/B.png''"] \ The E train \ldots \ close_monitor*[figs4] close_monitor*[figs2] text*[testRejected2::figure_group, caption="''figures/A.png''"] \ The A train \ldots \ close_monitor*[figs1] declare[[free_class_in_monitor_checking = false]] text\Resulting trace of figs1 as ML antiquotation: \ ML \@{trace_attribute figs1}\ text\Resulting trace of figs as text antiquotation:\ text\@{trace_attribute figs1}\ text\Test trace_attribute term antiquotation:\ term*\map snd @{trace-attribute \figs1\}\ value*\map snd @{trace-attribute \figs1\}\ term*\map fst @{trace-attribute \aaa\}\ value*\map fst @{trace-attribute \aaa\}\ term*\map fst @{trace-attribute \test_monitor_M\}\ value*\map fst @{trace-attribute \test_monitor_M\}\ definition example_expression where "example_expression \ \\''Conceptual.A''\ || \''Conceptual.F''\\\<^sup>*" value* \ DA.accepts (na2da (rexp2na example_expression)) (map fst @{trace-attribute \aaa\}) \ definition word_test :: "'a list \ 'a rexp \ bool" (infix "is-in" 60) where " w is-in rexp \ DA.accepts (na2da (rexp2na rexp)) (w)" value* \ (map fst @{trace-attribute \aaa\}) is-in example_expression \ (*<*) text\Final Status:\ print_doc_items print_doc_classes end (*>*)