Nominal/nominal_dt_supp.ML
author Christian Urban <urbanc@in.tum.de>
Mon, 27 Sep 2010 09:51:15 -0400
changeset 2492 5ac9a74d22fd
parent 2491 d0961e6d6881
child 2493 2e174807c891
permissions -rw-r--r--
post-processed eq_iff and supp threormes according to the fv-supp equality
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
(*  Title:      nominal_dt_alpha.ML
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
    Author:     Christian Urban
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
    Author:     Cezary Kaliszyk
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
  Deriving support propoerties for the quotient types.
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
*)
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
signature NOMINAL_DT_SUPP =
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
sig
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  val prove_supports: Proof.context -> thm list -> term list -> thm list  
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2449
diff changeset
    11
  val prove_fsupp: Proof.context -> typ list -> thm -> thm list -> thm list
2451
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
    12
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
    13
  val fs_instance: typ list -> string list -> (string * sort) list -> thm list ->  
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
    14
    local_theory -> local_theory
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    15
2483
37941f58ab8f removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 2481
diff changeset
    16
  val prove_fv_supp: typ list -> term list -> term list -> term list -> term list -> thm list -> 
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
    17
    thm list -> thm list -> thm list -> thm -> bclause list list -> Proof.context -> thm list 
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
end
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
structure Nominal_Dt_Supp: NOMINAL_DT_SUPP =
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
struct
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    23
fun lookup xs x = the (AList.lookup (op=) xs x)
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2449
diff changeset
    25
(* supports lemmas for constructors *)
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
fun mk_supports_goal ctxt qtrm =
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    28
  let  
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    29
    val vs = fresh_args ctxt qtrm
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    30
    val rhs = list_comb (qtrm, vs)
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    31
    val lhs = fold (curry HOLogic.mk_prod) vs @{term "()"}
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    32
      |> mk_supp
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    33
  in
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    34
    mk_supports lhs rhs
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    35
    |> HOLogic.mk_Trueprop
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    36
  end
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
fun supports_tac ctxt perm_simps =
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    39
  let
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    40
    val ss1 = HOL_basic_ss addsimps @{thms supports_def fresh_def[symmetric]}
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    41
    val ss2 = HOL_ss addsimps @{thms swap_fresh_fresh fresh_Pair}
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    42
  in
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    43
    EVERY' [ simp_tac ss1,
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    44
             Nominal_Permeq.eqvt_strict_tac ctxt perm_simps [],
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    45
             simp_tac ss2 ]
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    46
  end
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
fun prove_supports_single ctxt perm_simps qtrm =
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    49
  let
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    50
    val goal = mk_supports_goal ctxt qtrm 
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    51
    val ctxt' = Variable.auto_fixes goal ctxt
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    52
  in
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    53
    Goal.prove ctxt' [] [] goal
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    54
      (K (HEADGOAL (supports_tac ctxt perm_simps)))
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    55
    |> singleton (ProofContext.export ctxt' ctxt)
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    56
  end
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
fun prove_supports ctxt perm_simps qtrms =
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
  map (prove_supports_single ctxt perm_simps) qtrms
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2449
diff changeset
    62
(* finite supp lemmas for qtypes *)
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2449
diff changeset
    64
fun prove_fsupp ctxt qtys qinduct qsupports_thms =
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    65
  let
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    66
    val (vs, ctxt') = Variable.variant_fixes (replicate (length qtys) "x") ctxt
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    67
    val goals = vs ~~ qtys
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    68
      |> map Free
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    69
      |> map (mk_finite o mk_supp)
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    70
      |> foldr1 (HOLogic.mk_conj)
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    71
      |> HOLogic.mk_Trueprop
2450
217ef3e4282e added proofs for fsupp properties
Christian Urban <urbanc@in.tum.de>
parents: 2449
diff changeset
    72
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    73
    val tac = 
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    74
      EVERY' [ rtac @{thm supports_finite},
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    75
               resolve_tac qsupports_thms,
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    76
               asm_simp_tac (HOL_ss addsimps @{thms finite_supp supp_Pair finite_Un}) ]
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    77
  in
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    78
    Goal.prove ctxt' [] [] goals
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    79
      (K (HEADGOAL (rtac qinduct THEN_ALL_NEW tac)))
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    80
    |> singleton (ProofContext.export ctxt' ctxt)
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    81
    |> Datatype_Aux.split_conj_thm
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    82
    |> map zero_var_indexes
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    83
  end
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
2451
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
    85
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
    86
(* finite supp instances *)
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
    87
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
    88
fun fs_instance qtys qfull_ty_names tvs qfsupp_thms lthy =
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    89
  let
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    90
    val lthy1 = 
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    91
      lthy
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    92
      |> Local_Theory.exit_global
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    93
      |> Class.instantiation (qfull_ty_names, tvs, @{sort fs}) 
2451
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
    94
  
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    95
    fun tac _ =
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    96
      Class.intro_classes_tac [] THEN
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    97
        (ALLGOALS (resolve_tac qfsupp_thms))
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    98
  in
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
    99
    lthy1
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   100
    |> Class.prove_instantiation_exit tac 
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   101
    |> Named_Target.theory_init
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   102
  end
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   103
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   104
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   105
(* proves that fv and fv_bn equals supp *)
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   106
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   107
fun gen_mk_goals fv supp =
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   108
  let
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   109
    val arg_ty = 
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   110
      fastype_of fv
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   111
      |> domain_type
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   112
  in
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   113
    (arg_ty, fn x => HOLogic.mk_eq (fv $ x, supp x))
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   114
  end
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   115
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   116
fun mk_fvs_goals fv = gen_mk_goals fv mk_supp
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   117
fun mk_fv_bns_goals fv_bn alpha_bn = gen_mk_goals fv_bn (mk_supp_rel alpha_bn)
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   118
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   119
fun add_ss thms =
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   120
  HOL_basic_ss addsimps thms
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   121
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   122
fun symmetric thms = 
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   123
  map (fn thm => thm RS @{thm sym}) thms
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   124
2491
d0961e6d6881 more consistent naming in Abs.thy
Christian Urban <urbanc@in.tum.de>
parents: 2483
diff changeset
   125
val supp_Abs_set = @{thms supp_Abs(1)[symmetric]}
d0961e6d6881 more consistent naming in Abs.thy
Christian Urban <urbanc@in.tum.de>
parents: 2483
diff changeset
   126
val supp_Abs_res = @{thms supp_Abs(2)[symmetric]}
d0961e6d6881 more consistent naming in Abs.thy
Christian Urban <urbanc@in.tum.de>
parents: 2483
diff changeset
   127
val supp_Abs_lst = @{thms supp_Abs(3)[symmetric]}
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   128
2491
d0961e6d6881 more consistent naming in Abs.thy
Christian Urban <urbanc@in.tum.de>
parents: 2483
diff changeset
   129
fun mk_supp_abs ctxt (BC (Set, _, _)) = EqSubst.eqsubst_tac ctxt [1] supp_Abs_set 
d0961e6d6881 more consistent naming in Abs.thy
Christian Urban <urbanc@in.tum.de>
parents: 2483
diff changeset
   130
  | mk_supp_abs ctxt (BC (Res, _, _)) = EqSubst.eqsubst_tac ctxt [1] supp_Abs_res
d0961e6d6881 more consistent naming in Abs.thy
Christian Urban <urbanc@in.tum.de>
parents: 2483
diff changeset
   131
  | mk_supp_abs ctxt (BC (Lst, _, _)) = EqSubst.eqsubst_tac ctxt [1] supp_Abs_lst
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   132
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   133
fun mk_supp_abs_tac ctxt [] = []
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   134
  | mk_supp_abs_tac ctxt (BC (_, [], _)::xs) = mk_supp_abs_tac ctxt xs
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   135
  | mk_supp_abs_tac ctxt (bc::xs) = (DETERM o mk_supp_abs ctxt bc)::mk_supp_abs_tac ctxt xs
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   136
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   137
fun mk_bn_supp_abs_tac trm =
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   138
  trm
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   139
  |> fastype_of
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   140
  |> body_type
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   141
  |> (fn ty => case ty of
2491
d0961e6d6881 more consistent naming in Abs.thy
Christian Urban <urbanc@in.tum.de>
parents: 2483
diff changeset
   142
        @{typ "atom set"}  => simp_tac (add_ss supp_Abs_set)
d0961e6d6881 more consistent naming in Abs.thy
Christian Urban <urbanc@in.tum.de>
parents: 2483
diff changeset
   143
      | @{typ "atom list"} => simp_tac (add_ss supp_Abs_lst)
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   144
      | _ => raise TERM ("mk_bn_supp_abs_tac", [trm]))
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   145
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   146
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   147
val thms1 = @{thms supp_Pair supp_eqvt[symmetric] Un_assoc conj_assoc}
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   148
val thms2 = @{thms de_Morgan_conj Collect_disj_eq finite_Un}
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   149
val thms3 = @{thms alphas prod_alpha_def prod_fv.simps prod_rel.simps permute_prod_def 
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   150
  prod.recs prod.cases prod.inject not_True_eq_False empty_def[symmetric] Finite_Set.finite.emptyI}
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   151
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   152
fun p_tac msg i = 
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   153
  if false then print_tac ("ptest: " ^ msg) else all_tac
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   154
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   155
fun q_tac msg i = 
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   156
  if true then print_tac ("qtest: " ^ msg) else all_tac
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   157
2483
37941f58ab8f removed dead code
Christian Urban <urbanc@in.tum.de>
parents: 2481
diff changeset
   158
fun prove_fv_supp qtys qtrms fvs fv_bns alpha_bns fv_simps eq_iffs perm_simps 
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   159
  fv_bn_eqvts qinduct bclausess ctxt =
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   160
  let
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   161
    val goals1 = map mk_fvs_goals fvs
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   162
    val goals2 = map2 mk_fv_bns_goals fv_bns alpha_bns   
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   163
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   164
    fun tac ctxt =
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   165
      SUBGOAL (fn (goal, i) =>
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   166
        let
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   167
          val (fv_fun, arg) = 
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   168
            goal |> Envir.eta_contract
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   169
                 |> Logic.strip_assums_concl
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   170
                 |> HOLogic.dest_Trueprop
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   171
                 |> fst o HOLogic.dest_eq
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   172
                 |> dest_comb
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   173
          val supp_abs_tac = 
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   174
            case (AList.lookup (op=) (qtrms ~~ bclausess) (head_of arg)) of
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   175
              SOME bclauses => EVERY' (mk_supp_abs_tac ctxt bclauses)
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   176
            | NONE => mk_bn_supp_abs_tac fv_fun
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   177
        in
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   178
          EVERY' [ TRY o asm_full_simp_tac (add_ss (@{thm supp_Pair[symmetric]}::fv_simps)),
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   179
                   TRY o supp_abs_tac,
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   180
                   TRY o simp_tac (add_ss @{thms supp_def supp_rel_def}),
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   181
                   TRY o Nominal_Permeq.eqvt_tac ctxt (perm_simps @ fv_bn_eqvts) [], 
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   182
                   TRY o simp_tac (add_ss (@{thms Abs_eq_iff} @ eq_iffs)),
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   183
                   TRY o asm_full_simp_tac (add_ss thms3),
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   184
                   TRY o simp_tac (add_ss thms2),
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   185
                   TRY o asm_full_simp_tac (add_ss (thms1 @ (symmetric fv_bn_eqvts)))] i
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   186
        end)
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   187
  in
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   188
    induct_prove qtys (goals1 @ goals2) qinduct tac ctxt
2492
5ac9a74d22fd post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents: 2491
diff changeset
   189
    |> map atomize
5ac9a74d22fd post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
parents: 2491
diff changeset
   190
    |> map (simplify (HOL_basic_ss addsimps @{thms fun_eq_iff[symmetric]}))
2481
3a5ebb2fcdbf made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
parents: 2475
diff changeset
   191
  end
2475
486d4647bb37 supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
parents: 2451
diff changeset
   192
2451
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
   193
d2e929f51fa9 added fs-instance proofs
Christian Urban <urbanc@in.tum.de>
parents: 2450
diff changeset
   194
2448
b9d9c4540265 proved supports lemmas
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   195
end (* structure *)