upgrade to Isabelle devel/28f9e9b80c49 and afp-devel

This commit is contained in:
Frédéric Tuong 2018-07-18 10:44:10 -04:00
parent 4f34b5b2f2
commit 0f3157d521
42 changed files with 336 additions and 261 deletions

23
ROOT
View File

@ -103,16 +103,16 @@ session "OCL-all-dirty" in "src" = "HOL-Library" +
options [quick_and_dirty,document=pdf,document_output=document_generated,
document_variants="document=afp,-annexa,-noexample",
show_question_marks = false]
sessions
OCL
FOCL
theories
"../src/UML_Main"
"../src/basic_types/UML_UnlimitedNatural"
"../examples/empirical_evaluation/Class_model"
"../src/compiler/Generator_static"
"../examples/Employee_Model/Analysis/Analysis_OCL"
"../examples/Employee_Model/Design/Design_OCL"
"../doc/Employee_AnalysisModel_UMLPart_generated"
"../doc/Employee_DesignModel_UMLPart_generated"
@ -140,23 +140,6 @@ session "OCL-all-dirty" in "src" = "HOL-Library" +
"../examples/archive/OCL_core_experiments"
"../examples/archive/OCL_lib_Gogolla_challenge_naive"
"../examples/archive/OCL_lib_Gogolla_challenge_integer"
document_files
"conclusion.tex"
"figures/AbstractSimpleChair.pdf"
"figures/jedit.png"
(*"figures/logo_focl.pdf"*)
"figures/pdf.png"
"figures/person.png"
"figures/pre-post.pdf"
"fixme.sty"
"hol-ocl-isar.sty"
"introduction.tex"
"lstisar.sty"
"omg.sty"
"prooftree.sty"
"root.bib"
"root.tex"
"FOCL_Syntax.tex"
(******************************************************)

1
ROOTS Normal file
View File

@ -0,0 +1 @@
src/compiler_generic

View File

@ -44,8 +44,7 @@ chapter{* Example: Abstract List *}
theory
AbstractList
imports
"../src/UML_OCL"
(* separate compilation : UML_OCL *)
FOCL.UML_OCL
begin
generation_syntax [ shallow ]

View File

@ -44,7 +44,7 @@ chapter{* Part ... *}
theory
Bank_Model
imports
"../src/UML_OCL"
FOCL.UML_OCL
begin
Class Bank

View File

@ -43,7 +43,7 @@ chapter{* Part ... *}
theory Bank_Test_Model
imports
"../src/UML_OCL"
FOCL.UML_OCL
begin
Class Account

View File

@ -43,7 +43,7 @@ chapter{* Part ... *}
theory Clocks_Lib_Model
imports
"../src/UML_OCL"
FOCL.UML_OCL
begin
Class Clock

View File

@ -201,6 +201,7 @@ lemmas cps23 =
StrictRefEq\<^sub>O\<^sub>b\<^sub>j\<^sub>e\<^sub>c\<^sub>t_strict2
[of "x::Person",
simplified StrictRefEq\<^sub>O\<^sub>b\<^sub>j\<^sub>e\<^sub>c\<^sub>t_\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n[symmetric]]
for x y \<tau> P Q
(* TODO: Analogue for object. *)
@ -690,8 +691,8 @@ by(rule OclAny_allInstances_generic_oclIsTypeOf\<^sub>O\<^sub>c\<^sub>l\<^sub>A\
lemma OclAny_allInstances_generic_oclIsTypeOf\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y2:
assumes [simp]: "\<And>x. pre_post (x, x) = x"
shows "\<exists>\<tau>. (\<tau> \<Turnstile> not ((OclAllInstances_generic pre_post OclAny)->forAll\<^sub>S\<^sub>e\<^sub>t(X|X .oclIsTypeOf(OclAny))))"
proof - fix oid a let ?t0 = "\<lparr>heap = empty(oid \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y (mk\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y oid \<lfloor>a\<rfloor>)),
assocs = empty\<rparr>" show ?thesis
proof - fix oid a let ?t0 = "\<lparr>heap = Map.empty(oid \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y (mk\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y oid \<lfloor>a\<rfloor>)),
assocs = Map.empty\<rparr>" show ?thesis
apply(rule_tac x = "(?t0, ?t0)" in exI, simp add: OclValid_def del: OclAllInstances_generic_def)
apply(simp only: UML_Set.OclForall_def refl if_True
OclAllInstances_generic_defined[simplified OclValid_def])
@ -1064,7 +1065,7 @@ definition "person9 \<equiv> mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n
text_raw{* \endisatagafp*}
definition
"\<sigma>\<^sub>1 \<equiv> \<lparr> heap = empty(oid0 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n (mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid0 \<lfloor>1000\<rfloor>))
"\<sigma>\<^sub>1 \<equiv> \<lparr> heap = Map.empty(oid0 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n (mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid0 \<lfloor>1000\<rfloor>))
(oid1 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n (mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid1 \<lfloor>1200\<rfloor>))
(*oid2*)
(oid3 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n (mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid3 \<lfloor>2600\<rfloor>))
@ -1073,10 +1074,10 @@ definition
(*oid6*)
(*oid7*)
(oid8 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person9),
assocs = empty(oid\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n\<B>\<O>\<S>\<S> \<mapsto> [[[oid0],[oid1]],[[oid3],[oid4]],[[oid5],[oid3]]]) \<rparr>"
assocs = Map.empty(oid\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n\<B>\<O>\<S>\<S> \<mapsto> [[[oid0],[oid1]],[[oid3],[oid4]],[[oid5],[oid3]]]) \<rparr>"
definition
"\<sigma>\<^sub>1' \<equiv> \<lparr> heap = empty(oid0 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person1)
"\<sigma>\<^sub>1' \<equiv> \<lparr> heap = Map.empty(oid0 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person1)
(oid1 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person2)
(oid2 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person3)
(oid3 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person4)
@ -1085,9 +1086,9 @@ definition
(oid6 \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y person7)
(oid7 \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y person8)
(oid8 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person9),
assocs = empty(oid\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n\<B>\<O>\<S>\<S> \<mapsto> [[[oid0],[oid1]],[[oid1],[oid1]],[[oid5],[oid6]],[[oid6],[oid6]]]) \<rparr>"
assocs = Map.empty(oid\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n\<B>\<O>\<S>\<S> \<mapsto> [[[oid0],[oid1]],[[oid1],[oid1]],[[oid5],[oid6]],[[oid6],[oid6]]]) \<rparr>"
definition "\<sigma>\<^sub>0 \<equiv> \<lparr> heap = empty, assocs = empty \<rparr>"
definition "\<sigma>\<^sub>0 \<equiv> \<lparr> heap = Map.empty, assocs = Map.empty \<rparr>"
lemma basic_\<tau>_wff: "WFF(\<sigma>\<^sub>1,\<sigma>\<^sub>1')"
@ -1330,7 +1331,7 @@ proof -
done
qed
lemma perm_\<sigma>\<^sub>1' : "\<sigma>\<^sub>1' = \<lparr> heap = empty
lemma perm_\<sigma>\<^sub>1' : "\<sigma>\<^sub>1' = \<lparr> heap = Map.empty
(oid8 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person9)
(oid7 \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y person8)
(oid6 \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y person7)

View File

@ -50,8 +50,8 @@ begin
generation_syntax [ deep
(generation_semantics [ analysis (*, oid_start 10*) ])
(THEORY Employee_AnalysisModel_UMLPart_generated)
(IMPORTS ["../src/UML_Main", "../src/compiler/Static"]
"../src/compiler/Generator_dynamic_sequential")
(IMPORTS ["OCL.UML_Main", "FOCL.Static"]
"FOCL.Generator_dynamic_sequential")
SECTION
(*SORRY*) (*no_dirty*)
[ (* in Haskell *)

View File

@ -44,9 +44,9 @@ chapter{* Part ... *}
theory
Analysis_shallow
imports
"../../src/UML_Main"
"../../src/compiler/Static"
"../../src/compiler/Generator_dynamic_sequential"
OCL.UML_Main
FOCL.Static
FOCL.Generator_dynamic_sequential
begin
generation_syntax [ shallow (generation_semantics [ analysis ])

View File

@ -191,6 +191,7 @@ lemmas cps23 =
StrictRefEq\<^sub>O\<^sub>b\<^sub>j\<^sub>e\<^sub>c\<^sub>t_strict2
[of "x::Person",
simplified StrictRefEq\<^sub>O\<^sub>b\<^sub>j\<^sub>e\<^sub>c\<^sub>t_\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n[symmetric]]
for x y \<tau> P Q
(* TODO: Analogue for object. *)
@ -679,8 +680,8 @@ by(rule OclAny_allInstances_generic_oclIsTypeOf\<^sub>O\<^sub>c\<^sub>l\<^sub>A\
lemma OclAny_allInstances_generic_oclIsTypeOf\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y2:
assumes [simp]: "\<And>x. pre_post (x, x) = x"
shows "\<exists>\<tau>. (\<tau> \<Turnstile> not ((OclAllInstances_generic pre_post OclAny)->forAll\<^sub>S\<^sub>e\<^sub>t(X|X .oclIsTypeOf(OclAny))))"
proof - fix oid a let ?t0 = "\<lparr>heap = empty(oid \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y (mk\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y oid \<lfloor>a\<rfloor>)),
assocs = empty\<rparr>" show ?thesis
proof - fix oid a let ?t0 = "\<lparr>heap = Map.empty(oid \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y (mk\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y oid \<lfloor>a\<rfloor>)),
assocs = Map.empty\<rparr>" show ?thesis
apply(rule_tac x = "(?t0, ?t0)" in exI, simp add: OclValid_def del: OclAllInstances_generic_def)
apply(simp only: UML_Set.OclForall_def refl if_True
OclAllInstances_generic_defined[simplified OclValid_def])
@ -1022,7 +1023,7 @@ definition "person8 \<equiv> mk\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y
definition "person9 \<equiv> mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid8 \<lfloor>0\<rfloor> None"
definition
"\<sigma>\<^sub>1 \<equiv> \<lparr> heap = empty(oid0 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n (mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid0 \<lfloor>1000\<rfloor> \<lfloor>oid1\<rfloor>))
"\<sigma>\<^sub>1 \<equiv> \<lparr> heap = Map.empty(oid0 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n (mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid0 \<lfloor>1000\<rfloor> \<lfloor>oid1\<rfloor>))
(oid1 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n (mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid1 \<lfloor>1200\<rfloor> None))
(*oid2*)
(oid3 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n (mk\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n oid3 \<lfloor>2600\<rfloor> \<lfloor>oid4\<rfloor>))
@ -1031,10 +1032,10 @@ definition
(*oid6*)
(*oid7*)
(oid8 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person9),
assocs = empty \<rparr>"
assocs = Map.empty \<rparr>"
definition
"\<sigma>\<^sub>1' \<equiv> \<lparr> heap = empty(oid0 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person1)
"\<sigma>\<^sub>1' \<equiv> \<lparr> heap = Map.empty(oid0 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person1)
(oid1 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person2)
(oid2 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person3)
(oid3 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person4)
@ -1043,9 +1044,9 @@ definition
(oid6 \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y person7)
(oid7 \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y person8)
(oid8 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person9),
assocs = empty \<rparr>"
assocs = Map.empty \<rparr>"
definition "\<sigma>\<^sub>0 \<equiv> \<lparr> heap = empty, assocs = empty \<rparr>"
definition "\<sigma>\<^sub>0 \<equiv> \<lparr> heap = Map.empty, assocs = Map.empty \<rparr>"
lemma basic_\<tau>_wff: "WFF(\<sigma>\<^sub>1,\<sigma>\<^sub>1')"
@ -1283,7 +1284,7 @@ proof -
done
qed
lemma perm_\<sigma>\<^sub>1' : "\<sigma>\<^sub>1' = \<lparr> heap = empty
lemma perm_\<sigma>\<^sub>1' : "\<sigma>\<^sub>1' = \<lparr> heap = Map.empty
(oid8 \<mapsto> in\<^sub>P\<^sub>e\<^sub>r\<^sub>s\<^sub>o\<^sub>n person9)
(oid7 \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y person8)
(oid6 \<mapsto> in\<^sub>O\<^sub>c\<^sub>l\<^sub>A\<^sub>n\<^sub>y person7)

View File

@ -50,8 +50,8 @@ begin
generation_syntax [ deep
(generation_semantics [ design (*, oid_start 10*) ])
(THEORY Employee_DesignModel_UMLPart_generated)
(IMPORTS ["../src/UML_Main", "../src/compiler/Static"]
"../src/compiler/Generator_dynamic_sequential")
(IMPORTS ["OCL.UML_Main", "FOCL.Static"]
"FOCL.Generator_dynamic_sequential")
SECTION
(*SORRY*) (*no_dirty*)
[ (* in Haskell *)

View File

@ -44,9 +44,9 @@ chapter{* Part ... *}
theory
Design_shallow
imports
"../../src/UML_Main"
"../../src/compiler/Static"
"../../src/compiler/Generator_dynamic_sequential"
OCL.UML_Main
FOCL.Static
FOCL.Generator_dynamic_sequential
begin
generation_syntax [ shallow (generation_semantics [ design ])

View File

@ -42,8 +42,7 @@
theory
Flight_Model
imports
"../src/UML_OCL"
(* separate compilation : UML_OCL *)
FOCL.UML_OCL
begin
subsection\<open> Class Model \<close>

View File

@ -50,8 +50,7 @@ chapter{* Example: Linked List *}
theory
LinkedList
imports
"../src/UML_OCL"
(* separate compilation : UML_OCL *)
FOCL.UML_OCL
begin
generation_syntax [ shallow ]

View File

@ -42,8 +42,7 @@
theory
Flight_Model_compact
imports
"../../src/UML_OCL"
(* separate compilation : UML_OCL *)
FOCL.UML_OCL
begin
subsection\<open> Class Model \<close>

View File

@ -48,7 +48,7 @@ chapter{* Gogolla's challenge on Sets *}
theory
Isabelle_Finite_Set
imports
"../../src/collection_types/UML_Set"
OCL.UML_Set
begin
no_notation None ("\<bottom>")

View File

@ -46,7 +46,7 @@
theory
OCL_core_experiments
imports
"../../src/UML_Logic"
OCL.UML_Logic
begin
section{* OCL Core Definitions *}

View File

@ -48,7 +48,7 @@ chapter{* Gogolla's challenge on Sets *}
theory
OCL_lib_Gogolla_challenge
imports
"../../src/UML_Library"
OCL.UML_Library
Isabelle_Finite_Set
begin

View File

@ -42,7 +42,7 @@
chapter{* Part ... *}
theory Simple_Model
imports "../../src/UML_OCL"
imports FOCL.UML_OCL
begin
Class A

View File

@ -45,7 +45,7 @@ subsection\<open>Introduction\<close>
theory
Toy_deep
imports
"../../src/compiler/Generator_dynamic_sequential"
FOCL.Generator_dynamic_sequential
begin
ML_file "~~/src/Doc/antiquote_setup.ML"
@ -134,7 +134,7 @@ End
text\<open>The ``blue'' color of @{command End} indicates that
@{command End} is not a ``green'' keyword.
@{command End} and @{command Class} are in fact similar, they belong to the group of meta-commands
(all meta-commands are defined in @{theory Generator_dynamic_sequential}).
(all meta-commands are defined in @{theory FOCL.Generator_dynamic_sequential}).
At run-time and in @{keyword "deep"} mode, all meta-commands have
approximately the same semantics: they only display some quantity of Isabelle code
in the output window (as long as meta-commands are syntactically correctly formed).
@ -318,9 +318,9 @@ Meta-commands are obviously not restricted to manipulate expressions in the Oute
It is possible to build meta-commands so that Inner Syntax expressions are directly parsed.
However the dependencies of this theory have been minimized so that experimentations
and debugging can easily occur in @{keyword "deep"} mode
(this file only depends on @{theory Generator_dynamic_sequential}).
(this file only depends on @{theory FOCL.Generator_dynamic_sequential}).
Since the Inner Syntax expressions would perhaps manipulate expressions coming from other theories
than @{theory Generator_dynamic_sequential},
than @{theory FOCL.Generator_dynamic_sequential},
it can be desirable to consider the Inner Syntax container as a string and leave the parsing
for subsequent semantic floors.
@ -384,7 +384,7 @@ we retrieve the first generated file in the mentioned directory:
Because this file still contains meta-commands, we are here executing again
a new generating step inside this file, the new result becomes saved in
@{file "../../doc/Employee_DesignModel_UMLPart_generated_generated.thy"}.
As remark, in this last file, the dependency to @{theory Generator_dynamic_sequential} was
As remark, in this last file, the dependency to @{theory FOCL.Generator_dynamic_sequential} was
automatically removed because the meta-compiler has detected the absence of meta-commands
in the generated content.

View File

@ -45,9 +45,9 @@ subsection\<open>Introduction\<close>
theory
Toy_shallow
imports
"../../src/UML_Main"
"../../src/compiler/Static"
"../../src/compiler/Generator_dynamic_sequential"
OCL.UML_Main
FOCL.Static
FOCL.Generator_dynamic_sequential
begin
ML_file "~~/src/Doc/antiquote_setup.ML"
@ -56,7 +56,7 @@ In this example, we configure our package to execute tactic SML code
(corresponding to some generated \verb|.thy| file, @{file "Toy_deep.thy"}
details how to obtain such generated \verb|.thy| file).
Since SML code are already compiled (or reflected) and bound with the native Isabelle API in
@{theory Generator_dynamic_sequential}, nothing is generated in this theory.
@{theory FOCL.Generator_dynamic_sequential}, nothing is generated in this theory.
The system only parses arguments given to meta-commands and immediately calls the corresponding
compiled functions.

View File

@ -42,7 +42,7 @@
chapter{* Part ... *}
theory Class_model
imports "../../src/compiler/core/Core_init"
imports FOCL.Core_init
begin
definition "print_class =

View File

@ -92,8 +92,8 @@ by(simp add: OclValid_def true_def k_def)+
generation_syntax [ (*deep
(*(generation_semantics [ analysis (*, oid_start 10*) ])*)
(THEORY Model_generated)
(IMPORTS ["../src/UML_Main", "../src/compiler/Static"]
"../src/compiler/Generator_dynamic_sequential")
(IMPORTS ["OCL.UML_Main", "FOCL.Static"]
"FOCL.Generator_dynamic_sequential")
SECTION
(*SORRY*)
[ (*in OCaml module_name M*)

View File

@ -298,11 +298,11 @@ qed
lemma state_update_vs_allInstances_generic_empty:
assumes [simp]: "\<And>a. pre_post (mk a) = a"
shows "(mk \<lparr>heap=empty, assocs=A\<rparr>) \<Turnstile> OclAllInstances_generic pre_post Type \<doteq> Set{}"
shows "(mk \<lparr>heap=Map.empty, assocs=A\<rparr>) \<Turnstile> OclAllInstances_generic pre_post Type \<doteq> Set{}"
proof -
have state_update_vs_allInstances_empty:
"(OclAllInstances_generic pre_post Type) (mk \<lparr>heap=empty, assocs=A\<rparr>) =
Set{} (mk \<lparr>heap=empty, assocs=A\<rparr>)"
"(OclAllInstances_generic pre_post Type) (mk \<lparr>heap=Map.empty, assocs=A\<rparr>) =
Set{} (mk \<lparr>heap=Map.empty, assocs=A\<rparr>)"
by(simp add: OclAllInstances_generic_def mtSet_def)
show ?thesis
apply(simp only: OclValid_def, subst StrictRefEq\<^sub>S\<^sub>e\<^sub>t.cp0,
@ -523,7 +523,7 @@ shows "is_represented_in_state snd x H \<tau>"
by(rule represented_generic_objects_in_state[OF A[simplified OclAllInstances_at_post_def]])
lemma state_update_vs_allInstances_at_post_empty:
shows "(\<sigma>, \<lparr>heap=empty, assocs=A\<rparr>) \<Turnstile> Type .allInstances() \<doteq> Set{}"
shows "(\<sigma>, \<lparr>heap=Map.empty, assocs=A\<rparr>) \<Turnstile> Type .allInstances() \<doteq> Set{}"
unfolding OclAllInstances_at_post_def
by(rule state_update_vs_allInstances_generic_empty[OF snd_conv])
@ -633,7 +633,7 @@ by(rule represented_generic_objects_in_state[OF A[simplified OclAllInstances_at_
lemma state_update_vs_allInstances_at_pre_empty:
shows "(\<lparr>heap=empty, assocs=A\<rparr>, \<sigma>) \<Turnstile> Type .allInstances@pre() \<doteq> Set{}"
shows "(\<lparr>heap=Map.empty, assocs=A\<rparr>, \<sigma>) \<Turnstile> Type .allInstances@pre() \<doteq> Set{}"
unfolding OclAllInstances_at_pre_def
by(rule state_update_vs_allInstances_generic_empty[OF fst_conv])

View File

@ -44,7 +44,7 @@
******************************************************************************)
theory UML_UnlimitedNatural
imports "../UML_PropertyProfiles"
imports OCL.UML_PropertyProfiles
begin
section{* ... *}

View File

@ -2042,7 +2042,7 @@ in
:: acc)
end)
l_rep
(Symbol.explode content, (Position.advance_offset 1 pos, 0), [])
(Symbol.explode content, (Position.advance_offsets 1 pos, 0), [])
|> #3
in Position.reports l_rep end)
l_rep

View File

@ -2075,7 +2075,7 @@ in
:: acc)
end)
l_rep
(Symbol.explode content, (Position.advance_offset 1 pos, 0), [])
(Symbol.explode content, (Position.advance_offsets 1 pos, 0), [])
|> #3
in Position.reports l_rep end)
l_rep

View File

@ -44,7 +44,7 @@ text\<open>We present two solutions for obtaining an Isabelle file.\<close>
section\<open>Static Meta Embedding with Exportation\<close>
theory Generator_static
imports Printer
imports FOCL.Printer
begin
ML_file "~~/src/Doc/antiquote_setup.ML"

View File

@ -45,7 +45,7 @@ theory Init_rbt
imports "../compiler_generic/Init"
"HOL-Library.RBT"
"HOL-Library.Char_ord"
"HOL-Library.List_lexord"
"HOL-Library.List_Lexorder"
"HOL-Library.Product_Lexorder"
begin

View File

@ -41,9 +41,9 @@
(*<*)
theory Rail
imports "../UML_Types"
imports OCL.UML_Types
Aux_text
Generator_dynamic_sequential
FOCL.Generator_dynamic_sequential
begin
ML_file "~~/src/Doc/antiquote_setup.ML"
(*>*)

View File

@ -331,7 +331,7 @@ As general remark, all the future translating steps
will extensively use Isabelle expressions,
represented by its Meta-Model, for example lots of functions will use @{term "Term_app"}...
So the overall can be simplified by the use of polymorphic cartouches.
It looks feasible to add a new front-end for cartouches in @{theory "Init"}
It looks feasible to add a new front-end for cartouches in @{theory "FOCL.Init"}
supporting the use of Isabelle syntax in cartouches,
then we could obtain at the end a parsed Isabelle Meta-Model in Isabelle.\<close>

View File

@ -157,7 +157,7 @@ section\<open>Finalizing the Parser\<close>
text\<open>It should be feasible to invent a meta-command (e.g., @{text "datatype'"})
to automatically generate the previous recursors in @{text Parse}.
Otherwise as an extra check, one can also overload polymorphic cartouches in @{theory Init}
Otherwise as an extra check, one can also overload polymorphic cartouches in @{theory FOCL.Init}
to really check that all the given constructor exists at the time of editing
(similarly as writing @{verbatim "@{term ...}"},
when it is embedded in a @{verbatim "text"} command).\<close>

View File

@ -31,6 +31,7 @@ sig
val parse_tokens: theory -> Proof.state option -> Token.T list -> Toplevel.transitions list
val parse: theory -> Proof.state option -> Position.T -> string -> Toplevel.transitions list
val parse_spans: Token.T list -> Command_Span.span list
val make_span: Token.T list -> Command_Span.span
val command_reports: theory -> Token.T -> Position.report_text list
val check_command: Proof.context -> command_keyword -> string
end;
@ -278,6 +279,11 @@ fun parse_spans toks =
end;
fun make_span toks =
(case parse_spans toks of
[span] => span
| _ => Command_Span.Span (Command_Span.Malformed_Span, toks));
(* check commands *)

View File

@ -48,7 +48,7 @@ sig
val keep': (bool -> state -> unit) -> transition -> transition
val keep_proof: (state -> unit) -> transition -> transition
val ignored: Position.T -> transitions
val is_ignored: transition -> bool
val is_ignored: transitions -> bool
val malformed: Position.T -> string -> transitions
val generic_theory: (generic_theory -> generic_theory) -> transition -> transition
val theory': (bool -> theory -> theory) -> transition -> transition
@ -392,7 +392,8 @@ fun keep_proof f =
fun ignored' pos = empty |> name "<ignored>" |> position pos |> keep (fn _ => ());
fun ignored pos = [ignored' pos];
fun is_ignored tr = name_of tr = "<ignored>";
fun is_ignored' tr = name_of tr = "<ignored>";
val is_ignored = fn [] => false | (tr :: _) => is_ignored' tr;
fun malformed' pos msg =
empty |> name "<malformed>" |> position pos |> keep (fn _ => error msg);
@ -700,19 +701,19 @@ fun timing_estimate elem =
let val trs = tl (Thy_Syntax.flat_element elem)
in fold (fn tr => fn t => get_timing tr + t) trs Time.zeroTime end;
fun proof_future_enabled estimate st =
fun future_proofs_enabled estimate st =
(case try proof_of st of
NONE => false
| SOME state =>
not (Proof.is_relevant state) andalso
(if can (Proof.assert_bottom true) state
then Goal.future_enabled 1
else Goal.future_enabled 2 orelse Goal.future_enabled_timing estimate));
then Future.proofs_enabled 1
else Future.proofs_enabled 2 orelse Future.proofs_enabled_timing estimate));
fun atom_result keywords tr st =
let
val st' =
if Goal.future_enabled 1 andalso Keyword.is_diag keywords (name_of tr) then
if Future.proofs_enabled 1 andalso Keyword.is_diag keywords (name_of tr) then
(Execution.fork
{name = "Toplevel.diag", pos = pos_of tr, pri = ~1}
(fn () => command tr st); st)
@ -728,7 +729,7 @@ fun element_result keywords (Thy_Syntax.Element (tr, NONE)) st = atom_result key
val (body_elems, end_tr) = element_rest;
val estimate = timing_estimate elem;
in
if not (proof_future_enabled estimate st')
if not (future_proofs_enabled estimate st')
then
let
val proof_trs = maps Thy_Syntax.flat_element body_elems @ [end_tr];

View File

@ -12,17 +12,21 @@ sig
val read: Keyword.keywords -> theory -> Proof.state option -> Path.T-> (unit -> theory) ->
blob list * int -> Token.T list -> Toplevel.transitions
type eval
val eval_command_id: eval -> Document_ID.command
val eval_exec_id: eval -> Document_ID.exec
val eval_eq: eval * eval -> bool
val eval_running: eval -> bool
val eval_finished: eval -> bool
val eval_result_command: eval -> Toplevel.transitions
val eval_result_state: eval -> Toplevel.state
val eval: Keyword.keywords -> Path.T -> (unit -> theory) ->
blob list * int -> Token.T list -> eval -> eval
blob list * int -> Document_ID.command -> Token.T list -> eval -> eval
type print
type print_fn = Toplevel.transition -> Toplevel.state -> unit
val print0: {pri: int, print_fn: print_fn} -> eval -> print
val print: bool -> (string * string list) list -> Keyword.keywords -> string ->
eval -> print list -> print list option
type print_fn = Toplevel.transition -> Toplevel.state -> unit
val parallel_print: print -> bool
type print_function =
{keywords: Keyword.keywords, command_name: string, args: string list, exec_id: Document_ID.exec} ->
{delay: Time.time option, pri: int, persistent: bool, strict: bool, print_fn: print_fn} option
@ -33,6 +37,7 @@ sig
val no_exec: exec
val exec_ids: exec option -> Document_ID.exec list
val exec: Document_ID.execution -> exec -> unit
val exec_parallel_prints: Document_ID.execution -> Future.task list -> exec -> exec option
end;
structure Command: COMMAND =
@ -162,7 +167,11 @@ fun init_eval_state opt_thy =
command = [],
state = [case opt_thy of NONE => Toplevel.toplevel | SOME thy => Toplevel.theory_toplevel thy]};
datatype eval = Eval of {exec_id: Document_ID.exec, eval_process: eval_states lazy};
datatype eval =
Eval of
{command_id: Document_ID.command, exec_id: Document_ID.exec, eval_process: eval_states lazy};
fun eval_command_id (Eval {command_id, ...}) = command_id;
fun eval_exec_id (Eval {exec_id, ...}) = exec_id;
val eval_eq = op = o apply2 eval_exec_id;
@ -173,6 +182,7 @@ fun eval_finished (Eval {eval_process, ...}) = Lazy.is_finished eval_process;
fun eval_result (Eval {eval_process, ...}) =
task_context (Future.worker_subgroup ()) Lazy.force eval_process;
val eval_result_command = #command o eval_result;
val eval_result_state = List.last o #state o eval_result;
local
@ -191,7 +201,7 @@ fun reset_state keywords tr st0 = Toplevel.setmp_thread_position tr (fn () =>
end) ();
fun run keywords int tr st =
if Goal.future_enabled 1 andalso Keyword.is_diag keywords (Toplevel.name_of tr) then
if Future.proofs_enabled 1 andalso Keyword.is_diag keywords (Toplevel.name_of tr) then
(Execution.fork {name = "Toplevel.diag", pos = Toplevel.pos_of tr, pri = ~1}
(fn () => Toplevel.command_exception int tr st); ([], SOME st))
else Toplevel.command_errors int tr st;
@ -270,7 +280,7 @@ fun eval_state keywords span l_tr ({state, ...}: eval_states) =
in
fun eval keywords master_dir init blobs_info span eval0 =
fun eval keywords master_dir init blobs_info command_id span eval0 =
let
val exec_id = Document_ID.make ();
fun process () =
@ -284,7 +294,9 @@ fun eval keywords master_dir init blobs_info span eval0 =
(fn () =>
read keywords thy st master_dir init blobs_info span |> Toplevel.exec_id exec_id) ();
in eval_state keywords span tr eval_state0 end;
in Eval {exec_id = exec_id, eval_process = Lazy.lazy_name "Command.eval" process} end;
in
Eval {command_id = command_id, exec_id = exec_id, eval_process = Lazy.lazy_name "Command.eval" process}
end;
end;
@ -321,13 +333,7 @@ fun print_persistent (Print {persistent, ...}) = persistent;
val overlay_ord = prod_ord string_ord (list_ord string_ord);
in
fun print command_visible command_overlays keywords command_name eval old_prints =
let
val print_functions = Synchronized.value print_functions;
fun make_print name args {delay, pri, persistent, strict, print_fn} =
fun make_print (name, args) {delay, pri, persistent, strict, print_fn} eval =
let
val exec_id = Document_ID.make ();
fun process () =
@ -347,11 +353,21 @@ fun print command_visible command_overlays keywords command_name eval old_prints
exec_id = exec_id, print_process = Lazy.lazy_name "Command.print" process}
end;
fun bad_print name args exn =
make_print name args {delay = NONE, pri = 0, persistent = false,
fun bad_print name_args exn =
make_print name_args {delay = NONE, pri = 0, persistent = false,
strict = false, print_fn = fn _ => fn _ => Exn.reraise exn};
fun new_print name args get_pr =
in
fun print0 {pri, print_fn} =
make_print ("", [serial_string ()])
{delay = NONE, pri = pri, persistent = true, strict = true, print_fn = print_fn};
fun print command_visible command_overlays keywords command_name eval old_prints =
let
val print_functions = Synchronized.value print_functions;
fun new_print (name, args) get_pr =
let
val params =
{keywords = keywords,
@ -361,31 +377,39 @@ fun print command_visible command_overlays keywords command_name eval old_prints
in
(case Exn.capture (Runtime.controlled_execution NONE get_pr) params of
Exn.Res NONE => NONE
| Exn.Res (SOME pr) => SOME (make_print name args pr)
| Exn.Exn exn => SOME (bad_print name args exn))
| Exn.Res (SOME pr) => SOME (make_print (name, args) pr eval)
| Exn.Exn exn => SOME (bad_print (name, args) exn eval))
end;
fun get_print (a, b) =
(case find_first (fn Print {name, args, ...} => name = a andalso args = b) old_prints of
fun get_print (name, args) =
(case find_first (fn Print print => (#name print, #args print) = (name, args)) old_prints of
NONE =>
(case AList.lookup (op =) print_functions a of
NONE => SOME (bad_print a b (ERROR ("Missing print function " ^ quote a)))
| SOME get_pr => new_print a b get_pr)
(case AList.lookup (op =) print_functions name of
NONE =>
SOME (bad_print (name, args) (ERROR ("Missing print function " ^ quote name)) eval)
| SOME get_pr => new_print (name, args) get_pr)
| some => some);
val new_prints =
val retained_prints =
filter (fn print => print_finished print andalso print_persistent print) old_prints;
val visible_prints =
if command_visible then
fold (fn (a, _) => cons (a, [])) print_functions command_overlays
fold (fn (name, _) => cons (name, [])) print_functions command_overlays
|> sort_distinct overlay_ord
|> map_filter get_print
else filter (fn print => print_finished print andalso print_persistent print) old_prints;
else [];
val new_prints = visible_prints @ retained_prints;
in
if eq_list print_eq (old_prints, new_prints) then NONE else SOME new_prints
end;
fun parallel_print (Print {pri, ...}) =
pri <= 0 orelse (Future.enabled () andalso Options.default_bool "parallel_print");
fun print_function name f =
Synchronized.change print_functions (fn funs =>
(if not (AList.defined (op =) funs name) then ()
(if name = "" then error "Unnamed print function" else ();
if not (AList.defined (op =) funs name) then ()
else warning ("Redefining command print function: " ^ quote name);
AList.update (op =) (name, f) funs));
@ -419,7 +443,9 @@ val _ =
type exec = eval * print list;
fun init_exec opt_thy : exec =
(Eval {exec_id = Document_ID.none, eval_process = Lazy.value (init_eval_state opt_thy)}, []);
(Eval
{command_id = Document_ID.none, exec_id = Document_ID.none,
eval_process = Lazy.value (init_eval_state opt_thy)}, []);
val no_exec = init_exec NONE;
@ -438,19 +464,16 @@ fun run_process execution_id exec_id process =
fun ignore_process process =
Lazy.is_running process orelse Lazy.is_finished process;
fun run_eval execution_id (Eval {exec_id, eval_process}) =
fun run_eval execution_id (Eval {exec_id, eval_process, ...}) =
if Lazy.is_finished eval_process then ()
else run_process execution_id exec_id eval_process;
fun run_print execution_id (Print {name, delay, pri, exec_id, print_process, ...}) =
if ignore_process print_process then ()
else if pri <= 0 orelse (Multithreading.enabled () andalso Options.default_bool "parallel_print")
then
fun fork_print execution_id deps (Print {name, delay, pri, exec_id, print_process, ...}) =
let
val group = Future.worker_subgroup ();
fun fork () =
ignore ((singleton o Future.forks)
{name = name, group = SOME group, deps = [], pri = pri, interrupts = true}
{name = name, group = SOME group, deps = deps, pri = pri, interrupts = true}
(fn () =>
if ignore_process print_process then ()
else run_process execution_id exec_id print_process));
@ -458,7 +481,11 @@ fun run_print execution_id (Print {name, delay, pri, exec_id, print_process, ...
(case delay of
NONE => fork ()
| SOME d => ignore (Event_Timer.request (Time.now () + d) fork))
end
end;
fun run_print execution_id (print as Print {exec_id, print_process, ...}) =
if ignore_process print_process then ()
else if parallel_print print then fork_print execution_id [] print
else run_process execution_id exec_id print_process;
in
@ -466,7 +493,11 @@ in
fun exec execution_id (eval, prints) =
(run_eval execution_id eval; List.app (run_print execution_id) prints);
end;
fun exec_parallel_prints execution_id deps (exec as (Eval {eval_process, ...}, prints)) =
if Lazy.is_finished eval_process
then (List.app (fork_print execution_id deps) prints; NONE)
else SOME exec;
end;
end;

View File

@ -7,18 +7,22 @@ file dependencies.
signature THY_INFO =
sig
type presentation_context =
{options: Options.T, file_pos: Position.T, adjust_pos: Position.T -> Position.T,
segments: Thy_Output.segment list}
val apply_presentation: presentation_context -> theory -> unit
val add_presentation: (presentation_context -> theory -> unit) -> theory -> theory
val get_names: unit -> string list
val lookup_theory: string -> theory option
val get_theory: string -> theory
val master_directory: string -> Path.T
val remove_thy: string -> unit
val use_theories:
{document: bool,
type context =
{options: Options.T,
symbols: HTML.symbols,
bibtex_entries: string list,
last_timing: Toplevel.transition -> Time.time,
qualifier: string,
master_dir: Path.T} -> (string * Position.T) list -> unit
last_timing: Toplevel.transition -> Time.time}
val use_theories: context -> string -> Path.T -> (string * Position.T) list -> unit
val use_thy: string -> unit
val script_thy: Position.T -> string -> theory -> theory
val register_thy: theory -> unit
@ -28,6 +32,45 @@ end;
structure Thy_Info: THY_INFO =
struct
(** presentation of consolidated theory **)
type presentation_context =
{options: Options.T, file_pos: Position.T, adjust_pos: Position.T -> Position.T,
segments: Thy_Output.segment list};
structure Presentation = Theory_Data
(
type T = ((presentation_context -> theory -> unit) * stamp) list;
val empty = [];
val extend = I;
fun merge data : T = Library.merge (eq_snd op =) data;
);
fun apply_presentation (context: presentation_context) thy =
ignore (Presentation.get thy |> Par_List.map (fn (f, _) => f context thy));
fun add_presentation f = Presentation.map (cons (f, stamp ()));
val _ =
Theory.setup (add_presentation (fn {options, file_pos, segments, ...} => fn thy =>
if exists (Toplevel.is_skipped_proof o #state) segments then ()
else
let
val body = Thy_Output.present_thy thy segments;
val option = Present.document_option options;
in
if #disabled option then ()
else
let
val latex = Latex.isabelle_body (Context.theory_name thy) body;
val output = [Latex.output_text latex, Latex.output_positions file_pos latex];
val _ = Export.export thy "document.tex" output;
val _ = if #enabled option then Present.theory_output thy output else ();
in () end
end));
(** thy database **)
(* messages *)
@ -136,6 +179,21 @@ fun update deps theory thys =
fun update_thy deps theory = change_thys (update deps theory);
(* context *)
type context =
{options: Options.T,
symbols: HTML.symbols,
bibtex_entries: string list,
last_timing: Toplevel.transition -> Time.time};
fun default_context (): context =
{options = Options.default (),
symbols = HTML.no_symbols,
bibtex_entries = [],
last_timing = K Time.zeroTime};
(* scheduling loader tasks *)
datatype result =
@ -282,16 +340,15 @@ fun excursion keywords master_dir last_timing init elements =
val thy = Toplevel.end_theory end_pos end_state;
in (results, thy) end;
fun eval_thy {document, symbols, bibtex_entries, last_timing} update_time master_dir header
text_pos text parents =
fun eval_thy (context: context) update_time master_dir header text_pos text parents =
let
val {options, symbols, bibtex_entries, last_timing} = context;
val (name, _) = #name header;
val keywords =
fold (curry Keyword.merge_keywords o Thy_Header.get_keywords) parents
(Keyword.add_keywords (#keywords header) Keyword.empty_keywords);
val toks = Token.explode keywords text_pos text;
val spans = Outer_Syntax.parse_spans toks;
val spans = Outer_Syntax.parse_spans (Token.explode keywords text_pos text);
val elements = map (Thy_Syntax.map_element Span_cmd)
(Thy_Syntax.parse_elements keywords
(fn x => Command_Span.Span (x, []))
@ -309,13 +366,17 @@ fun eval_thy {document, symbols, bibtex_entries, last_timing} update_time master
fun present () =
let
val res = filter_out (Toplevel.is_ignored o #1) (maps Toplevel.join_results results);
in
if exists (Toplevel.is_skipped_proof o #2) res then ()
else
if document then let val body = Thy_Output.present_thy thy res toks in Present.theory_output text_pos thy body end else ()
end;
fun split_trans [] acc = rev acc
| split_trans (x :: xs) acc =
case chop_prefix let val pos_of = Toplevel.pos_of o fst
val p = pos_of x in fn t => p = pos_of t end
xs of
(xs1, xs2) => split_trans xs2 ((x :: xs1) :: acc);
val segments = (spans ~~ split_trans (maps Toplevel.join_results results) [])
|> map (fn (span, results) => {span = span, command = map #1 results, state = #2 (hd results)});
val context: presentation_context =
{options = options, file_pos = text_pos, adjust_pos = I, segments = segments};
in apply_presentation context thy end;
in (thy, present, size text) end;
@ -427,20 +488,13 @@ end;
(* use theories *)
fun use_theories {document, symbols, bibtex_entries, last_timing, qualifier, master_dir} imports =
let
val context =
{document = document, symbols = symbols, bibtex_entries = bibtex_entries,
last_timing = last_timing};
val (_, tasks) = require_thys context [] qualifier master_dir imports String_Graph.empty;
in if Multithreading.enabled () then schedule_futures tasks else schedule_seq tasks end;
fun use_theories context qualifier master_dir imports =
let val (_, tasks) = require_thys context [] qualifier master_dir imports String_Graph.empty
in if Multithreading.max_threads () > 1 then schedule_futures tasks else schedule_seq tasks end;
fun use_thy name =
use_theories
{document = false, symbols = HTML.no_symbols, bibtex_entries = [],
last_timing = K Time.zeroTime, qualifier = Resources.default_qualifier,
master_dir = Path.current}
[(name, Position.none)];
use_theories (default_context ()) Resources.default_qualifier
Path.current [(name, Position.none)];
(* toplevel scripting -- without maintaining database *)

View File

@ -10,8 +10,8 @@ sig
val check_comments: Proof.context -> Symbol_Pos.T list -> unit
val output_token: Proof.context -> Token.T -> Latex.text list
val output_source: Proof.context -> string -> Latex.text list
val present_thy: theory -> (Toplevel.transition * Toplevel.state) list ->
Token.T list -> Latex.text list
type segment = {span: Command_Span.span, command: Toplevel.transitions, state: Toplevel.state}
val present_thy: theory -> segment list -> Latex.text list
val pretty_term: Proof.context -> term -> Pretty.T
val pretty_thm: Proof.context -> thm -> Pretty.T
val lines: Latex.text list -> Latex.text list
@ -117,13 +117,14 @@ fun output_comment_symbols ctxt {antiq} (comment, syms) =
|> maps output_symbols_antiq
| (SOME comment, _) => output_comment ctxt (comment, syms));
in
fun output_body ctxt antiq bg en syms =
Comment.read_body syms
|> maps (output_comment_symbols ctxt {antiq = antiq})
|> Latex.enclose_body bg en
and output_token ctxt tok =
|> Latex.enclose_body bg en;
in
fun output_token ctxt tok =
let
fun output antiq bg en =
output_body ctxt antiq bg en (Input.source_explode (Token.input_of tok));
@ -245,7 +246,7 @@ fun present_span thy keywords document_tags span state state'
let
val ctxt' =
Toplevel.presentation_context state'
handle Toplevel.UNDEF => Proof_Context.init_global (Context.get_theory thy Context.PureN);
handle Toplevel.UNDEF => Proof_Context.get_global thy Context.PureN;
val present = fold (fn (tok, (flag, 0)) =>
fold cons (present_token ctxt' tok)
#> cons (Latex.string flag)
@ -338,15 +339,10 @@ val locale =
in
fun present_thy thy command_results toks =
type segment = {span: Command_Span.span, command: Toplevel.transitions, state: Toplevel.state};
fun present_thy thy (segments: segment list) =
let
fun split_trans [] acc = rev acc
| split_trans (x :: xs) acc =
case chop_prefix let val pos_of = Toplevel.pos_of o fst
val p = pos_of x in fn t => p = pos_of t end
xs of
(xs1, xs2) => split_trans xs2 ((x :: xs1) :: acc);
val command_results = split_trans command_results [];
val keywords = Thy_Header.get_keywords thy;
@ -411,28 +407,33 @@ fun present_thy thy command_results toks =
>> (fn (((toks1, (cmd, tok2)), toks3), tok4) =>
make_span (the cmd) (toks1 @ (tok2 :: (toks3 @ the_default [] tok4))));
val spans = toks
val spans = segments
|> maps (Command_Span.content o #span)
|> drop_suffix Token.is_space
|> Source.of_list
|> Source.source' 0 Token.stopper (Scan.error (Scan.bulk tokens >> flat))
|> Source.source stopper (Scan.error (Scan.bulk span))
|> Source.exhaust;
val command_results =
segments |> map_filter (fn {command, state, ...} =>
if Toplevel.is_ignored command then NONE else SOME (command, state));
(* present commands *)
val document_tags = space_explode "," (Options.default_string \<^system_option>\<open>document_tags\<close>);
fun present_command tr span st st' =
Toplevel.setmp_thread_position tr
fun present_command trs span st st' =
Toplevel.setmp_thread_position (hd trs)
(present_span thy keywords document_tags span st st');
fun present _ [] = I
| present st (((tr, st'), span) :: rest) = present_command tr span st st' #> present st' rest;
| present st ((span, (tr, st')) :: rest) = present_command tr span st st' #> present st' rest;
in
if length command_results = length spans then
((NONE, []), NONE, true, [], (I, I))
|> present Toplevel.toplevel (map (apfst List.last) (command_results ~~ spans))
|> present Toplevel.toplevel (spans ~~ command_results)
|> present_trailer
|> rev
else error "Messed-up outer syntax for presentation"

View File

@ -45,7 +45,7 @@ theory Init_rbt
imports "../../Init"
"HOL-Library.RBT"
"HOL-Library.Char_ord"
"HOL-Library.List_lexord"
"HOL-Library.List_Lexorder"
"HOL-Library.Product_Lexorder"
begin

View File

@ -261,7 +261,7 @@ As general remark, all the future translating steps
will extensively use Isabelle expressions,
represented by its Meta-Model, for example lots of functions will use @{term "Term_app"}...
So the overall can be simplified by the use of polymorphic cartouches.
It looks feasible to add a new front-end for cartouches in @{theory "Init"}
It looks feasible to add a new front-end for cartouches in @{theory "Isabelle_Meta_Model.Init"}
supporting the use of Isabelle syntax in cartouches,
then we could obtain at the end a parsed Isabelle Meta-Model in Isabelle.\<close>

View File

@ -154,7 +154,7 @@ section\<open>Finalizing the Parser\<close>
text\<open>It should be feasible to invent a meta-command (e.g., @{text "datatype'"})
to automatically generate the previous recursors in @{text Parse}.
Otherwise as an extra check, one can also overload polymorphic cartouches in @{theory Init}
Otherwise as an extra check, one can also overload polymorphic cartouches in @{theory Isabelle_Meta_Model.Init}
to really check that all the given constructor exists at the time of editing
(similarly as writing @{verbatim "@{term ...}"},
when it is embedded in a @{verbatim "text"} command).\<close>

View File

@ -134,7 +134,7 @@ End
text\<open>The ``blue'' color of @{command End} indicates that
@{command End} is not a ``green'' keyword.
@{command End} and @{command Class} are in fact similar, they belong to the group of meta-commands
(all meta-commands are defined in @{theory Generator_dynamic_sequential}).
(all meta-commands are defined in @{theory Isabelle_Meta_Model.Generator_dynamic_sequential}).
At run-time and in @{keyword "deep"} mode, all meta-commands have
approximately the same semantics: they only display some quantity of Isabelle code
in the output window (as long as meta-commands are syntactically correctly formed).
@ -318,9 +318,9 @@ Meta-commands are obviously not restricted to manipulate expressions in the Oute
It is possible to build meta-commands so that Inner Syntax expressions are directly parsed.
However the dependencies of this theory have been minimized so that experimentations
and debugging can easily occur in @{keyword "deep"} mode
(this file only depends on @{theory Generator_dynamic_sequential}).
(this file only depends on @{theory Isabelle_Meta_Model.Generator_dynamic_sequential}).
Since the Inner Syntax expressions would perhaps manipulate expressions coming from other theories
than @{theory Generator_dynamic_sequential},
than @{theory Isabelle_Meta_Model.Generator_dynamic_sequential},
it can be desirable to consider the Inner Syntax container as a string and leave the parsing
for subsequent semantic floors.
@ -384,7 +384,7 @@ we retrieve the first generated file in the mentioned directory:
Because this file still contains meta-commands, we are here executing again
a new generating step inside this file, the new result becomes saved in
@{file "../document_generated/Design_generated_generated.thy"}.
As remark, in this last file, the dependency to @{theory Generator_dynamic_sequential} was
As remark, in this last file, the dependency to @{theory Isabelle_Meta_Model.Generator_dynamic_sequential} was
automatically removed because the meta-compiler has detected the absence of meta-commands
in the generated content.

View File

@ -56,7 +56,7 @@ In this example, we configure our package to execute tactic SML code
(corresponding to some generated \verb|.thy| file, @{file "Design_deep.thy"}
details how to obtain such generated \verb|.thy| file).
Since SML code are already compiled (or reflected) and bound with the native Isabelle API in
@{theory Generator_dynamic_sequential}, nothing is generated in this theory.
@{theory Isabelle_Meta_Model.Generator_dynamic_sequential}, nothing is generated in this theory.
The system only parses arguments given to meta-commands and immediately calls the corresponding
compiled functions.