equal
deleted
inserted
replaced
852 \end{mldecls} |
852 \end{mldecls} |
853 \begin{mldecls} |
853 \begin{mldecls} |
854 @{index_ML_type Name.context} \\ |
854 @{index_ML_type Name.context} \\ |
855 @{index_ML Name.context: Name.context} \\ |
855 @{index_ML Name.context: Name.context} \\ |
856 @{index_ML Name.declare: "string -> Name.context -> Name.context"} \\ |
856 @{index_ML Name.declare: "string -> Name.context -> Name.context"} \\ |
857 @{index_ML Name.invents: "Name.context -> string -> int -> string list"} \\ |
857 @{index_ML Name.invent: "Name.context -> string -> int -> string list"} \\ |
858 @{index_ML Name.variant: "string -> Name.context -> string * Name.context"} \\ |
858 @{index_ML Name.variant: "string -> Name.context -> string * Name.context"} \\ |
859 \end{mldecls} |
859 \end{mldecls} |
860 \begin{mldecls} |
860 \begin{mldecls} |
861 @{index_ML Variable.names_of: "Proof.context -> Name.context"} \\ |
861 @{index_ML Variable.names_of: "Proof.context -> Name.context"} \\ |
862 \end{mldecls} |
862 \end{mldecls} |
873 used names; the initial value is @{ML "Name.context"}. |
873 used names; the initial value is @{ML "Name.context"}. |
874 |
874 |
875 \item @{ML Name.declare}~@{text "name"} enters a used name into the |
875 \item @{ML Name.declare}~@{text "name"} enters a used name into the |
876 context. |
876 context. |
877 |
877 |
878 \item @{ML Name.invents}~@{text "context name n"} produces @{text |
878 \item @{ML Name.invent}~@{text "context name n"} produces @{text |
879 "n"} fresh names derived from @{text "name"}. |
879 "n"} fresh names derived from @{text "name"}. |
880 |
880 |
881 \item @{ML Name.variant}~@{text "name context"} produces a fresh |
881 \item @{ML Name.variant}~@{text "name context"} produces a fresh |
882 variant of @{text "name"}; the result is declared to the context. |
882 variant of @{text "name"}; the result is declared to the context. |
883 |
883 |
895 |
895 |
896 text %mlex {* The following simple examples demonstrate how to produce |
896 text %mlex {* The following simple examples demonstrate how to produce |
897 fresh names from the initial @{ML Name.context}. *} |
897 fresh names from the initial @{ML Name.context}. *} |
898 |
898 |
899 ML {* |
899 ML {* |
900 val list1 = Name.invents Name.context "a" 5; |
900 val list1 = Name.invent Name.context "a" 5; |
901 @{assert} (list1 = ["a", "b", "c", "d", "e"]); |
901 @{assert} (list1 = ["a", "b", "c", "d", "e"]); |
902 |
902 |
903 val list2 = |
903 val list2 = |
904 #1 (fold_map Name.variant ["x", "x", "a", "a", "'a", "'a"] Name.context); |
904 #1 (fold_map Name.variant ["x", "x", "a", "a", "'a", "'a"] Name.context); |
905 @{assert} (list2 = ["x", "xa", "a", "aa", "'a", "'aa"]); |
905 @{assert} (list2 = ["x", "xa", "a", "aa", "'a", "'aa"]); |
912 begin |
912 begin |
913 |
913 |
914 ML {* |
914 ML {* |
915 val names = Variable.names_of @{context}; |
915 val names = Variable.names_of @{context}; |
916 |
916 |
917 val list1 = Name.invents names "a" 5; |
917 val list1 = Name.invent names "a" 5; |
918 @{assert} (list1 = ["d", "e", "f", "g", "h"]); |
918 @{assert} (list1 = ["d", "e", "f", "g", "h"]); |
919 |
919 |
920 val list2 = |
920 val list2 = |
921 #1 (fold_map Name.variant ["x", "x", "a", "a", "'a", "'a"] names); |
921 #1 (fold_map Name.variant ["x", "x", "a", "a", "'a", "'a"] names); |
922 @{assert} (list2 = ["x", "xa", "aa", "ab", "'aa", "'ab"]); |
922 @{assert} (list2 = ["x", "xa", "aa", "ab", "'aa", "'ab"]); |