src/HOL/Integ/simproc.ML
author paulson
Thu, 23 Sep 1999 13:07:25 +0200
changeset 7585 dca904d4ce4c
parent 7076 a30e024791c6
permissions -rw-r--r--
Sets new component "restrict_to_left"
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5501
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Integ/simproc
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
     2
    ID:         $Id$
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
     5
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
     6
Apply Abel_Cancel to the integers
5501
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
     7
*)
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
     8
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
     9
7585
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    10
(*** Lemmas needed for the simprocs ***)
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5553
diff changeset
    11
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5553
diff changeset
    12
(*Deletion of other terms in the formula, seeking the -x at the front of z*)
7585
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    13
Goal "((x::int) + (y + z) = y + u) = ((x + z) = u)";
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    14
by (stac zadd_left_commute 1);
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    15
by (rtac zadd_left_cancel 1);
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    16
qed "zadd_cancel_21";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5553
diff changeset
    17
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5553
diff changeset
    18
(*A further rule to deal with the case that
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5553
diff changeset
    19
  everything gets cancelled on the right.*)
7585
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    20
Goal "((x::int) + (y + z) = y) = (x = -z)";
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    21
by (stac zadd_left_commute 1);
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    22
by (res_inst_tac [("t", "y")] (zadd_int0_right RS subst) 1
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    23
    THEN stac zadd_left_cancel 1);
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    24
by (simp_tac (simpset() addsimps [eq_zdiff_eq RS sym]) 1);
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    25
qed "zadd_cancel_end";
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    26
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    27
5501
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
    28
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
    29
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    30
structure Int_Cancel_Data =
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    31
struct
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    32
  val ss		= HOL_ss
5610
377acd99d74c simpler interface for Abel_Cancel
paulson
parents: 5595
diff changeset
    33
  val eq_reflection	= eq_reflection
5501
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
    34
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    35
  val thy	= IntDef.thy
7076
a30e024791c6 because intT is now defined in HOLogic
paulson
parents: 6917
diff changeset
    36
  val T		= HOLogic.intT
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    37
  val zero	= Const ("IntDef.int", HOLogic.natT --> T) $ HOLogic.zero
7585
dca904d4ce4c Sets new component "restrict_to_left"
paulson
parents: 7076
diff changeset
    38
  val restrict_to_left  = restrict_to_left
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    39
  val add_cancel_21	= zadd_cancel_21
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    40
  val add_cancel_end	= zadd_cancel_end
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    41
  val add_left_cancel	= zadd_left_cancel
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    42
  val add_assoc		= zadd_assoc
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    43
  val add_commute	= zadd_commute
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    44
  val add_left_commute	= zadd_left_commute
6917
eba301caceea Introduction of integer division algorithm
paulson
parents: 5610
diff changeset
    45
  val add_0		= zadd_int0
eba301caceea Introduction of integer division algorithm
paulson
parents: 5610
diff changeset
    46
  val add_0_right	= zadd_int0_right
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    47
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    48
  val eq_diff_eq	= eq_zdiff_eq
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    49
  val eqI_rules		= [zless_eqI, zeq_eqI, zle_eqI]
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    50
  fun dest_eqI th = 
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    51
      #1 (HOLogic.dest_bin "op =" HOLogic.boolT 
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    52
	      (HOLogic.dest_Trueprop (concl_of th)))
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    53
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    54
  val diff_def		= zdiff_def
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    55
  val minus_add_distrib	= zminus_zadd_distrib
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    56
  val minus_minus	= zminus_zminus
6917
eba301caceea Introduction of integer division algorithm
paulson
parents: 5610
diff changeset
    57
  val minus_0		= zminus_int0
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    58
  val add_inverses	= [zadd_zminus_inverse, zadd_zminus_inverse2];
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    59
  val cancel_simps	= [zadd_zminus_cancel, zminus_zadd_cancel]
5501
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
    60
end;
a63e0c326e6c new files in Integ
paulson
parents:
diff changeset
    61
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    62
structure Int_Cancel = Abel_Cancel (Int_Cancel_Data);
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5553
diff changeset
    63
5595
d283d6120548 now invokes functor
paulson
parents: 5582
diff changeset
    64
Addsimprocs [Int_Cancel.sum_conv, Int_Cancel.rel_conv];
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5553
diff changeset
    65
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5553
diff changeset
    66