diff --git a/examples/simple/Concept_Example.thy b/examples/simple/Concept_Example.thy new file mode 100644 index 00000000..d8c3cdb7 --- /dev/null +++ b/examples/simple/Concept_Example.thy @@ -0,0 +1,50 @@ +chapter\Setting and modifying attributes of doc-items\ + +theory Concept_Example + imports "../../ontologies/Conceptual" (* we use the generic "Conceptual" ontology *) +begin + +text\@{theory Conceptual} provides a monitor @{typ M} enforcing a particular document structure. + Here, we say: From now on, this structural rules are respected wrt. all doc\_classes M is + enabled for.\ +open_monitor*[struct::M] + +section*[a::A, x = "3"] \ Lorem ipsum dolor sit amet, ... \ + +text*[c1::C, x = "''beta''"] \ ... suspendisse non arcu malesuada mollis, nibh morbi, ... \ + +text*[d::D, a1 = "X3"] \ ... phasellus amet id massa nunc, pede suscipit repellendus, + ... @{docitem \c1\} @{thm "refl"}\ + + +update_instance*[d::D, a1 := X2] + +text\ ... in ut tortor ... @{docitem \a\} ... @{A \a\}\ + +text*[c2::C, x = "''delta''"] \ ... in ut tortor eleifend augue pretium consectetuer. \ + +section*[f::F] \ Lectus accumsan velit ultrices, ... }\ + +theorem some_proof : "P" sorry + +text\This is an example where we add a theorem into a kind of "result-list" of the doc-item f.\ +update_instance*[f::F,r:="[@{thm ''Concept_Example.some_proof''}]"] + +text\ ..., mauris amet, id elit aliquam aptent id, ... @{docitem \a\} \ + +text\Here we add and maintain a link that is actually modeled as m-to-n relation ...\ +update_instance*[f::F,b:="{(@{docitem ''a''}::A,@{docitem ''c1''}::C), + (@{docitem ''a''}, @{docitem ''c2''})}"] + +close_monitor*[struct] + +text\And the trace of the monitor is:\ +ML\@{trace_attribute struct}\ + +print_doc_classes +print_doc_items + + + +end + \ No newline at end of file diff --git a/examples/simple/Concept_ExampleInvariant.thy b/examples/simple/Concept_ExampleInvariant.thy new file mode 100644 index 00000000..850ac484 --- /dev/null +++ b/examples/simple/Concept_ExampleInvariant.thy @@ -0,0 +1,39 @@ +chapter\Setting and modifying attributes of doc-items\ + +theory Concept_ExampleInvariant + imports "../../ontologies/Conceptual" (* we use the generic "Conceptual" ontology *) +begin + +print_doc_classes +print_doc_items + +ML\fun check_A_invariant oid ctxt = + let val term = AttributeAccess.calc_attr_access ctxt "x" oid @{here} + val (@{typ "int"},x_value) = HOLogic.dest_number term + in if x_value > 5 then error("class A invariant violation") else true end +\ + +text\Watch out: The current programming interface to document class invariants is pretty low-level: +\<^item> No inheritance principle +\<^item> No high-level notation in HOL +\<^item> Typing on ML level is assumed to be correct. +The implementor of an ontology must know what he does ... +\ +setup\DOF_core.update_class_invariant "Conceptual.A" (fn oid => + fn ctxt => + (writeln ("sample echo : "^oid); true))\ + +section*[b::A, x = "5"] \ Lorem ipsum dolor sit amet, ... \ + +setup\DOF_core.update_class_invariant "Conceptual.A" check_A_invariant\ + +(* test : should fail : +section*[c::A, x = "6"] \ Lorem ipsum dolor sit amet, ... \ +*) + +(* to test : updates *) + +(* to do: trace example *) + +end + \ No newline at end of file