Nominal/nominal_eqvt.ML
author Christian Urban <urbanc@in.tum.de>
Wed, 13 Apr 2011 13:41:52 +0100
changeset 2765 7ac5e5c86c7d
parent 2650 e5fa8de0e4bd
child 2778 d7183105e304
permissions -rw-r--r--
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
(*  Title:      nominal_eqvt.ML
1835
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
     2
    Author:     Stefan Berghofer (original code)
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
    Author:     Christian Urban
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
    Automatic proofs for equivariance of inductive predicates.
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
*)
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
2765
7ac5e5c86c7d introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents: 2650
diff changeset
     8
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
signature NOMINAL_EQVT =
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
sig
1835
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    11
  val eqvt_rel_tac: Proof.context -> string list -> term -> thm -> thm list -> int -> tactic
1948
Christian Urban <urbanc@in.tum.de>
parents: 1866
diff changeset
    12
  val eqvt_rel_single_case_tac: Proof.context -> string list -> term -> thm -> int -> tactic
2107
5686d83db1f9 ingnored parameters in equivariance; added a proper interface to be called from ML
Christian Urban <urbanc@in.tum.de>
parents: 2081
diff changeset
    13
  
2650
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
    14
  val raw_equivariance: bool -> term list -> thm -> thm list -> Proof.context -> thm list * local_theory
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
    15
  val equivariance: string -> Proof.context -> (thm list * local_theory)
2107
5686d83db1f9 ingnored parameters in equivariance; added a proper interface to be called from ML
Christian Urban <urbanc@in.tum.de>
parents: 2081
diff changeset
    16
  val equivariance_cmd: string -> Proof.context -> local_theory
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
end
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
structure Nominal_Eqvt : NOMINAL_EQVT =
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
struct
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
open Nominal_Permeq;
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
open Nominal_ThmDecls;
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
val atomize_conv = 
2620
81921f8ad245 updated to Isabelle 22 December
Christian Urban <urbanc@in.tum.de>
parents: 2568
diff changeset
    26
  Raw_Simplifier.rewrite_cterm (true, false, false) (K (K NONE))
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
    (HOL_basic_ss addsimps @{thms induct_atomize});
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
val atomize_intr = Conv.fconv_rule (Conv.prems_conv ~1 atomize_conv);
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
fun atomize_induct ctxt = Conv.fconv_rule (Conv.prems_conv ~1
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
  (Conv.params_conv ~1 (K (Conv.prems_conv ~1 atomize_conv)) ctxt));
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
1835
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    32
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    33
(** equivariance tactics **)
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    34
1866
6d4e4bf9bce6 automatic proofs for equivariance of alphas
Christian Urban <urbanc@in.tum.de>
parents: 1861
diff changeset
    35
val perm_boolE = @{thm permute_boolE}
6d4e4bf9bce6 automatic proofs for equivariance of alphas
Christian Urban <urbanc@in.tum.de>
parents: 1861
diff changeset
    36
1948
Christian Urban <urbanc@in.tum.de>
parents: 1866
diff changeset
    37
fun eqvt_rel_single_case_tac ctxt pred_names pi intro  = 
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    38
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    39
    val thy = ProofContext.theory_of ctxt
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    40
    val cpi = Thm.cterm_of thy (mk_minus pi)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    41
    val pi_intro_rule = Drule.instantiate' [] [SOME cpi] perm_boolE
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    42
    val simps1 = HOL_basic_ss addsimps @{thms permute_fun_def minus_minus split_paired_all}
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    43
    val simps2 = HOL_basic_ss addsimps @{thms permute_bool_def}
2765
7ac5e5c86c7d introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents: 2650
diff changeset
    44
    val eqvt_sconfig = 
7ac5e5c86c7d introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents: 2650
diff changeset
    45
          eqvt_strict_config addpres @{thms permute_minus_cancel(2)} addexcls pred_names
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    46
  in
2765
7ac5e5c86c7d introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents: 2650
diff changeset
    47
    eqvt_tac ctxt (eqvt_strict_config addexcls pred_names) THEN'
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    48
    SUBPROOF (fn {prems, context as ctxt, ...} =>
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    49
      let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    50
        val prems' = map (transform_prem2 ctxt pred_names) prems
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    51
        val tac1 = resolve_tac prems'
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    52
        val tac2 = EVERY' [ rtac pi_intro_rule, 
2765
7ac5e5c86c7d introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents: 2650
diff changeset
    53
          eqvt_tac ctxt eqvt_sconfig, resolve_tac prems' ]
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    54
        val tac3 = EVERY' [ rtac pi_intro_rule, 
2765
7ac5e5c86c7d introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents: 2650
diff changeset
    55
          eqvt_tac ctxt eqvt_sconfig, simp_tac simps1, 
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    56
          simp_tac simps2, resolve_tac prems']
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    57
      in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    58
        (rtac intro THEN_ALL_NEW FIRST' [tac1, tac2, tac3]) 1 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    59
      end) ctxt
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    60
  end
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
1835
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    62
fun eqvt_rel_tac ctxt pred_names pi induct intros =
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    63
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    64
    val cases = map (eqvt_rel_single_case_tac ctxt pred_names pi) intros
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    65
  in
2650
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
    66
    EVERY' ((DETERM o rtac induct) :: cases)
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    67
  end
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
1835
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    69
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    70
(** equivariance procedure *)
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    71
2107
5686d83db1f9 ingnored parameters in equivariance; added a proper interface to be called from ML
Christian Urban <urbanc@in.tum.de>
parents: 2081
diff changeset
    72
fun prepare_goal pi pred =
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    73
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    74
    val (c, xs) = strip_comb pred;
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    75
  in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    76
    HOLogic.mk_imp (pred, list_comb (c, map (mk_perm pi) xs))
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    77
  end
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
1835
636de31888a6 tuned and removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 1833
diff changeset
    79
(* stores thm under name.eqvt and adds [eqvt]-attribute *)
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    80
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
fun note_named_thm (name, thm) ctxt = 
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    82
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    83
    val thm_name = Binding.qualified_name 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    84
      (Long_Name.qualify (Long_Name.base_name name) "eqvt")
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    85
    val attr = Attrib.internal (K eqvt_add)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    86
    val ((_, [thm']), ctxt') =  Local_Theory.note ((thm_name, [attr]), [thm]) ctxt
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    87
  in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    88
    (thm', ctxt')
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    89
  end
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
2650
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
    91
fun get_name (Const (a, _)) = a
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
    92
  | get_name (Free  (a, _)) = a
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
    93
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
    94
fun raw_equivariance note_flag pred_trms raw_induct intrs ctxt = 
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    95
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    96
    val is_already_eqvt = 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    97
      filter (is_eqvt ctxt) pred_trms
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    98
      |> map (Syntax.string_of_term ctxt)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
    99
    val _ = if null is_already_eqvt then ()
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   100
      else error ("Already equivariant: " ^ commas is_already_eqvt)
2117
b3a5bda07007 added a test whether some of the constants already equivariant (then the procedure has to fail).
Christian Urban <urbanc@in.tum.de>
parents: 2110
diff changeset
   101
2650
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   102
    val pred_names = map get_name pred_trms
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   103
    val raw_induct' = atomize_induct ctxt raw_induct
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   104
    val intrs' = map atomize_intr intrs
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   105
  
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   106
    val (([raw_concl], [raw_pi]), ctxt') = 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   107
      ctxt 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   108
      |> Variable.import_terms false [concl_of raw_induct'] 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   109
      ||>> Variable.variant_fixes ["p"]
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   110
    val pi = Free (raw_pi, @{typ perm})
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   111
  
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   112
    val preds = map (fst o HOLogic.dest_imp)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   113
      (HOLogic.dest_conj (HOLogic.dest_Trueprop raw_concl));
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   114
  
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   115
    val goal = HOLogic.mk_Trueprop 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   116
      (foldr1 HOLogic.mk_conj (map (prepare_goal pi) preds))
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   117
  
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   118
    val thms = Goal.prove ctxt' [] [] goal 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   119
      (fn {context,...} => eqvt_rel_tac context pred_names pi raw_induct' intrs' 1)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   120
      |> Datatype_Aux.split_conj_thm 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   121
      |> ProofContext.export ctxt' ctxt
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   122
      |> map (fn th => th RS mp)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   123
      |> map zero_var_indexes
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   124
  in
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   125
    if note_flag
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   126
    then fold_map note_named_thm (pred_names ~~ thms) ctxt 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   127
    else (thms, ctxt) 
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   128
  end
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
2650
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   130
fun equivariance pred_name ctxt =
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   131
  let
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   132
    val thy = ProofContext.theory_of ctxt
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   133
    val (_, {preds, raw_induct, intrs, ...}) =
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   134
      Inductive.the_inductive ctxt (Sign.intern_const thy pred_name)
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   135
  in
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   136
    raw_equivariance false preds raw_induct intrs ctxt 
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   137
  end
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   138
2107
5686d83db1f9 ingnored parameters in equivariance; added a proper interface to be called from ML
Christian Urban <urbanc@in.tum.de>
parents: 2081
diff changeset
   139
fun equivariance_cmd pred_name ctxt =
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   140
  let
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   141
    val thy = ProofContext.theory_of ctxt
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   142
    val (_, {preds, raw_induct, intrs, ...}) =
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   143
      Inductive.the_inductive ctxt (Sign.intern_const thy pred_name)
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   144
  in
2650
e5fa8de0e4bd derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents: 2620
diff changeset
   145
    raw_equivariance true preds raw_induct intrs ctxt |> snd
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   146
  end
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
2168
ce0255ffaeb4 Renamings
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2117
diff changeset
   148
local structure P = Parse and K = Keyword in
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
val _ =
2168
ce0255ffaeb4 Renamings
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2117
diff changeset
   151
  Outer_Syntax.local_theory "equivariance"
1948
Christian Urban <urbanc@in.tum.de>
parents: 1866
diff changeset
   152
    "Proves equivariance for inductive predicate involving nominal datatypes." 
2107
5686d83db1f9 ingnored parameters in equivariance; added a proper interface to be called from ML
Christian Urban <urbanc@in.tum.de>
parents: 2081
diff changeset
   153
      K.thy_decl (P.xname >> equivariance_cmd);
2477
2f289c1f6cf1 tuned code
Christian Urban <urbanc@in.tum.de>
parents: 2311
diff changeset
   154
1833
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
end;
2050b5723c04 added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
2069
2b6ba4d4e19a Fixes for new isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 2064
diff changeset
   157
end (* structure *)