(************************************************************************* * Copyright (C) * 2019-2023 The University of Exeter * 2018-2023 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 *************************************************************************) chapter\Testing Nested Monitors\ theory Concept_MonitorTest1 imports "Isabelle_DOF_Unit_Tests_document" "Isabelle_DOF-Ontologies.Conceptual" (* we use the generic "Conceptual" ontology *) TestKit begin section\Test Purpose.\ text\ Creation of document parts that are controlled by (nested, locally defined) monitors. \ open_monitor*[aaa::Conceptual.M] text*[test::A]\For Test and Validation\ text\Defining some document elements to be referenced in later on in another theory: \ text*[sdf] \ Lorem ipsum ... \ \ \anonymous reference, ignored by monitor.\ text*[sdfg :: F] \ Lorem ipsum ...\ \ \causes just warnings for invariant violations due to non-strict checking mode\ close_monitor*[aaa] \ \causes warning: accept clause 1 not in final state .\ section\A Local Monitor Class Definition\ doc_class test_monitor_free = tmhd :: int doc_class test_monitor_head = tmhd :: int doc_class test_monitor_A = test_monitor_head + tmA :: int doc_class test_monitor_B = test_monitor_A + tmB :: int doc_class test_monitor_C = test_monitor_A + tmC :: int doc_class test_monitor_D = test_monitor_B + tmD :: int doc_class test_monitor_E = test_monitor_D + tmE :: int doc_class monitor_M = tmM :: int rejects "test_monitor_A" accepts "test_monitor_head ~~ test_monitor_B ~~ test_monitor_C" section\A more Complex Monitoring Example \ text\Consult the status of the DOF engine:\ print_doc_classes print_doc_items declare[[free_class_in_monitor_checking]] open_monitor*[test_monitor_M::monitor_M] text*[testFree::test_monitor_free]\...\ open_monitor*[test_monitor_M2::monitor_M] declare[[strict_monitor_checking]] text-assert-error[test_monitor_A1::test_monitor_A]\\ \accepts clause 1 of monitor Concept_MonitorTest1.test_monitor_M rejected\ declare[[strict_monitor_checking=false]] text*[test_monitor_A1::test_monitor_A]\\ \ \the same in non-strict monitor checking.\ declare[[free_class_in_monitor_strict_checking]] text-assert-error[testFree2::test_monitor_free]\\ \accepts clause 1 of monitor Concept_MonitorTest1.test_monitor_M not enabled\ declare[[free_class_in_monitor_strict_checking=false]] text*[test_monitor_head1::test_monitor_head]\\ text*[testFree3::test_monitor_free]\\ text*[test_monitor_B1::test_monitor_B]\\ text*[testFree4::test_monitor_free]\\ text*[test_monitor_D1::test_monitor_D]\\ text*[testFree5::test_monitor_free]\\ text*[test_monitor_C1::test_monitor_C]\\ text*[testFree6::test_monitor_free]\\ close_monitor*[test_monitor_M2] close_monitor*[test_monitor_M] declare[[free_class_in_monitor_checking = false]] text\Consult the final status of the DOF engine:\ print_doc_classes print_doc_items ML\ val (oid, DOF_core.Instance {value, ...}) = Name_Space.check (Context.Proof \<^context>) (DOF_core.get_instances \<^context>) ("aaa", Position.none) \ term*\map fst @{trace-attribute \test_monitor_M\}\ value*\map fst @{trace-attribute \test_monitor_M\}\ ML\@{assert} ([("Conceptual.A", "test"), ("Conceptual.F", "sdfg")] = @{trace_attribute aaa}) \ open_monitor*[test_monitor_M3::monitor_M] declare[[strict_monitor_checking]] text-assert-error[test_monitor_A2::test_monitor_A]\\ \accepts clause 1 of monitor Concept_MonitorTest1.test_monitor_M3 rejected\ declare[[strict_monitor_checking=false]] text*[test_monitor_A3::test_monitor_A]\\ \ \the same in non-strict monitor checking.\ declare[[free_class_in_monitor_strict_checking]] text-assert-error[testFree7::test_monitor_free]\\ \accepts clause 1 of monitor Concept_MonitorTest1.test_monitor_M3 not enabled\ declare[[free_class_in_monitor_strict_checking=false]] end