1 (* Title: functions on lists for Programs
2 Author: Walther Neuper 0108
3 (c) due to copyright terms
7 imports Complex_Main "~~/src/Tools/isac/KEStore"
10 ML_file "~~/src/Tools/isac/ProgLang/termC.sml"
11 ML_file "~~/src/Tools/isac/ProgLang/calculate.sml"
12 ML_file "~~/src/Tools/isac/ProgLang/rewrite.sml"
15 This file gives names to equations of function definitions,
16 which are required for Lucas-Interpretation (by Isac's rewriter) of
17 Isac's programming language. This language preceeded the function package
18 in 2002. For naming "axiomatization" is used for reasons of uniformity
19 with the other replacements for "axioms".
20 Another reminiscence from Isabelle2002 are Isac-specific numerals,
21 introduced in order to have floating point numerals at a time,
22 when Isabelle did not consider that requirement. For the sake of uniformity
23 'nat' from List.thy is replaced by 'real'.
25 TODO: shift name-declarations to HOL/List.thy, adopt new names from there
26 and remove this ListC.thy.
27 Note: *one* "axiomatization" over all equations caused strange "'a list list"
31 primrec LENGTH :: "'a list => real"
33 LENGTH_NIL: "LENGTH [] = 0" |
34 LENGTH_CONS: "LENGTH (x#xs) = 1 + LENGTH xs"
36 consts NTH :: "[real, 'a list] => 'a"
38 NTH_NIL: "NTH 1 (x # xs) = x" and
39 NTH_CONS: (*NO primrec, fun ..*)"1 < n ==> NTH n (x # xs) = NTH (n + -1) xs"
42 hd_thm: "hd (x # xs) = x"
45 tl_Nil: "tl [] = []" and
46 tl_Cons: "tl (x # xs) = xs"
49 LAST: "last (x # xs) = (if xs = [] then x else last xs)"
52 butlast_Nil: "butlast [] = []" and
53 butlast_Cons: "butlast (x # xs) = (if xs = [] then [] else x # butlast xs)"
56 map_Nil:"map f [] = []" and
57 map_Cons: "map f (x # xs) = f x # map f xs"
60 rev_Nil: "rev [] = []" and
61 rev_Cons: "rev (x # xs) = rev xs @ [x]"
64 filter_Nil: "filter P [] = []" and
65 filter_Cons: "filter P (x # xs) = (if P x then x # filter P xs else filter P xs)"
68 concat_Nil: "concat [] = []" and
69 concat_Cons: "concat (x # xs) = x @ concat xs"
72 takeWhile_Nil: "takeWhile P [] = []" and
73 takeWhile_Cons: "takeWhile P (x # xs) = (if P x then x # takeWhile P xs else [])"
76 dropWhile_Nil: "dropWhile P [] = []" and
77 dropWhile_Cons: "dropWhile P (x # xs) = (if P x then dropWhile P xs else x#xs)"
80 zip_Nil: "zip xs [] = []" and
81 zip_Cons: "zip xs (y # ys) = (case xs of [] => [] | z # zs => (z,y) # zip zs ys)"
84 distinct_Nil: "distinct [] = True" and
85 distinct_Cons: "distinct (x # xs) = (x ~: set xs & distinct xs)"
88 remdups_Nil: "remdups [] = []" and
89 remdups_Cons: "remdups (x#xs) = (if x : set xs then remdups xs else x # remdups xs)"
91 (** Lexicographic orderings on lists ...!!!**)
93 ML{* (*the former ListC.ML*)
94 (** rule set for evaluating listexpr in scripts **)
96 Rls{id = "list_rls", preconds = [], rew_ord = ("dummy_ord", dummy_ord),
97 erls = Erls, srls = Erls, calc = [], errpatts = [],
98 rules = [Thm ("refl", num_str @{thm refl}), (*'a<>b -> FALSE' by fun eval_equal*)
99 Thm ("o_apply", num_str @{thm o_apply}),
101 Thm ("NTH_CONS",num_str @{thm NTH_CONS}),(*erls for cond. in Atools.ML*)
102 Thm ("NTH_NIL",num_str @{thm NTH_NIL}),
103 Thm ("append_Cons",num_str @{thm append_Cons}),
104 Thm ("append_Nil",num_str @{thm append_Nil}),
105 (* Thm ("butlast_Cons",num_str @{thm butlast_Cons}),
106 Thm ("butlast_Nil",num_str @{thm butlast_Nil}),*)
107 Thm ("concat_Cons",num_str @{thm concat_Cons}),
108 Thm ("concat_Nil",num_str @{thm concat_Nil}),
109 (* Thm ("del_base",num_str @{thm del_base}),
110 Thm ("del_rec",num_str @{thm del_rec}), *)
112 Thm ("distinct_Cons",num_str @{thm distinct_Cons}),
113 Thm ("distinct_Nil",num_str @{thm distinct_Nil}),
114 Thm ("dropWhile_Cons",num_str @{thm dropWhile_Cons}),
115 Thm ("dropWhile_Nil",num_str @{thm dropWhile_Nil}),
116 Thm ("filter_Cons",num_str @{thm filter_Cons}),
117 Thm ("filter_Nil",num_str @{thm filter_Nil}),
118 Thm ("foldr_Cons",num_str @{thm foldr_Cons}),
119 Thm ("foldr_Nil",num_str @{thm foldr_Nil}),
120 Thm ("hd_thm",num_str @{thm hd_thm}),
121 Thm ("LAST",num_str @{thm LAST}),
122 Thm ("LENGTH_CONS",num_str @{thm LENGTH_CONS}),
123 Thm ("LENGTH_NIL",num_str @{thm LENGTH_NIL}),
124 (* Thm ("list_diff_def",num_str @{thm list_diff_def}),*)
125 Thm ("map_Cons",num_str @{thm map_Cons}),
126 Thm ("map_Nil",num_str @{thm map_Cons}),
127 (* Thm ("mem_Cons",num_str @{thm mem_Cons}),
128 Thm ("mem_Nil",num_str @{thm mem_Nil}), *)
129 (* Thm ("null_Cons",num_str @{thm null_Cons}),
130 Thm ("null_Nil",num_str @{thm null_Nil}),*)
131 Thm ("remdups_Cons",num_str @{thm remdups_Cons}),
132 Thm ("remdups_Nil",num_str @{thm remdups_Nil}),
133 Thm ("rev_Cons",num_str @{thm rev_Cons}),
134 Thm ("rev_Nil",num_str @{thm rev_Nil}),
135 Thm ("take_Nil",num_str @{thm take_Nil}),
136 Thm ("take_Cons",num_str @{thm take_Cons}),
137 Thm ("tl_Cons",num_str @{thm tl_Cons}),
138 Thm ("tl_Nil",num_str @{thm tl_Nil}),
139 Thm ("zip_Cons",num_str @{thm zip_Cons}),
140 Thm ("zip_Nil",num_str @{thm zip_Nil})],
143 setup {* KEStore_Elems.add_rlss [("list_rls", (Context.theory_name @{theory}, list_rls))] *}