Separation_Algebra/Sep_Tactics.thy
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sat, 13 Sep 2014 04:39:07 +0100
changeset 26 1cde7bf45858
parent 25 a5f5b9336007
permissions -rw-r--r--
deleted *~ files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     1
(* Authors: Gerwin Klein and Rafal Kolanski, 2012
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     2
   Maintainers: Gerwin Klein <kleing at cse.unsw.edu.au>
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     3
                Rafal Kolanski <rafal.kolanski at nicta.com.au>
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     4
*)
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     5
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     6
header "Separation Logic Tactics"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     7
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     8
theory Sep_Tactics
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
     9
imports Separation_Algebra 
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    10
uses "sep_tactics.ML"
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
begin
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    13
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    14
text {* A number of proof methods to assist with reasoning about separation logic. *}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    15
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    16
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    17
section {* Selection (move-to-front) tactics *}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    18
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    19
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    20
  fun sep_select_method n ctxt =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    21
        Method.SIMPLE_METHOD' (sep_select_tac ctxt n);
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    22
  fun sep_select_asm_method n ctxt =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    23
        Method.SIMPLE_METHOD' (sep_select_asm_tac ctxt n);
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    24
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    25
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    26
method_setup sep_select = {*
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    27
  Scan.lift Parse.int >> sep_select_method
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    28
*} "Select nth separation conjunct in conclusion"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    29
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    30
method_setup sep_select_asm = {*
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    31
  Scan.lift Parse.int >> sep_select_asm_method
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    32
*} "Select nth separation conjunct in assumptions"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    33
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    34
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    35
section {* Substitution *}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    36
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    37
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    38
  fun sep_subst_method ctxt occs thms =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    39
        SIMPLE_METHOD' (sep_subst_tac ctxt occs thms);
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    40
  fun sep_subst_asm_method ctxt occs thms =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    41
        SIMPLE_METHOD' (sep_subst_asm_tac ctxt occs thms);
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    42
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    43
  val sep_subst_parser =
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    44
        Args.mode "asm"
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    45
        -- Scan.lift (Scan.optional (Args.parens (Scan.repeat Parse.nat)) [0])
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    46
        -- Attrib.thms;
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    47
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    48
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    49
method_setup "sep_subst" = {*
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    50
  sep_subst_parser >>
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    51
    (fn ((asm, occs), thms) => fn ctxt =>
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    52
      (if asm then sep_subst_asm_method else sep_subst_method) ctxt occs thms)
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    53
*}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    54
"single-step substitution after solving one separation logic assumption"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    55
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    56
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    57
section {* Forward Reasoning *}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    58
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    59
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    60
  fun sep_drule_method thms ctxt = SIMPLE_METHOD' (sep_dtac ctxt thms);
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    61
  fun sep_frule_method thms ctxt = SIMPLE_METHOD' (sep_ftac ctxt thms);
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    62
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    63
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    64
method_setup "sep_drule" = {*
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    65
  Attrib.thms >> sep_drule_method
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    66
*} "drule after separating conjunction reordering"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    67
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    68
method_setup "sep_frule" = {*
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    69
  Attrib.thms >> sep_frule_method
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    70
*} "frule after separating conjunction reordering"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    71
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    72
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    73
section {* Backward Reasoning *}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    75
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    76
  fun sep_rule_method thms ctxt = SIMPLE_METHOD' (sep_rtac ctxt thms)
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    77
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    78
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
method_setup "sep_rule" = {*
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
    80
  Attrib.thms >> sep_rule_method
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
*} "applies rule after separating conjunction reordering"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    84
section {* Cancellation of Common Conjuncts via Elimination Rules *}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    85
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    86
ML {*
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    87
  structure SepCancel_Rules = Named_Thms (
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    88
    val name = @{binding "sep_cancel"};
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    89
    val description = "sep_cancel rules";
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    90
  );
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    91
*}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    92
setup SepCancel_Rules.setup
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    93
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    94
text {*
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    95
  The basic @{text sep_cancel_tac} is minimal. It only eliminates
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    96
  erule-derivable conjuncts between an assumption and the conclusion.
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    97
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    98
  To have a more useful tactic, we augment it with more logic, to proceed as
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    99
  follows:
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   100
  \begin{itemize}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   101
  \item try discharge the goal first using @{text tac}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   102
  \item if that fails, invoke @{text sep_cancel_tac}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   103
  \item if @{text sep_cancel_tac} succeeds
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   104
    \begin{itemize}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   105
    \item try to finish off with tac (but ok if that fails)
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   106
    \item try to finish off with @{term sep_true} (but ok if that fails)
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   107
    \end{itemize}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   108
  \end{itemize}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   109
  *}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   110
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   111
ML {*
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   112
  fun sep_cancel_smart_tac ctxt tac =
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   113
    let fun TRY' tac = tac ORELSE' (K all_tac)
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   114
    in
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   115
      tac
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   116
      ORELSE' (sep_cancel_tac ctxt tac
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   117
               THEN' TRY' tac
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   118
               THEN' TRY' (rtac @{thm TrueI}))
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   119
      ORELSE' (etac @{thm sep_conj_sep_emptyE}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   120
               THEN' sep_cancel_tac ctxt tac
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   121
               THEN' TRY' tac
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   122
               THEN' TRY' (rtac @{thm TrueI}))
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   123
    end;
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   124
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   125
  fun sep_cancel_smart_tac_rules ctxt etacs =
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   126
      sep_cancel_smart_tac ctxt (FIRST' ([atac] @ etacs));
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   127
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   128
  fun sep_cancel_method ctxt =
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   129
    let
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   130
      val etacs = map etac (SepCancel_Rules.get ctxt);
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   131
    in
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   132
      SIMPLE_METHOD' (sep_cancel_smart_tac_rules ctxt etacs)
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   133
    end;
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   134
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   135
  val sep_cancel_syntax = Method.sections [
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   136
    Args.add -- Args.colon >> K (I, SepCancel_Rules.add)];
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   137
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   138
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   139
method_setup sep_cancel = {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   140
  sep_cancel_syntax >> K sep_cancel_method
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   141
*} "Separating conjunction conjunct cancellation"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   142
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   143
text {*
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   144
  As above, but use blast with a depth limit to figure out where cancellation
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   145
  can be done. *}
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   146
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   147
ML {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   148
  fun sep_cancel_blast_method ctxt =
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   149
    let
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   150
      val rules = SepCancel_Rules.get ctxt;
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   151
      val tac = Blast.depth_tac (ctxt addIs rules) 10;
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   152
    in
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   153
      SIMPLE_METHOD' (sep_cancel_smart_tac ctxt tac)
25
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   154
    end;
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   155
*}
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   156
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   157
method_setup sep_cancel_blast = {*
a5f5b9336007 thys2 added
Xingyuan Zhang <xingyuanzhang@126.com>
parents: 0
diff changeset
   158
  sep_cancel_syntax >> K sep_cancel_blast_method
0
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   159
*} "Separating conjunction conjunct cancellation using blast"
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   160
1378b654acde initial commit for Isabelle 2013-1
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
   161
end