src/HOL/Codegenerator_Test/Generate_Efficient_Datastructures.thy
author Andreas Lochbihler
Mon, 02 Sep 2013 16:28:11 +0200
changeset 53361 1cb7d3c0cf31
parent 51599 1559e9266280
child 54295 45a5523d4a63
permissions -rw-r--r--
move admissible out of class ccpo to avoid unnecessary class predicate in foundational theorems
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
     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
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    12
begin
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    13
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    14
(* 
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    15
   The following code equations have to be deleted because they use 
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    16
   lists to implement sets in the code generetor. 
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    17
*)
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    18
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    19
lemma [code, code del]:
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    20
  "Sup_pred_inst.Sup_pred = Sup_pred_inst.Sup_pred" ..
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    21
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    22
lemma [code, code del]:
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    23
  "Inf_pred_inst.Inf_pred = Inf_pred_inst.Inf_pred" ..
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    24
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    25
lemma [code, code del]:
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    26
  "pred_of_set = pred_of_set" ..
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    27
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    28
lemma [code, code del]:
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    29
  "acc = acc" ..
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    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
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    43
(*
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    44
  If the code generation ends with an exception with the following message:
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    45
  '"List.set" is not a constructor, on left hand side of equation: ...',
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    46
  the code equation in question has to be either deleted (like many others in this file) 
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    47
  or implemented for RBT trees.
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    48
*)
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    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
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
    57
  "(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
    58
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
    59
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
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
    61
  "(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
    62
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
    63
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
export_code _ checking Scala?
48624
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    65
9b71daba4ec7 add testing file for RBT_Set
kuncar
parents:
diff changeset
    66
end