doc-src/IsarImplementation/Thy/Prelim.thy
changeset 39866 5ec01d5acd0c
parent 39865 a724b90f951e
child 39876 1ff9bce085bd
equal deleted inserted replaced
39865:a724b90f951e 39866:5ec01d5acd0c
   641 
   641 
   642 text {* Now the user can refer to @{attribute my_flag} in
   642 text {* Now the user can refer to @{attribute my_flag} in
   643   declarations, while we can retrieve the current value from the
   643   declarations, while we can retrieve the current value from the
   644   context via @{ML Config.get}.  *}
   644   context via @{ML Config.get}.  *}
   645 
   645 
   646 ML_val {* Config.get @{context} my_flag *}
   646 ML_val {* @{assert} (Config.get @{context} my_flag = false) *}
   647 
   647 
   648 declare [[my_flag = true]]
   648 declare [[my_flag = true]]
   649 
   649 
   650 ML_val {* Config.get @{context} my_flag *}
   650 ML_val {* @{assert} (Config.get @{context} my_flag = true) *}
   651 
   651 
   652 example_proof
   652 example_proof
   653   note [[my_flag = false]]
   653   {
   654   ML_val {* Config.get @{context} my_flag *}
   654     note [[my_flag = false]]
       
   655     ML_val {* @{assert} (Config.get @{context} my_flag = false) *}
       
   656   }
       
   657   ML_val {* @{assert} (Config.get @{context} my_flag = true) *}
   655 qed
   658 qed
   656 
       
   657 ML_val {* Config.get @{context} my_flag *}
       
   658 
   659 
   659 
   660 
   660 section {* Names \label{sec:names} *}
   661 section {* Names \label{sec:names} *}
   661 
   662 
   662 text {* In principle, a name is just a string, but there are various
   663 text {* In principle, a name is just a string, but there are various
   886 
   887 
   887 text %mlex {* The following simple examples demonstrate how to produce
   888 text %mlex {* The following simple examples demonstrate how to produce
   888   fresh names from the initial @{ML Name.context}. *}
   889   fresh names from the initial @{ML Name.context}. *}
   889 
   890 
   890 ML {*
   891 ML {*
   891   Name.invents Name.context "a" 5;
   892   val list1 = Name.invents Name.context "a" 5;
   892   #1 (Name.variants ["x", "x", "a", "a", "'a", "'a"] Name.context);
   893   @{assert} (list1 = ["a", "b", "c", "d", "e"]);
       
   894 
       
   895   val list2 =
       
   896     #1 (Name.variants ["x", "x", "a", "a", "'a", "'a"] Name.context);
       
   897   @{assert} (list2 = ["x", "xa", "a", "aa", "'a", "'aa"]);
   893 *}
   898 *}
   894 
   899 
   895 text {* \medskip The same works reletively to the formal context as
   900 text {* \medskip The same works reletively to the formal context as
   896   follows. *}
   901   follows. *}
   897 
   902 
   898 locale ex = fixes a b c :: 'a
   903 locale ex = fixes a b c :: 'a
   899 begin
   904 begin
   900 
   905 
   901 ML {*
   906 ML {*
   902   val names = Variable.names_of @{context};
   907   val names = Variable.names_of @{context};
   903   Name.invents names "a" 5;
   908 
   904   #1 (Name.variants ["x", "x", "a", "a", "'a", "'a"] names);
   909   val list1 = Name.invents names "a" 5;
       
   910   @{assert} (list1 = ["d", "e", "f", "g", "h"]);
       
   911 
       
   912   val list2 =
       
   913     #1 (Name.variants ["x", "x", "a", "a", "'a", "'a"] names);
       
   914   @{assert} (list2 = ["x", "xa", "aa", "ab", "'aa", "'ab"]);
   905 *}
   915 *}
   906 
   916 
   907 end
   917 end
   908 
   918 
   909 
   919