neuper@37906
|
1 |
(* 6.8.02 change to Isabelle2002 caused error -- thy excluded !
|
neuper@37906
|
2 |
|
neuper@37906
|
3 |
Proving equations for primrec function(s) "InsSort.foldr" ...
|
neuper@37906
|
4 |
GC #1.17.30.54.345.21479: (10 ms)
|
neuper@37906
|
5 |
*** Definition of InsSort.ins :: "['a::ord list, 'a::ord] => 'a::ord list"
|
neuper@37906
|
6 |
*** imposes additional sort constraints on the declared type of the constant
|
neuper@37906
|
7 |
*** The error(s) above occurred in definition "InsSort.ins.ins_list_def (@@@)"
|
neuper@37906
|
8 |
*)
|
neuper@37906
|
9 |
|
neuper@37906
|
10 |
(* insertion sort, would need lists different from script-lists WN.11.00
|
neuper@37906
|
11 |
WN.7.5.03: -"- started with someList :: 'a list => unl, fun dest_list
|
neuper@37906
|
12 |
WN.8.5.03: error (@@@) remained with outcommenting foldr ?!?
|
neuper@37906
|
13 |
|
neuper@37906
|
14 |
*)
|
neuper@37906
|
15 |
|
neuper@37954
|
16 |
theory InsSort imports "../ProgLang/Script" begin
|
neuper@37906
|
17 |
|
neuper@37906
|
18 |
consts
|
neuper@37906
|
19 |
|
neuper@37906
|
20 |
(*foldr :: [['a,'b] => 'a, 'b list, 'a] => 'a
|
neuper@37906
|
21 |
WN.8.5.03: already defined in Isabelle2002 (instantiated by Typefix):
|
neuper@37906
|
22 |
"[[real, real] => real, real list, real] => real") : term
|
neuper@37906
|
23 |
|
neuper@37906
|
24 |
val t = str2term "foldr";
|
neuper@37906
|
25 |
val t =
|
neuper@37906
|
26 |
Const
|
neuper@37906
|
27 |
("List.foldr",
|
neuper@37906
|
28 |
"[[RealDef.real, RealDef.real] => RealDef.real, RealDef.real List.list,
|
neuper@37906
|
29 |
RealDef.real] => RealDef.real") : term
|
neuper@37906
|
30 |
*)
|
neuper@37906
|
31 |
ins :: ['a list,'a] => 'a list
|
neuper@37906
|
32 |
sort :: 'a list => 'a list
|
neuper@37906
|
33 |
|
neuper@37906
|
34 |
(*descriptions, script-id*)
|
neuper@37906
|
35 |
unsorted :: 'a list => unl
|
neuper@37906
|
36 |
sorted :: 'a list => unl
|
neuper@37906
|
37 |
|
neuper@37906
|
38 |
(*subproblem and script-name*)
|
neuper@37954
|
39 |
Ins'_sort :: "['a list,
|
neuper@37954
|
40 |
'a list] => 'a list"
|
neuper@37954
|
41 |
("((Script Ins'_sort (_ =))//
|
neuper@37954
|
42 |
(_))" 9)
|
neuper@37954
|
43 |
Sort :: "['a list,
|
neuper@37954
|
44 |
'a list] => 'a list"
|
neuper@37954
|
45 |
("((Script Sort (_ =))//
|
neuper@37954
|
46 |
(_))" 9)
|
neuper@37906
|
47 |
|
neuper@37906
|
48 |
(*primrec
|
neuper@37906
|
49 |
foldr_base "foldr f [] a = a"
|
neuper@37906
|
50 |
foldr_rec "foldr f (x#xs) a = foldr f xs (f a x)"
|
neuper@37906
|
51 |
*)
|
neuper@37906
|
52 |
|
neuper@37906
|
53 |
rules
|
neuper@37906
|
54 |
|
neuper@37947
|
55 |
(*primrec .. outcommented analoguous to ListC.thy*)
|
neuper@37906
|
56 |
ins_base "ins [] a = [a]"
|
neuper@37906
|
57 |
ins_rec "ins (x#xs) a = (if x < a then x#(ins xs a) else a#(x#xs))"
|
neuper@37906
|
58 |
|
neuper@37906
|
59 |
sort_def "sort ls = foldr ins ls []"
|
neuper@37906
|
60 |
|
neuper@37954
|
61 |
ML {*
|
neuper@37954
|
62 |
(** problem type **)
|
neuper@37954
|
63 |
|
neuper@37954
|
64 |
store_pbt
|
neuper@37954
|
65 |
(prep_pbt (theory "InsSort")
|
neuper@37954
|
66 |
(["functional"]:pblID,
|
neuper@37954
|
67 |
[("#Given" ,["unsorted u_"]),
|
neuper@37954
|
68 |
("#Find" ,["sorted s_"])
|
neuper@37954
|
69 |
],
|
neuper@37954
|
70 |
[]));
|
neuper@37954
|
71 |
|
neuper@37954
|
72 |
store_pbt
|
neuper@37954
|
73 |
(prep_pbt (theory "InsSort")
|
neuper@37954
|
74 |
(["inssort","functional"]:pblID,
|
neuper@37954
|
75 |
[("#Given" ,["unsorted u_"]),
|
neuper@37954
|
76 |
("#Find" ,["sorted s_"])
|
neuper@37954
|
77 |
],
|
neuper@37954
|
78 |
[]));
|
neuper@37954
|
79 |
|
neuper@37954
|
80 |
(** method,
|
neuper@37954
|
81 |
todo: implementation needs extra object-level lists **)
|
neuper@37954
|
82 |
|
neuper@37954
|
83 |
store_met
|
neuper@37954
|
84 |
(prep_met (theory "Diff")
|
neuper@37954
|
85 |
(["InsSort"],
|
neuper@37954
|
86 |
[],
|
neuper@37954
|
87 |
{rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
|
neuper@37954
|
88 |
crls = Atools_rls, nrls=norm_Rational
|
neuper@37954
|
89 |
(*, asm_rls=[],asm_thm=[]*)}, "empty_script"));
|
neuper@37954
|
90 |
store_met
|
neuper@37954
|
91 |
(prep_met (theory "InsSort") (*test-version for [#1,#3,#2] only: see *.sml*)
|
neuper@37954
|
92 |
(["InsSort""sort"]:metID,
|
neuper@37954
|
93 |
[("#Given" ,["unsorted u_"]),
|
neuper@37954
|
94 |
("#Find" ,["sorted s_"])
|
neuper@37954
|
95 |
],
|
neuper@37954
|
96 |
{rew_ord'="tless_true",rls'=eval_rls,calc = [], srls = e_rls, prls=e_rls,
|
neuper@37954
|
97 |
crls = eval_rls, nrls=norm_Rational(*,asm_rls=[],asm_thm=[]*)},
|
neuper@37954
|
98 |
"Script Sort (u_::'a list) = (Rewrite_Set ins_sort False) u_"
|
neuper@37954
|
99 |
));
|
neuper@37954
|
100 |
|
neuper@37967
|
101 |
ruleset' := overwritelthy @{theory} (!ruleset',
|
neuper@37954
|
102 |
[(*("ins_sort",ins_sort) overwrites a Isa fun!!*)
|
neuper@37954
|
103 |
]:(string * rls) list);
|
neuper@37954
|
104 |
*}
|
neuper@37954
|
105 |
|
neuper@37906
|
106 |
end
|