src/HOL/Tools/Lifting/lifting_info.ML
author wenzelm
Thu, 04 Apr 2013 18:20:00 +0200
changeset 51618 a3577cd80c41
parent 51427 08bb00239652
child 51994 82cc2aeb7d13
permissions -rw-r--r--
tuned signature -- avoid intrusion of slightly odd Swing structures into pure Markup_Tree;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
     1
(*  Title:      HOL/Tools/Lifting/lifting_info.ML
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
     2
    Author:     Ondrej Kuncar
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
     3
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
     4
Context data for the lifting package.
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
     5
*)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
     6
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
     7
signature LIFTING_INFO =
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
     8
sig
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
     9
  type quotmaps = {rel_quot_thm: thm}
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    10
  val lookup_quotmaps: Proof.context -> string -> quotmaps option
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    11
  val lookup_quotmaps_global: theory -> string -> quotmaps option
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    12
  val print_quotmaps: Proof.context -> unit
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    13
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
    14
  type pcrel_info = {pcrel_def: thm, pcr_cr_eq: thm}
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
    15
  type quotients = {quot_thm: thm, pcrel_info: pcrel_info option}
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    16
  val transform_quotients: morphism -> quotients -> quotients
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    17
  val lookup_quotients: Proof.context -> string -> quotients option
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    18
  val lookup_quotients_global: theory -> string -> quotients option
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    19
  val update_quotients: string -> quotients -> Context.generic -> Context.generic
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    20
  val dest_quotients: Proof.context -> quotients list
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    21
  val print_quotients: Proof.context -> unit
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    22
47634
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
    23
  val get_invariant_commute_rules: Proof.context -> thm list
47936
756f30eac792 infrastructure that makes possible to prove that a relation is reflexive
kuncar
parents: 47784
diff changeset
    24
  
47982
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47951
diff changeset
    25
  val get_reflexivity_rules: Proof.context -> thm list
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47951
diff changeset
    26
  val add_reflexivity_rule_attribute: attribute
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47951
diff changeset
    27
  val add_reflexivity_rule_attrib: Attrib.src
47634
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
    28
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
    29
  type relator_distr_data = {pos_mono_rule: thm, neg_mono_rule: thm, 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
    30
    pos_distr_rules: thm list, neg_distr_rules: thm list}
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
    31
  val lookup_relator_distr_data: Proof.context -> string -> relator_distr_data option
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
    32
  val lookup_relator_distr_data_global: theory -> string -> relator_distr_data option
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
    33
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    34
  val setup: theory -> theory
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    35
end;
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    36
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    37
structure Lifting_Info: LIFTING_INFO =
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    38
struct
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    39
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
    40
open Lifting_Util
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
    41
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    42
(** data containers **)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    43
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
    44
(* info about Quotient map theorems *)
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
    45
type quotmaps = {rel_quot_thm: thm}
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    46
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    47
structure Quotmaps = Generic_Data
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    48
(
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    49
  type T = quotmaps Symtab.table
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    50
  val empty = Symtab.empty
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    51
  val extend = I
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    52
  fun merge data = Symtab.merge (K true) data
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    53
)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    54
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    55
val lookup_quotmaps = Symtab.lookup o Quotmaps.get o Context.Proof
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    56
val lookup_quotmaps_global = Symtab.lookup o Quotmaps.get o Context.Theory
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    57
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    58
(* FIXME export proper internal update operation!? *)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
    59
47784
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    60
fun quot_map_thm_sanity_check rel_quot_thm ctxt =
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    61
  let
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    62
    fun quot_term_absT ctxt quot_term = 
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    63
      let 
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    64
        val (_, abs, _, _) = (dest_Quotient o HOLogic.dest_Trueprop) quot_term
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    65
          handle TERM (_, [t]) => error (Pretty.string_of (Pretty.block
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    66
            [Pretty.str "The Quotient map theorem is not in the right form.",
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    67
             Pretty.brk 1,
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    68
             Pretty.str "The following term is not the Quotient predicate:",
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    69
             Pretty.brk 1,
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    70
             Syntax.pretty_term ctxt t]))
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    71
      in
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    72
        fastype_of abs
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    73
      end
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    74
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    75
    val ((_, [rel_quot_thm_fixed]), ctxt') = Variable.importT [rel_quot_thm] ctxt
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    76
    val rel_quot_thm_prop = prop_of rel_quot_thm_fixed
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    77
    val rel_quot_thm_concl = Logic.strip_imp_concl rel_quot_thm_prop
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    78
    val rel_quot_thm_prems = Logic.strip_imp_prems rel_quot_thm_prop;
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    79
    val concl_absT = quot_term_absT ctxt' rel_quot_thm_concl
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    80
    val concl_tfrees = Term.add_tfree_namesT (concl_absT) []
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    81
    val prems_tfrees = fold (fn typ => fn list => Term.add_tfree_namesT (quot_term_absT ctxt' typ) list) 
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    82
                          rel_quot_thm_prems []
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    83
    val extra_prem_tfrees =
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    84
      case subtract (op =) concl_tfrees prems_tfrees of
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    85
        [] => []
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    86
      | extras => [Pretty.block ([Pretty.str "Extra type variables in the premises:",
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    87
                                 Pretty.brk 1] @ 
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    88
                                 ((Pretty.commas o map (Pretty.str o quote)) extras) @
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    89
                                 [Pretty.str "."])]
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    90
    val errs = extra_prem_tfrees 
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    91
  in
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    92
    if null errs then () else error (cat_lines (["Sanity check of the quotient map theorem failed:",""] 
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    93
                                                 @ (map Pretty.string_of errs)))
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    94
  end
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    95
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    96
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
    97
fun add_quot_map rel_quot_thm ctxt = 
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
    98
  let
47784
fe43977e434f added a basic sanity check for quot_map
kuncar
parents: 47777
diff changeset
    99
    val _ = Context.cases (K ()) (quot_map_thm_sanity_check rel_quot_thm) ctxt
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   100
    val rel_quot_thm_concl = (Logic.strip_imp_concl o prop_of) rel_quot_thm
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   101
    val (_, abs, _, _) = (dest_Quotient o HOLogic.dest_Trueprop) rel_quot_thm_concl
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   102
    val relatorT_name = (fst o dest_Type o fst o dest_funT o fastype_of) abs
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   103
    val minfo = {rel_quot_thm = rel_quot_thm}
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   104
  in
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   105
    Quotmaps.map (Symtab.update (relatorT_name, minfo)) ctxt
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   106
  end    
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   107
47951
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   108
val quot_map_attribute_setup =
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   109
  Attrib.setup @{binding quot_map} (Scan.succeed (Thm.declaration_attribute add_quot_map))
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   110
    "declaration of the Quotient map theorem"
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   111
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   112
fun print_quotmaps ctxt =
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   113
  let
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   114
    fun prt_map (ty_name, {rel_quot_thm}) =
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   115
      Pretty.block (separate (Pretty.brk 2)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   116
         [Pretty.str "type:", 
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   117
          Pretty.str ty_name,
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   118
          Pretty.str "quot. theorem:", 
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47634
diff changeset
   119
          Syntax.pretty_term ctxt (prop_of rel_quot_thm)])
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   120
  in
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   121
    map prt_map (Symtab.dest (Quotmaps.get (Context.Proof ctxt)))
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   122
    |> Pretty.big_list "maps for type constructors:"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   123
    |> Pretty.writeln
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   124
  end
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   125
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   126
(* info about quotient types *)
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   127
type pcrel_info = {pcrel_def: thm, pcr_cr_eq: thm}
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   128
type quotients = {quot_thm: thm, pcrel_info: pcrel_info option}
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   129
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   130
structure Quotients = Generic_Data
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   131
(
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   132
  type T = quotients Symtab.table
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   133
  val empty = Symtab.empty
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   134
  val extend = I
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   135
  fun merge data = Symtab.merge (K true) data
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   136
)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   137
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   138
fun transform_pcrel_info phi {pcrel_def, pcr_cr_eq} =
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   139
  {pcrel_def = Morphism.thm phi pcrel_def, pcr_cr_eq = Morphism.thm phi pcr_cr_eq}
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   140
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   141
fun transform_quotients phi {quot_thm, pcrel_info} =
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   142
  {quot_thm = Morphism.thm phi quot_thm, pcrel_info = Option.map (transform_pcrel_info phi) pcrel_info}
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   143
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   144
val lookup_quotients = Symtab.lookup o Quotients.get o Context.Proof
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   145
val lookup_quotients_global = Symtab.lookup o Quotients.get o Context.Theory
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   146
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   147
fun update_quotients str qinfo = Quotients.map (Symtab.update (str, qinfo))
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   148
47951
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   149
fun delete_quotients quot_thm ctxt =
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   150
  let
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   151
    val (_, qtyp) = quot_thm_rty_qty quot_thm
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   152
    val qty_full_name = (fst o dest_Type) qtyp
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   153
    val symtab = Quotients.get ctxt
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   154
    val opt_stored_quot_thm = Symtab.lookup symtab qty_full_name
47951
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   155
  in
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   156
    case opt_stored_quot_thm of
50227
01d545993e8c generate a parameterized correspondence relation
kuncar
parents: 47982
diff changeset
   157
      SOME data => 
01d545993e8c generate a parameterized correspondence relation
kuncar
parents: 47982
diff changeset
   158
        if Thm.eq_thm_prop (#quot_thm data, quot_thm) then
47951
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   159
          Quotients.map (Symtab.delete qty_full_name) ctxt
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   160
        else
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   161
          ctxt
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   162
      | NONE => ctxt
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   163
  end
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   164
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   165
fun dest_quotients ctxt =  (* FIXME slightly expensive way to retrieve data *)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   166
  map snd (Symtab.dest (Quotients.get (Context.Proof ctxt)))
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   167
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   168
fun print_quotients ctxt =
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   169
  let
51426
f25ee4fb437d made SML/NJ happy;
wenzelm
parents: 51374
diff changeset
   170
    fun prt_quot (qty_name, {quot_thm, pcrel_info}: quotients) =
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   171
      Pretty.block (separate (Pretty.brk 2)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   172
       [Pretty.str "type:", 
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   173
        Pretty.str qty_name,
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   174
        Pretty.str "quot. thm:",
50227
01d545993e8c generate a parameterized correspondence relation
kuncar
parents: 47982
diff changeset
   175
        Syntax.pretty_term ctxt (prop_of quot_thm),
01d545993e8c generate a parameterized correspondence relation
kuncar
parents: 47982
diff changeset
   176
        Pretty.str "pcrel_def thm:",
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   177
        option_fold (Pretty.str "-") ((Syntax.pretty_term ctxt) o prop_of o #pcrel_def) pcrel_info,
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   178
        Pretty.str "pcr_cr_eq thm:",
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   179
        option_fold (Pretty.str "-") ((Syntax.pretty_term ctxt) o prop_of o #pcr_cr_eq) pcrel_info])
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   180
  in
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   181
    map prt_quot (Symtab.dest (Quotients.get (Context.Proof ctxt)))
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   182
    |> Pretty.big_list "quotients:"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   183
    |> Pretty.writeln
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   184
  end
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   185
47951
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   186
val quot_del_attribute_setup =
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   187
  Attrib.setup @{binding quot_del} (Scan.succeed (Thm.declaration_attribute delete_quotients))
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   188
    "deletes the Quotient theorem"
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   189
47634
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   190
structure Invariant_Commute = Named_Thms
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   191
(
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   192
  val name = @{binding invariant_commute}
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   193
  val description = "theorems that a relator of an invariant is an invariant of the corresponding predicate"
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   194
)
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   195
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   196
fun get_invariant_commute_rules ctxt = map safe_mk_meta_eq (Invariant_Commute.get ctxt)
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   197
47936
756f30eac792 infrastructure that makes possible to prove that a relation is reflexive
kuncar
parents: 47784
diff changeset
   198
structure Reflp_Preserve = Named_Thms
756f30eac792 infrastructure that makes possible to prove that a relation is reflexive
kuncar
parents: 47784
diff changeset
   199
(
47982
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47951
diff changeset
   200
  val name = @{binding reflexivity_rule}
47936
756f30eac792 infrastructure that makes possible to prove that a relation is reflexive
kuncar
parents: 47784
diff changeset
   201
  val description = "theorems that a relator preserves a reflexivity property"
756f30eac792 infrastructure that makes possible to prove that a relation is reflexive
kuncar
parents: 47784
diff changeset
   202
)
756f30eac792 infrastructure that makes possible to prove that a relation is reflexive
kuncar
parents: 47784
diff changeset
   203
47982
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47951
diff changeset
   204
val get_reflexivity_rules = Reflp_Preserve.get
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47951
diff changeset
   205
val add_reflexivity_rule_attribute = Reflp_Preserve.add
7aa35601ff65 prove reflexivity also for the quotient composition relation; reflp_preserve renamed to reflexivity_rule
kuncar
parents: 47951
diff changeset
   206
val add_reflexivity_rule_attrib = Attrib.internal (K add_reflexivity_rule_attribute)
47936
756f30eac792 infrastructure that makes possible to prove that a relation is reflexive
kuncar
parents: 47784
diff changeset
   207
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   208
(* info about relator distributivity theorems *)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   209
type relator_distr_data = {pos_mono_rule: thm, neg_mono_rule: thm, 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   210
  pos_distr_rules: thm list, neg_distr_rules: thm list}
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   211
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   212
fun map_relator_distr_data f1 f2 f3 f4
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   213
  {pos_mono_rule, neg_mono_rule, pos_distr_rules, neg_distr_rules} =
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   214
  {pos_mono_rule   = f1 pos_mono_rule, 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   215
   neg_mono_rule   = f2 neg_mono_rule,
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   216
   pos_distr_rules = f3 pos_distr_rules, 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   217
   neg_distr_rules = f4 neg_distr_rules}
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   218
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   219
fun map_pos_mono_rule f = map_relator_distr_data f I I I
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   220
fun map_neg_mono_rule f = map_relator_distr_data I f I I
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   221
fun map_pos_distr_rules f = map_relator_distr_data I I f I 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   222
fun map_neg_distr_rules f = map_relator_distr_data I I I f
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   223
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   224
structure Relator_Distr = Generic_Data
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   225
(
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   226
  type T = relator_distr_data Symtab.table
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   227
  val empty = Symtab.empty
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   228
  val extend = I
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   229
  fun merge data = Symtab.merge (K true) data
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   230
);
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   231
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   232
fun introduce_polarities rule =
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   233
  let
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   234
    val dest_less_eq = HOLogic.dest_bin @{const_name "less_eq"} dummyT
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   235
    val prems_pairs = map (dest_less_eq o HOLogic.dest_Trueprop) (prems_of rule)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   236
    val equal_prems = filter op= prems_pairs
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   237
    val _ = if null equal_prems then () 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   238
      else error "The rule contains reflexive assumptions."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   239
    val concl_pairs = rule 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   240
      |> concl_of
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   241
      |> HOLogic.dest_Trueprop
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   242
      |> dest_less_eq
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   243
      |> pairself (snd o strip_comb)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   244
      |> op~~
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   245
      |> filter_out op=
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   246
    
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   247
    val _ = if has_duplicates op= concl_pairs 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   248
      then error "The rule contains duplicated variables in the conlusion." else ()
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   249
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   250
    fun rewrite_prem prem_pair = 
51427
08bb00239652 proper use of "member", without embarking on delicate questions about SML equality types;
wenzelm
parents: 51426
diff changeset
   251
      if member op= concl_pairs prem_pair
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   252
      then HOLogic.Trueprop_conv (Conv.rewr_conv (Thm.symmetric @{thm POS_def}))
51427
08bb00239652 proper use of "member", without embarking on delicate questions about SML equality types;
wenzelm
parents: 51426
diff changeset
   253
      else if member op= concl_pairs (swap prem_pair)
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   254
        then HOLogic.Trueprop_conv (Conv.rewr_conv (Thm.symmetric @{thm NEG_def}))
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   255
      else error "The rule contains a non-relevant assumption."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   256
    
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   257
    fun rewrite_prems [] = Conv.all_conv
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   258
      | rewrite_prems (x::xs) = Conv.implies_conv (rewrite_prem x) (rewrite_prems xs)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   259
    
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   260
    val rewrite_prems_conv = rewrite_prems prems_pairs
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   261
    val rewrite_concl_conv = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   262
      Conv.concl_conv ~1 (HOLogic.Trueprop_conv (Conv.rewr_conv (Thm.symmetric @{thm POS_def})))
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   263
  in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   264
    (Conv.fconv_rule (rewrite_prems_conv then_conv rewrite_concl_conv)) rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   265
  end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   266
  handle 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   267
    TERM _ => error "The rule has a wrong format."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   268
    | CTERM _ => error "The rule has a wrong format."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   269
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   270
fun negate_mono_rule mono_rule = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   271
  let
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   272
    val rewr_conv = HOLogic.Trueprop_conv (Conv.rewrs_conv [@{thm POS_NEG}, @{thm NEG_POS}])
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   273
  in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   274
    Conv.fconv_rule (Conv.prems_conv ~1 rewr_conv then_conv Conv.concl_conv ~1 rewr_conv) mono_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   275
  end;
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   276
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   277
fun add_mono_rule mono_rule ctxt = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   278
  let
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   279
    val mono_rule = introduce_polarities mono_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   280
    val mono_ruleT_name = (fst o dest_Type o fst o relation_types o fst o relation_types o snd o 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   281
      dest_Const o head_of o HOLogic.dest_Trueprop o concl_of) mono_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   282
    val _ = if Symtab.defined (Relator_Distr.get ctxt) mono_ruleT_name 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   283
      then error ("Monotocity rule for type " ^ quote mono_ruleT_name ^ " is already_defined.")
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   284
      else ()
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   285
    val neg_mono_rule = negate_mono_rule mono_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   286
    val relator_distr_data = {pos_mono_rule = mono_rule, neg_mono_rule = neg_mono_rule, 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   287
      pos_distr_rules = [], neg_distr_rules = []}
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   288
  in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   289
    Relator_Distr.map (Symtab.update (mono_ruleT_name, relator_distr_data)) ctxt
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   290
  end;
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   291
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   292
local 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   293
  fun add_distr_rule update_entry distr_rule ctxt =
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   294
    let
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   295
      val distr_ruleT_name = (fst o dest_Type o fst o relation_types o fst o relation_types o snd o 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   296
        dest_Const o head_of o HOLogic.dest_Trueprop o concl_of) distr_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   297
    in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   298
      if Symtab.defined (Relator_Distr.get ctxt) distr_ruleT_name then 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   299
        Relator_Distr.map (Symtab.map_entry distr_ruleT_name (update_entry distr_rule)) ctxt
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   300
      else error "The monoticity rule is not defined."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   301
    end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   302
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   303
    fun rewrite_concl_conv thm ctm = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   304
      Conv.concl_conv ~1 (HOLogic.Trueprop_conv (Conv.rewr_conv (Thm.symmetric thm))) ctm
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   305
      handle CTERM _ => error "The rule has a wrong format."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   306
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   307
in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   308
  fun add_pos_distr_rule distr_rule ctxt = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   309
    let
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   310
      val distr_rule = Conv.fconv_rule (rewrite_concl_conv @{thm POS_def}) distr_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   311
      fun update_entry distr_rule data = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   312
        map_pos_distr_rules (cons (@{thm POS_trans} OF [distr_rule, #pos_mono_rule data])) data
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   313
    in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   314
      add_distr_rule update_entry distr_rule ctxt
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   315
    end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   316
    handle THM _ => error "Combining of the distr. rule and the monotonicity rule together has failed."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   317
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   318
  
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   319
  fun add_neg_distr_rule distr_rule ctxt = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   320
    let
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   321
      val distr_rule = Conv.fconv_rule (rewrite_concl_conv @{thm NEG_def}) distr_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   322
      fun update_entry distr_rule data = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   323
        map_neg_distr_rules (cons (@{thm NEG_trans} OF [distr_rule, #neg_mono_rule data])) data
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   324
    in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   325
      add_distr_rule update_entry distr_rule ctxt
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   326
    end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   327
    handle THM _ => error "Combining of the distr. rule and the monotonicity rule together has failed."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   328
end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   329
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   330
local 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   331
  val eq_refl2 = sym RS @{thm eq_refl}
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   332
in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   333
  fun add_eq_distr_rule distr_rule ctxt =
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   334
    let 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   335
      val pos_distr_rule = @{thm eq_refl} OF [distr_rule]
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   336
      val neg_distr_rule = eq_refl2 OF [distr_rule]
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   337
    in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   338
      ctxt 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   339
      |> add_pos_distr_rule pos_distr_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   340
      |> add_neg_distr_rule neg_distr_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   341
    end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   342
end;
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   343
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   344
local
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   345
  fun sanity_check rule =
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   346
    let
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   347
      val assms = map (perhaps (try HOLogic.dest_Trueprop)) (prems_of rule)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   348
      val concl = (perhaps (try HOLogic.dest_Trueprop)) (concl_of rule);
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   349
      val (lhs, rhs) = case concl of
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   350
        Const ("Orderings.ord_class.less_eq", _) $ (lhs as Const ("Relation.relcompp",_) $ _ $ _) $ rhs => 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   351
          (lhs, rhs)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   352
        | Const ("Orderings.ord_class.less_eq", _) $ rhs $ (lhs as Const ("Relation.relcompp",_) $ _ $ _) => 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   353
          (lhs, rhs)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   354
        | Const ("HOL.eq", _) $ (lhs as Const ("Relation.relcompp",_) $ _ $ _) $ rhs => (lhs, rhs)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   355
        | _ => error "The rule has a wrong format."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   356
      
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   357
      val lhs_vars = Term.add_vars lhs []
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   358
      val rhs_vars = Term.add_vars rhs []
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   359
      val assms_vars = fold Term.add_vars assms [];
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   360
      val _ = if has_duplicates op= lhs_vars then error "Left-hand side has variable duplicates" else ()
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   361
      val _ = if subset op= (rhs_vars, lhs_vars) then () 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   362
        else error "Extra variables in the right-hand side of the rule"
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   363
      val _ = if subset op= (assms_vars, lhs_vars) then () 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   364
        else error "Extra variables in the assumptions of the rule"
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   365
      val rhs_args = (snd o strip_comb) rhs;
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   366
      fun check_comp t = case t of 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   367
        Const ("Relation.relcompp", _) $ Var (_, _) $ Var (_,_) => ()
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   368
        | _ => error "There is an argument on the rhs that is not a composition."
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   369
      val _ = map check_comp rhs_args
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   370
    in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   371
      ()
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   372
    end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   373
in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   375
  fun add_distr_rule distr_rule ctxt = 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   376
    let
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   377
      val _ = sanity_check distr_rule
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   378
      val concl = (perhaps (try HOLogic.dest_Trueprop)) (concl_of distr_rule)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   379
    in
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   380
      case concl of
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   381
        Const ("Orderings.ord_class.less_eq", _) $ (Const ("Relation.relcompp",_) $ _ $ _) $ _ => 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   382
          add_pos_distr_rule distr_rule ctxt
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   383
        | Const ("Orderings.ord_class.less_eq", _) $ _ $ (Const ("Relation.relcompp",_) $ _ $ _) => 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   384
          add_neg_distr_rule distr_rule ctxt
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   385
        | Const ("HOL.eq", _) $ (Const ("Relation.relcompp",_) $ _ $ _) $ _ =>
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   386
          add_eq_distr_rule distr_rule ctxt
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   387
    end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   388
end
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   389
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   390
fun get_distr_rules_raw ctxt = Symtab.fold 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   391
  (fn (_, {pos_distr_rules, neg_distr_rules, ...}) => fn rules => pos_distr_rules @ neg_distr_rules @ rules) 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   392
    (Relator_Distr.get ctxt) []
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   393
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   394
fun get_mono_rules_raw ctxt = Symtab.fold 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   395
  (fn (_, {pos_mono_rule, neg_mono_rule, ...}) => fn rules => [pos_mono_rule, neg_mono_rule] @ rules) 
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   396
    (Relator_Distr.get ctxt) []
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   397
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   398
val lookup_relator_distr_data = Symtab.lookup o Relator_Distr.get o Context.Proof
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   399
val lookup_relator_distr_data_global = Symtab.lookup o Relator_Distr.get o Context.Theory
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   400
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   401
val relator_distr_attribute_setup =
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   402
  Attrib.setup @{binding relator_mono} (Scan.succeed (Thm.declaration_attribute add_mono_rule))
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   403
    "declaration of relator's monoticity"
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   404
  #> Attrib.setup @{binding relator_distr} (Scan.succeed (Thm.declaration_attribute add_distr_rule))
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   405
    "declaration of relator's distributivity over OO"
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   406
  #> Global_Theory.add_thms_dynamic
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   407
     (@{binding relator_distr_raw}, get_distr_rules_raw)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   408
  #> Global_Theory.add_thms_dynamic
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   409
     (@{binding relator_mono_raw}, get_mono_rules_raw)
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   410
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   411
(* theory setup *)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   412
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   413
val setup =
47951
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   414
  quot_map_attribute_setup
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47936
diff changeset
   415
  #> quot_del_attribute_setup
47634
091bcd569441 hide the invariant constant for relators: invariant_commute infrastracture
kuncar
parents: 47308
diff changeset
   416
  #> Invariant_Commute.setup
47936
756f30eac792 infrastructure that makes possible to prove that a relation is reflexive
kuncar
parents: 47784
diff changeset
   417
  #> Reflp_Preserve.setup
51374
84d01fd733cf lift_definition and setup_lifting generate parametric transfer rules if parametricity theorems are provided
kuncar
parents: 50227
diff changeset
   418
  #> relator_distr_attribute_setup
47308
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   419
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   420
(* outer syntax commands *)
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   421
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   422
val _ =
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   423
  Outer_Syntax.improper_command @{command_spec "print_quotmaps"} "print quotient map functions"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   424
    (Scan.succeed (Toplevel.keep (print_quotmaps o Toplevel.context_of)))
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   425
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   426
val _ =
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   427
  Outer_Syntax.improper_command @{command_spec "print_quotients"} "print quotients"
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   428
    (Scan.succeed (Toplevel.keep (print_quotients o Toplevel.context_of)))
9caab698dbe4 new package Lifting - initial commit
kuncar
parents:
diff changeset
   429
51426
f25ee4fb437d made SML/NJ happy;
wenzelm
parents: 51374
diff changeset
   430
end;