| author | blanchet | 
| Thu, 02 May 2013 21:04:50 +0200 | |
| changeset 51869 | d58cd7673b04 | 
| parent 51599 | 1559e9266280 | 
| child 53361 | 1cb7d3c0cf31 | 
| permissions | -rw-r--r-- | 
| 
51161
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
1  | 
|
| 
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
2  | 
(* Author: Ondrej Kuncar, TU Muenchen *)  | 
| 
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
3  | 
|
| 
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
4  | 
header {* Pervasive test of code generator *}
 | 
| 48624 | 5  | 
|
| 
51161
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
6  | 
theory Generate_Efficient_Datastructures  | 
| 
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
7  | 
imports  | 
| 
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
8  | 
Candidates  | 
| 
51599
 
1559e9266280
optionalized very specific code setup for multisets
 
haftmann 
parents: 
51161 
diff
changeset
 | 
9  | 
"~~/src/HOL/Library/DAList_Multiset"  | 
| 
51161
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
10  | 
"~~/src/HOL/Library/RBT_Mapping"  | 
| 
 
6ed12ae3b3e1
attempt to re-establish conventions which theories are loaded into the grand unified library theory;
 
haftmann 
parents: 
51139 
diff
changeset
 | 
11  | 
"~~/src/HOL/Library/RBT_Set"  | 
| 48624 | 12  | 
begin  | 
13  | 
||
14  | 
(*  | 
|
15  | 
The following code equations have to be deleted because they use  | 
|
16  | 
lists to implement sets in the code generetor.  | 
|
17  | 
*)  | 
|
18  | 
||
19  | 
lemma [code, code del]:  | 
|
20  | 
"Sup_pred_inst.Sup_pred = Sup_pred_inst.Sup_pred" ..  | 
|
21  | 
||
22  | 
lemma [code, code del]:  | 
|
23  | 
"Inf_pred_inst.Inf_pred = Inf_pred_inst.Inf_pred" ..  | 
|
24  | 
||
25  | 
lemma [code, code del]:  | 
|
26  | 
"pred_of_set = pred_of_set" ..  | 
|
27  | 
||
28  | 
lemma [code, code del]:  | 
|
29  | 
"acc = acc" ..  | 
|
30  | 
||
| 
51139
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
31  | 
lemma [code, code del]:  | 
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
32  | 
"Cardinality.card' = Cardinality.card'" ..  | 
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
33  | 
|
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
34  | 
lemma [code, code del]:  | 
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
35  | 
"Cardinality.finite' = Cardinality.finite'" ..  | 
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
36  | 
|
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
37  | 
lemma [code, code del]:  | 
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
38  | 
"Cardinality.subset' = Cardinality.subset'" ..  | 
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
39  | 
|
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
40  | 
lemma [code, code del]:  | 
| 
 
c8e3cf3520b3
partially revert 0dac0158b8d4 as it too aggressively spreads card_UNIV type class whose dictionary constructions can slow down generated code;
 
Andreas Lochbihler 
parents: 
51116 
diff
changeset
 | 
41  | 
"Cardinality.eq_set = Cardinality.eq_set" ..  | 
| 
51116
 
0dac0158b8d4
implement code generation for finite, card, op = and op <= for sets always via finite_UNIV and card_UNIV, as fragile rewrites based on sorts are hard to find and debug
 
Andreas Lochbihler 
parents: 
50996 
diff
changeset
 | 
42  | 
|
| 48624 | 43  | 
(*  | 
44  | 
If the code generation ends with an exception with the following message:  | 
|
45  | 
'"List.set" is not a constructor, on left hand side of equation: ...',  | 
|
46  | 
the code equation in question has to be either deleted (like many others in this file)  | 
|
47  | 
or implemented for RBT trees.  | 
|
48  | 
*)  | 
|
49  | 
||
| 
50996
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
50  | 
export_code _ checking SML OCaml? Haskell?  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
51  | 
|
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
52  | 
(* Extra setup to make Scala happy *)  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
53  | 
(* If the compilation fails with an error "ambiguous implicit values",  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
54  | 
read \<section>7.1 in the Code Generation Manual *)  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
55  | 
|
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
56  | 
class ccpo_linorder = ccpo + linorder  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
57  | 
|
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
58  | 
lemma [code]:  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
59  | 
  "(Complete_Partial_Order.admissible :: ('a :: ccpo_linorder \<Rightarrow> bool) \<Rightarrow> bool) P = 
 | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
60  | 
(\<forall>A. Complete_Partial_Order.chain (op \<le>) A \<longrightarrow> (\<forall>x\<in>A. P x) \<longrightarrow> P (Sup A))"  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
61  | 
unfolding admissible_def by blast  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
62  | 
|
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
63  | 
lemma [code]:  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
64  | 
  "(gfp :: ('a :: complete_linorder \<Rightarrow> 'a) \<Rightarrow> 'a) f = Sup {u. u \<le> f u}"
 | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
65  | 
unfolding gfp_def by blast  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
66  | 
|
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
67  | 
lemma [code]:  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
68  | 
  "(lfp :: ('a :: complete_linorder \<Rightarrow> 'a) \<Rightarrow> 'a) f = Inf {u. f u \<le> u}"
 | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
69  | 
unfolding lfp_def by blast  | 
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
70  | 
|
| 
 
51ad7b4ac096
restore code equations for List.set in RBT_Set; make Scala happy according to 7.1 in the code generator manual
 
kuncar 
parents: 
49948 
diff
changeset
 | 
71  | 
export_code _ checking Scala?  | 
| 48624 | 72  | 
|
73  | 
end  |