Nominal/nominal_dt_quot.ML
author Christian Urban <urbanc@in.tum.de>
Sat, 14 Aug 2010 23:33:23 +0800
changeset 2398 1e6160690546
parent 2396 f2f611daf480
child 2400 c6d30d5f5ba1
permissions -rw-r--r--
improved code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2337
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
(*  Title:      nominal_dt_alpha.ML
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
    Author:     Christian Urban
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
    Author:     Cezary Kaliszyk
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
  Performing quotient constructions
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
*)
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
signature NOMINAL_DT_QUOT =
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
sig
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  val qtype_defs: (string list * binding * mixfix) list -> typ list -> term list -> 
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
    thm list -> local_theory -> Quotient_Info.quotdata_info list * local_theory
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
  val qconst_defs: typ list -> (string  * term * mixfix) list -> local_theory -> 
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
    Quotient_Info.qconsts_info list * local_theory
2346
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    15
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    16
  val qperm_defs: typ list -> string list -> (string * term * mixfix) list -> 
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    17
    thm list -> theory -> theory
2337
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
end
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
structure Nominal_Dt_Quot: NOMINAL_DT_QUOT =
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
struct
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
(* defines the quotient types *)
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
fun qtype_defs qtys_descr alpha_tys alpha_trms alpha_equivp_thms lthy =
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
let
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
  val qty_args1 = map2 (fn ty => fn trm => (ty, trm, false)) alpha_tys alpha_trms
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
  val qty_args2 = (qtys_descr ~~ qty_args1) ~~ alpha_equivp_thms
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
in
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
  fold_map Quotient_Type.add_quotient_type qty_args2 lthy
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
end 
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
2338
e1764a73c292 slight cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2337
diff changeset
    32
2337
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
(* defines quotient constants *)
2338
e1764a73c292 slight cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2337
diff changeset
    34
fun qconst_defs qtys consts_specs lthy =
2337
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
let
2338
e1764a73c292 slight cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2337
diff changeset
    36
  val (qconst_infos, lthy') = 
e1764a73c292 slight cleaning
Christian Urban <urbanc@in.tum.de>
parents: 2337
diff changeset
    37
    fold_map (Quotient_Def.lift_raw_const qtys) consts_specs lthy
2337
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
  val phi = ProofContext.export_morphism lthy' lthy
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
in
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  (map (Quotient_Info.transform_qconsts phi) qconst_infos, lthy')
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
end
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
2346
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    44
(* defines the quotient permutations *)
2398
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2396
diff changeset
    45
fun qperm_defs qtys full_tnames perm_specs thms thy =
2346
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    46
let
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    47
  val lthy =
2396
f2f611daf480 updated to Isabelle 12th Aug
Christian Urban <urbanc@in.tum.de>
parents: 2346
diff changeset
    48
    Class.instantiation (full_tnames, [], @{sort pt}) thy;
2398
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2396
diff changeset
    49
  
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2396
diff changeset
    50
  val (_, lthy') = qconst_defs qtys perm_specs lthy;
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2396
diff changeset
    51
2346
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    52
  val lifted_thms = map (Quotient_Tacs.lifted qtys lthy') thms;
2398
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2396
diff changeset
    53
2346
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    54
  fun tac _ =
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    55
    Class.intro_classes_tac [] THEN
2398
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2396
diff changeset
    56
      (ALLGOALS (resolve_tac lifted_thms))
2346
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    57
in
2398
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2396
diff changeset
    58
  lthy'
1e6160690546 improved code
Christian Urban <urbanc@in.tum.de>
parents: 2396
diff changeset
    59
  |> Class.prove_instantiation_exit tac 
2346
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    60
end
4c5881455923 more on the paper
Christian Urban <urbanc@in.tum.de>
parents: 2338
diff changeset
    61
2337
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
end (* structure *)
b151399bd2c3 fixed according to changes in quotient
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64