From 5aad659a85ebec7f37de7a0b2b4331d4153e1c13 Mon Sep 17 00:00:00 2001 From: Burkhart Wolff Date: Thu, 1 Jul 2021 13:12:18 +0200 Subject: [PATCH] some observations on invariant code generation --- src/ontologies/Conceptual/Conceptual.thy | 32 +++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/ontologies/Conceptual/Conceptual.thy b/src/ontologies/Conceptual/Conceptual.thy index 556400e..e34f02c 100755 --- a/src/ontologies/Conceptual/Conceptual.thy +++ b/src/ontologies/Conceptual/Conceptual.thy @@ -57,15 +57,41 @@ doc_class F = b :: "(A \ C) set" <= "{}" (* This is a relation link, roughly corresponding to an association class. It can be used to track claims to result - relations, for example.*) - invariant b :: "\\::F. r \ \ [] \ card(b \) \ 3" - and c :: "\\::F. properties \ \ []" + b' :: "(A \ C) list" <= "[]" + invariant br :: "\\::F. r \ \ [] \ card(b \) \ 3" + and br':: "\\::F. r \ \ [] \ length(b' \) \ 3" + and cr :: "\\::F. properties \ \ []" + +text\The effect of the invariant declaration is to provide intern definitions for validation +functions of this invariant. They can be referenced as follows:\ +thm br_inv_def +thm br'_inv_def +thm cr_inv_def + +text\Now, we can use these definitions in order to generate code for these validation functions. +Note, however, that not everything that we can write in an invariant (basically: HOL) is executable, +or even compilable by the code generator setup:\ + +ML\ val cr_inv_code = @{code "cr_inv"} \ \\works albeit thm is abstract ...\ +text\while in :\ +(* +ML\ val br_inv_code = @{code "br_inv"} \ \\does not work ...\ +*) +text\... the compilation fails due to the fact that nothing prevents the user + to define an infinite relation between \<^typ>\A\ and \<^typ>\C\. However, the alternative +variant: \ + +ML\ val br'_inv_code = @{code "br'_inv"} \ \\does work ...\ + +text\... is compilable ...\ + doc_class G = C + g :: "thm" <= "@{thm \HOL.refl\}" doc_class M = - trace :: "(A + C + D + F) list" + ok :: "unit" accepts "A ~~ \C || D\\<^sup>* ~~ \F\"