diff --git a/examples/technical_report/Isabelle_DOF-Manual/04_RefMan.thy b/examples/technical_report/Isabelle_DOF-Manual/04_RefMan.thy index 5338d63..2482345 100644 --- a/examples/technical_report/Isabelle_DOF-Manual/04_RefMan.thy +++ b/examples/technical_report/Isabelle_DOF-Manual/04_RefMan.thy @@ -1040,8 +1040,15 @@ subsection*["sec:class_inv"::technical]\ODL Class Invariants\ text\ Ontological classes as described so far are too liberal in many situations. There is a first high-level syntax implementation for class invariants. - These invariants can be checked when an instance of the class is defined. + These invariants are checked when an instance of the class is defined, + and trigger warnings. + The checking is enabled by default but can be disabled with the + \<^boxed_theory_text>\invariants_checking\ theory attribute: + @{boxed_theory_text [display]\ + declare[[invariants_checking = false]]\} + To enable the strict checking of the invariants, + that is to trigger errors instead of warnings, the \<^boxed_theory_text>\invariants_strict_checking\ theory attribute must be set: @{boxed_theory_text [display]\ diff --git a/src/DOF/Isa_DOF.thy b/src/DOF/Isa_DOF.thy index c2ca052..2974e9a 100644 --- a/src/DOF/Isa_DOF.thy +++ b/src/DOF/Isa_DOF.thy @@ -821,6 +821,9 @@ val (free_class_in_monitor_checking, free_class_in_monitor_checking_setup) val (free_class_in_monitor_strict_checking, free_class_in_monitor_strict_checking_setup) = Attrib.config_bool \<^binding>\free_class_in_monitor_strict_checking\ (K false); +val (invariants_checking, invariants_checking_setup) + = Attrib.config_bool \<^binding>\invariants_checking\ (K true); + val (invariants_strict_checking, invariants_strict_checking_setup) = Attrib.config_bool \<^binding>\invariants_strict_checking\ (K false); @@ -835,6 +838,7 @@ end (* struct *) setup\DOF_core.strict_monitor_checking_setup #> DOF_core.free_class_in_monitor_checking_setup #> DOF_core.free_class_in_monitor_strict_checking_setup + #> DOF_core.invariants_checking_setup #> DOF_core.invariants_strict_checking_setup #> DOF_core.invariants_checking_with_tactics_setup\ @@ -1756,7 +1760,9 @@ fun create_and_check_docitem is_monitor {is_inline=is_inline} oid pos cid_pos do for example when you just want a document element to be referenceable without using the burden of ontology classes. ex: text*[sdf]\ Lorem ipsum @{thm refl}\ *) - |> (fn thy => if default_cid then thy else check_invariants thy oid) + |> (fn thy => if default_cid then thy + else if Config.get_global thy DOF_core.invariants_checking + then check_invariants thy oid else thy) end end (* structure Docitem_Parser *) @@ -1941,7 +1947,9 @@ fun update_instance_command (((oid:string,pos),cid_pos), in thy |> DOF_core.update_value_global oid def_trans_input_term def_trans_value |> check_inv - |> (fn thy => Value_Command.Docitem_Parser.check_invariants thy oid) + |> (fn thy => if Config.get_global thy DOF_core.invariants_checking + then Value_Command.Docitem_Parser.check_invariants thy oid + else thy) end @@ -2003,7 +2011,9 @@ fun close_monitor_command (args as (((oid:string,pos),cid_pos), in thy |> (fn thy => (check_lazy_inv thy; thy)) |> update_instance_command args |> (fn thy => (check_inv thy; thy)) - |> (fn thy => Value_Command.Docitem_Parser.check_invariants thy oid) + |> (fn thy => if Config.get_global thy DOF_core.invariants_checking + then Value_Command.Docitem_Parser.check_invariants thy oid + else thy) |> delete_monitor_entry end