src/HOL/Tools/Lifting/lifting_util.ML
author blanchet
Mon, 23 Jul 2012 15:32:30 +0200
changeset 48442 3c9890c19e90
parent 47951 8c8a03765de7
child 50225 f478f4ca7f19
permissions -rw-r--r--
cap the number of facts returned by MaSh
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47698
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     1
(*  Title:      HOL/Tools/Lifting/lifting_util.ML
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     2
    Author:     Ondrej Kuncar
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     3
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     4
General-purpose functions used by the Lifting package.
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     5
*)
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     6
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     7
signature LIFTING_UTIL =
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     8
sig
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
     9
  val MRSL: thm list * thm -> thm
47699
bb6b147c6531 added useful Trueprop_conv
kuncar
parents: 47698
diff changeset
    10
  val Trueprop_conv: conv -> conv
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47699
diff changeset
    11
  val dest_Quotient: term -> term * term * term * term
47951
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    12
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    13
  val quot_thm_rel: thm -> term
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    14
  val quot_thm_abs: thm -> term
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    15
  val quot_thm_rep: thm -> term
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    16
  val quot_thm_rty_qty: thm -> typ * typ
47698
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    17
end;
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    18
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    19
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    20
structure Lifting_Util: LIFTING_UTIL =
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    21
struct
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    22
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    23
infix 0 MRSL
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    24
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    25
fun ants MRSL thm = fold (fn rl => fn thm => rl RS thm) ants thm
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    26
47699
bb6b147c6531 added useful Trueprop_conv
kuncar
parents: 47698
diff changeset
    27
fun Trueprop_conv cv ct =
bb6b147c6531 added useful Trueprop_conv
kuncar
parents: 47698
diff changeset
    28
  (case Thm.term_of ct of
bb6b147c6531 added useful Trueprop_conv
kuncar
parents: 47698
diff changeset
    29
    Const (@{const_name Trueprop}, _) $ _ => Conv.arg_conv cv ct
bb6b147c6531 added useful Trueprop_conv
kuncar
parents: 47698
diff changeset
    30
  | _ => raise CTERM ("Trueprop_conv", [ct]))
bb6b147c6531 added useful Trueprop_conv
kuncar
parents: 47698
diff changeset
    31
47777
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47699
diff changeset
    32
fun dest_Quotient (Const (@{const_name Quotient}, _) $ rel $ abs $ rep $ cr)
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47699
diff changeset
    33
      = (rel, abs, rep, cr)
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47699
diff changeset
    34
  | dest_Quotient t = raise TERM ("dest_Quotient", [t])
f29e7dcd7c40 use a quot_map theorem attribute instead of the complicated map attribute
kuncar
parents: 47699
diff changeset
    35
47951
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    36
(*
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    37
  quot_thm_rel, quot_thm_abs, quot_thm_rep and quot_thm_rty_qty - simple functions
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    38
    for destructing quotient theorems (Quotient R Abs Rep T).
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    39
*)
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    40
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    41
fun quot_thm_rel quot_thm =
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    42
  case (dest_Quotient o HOLogic.dest_Trueprop o prop_of) quot_thm of
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    43
    (rel, _, _, _) => rel
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    44
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    45
fun quot_thm_abs quot_thm =
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    46
  case (dest_Quotient o HOLogic.dest_Trueprop o prop_of) quot_thm of
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    47
    (_, abs, _, _) => abs
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    48
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    49
fun quot_thm_rep quot_thm =
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    50
  case (dest_Quotient o HOLogic.dest_Trueprop o prop_of) quot_thm of
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    51
    (_, _, rep, _) => rep
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    52
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    53
fun quot_thm_rty_qty quot_thm =
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    54
  let
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    55
    val abs = quot_thm_abs quot_thm
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    56
    val abs_type = fastype_of abs  
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    57
  in
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    58
    (domain_type abs_type, range_type abs_type)
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    59
  end
8c8a03765de7 quot_del attribute, it allows us to deregister quotient types
kuncar
parents: 47777
diff changeset
    60
47698
18202d3d5832 move MRSL to a separate file
kuncar
parents:
diff changeset
    61
end;