src/HOL/Presburger.thy
author huffman
Wed, 20 Jun 2007 05:06:56 +0200
changeset 23430 771117253634
parent 23405 8993b3144358
child 23438 dd824e86fa8a
permissions -rw-r--r--
section headings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23148
ef3fa1386102 fixed title;
wenzelm
parents: 23146
diff changeset
     1
(*  Title:      HOL/Presburger.thy
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     2
    ID:         $Id$
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
     3
    Author:     Amine Chaieb, TU Muenchen
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     4
*)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
     5
23430
771117253634 section headings
huffman
parents: 23405
diff changeset
     6
header {* Decision Procedure for Presburger Arithmetic *}
771117253634 section headings
huffman
parents: 23405
diff changeset
     7
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15013
diff changeset
     8
theory Presburger
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents: 23148
diff changeset
     9
imports NatSimprocs SetInterval
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    10
  uses "Tools/Presburger/cooper_data" "Tools/Presburger/qelim" 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    11
       "Tools/Presburger/generated_cooper.ML"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    12
       ("Tools/Presburger/cooper.ML") ("Tools/Presburger/presburger.ML") 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    13
       
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15013
diff changeset
    14
begin
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    15
setup {* Cooper_Data.setup*}
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    16
23430
771117253634 section headings
huffman
parents: 23405
diff changeset
    17
subsection{* The @{text "-\<infinity>"} and @{text "+\<infinity>"} Properties *}
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    18
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    19
lemma minf:
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    20
  "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x<z. P x = P' x; \<exists>z.\<forall>x<z. Q x = Q' x\<rbrakk> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    21
     \<Longrightarrow> \<exists>z.\<forall>x<z. (P x \<and> Q x) = (P' x \<and> Q' x)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    22
  "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x<z. P x = P' x; \<exists>z.\<forall>x<z. Q x = Q' x\<rbrakk> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    23
     \<Longrightarrow> \<exists>z.\<forall>x<z. (P x \<or> Q x) = (P' x \<or> Q' x)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    24
  "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x = t) = False"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    25
  "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x \<noteq> t) = True"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    26
  "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x < t) = True"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    27
  "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x \<le> t) = True"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    28
  "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x > t) = False"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    29
  "\<exists>(z ::'a::{linorder}).\<forall>x<z.(x \<ge> t) = False"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    30
  "\<exists>z.\<forall>(x::'a::{linorder,plus,times})<z. (d dvd x + s) = (d dvd x + s)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    31
  "\<exists>z.\<forall>(x::'a::{linorder,plus,times})<z. (\<not> d dvd x + s) = (\<not> d dvd x + s)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    32
  "\<exists>z.\<forall>x<z. F = F"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    33
  by ((erule exE, erule exE,rule_tac x="min z za" in exI,simp)+, (rule_tac x="t" in exI,fastsimp)+) simp_all
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    34
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    35
lemma pinf:
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    36
  "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x>z. P x = P' x; \<exists>z.\<forall>x>z. Q x = Q' x\<rbrakk> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    37
     \<Longrightarrow> \<exists>z.\<forall>x>z. (P x \<and> Q x) = (P' x \<and> Q' x)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    38
  "\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x>z. P x = P' x; \<exists>z.\<forall>x>z. Q x = Q' x\<rbrakk> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    39
     \<Longrightarrow> \<exists>z.\<forall>x>z. (P x \<or> Q x) = (P' x \<or> Q' x)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    40
  "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x = t) = False"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    41
  "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x \<noteq> t) = True"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    42
  "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x < t) = False"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    43
  "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x \<le> t) = False"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    44
  "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x > t) = True"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    45
  "\<exists>(z ::'a::{linorder}).\<forall>x>z.(x \<ge> t) = True"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    46
  "\<exists>z.\<forall>(x::'a::{linorder,plus,times})>z. (d dvd x + s) = (d dvd x + s)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    47
  "\<exists>z.\<forall>(x::'a::{linorder,plus,times})>z. (\<not> d dvd x + s) = (\<not> d dvd x + s)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    48
  "\<exists>z.\<forall>x>z. F = F"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    49
  by ((erule exE, erule exE,rule_tac x="max z za" in exI,simp)+,(rule_tac x="t" in exI,fastsimp)+) simp_all
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    50
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    51
lemma inf_period:
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    52
  "\<lbrakk>\<forall>x k. P x = P (x - k*D); \<forall>x k. Q x = Q (x - k*D)\<rbrakk> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    53
    \<Longrightarrow> \<forall>x k. (P x \<and> Q x) = (P (x - k*D) \<and> Q (x - k*D))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    54
  "\<lbrakk>\<forall>x k. P x = P (x - k*D); \<forall>x k. Q x = Q (x - k*D)\<rbrakk> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    55
    \<Longrightarrow> \<forall>x k. (P x \<or> Q x) = (P (x - k*D) \<or> Q (x - k*D))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    56
  "(d::'a::{comm_ring}) dvd D \<Longrightarrow> \<forall>x k. (d dvd x + t) = (d dvd (x - k*D) + t)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    57
  "(d::'a::{comm_ring}) dvd D \<Longrightarrow> \<forall>x k. (\<not>d dvd x + t) = (\<not>d dvd (x - k*D) + t)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    58
  "\<forall>x k. F = F"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    59
by simp_all
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    60
  (clarsimp simp add: dvd_def, rule iffI, clarsimp,rule_tac x = "kb - ka*k" in exI,
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    61
    simp add: ring_eq_simps, clarsimp,rule_tac x = "kb + ka*k" in exI,simp add: ring_eq_simps)+
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
    62
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    63
section{* The A and B sets *}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    64
lemma bset:
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    65
  "\<lbrakk>\<forall>x.(\<forall>j \<in> {1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> P x \<longrightarrow> P(x - D) ;
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    66
     \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> Q x \<longrightarrow> Q(x - D)\<rbrakk> \<Longrightarrow> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    67
  \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j) \<longrightarrow> (P x \<and> Q x) \<longrightarrow> (P(x - D) \<and> Q (x - D))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    68
  "\<lbrakk>\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> P x \<longrightarrow> P(x - D) ;
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    69
     \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> Q x \<longrightarrow> Q(x - D)\<rbrakk> \<Longrightarrow> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    70
  \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (P x \<or> Q x) \<longrightarrow> (P(x - D) \<or> Q (x - D))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    71
  "\<lbrakk>D>0; t - 1\<in> B\<rbrakk> \<Longrightarrow> (\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x = t) \<longrightarrow> (x - D = t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    72
  "\<lbrakk>D>0 ; t \<in> B\<rbrakk> \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<noteq> t) \<longrightarrow> (x - D \<noteq> t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    73
  "D>0 \<Longrightarrow> (\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x < t) \<longrightarrow> (x - D < t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    74
  "D>0 \<Longrightarrow> (\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<le> t) \<longrightarrow> (x - D \<le> t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    75
  "\<lbrakk>D>0 ; t \<in> B\<rbrakk> \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x > t) \<longrightarrow> (x - D > t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    76
  "\<lbrakk>D>0 ; t - 1 \<in> B\<rbrakk> \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<ge> t) \<longrightarrow> (x - D \<ge> t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    77
  "d dvd D \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (d dvd x+t) \<longrightarrow> (d dvd (x - D) + t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    78
  "d dvd D \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (\<not>d dvd x+t) \<longrightarrow> (\<not> d dvd (x - D) + t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    79
  "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j) \<longrightarrow> F \<longrightarrow> F"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    80
proof (blast, blast)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    81
  assume dp: "D > 0" and tB: "t - 1\<in> B"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    82
  show "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x = t) \<longrightarrow> (x - D = t))" 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    83
    apply (rule allI, rule impI,erule ballE[where x="1"],erule ballE[where x="t - 1"])
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    84
    using dp tB by simp_all
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    85
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    86
  assume dp: "D > 0" and tB: "t \<in> B"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    87
  show "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<noteq> t) \<longrightarrow> (x - D \<noteq> t))" 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    88
    apply (rule allI, rule impI,erule ballE[where x="D"],erule ballE[where x="t"])
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    89
    using dp tB by simp_all
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    90
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    91
  assume dp: "D > 0" thus "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x < t) \<longrightarrow> (x - D < t))" by arith
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    92
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    93
  assume dp: "D > 0" thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<le> t) \<longrightarrow> (x - D \<le> t)" by arith
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    94
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    95
  assume dp: "D > 0" and tB:"t \<in> B"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    96
  {fix x assume nob: "\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j" and g: "x > t" and ng: "\<not> (x - D) > t"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    97
    hence "x -t \<le> D" and "1 \<le> x - t" by simp+
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    98
      hence "\<exists>j \<in> {1 .. D}. x - t = j" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
    99
      hence "\<exists>j \<in> {1 .. D}. x = t + j" by (simp add: ring_eq_simps)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   100
      with nob tB have "False" by simp}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   101
  thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x > t) \<longrightarrow> (x - D > t)" by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   102
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   103
  assume dp: "D > 0" and tB:"t - 1\<in> B"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   104
  {fix x assume nob: "\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j" and g: "x \<ge> t" and ng: "\<not> (x - D) \<ge> t"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   105
    hence "x - (t - 1) \<le> D" and "1 \<le> x - (t - 1)" by simp+
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   106
      hence "\<exists>j \<in> {1 .. D}. x - (t - 1) = j" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   107
      hence "\<exists>j \<in> {1 .. D}. x = (t - 1) + j" by (simp add: ring_eq_simps)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   108
      with nob tB have "False" by simp}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   109
  thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (x \<ge> t) \<longrightarrow> (x - D \<ge> t)" by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   110
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   111
  assume d: "d dvd D"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   112
  {fix x assume H: "d dvd x + t" with d have "d dvd (x - D) + t"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   113
      by (clarsimp simp add: dvd_def,rule_tac x= "ka - k" in exI,simp add: ring_eq_simps)}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   114
  thus "\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (d dvd x+t) \<longrightarrow> (d dvd (x - D) + t)" by simp
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   115
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   116
  assume d: "d dvd D"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   117
  {fix x assume H: "\<not>(d dvd x + t)" with d have "\<not>d dvd (x - D) + t"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   118
      by (clarsimp simp add: dvd_def,erule_tac x= "ka + k" in allE,simp add: ring_eq_simps)}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   119
  thus "\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>B. x \<noteq> b + j)\<longrightarrow> (\<not>d dvd x+t) \<longrightarrow> (\<not>d dvd (x - D) + t)" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   120
qed blast
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   121
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   122
lemma aset:
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   123
  "\<lbrakk>\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> P x \<longrightarrow> P(x + D) ;
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   124
     \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> Q x \<longrightarrow> Q(x + D)\<rbrakk> \<Longrightarrow> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   125
  \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j) \<longrightarrow> (P x \<and> Q x) \<longrightarrow> (P(x + D) \<and> Q (x + D))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   126
  "\<lbrakk>\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> P x \<longrightarrow> P(x + D) ;
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   127
     \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> Q x \<longrightarrow> Q(x + D)\<rbrakk> \<Longrightarrow> 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   128
  \<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (P x \<or> Q x) \<longrightarrow> (P(x + D) \<or> Q (x + D))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   129
  "\<lbrakk>D>0; t + 1\<in> A\<rbrakk> \<Longrightarrow> (\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x = t) \<longrightarrow> (x + D = t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   130
  "\<lbrakk>D>0 ; t \<in> A\<rbrakk> \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<noteq> t) \<longrightarrow> (x + D \<noteq> t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   131
  "\<lbrakk>D>0; t\<in> A\<rbrakk> \<Longrightarrow>(\<forall>(x::int). (\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x < t) \<longrightarrow> (x + D < t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   132
  "\<lbrakk>D>0; t + 1 \<in> A\<rbrakk> \<Longrightarrow> (\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<le> t) \<longrightarrow> (x + D \<le> t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   133
  "D>0 \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x > t) \<longrightarrow> (x + D > t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   134
  "D>0 \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<ge> t) \<longrightarrow> (x + D \<ge> t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   135
  "d dvd D \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (d dvd x+t) \<longrightarrow> (d dvd (x + D) + t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   136
  "d dvd D \<Longrightarrow>(\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (\<not>d dvd x+t) \<longrightarrow> (\<not> d dvd (x + D) + t))"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   137
  "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j) \<longrightarrow> F \<longrightarrow> F"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   138
proof (blast, blast)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   139
  assume dp: "D > 0" and tA: "t + 1 \<in> A"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   140
  show "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x = t) \<longrightarrow> (x + D = t))" 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   141
    apply (rule allI, rule impI,erule ballE[where x="1"],erule ballE[where x="t + 1"])
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   142
    using dp tA by simp_all
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   143
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   144
  assume dp: "D > 0" and tA: "t \<in> A"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   145
  show "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<noteq> t) \<longrightarrow> (x + D \<noteq> t))" 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   146
    apply (rule allI, rule impI,erule ballE[where x="D"],erule ballE[where x="t"])
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   147
    using dp tA by simp_all
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   148
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   149
  assume dp: "D > 0" thus "(\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x > t) \<longrightarrow> (x + D > t))" by arith
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   150
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   151
  assume dp: "D > 0" thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<ge> t) \<longrightarrow> (x + D \<ge> t)" by arith
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   152
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   153
  assume dp: "D > 0" and tA:"t \<in> A"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   154
  {fix x assume nob: "\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j" and g: "x < t" and ng: "\<not> (x + D) < t"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   155
    hence "t - x \<le> D" and "1 \<le> t - x" by simp+
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   156
      hence "\<exists>j \<in> {1 .. D}. t - x = j" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   157
      hence "\<exists>j \<in> {1 .. D}. x = t - j" by (auto simp add: ring_eq_simps) 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   158
      with nob tA have "False" by simp}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   159
  thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x < t) \<longrightarrow> (x + D < t)" by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   160
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   161
  assume dp: "D > 0" and tA:"t + 1\<in> A"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   162
  {fix x assume nob: "\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j" and g: "x \<le> t" and ng: "\<not> (x + D) \<le> t"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   163
    hence "(t + 1) - x \<le> D" and "1 \<le> (t + 1) - x" by (simp_all add: ring_eq_simps)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   164
      hence "\<exists>j \<in> {1 .. D}. (t + 1) - x = j" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   165
      hence "\<exists>j \<in> {1 .. D}. x = (t + 1) - j" by (auto simp add: ring_eq_simps)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   166
      with nob tA have "False" by simp}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   167
  thus "\<forall>x.(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (x \<le> t) \<longrightarrow> (x + D \<le> t)" by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   168
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   169
  assume d: "d dvd D"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   170
  {fix x assume H: "d dvd x + t" with d have "d dvd (x + D) + t"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   171
      by (clarsimp simp add: dvd_def,rule_tac x= "ka + k" in exI,simp add: ring_eq_simps)}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   172
  thus "\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (d dvd x+t) \<longrightarrow> (d dvd (x + D) + t)" by simp
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   173
next
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   174
  assume d: "d dvd D"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   175
  {fix x assume H: "\<not>(d dvd x + t)" with d have "\<not>d dvd (x + D) + t"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   176
      by (clarsimp simp add: dvd_def,erule_tac x= "ka - k" in allE,simp add: ring_eq_simps)}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   177
  thus "\<forall>(x::int).(\<forall>j\<in>{1 .. D}. \<forall>b\<in>A. x \<noteq> b - j)\<longrightarrow> (\<not>d dvd x+t) \<longrightarrow> (\<not>d dvd (x + D) + t)" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   178
qed blast
14577
dbb95b825244 tuned document;
wenzelm
parents: 14485
diff changeset
   179
23430
771117253634 section headings
huffman
parents: 23405
diff changeset
   180
subsection{* Cooper's Theorem @{text "-\<infinity>"} and @{text "+\<infinity>"} Version *}
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   181
23430
771117253634 section headings
huffman
parents: 23405
diff changeset
   182
subsubsection{* First some trivial facts about periodic sets or predicates *}
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   183
lemma periodic_finite_ex:
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   184
  assumes dpos: "(0::int) < d" and modd: "ALL x k. P x = P(x - k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   185
  shows "(EX x. P x) = (EX j : {1..d}. P j)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   186
  (is "?LHS = ?RHS")
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   187
proof
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   188
  assume ?LHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   189
  then obtain x where P: "P x" ..
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   190
  have "x mod d = x - (x div d)*d" by(simp add:zmod_zdiv_equality mult_ac eq_diff_eq)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   191
  hence Pmod: "P x = P(x mod d)" using modd by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   192
  show ?RHS
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   193
  proof (cases)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   194
    assume "x mod d = 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   195
    hence "P 0" using P Pmod by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   196
    moreover have "P 0 = P(0 - (-1)*d)" using modd by blast
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   197
    ultimately have "P d" by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   198
    moreover have "d : {1..d}" using dpos by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   199
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   200
  next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   201
    assume not0: "x mod d \<noteq> 0"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   202
    have "P(x mod d)" using dpos P Pmod by(simp add:pos_mod_sign pos_mod_bound)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   203
    moreover have "x mod d : {1..d}"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   204
    proof -
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   205
      from dpos have "0 \<le> x mod d" by(rule pos_mod_sign)
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   206
      moreover from dpos have "x mod d < d" by(rule pos_mod_bound)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   207
      ultimately show ?thesis using not0 by(simp add:atLeastAtMost_iff)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   208
    qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   209
    ultimately show ?RHS ..
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   210
  qed
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   211
qed auto
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   212
23430
771117253634 section headings
huffman
parents: 23405
diff changeset
   213
subsubsection{* The @{text "-\<infinity>"} Version*}
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   214
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   215
lemma decr_lemma: "0 < (d::int) \<Longrightarrow> x - (abs(x-z)+1) * d < z"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   216
by(induct rule: int_gr_induct,simp_all add:int_distrib)
14577
dbb95b825244 tuned document;
wenzelm
parents: 14485
diff changeset
   217
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   218
lemma incr_lemma: "0 < (d::int) \<Longrightarrow> z < x + (abs(x-z)+1) * d"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   219
by(induct rule: int_gr_induct, simp_all add:int_distrib)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   220
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   221
theorem int_induct[case_names base step1 step2]:
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   222
  assumes 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   223
  base: "P(k::int)" and step1: "\<And>i. \<lbrakk>k \<le> i; P i\<rbrakk> \<Longrightarrow> P(i+1)" and
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   224
  step2: "\<And>i. \<lbrakk>k \<ge> i; P i\<rbrakk> \<Longrightarrow> P(i - 1)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   225
  shows "P i"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   226
proof -
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   227
  have "i \<le> k \<or> i\<ge> k" by arith
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   228
  thus ?thesis using prems int_ge_induct[where P="P" and k="k" and i="i"] int_le_induct[where P="P" and k="k" and i="i"] by blast
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   229
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   230
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   231
lemma decr_mult_lemma:
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   232
  assumes dpos: "(0::int) < d" and minus: "\<forall>x. P x \<longrightarrow> P(x - d)" and knneg: "0 <= k"
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   233
  shows "ALL x. P x \<longrightarrow> P(x - k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   234
using knneg
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   235
proof (induct rule:int_ge_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   236
  case base thus ?case by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   237
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   238
  case (step i)
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   239
  {fix x
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   240
    have "P x \<longrightarrow> P (x - i * d)" using step.hyps by blast
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   241
    also have "\<dots> \<longrightarrow> P(x - (i + 1) * d)" using minus[THEN spec, of "x - i * d"]
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 14577
diff changeset
   242
      by (simp add:int_distrib OrderedGroup.diff_diff_eq[symmetric])
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   243
    ultimately have "P x \<longrightarrow> P(x - (i + 1) * d)" by blast}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   244
  thus ?case ..
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   245
qed
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   246
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   247
lemma  minusinfinity:
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   248
  assumes dpos: "0 < d" and
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   249
    P1eqP1: "ALL x k. P1 x = P1(x - k*d)" and ePeqP1: "EX z::int. ALL x. x < z \<longrightarrow> (P x = P1 x)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   250
  shows "(EX x. P1 x) \<longrightarrow> (EX x. P x)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   251
proof
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   252
  assume eP1: "EX x. P1 x"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   253
  then obtain x where P1: "P1 x" ..
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   254
  from ePeqP1 obtain z where P1eqP: "ALL x. x < z \<longrightarrow> (P x = P1 x)" ..
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   255
  let ?w = "x - (abs(x-z)+1) * d"
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   256
  from dpos have w: "?w < z" by(rule decr_lemma)
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   257
  have "P1 x = P1 ?w" using P1eqP1 by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   258
  also have "\<dots> = P(?w)" using w P1eqP by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   259
  finally have "P ?w" using P1 by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   260
  thus "EX x. P x" ..
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   261
qed
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   262
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   263
lemma cpmi: 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   264
  assumes dp: "0 < D" and p1:"\<exists>z. \<forall> x< z. P x = P' x"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   265
  and nb:"\<forall>x.(\<forall> j\<in> {1..D}. \<forall>(b::int) \<in> B. x \<noteq> b+j) --> P (x) --> P (x - D)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   266
  and pd: "\<forall> x k. P' x = P' (x-k*D)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   267
  shows "(\<exists>x. P x) = ((\<exists> j\<in> {1..D} . P' j) | (\<exists> j \<in> {1..D}.\<exists> b\<in> B. P (b+j)))" 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   268
         (is "?L = (?R1 \<or> ?R2)")
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   269
proof-
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   270
 {assume "?R2" hence "?L"  by blast}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   271
 moreover
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   272
 {assume H:"?R1" hence "?L" using minusinfinity[OF dp pd p1] periodic_finite_ex[OF dp pd] by simp}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   273
 moreover 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   274
 { fix x
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   275
   assume P: "P x" and H: "\<not> ?R2"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   276
   {fix y assume "\<not> (\<exists>j\<in>{1..D}. \<exists>b\<in>B. P (b + j))" and P: "P y"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   277
     hence "~(EX (j::int) : {1..D}. EX (b::int) : B. y = b+j)" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   278
     with nb P  have "P (y - D)" by auto }
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   279
   hence "ALL x.~(EX (j::int) : {1..D}. EX (b::int) : B. P(b+j)) --> P (x) --> P (x - D)" by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   280
   with H P have th: " \<forall>x. P x \<longrightarrow> P (x - D)" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   281
   from p1 obtain z where z: "ALL x. x < z --> (P x = P' x)" by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   282
   let ?y = "x - (\<bar>x - z\<bar> + 1)*D"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   283
   have zp: "0 <= (\<bar>x - z\<bar> + 1)" by arith
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   284
   from dp have yz: "?y < z" using decr_lemma[OF dp] by simp   
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   285
   from z[rule_format, OF yz] decr_mult_lemma[OF dp th zp, rule_format, OF P] have th2: " P' ?y" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   286
   with periodic_finite_ex[OF dp pd]
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   287
   have "?R1" by blast}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   288
 ultimately show ?thesis by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   289
qed
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   290
23430
771117253634 section headings
huffman
parents: 23405
diff changeset
   291
subsubsection {* The @{text "+\<infinity>"} Version*}
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   292
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   293
lemma  plusinfinity:
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   294
  assumes dpos: "(0::int) < d" and
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   295
    P1eqP1: "\<forall>x k. P' x = P'(x - k*d)" and ePeqP1: "\<exists> z. \<forall> x>z. P x = P' x"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   296
  shows "(\<exists> x. P' x) \<longrightarrow> (\<exists> x. P x)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   297
proof
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   298
  assume eP1: "EX x. P' x"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   299
  then obtain x where P1: "P' x" ..
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   300
  from ePeqP1 obtain z where P1eqP: "\<forall>x>z. P x = P' x" ..
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   301
  let ?w' = "x + (abs(x-z)+1) * d"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   302
  let ?w = "x - (-(abs(x-z) + 1))*d"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   303
  have ww'[simp]: "?w = ?w'" by (simp add: ring_eq_simps)
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   304
  from dpos have w: "?w > z" by(simp only: ww' incr_lemma)
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   305
  hence "P' x = P' ?w" using P1eqP1 by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   306
  also have "\<dots> = P(?w)" using w P1eqP by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   307
  finally have "P ?w" using P1 by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   308
  thus "EX x. P x" ..
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   309
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   310
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   311
lemma incr_mult_lemma:
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   312
  assumes dpos: "(0::int) < d" and plus: "ALL x::int. P x \<longrightarrow> P(x + d)" and knneg: "0 <= k"
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   313
  shows "ALL x. P x \<longrightarrow> P(x + k*d)"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   314
using knneg
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   315
proof (induct rule:int_ge_induct)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   316
  case base thus ?case by simp
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   317
next
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   318
  case (step i)
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   319
  {fix x
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   320
    have "P x \<longrightarrow> P (x + i * d)" using step.hyps by blast
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   321
    also have "\<dots> \<longrightarrow> P(x + (i + 1) * d)" using plus[THEN spec, of "x + i * d"]
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   322
      by (simp add:int_distrib zadd_ac)
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   323
    ultimately have "P x \<longrightarrow> P(x + (i + 1) * d)" by blast}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   324
  thus ?case ..
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   325
qed
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   326
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   327
lemma cppi: 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   328
  assumes dp: "0 < D" and p1:"\<exists>z. \<forall> x> z. P x = P' x"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   329
  and nb:"\<forall>x.(\<forall> j\<in> {1..D}. \<forall>(b::int) \<in> A. x \<noteq> b - j) --> P (x) --> P (x + D)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   330
  and pd: "\<forall> x k. P' x= P' (x-k*D)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   331
  shows "(\<exists>x. P x) = ((\<exists> j\<in> {1..D} . P' j) | (\<exists> j \<in> {1..D}.\<exists> b\<in> A. P (b - j)))" (is "?L = (?R1 \<or> ?R2)")
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   332
proof-
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   333
 {assume "?R2" hence "?L"  by blast}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   334
 moreover
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   335
 {assume H:"?R1" hence "?L" using plusinfinity[OF dp pd p1] periodic_finite_ex[OF dp pd] by simp}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   336
 moreover 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   337
 { fix x
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   338
   assume P: "P x" and H: "\<not> ?R2"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   339
   {fix y assume "\<not> (\<exists>j\<in>{1..D}. \<exists>b\<in>A. P (b - j))" and P: "P y"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   340
     hence "~(EX (j::int) : {1..D}. EX (b::int) : A. y = b - j)" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   341
     with nb P  have "P (y + D)" by auto }
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   342
   hence "ALL x.~(EX (j::int) : {1..D}. EX (b::int) : A. P(b-j)) --> P (x) --> P (x + D)" by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   343
   with H P have th: " \<forall>x. P x \<longrightarrow> P (x + D)" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   344
   from p1 obtain z where z: "ALL x. x > z --> (P x = P' x)" by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   345
   let ?y = "x + (\<bar>x - z\<bar> + 1)*D"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   346
   have zp: "0 <= (\<bar>x - z\<bar> + 1)" by arith
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   347
   from dp have yz: "?y > z" using incr_lemma[OF dp] by simp
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   348
   from z[rule_format, OF yz] incr_mult_lemma[OF dp th zp, rule_format, OF P] have th2: " P' ?y" by auto
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   349
   with periodic_finite_ex[OF dp pd]
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   350
   have "?R1" by blast}
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   351
 ultimately show ?thesis by blast
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   352
qed
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   353
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   354
lemma simp_from_to: "{i..j::int} = (if j < i then {} else insert i {i+1..j})"
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   355
apply(simp add:atLeastAtMost_def atLeast_def atMost_def)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   356
apply(fastsimp)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   357
done
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   358
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   359
theorem unity_coeff_ex: "(\<exists>(x::'a::{semiring_0}). P (l * x)) \<equiv> (\<exists>x. l dvd (x + 0) \<and> P x)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   360
  apply (rule eq_reflection[symmetric])
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   361
  apply (rule iffI)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   362
  defer
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   363
  apply (erule exE)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   364
  apply (rule_tac x = "l * x" in exI)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   365
  apply (simp add: dvd_def)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   366
  apply (rule_tac x="x" in exI, simp)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   367
  apply (erule exE)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   368
  apply (erule conjE)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   369
  apply (erule dvdE)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   370
  apply (rule_tac x = k in exI)
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   371
  apply simp
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   372
  done
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   373
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   374
lemma zdvd_mono: assumes not0: "(k::int) \<noteq> 0"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   375
shows "((m::int) dvd t) \<equiv> (k*m dvd k*t)" 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   376
  using not0 by (simp add: dvd_def)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   377
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   378
lemma uminus_dvd_conv: "(d dvd (t::int)) \<equiv> (-d dvd t)" "(d dvd (t::int)) \<equiv> (d dvd -t)"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   379
  by simp_all
14577
dbb95b825244 tuned document;
wenzelm
parents: 14485
diff changeset
   380
text {* \bigskip Theorems for transforming predicates on nat to predicates on @{text int}*}
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   381
lemma all_nat: "(\<forall>x::nat. P x) = (\<forall>x::int. 0 <= x \<longrightarrow> P (nat x))"
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   382
  by (simp split add: split_nat)
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   383
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   384
lemma ex_nat: "(\<exists>x::nat. P x) = (\<exists>x::int. 0 <= x \<and> P (nat x))"
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23333
diff changeset
   385
  apply (auto split add: split_nat)
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23333
diff changeset
   386
  apply (rule_tac x="int x" in exI, simp)
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23333
diff changeset
   387
  apply (rule_tac x = "nat x" in exI,erule_tac x = "nat x" in allE, simp)
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23333
diff changeset
   388
  done
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   389
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   390
lemma zdiff_int_split: "P (int (x - y)) =
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   391
  ((y \<le> x \<longrightarrow> P (int x - int y)) \<and> (x < y \<longrightarrow> P 0))"
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23333
diff changeset
   392
  by (case_tac "y \<le> x", simp_all)
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   393
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   394
lemma number_of1: "(0::int) <= number_of n \<Longrightarrow> (0::int) <= number_of (n BIT b)" by simp
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   395
lemma number_of2: "(0::int) <= Numeral0" by simp
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   396
lemma Suc_plus1: "Suc n = n + 1" by simp
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   397
14577
dbb95b825244 tuned document;
wenzelm
parents: 14485
diff changeset
   398
text {*
dbb95b825244 tuned document;
wenzelm
parents: 14485
diff changeset
   399
  \medskip Specific instances of congruence rules, to prevent
dbb95b825244 tuned document;
wenzelm
parents: 14485
diff changeset
   400
  simplifier from looping. *}
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   401
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   402
theorem imp_le_cong: "(0 <= x \<Longrightarrow> P = P') \<Longrightarrow> (0 <= (x::int) \<longrightarrow> P) = (0 <= x \<longrightarrow> P')" by simp
18202
46af82efd311 presburger method updated to deal better with mod and div, tweo lemmas added to Divides.thy
chaieb
parents: 17589
diff changeset
   403
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   404
theorem conj_le_cong: "(0 <= x \<Longrightarrow> P = P') \<Longrightarrow> (0 <= (x::int) \<and> P) = (0 <= x \<and> P')" 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   405
  by (simp cong: conj_cong)
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20217
diff changeset
   406
lemma int_eq_number_of_eq:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20217
diff changeset
   407
  "(((number_of v)::int) = (number_of w)) = iszero ((number_of (v + (uminus w)))::int)"
18202
46af82efd311 presburger method updated to deal better with mod and div, tweo lemmas added to Divides.thy
chaieb
parents: 17589
diff changeset
   408
  by simp
46af82efd311 presburger method updated to deal better with mod and div, tweo lemmas added to Divides.thy
chaieb
parents: 17589
diff changeset
   409
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   410
lemma mod_eq0_dvd_iff[presburger]: "(m::nat) mod n = 0 \<longleftrightarrow> n dvd m"
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   411
unfolding dvd_eq_mod_eq_0[symmetric] ..
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   412
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   413
lemma zmod_eq0_zdvd_iff[presburger]: "(m::int) mod n = 0 \<longleftrightarrow> n dvd m"
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   414
unfolding zdvd_iff_zmod_eq_0[symmetric] ..
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   415
declare mod_1[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   416
declare mod_0[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   417
declare zmod_1[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   418
declare zmod_zero[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   419
declare zmod_self[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   420
declare mod_self[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   421
declare DIVISION_BY_ZERO_MOD[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   422
declare nat_mod_div_trivial[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   423
declare div_mod_equality2[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   424
declare div_mod_equality[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   425
declare mod_div_equality2[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   426
declare mod_div_equality[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   427
declare mod_mult_self1[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   428
declare mod_mult_self2[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   429
declare zdiv_zmod_equality2[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   430
declare zdiv_zmod_equality[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   431
declare mod2_Suc_Suc[presburger]
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   432
lemma [presburger]: "(a::int) div 0 = 0" and [presburger]: "a mod 0 = a"
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   433
using IntDiv.DIVISION_BY_ZERO by blast+
18202
46af82efd311 presburger method updated to deal better with mod and div, tweo lemmas added to Divides.thy
chaieb
parents: 17589
diff changeset
   434
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   435
use "Tools/Presburger/cooper.ML"
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   436
oracle linzqe_oracle ("term") = Coopereif.cooper_oracle
18202
46af82efd311 presburger method updated to deal better with mod and div, tweo lemmas added to Divides.thy
chaieb
parents: 17589
diff changeset
   437
23146
0bc590051d95 moved Integ files to canonical place;
wenzelm
parents: 22801
diff changeset
   438
use "Tools/Presburger/presburger.ML"
13876
68f4ed8311ac New decision procedure for Presburger arithmetic.
berghofe
parents:
diff changeset
   439
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   440
setup {* 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   441
  arith_tactic_add 
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   442
    (mk_arith_tactic "presburger" (fn i => fn st =>
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   443
       (warning "Trying Presburger arithmetic ...";   
23333
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   444
    Presburger.cooper_tac true [] [] ((ProofContext.init o theory_of_thm) st) i st)))
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   445
  (* FIXME!!!!!!! get the right context!!*)	
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   446
*}
23333
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   447
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   448
method_setup presburger = {*
23333
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   449
let
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   450
 fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ()
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   451
 fun simple_keyword k = Scan.lift (Args.$$$ k) >> K ()
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   452
 val addN = "add"
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   453
 val delN = "del"
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   454
 val elimN = "elim"
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   455
 val any_keyword = keyword addN || keyword delN || simple_keyword elimN
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   456
 val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   457
in
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   458
  fn src => Method.syntax 
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   459
   ((Scan.optional (simple_keyword elimN >> K false) true) -- 
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   460
    (Scan.optional (keyword addN |-- thms) []) -- 
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   461
    (Scan.optional (keyword delN |-- thms) [])) src 
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   462
  #> (fn (((elim, add_ths), del_ths),ctxt) => 
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   463
         Method.SIMPLE_METHOD' (Presburger.cooper_tac elim add_ths del_ths ctxt))
ec5b4ab52026 Method now takes theorems to be added or deleted from a simpset for simplificatio before the core method starts
chaieb
parents: 23314
diff changeset
   464
end
23314
6894137e854a A new and cleaned up Theory for QE. for Presburger arithmetic
chaieb
parents: 23253
diff changeset
   465
*} ""
22801
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   466
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   467
lemma [presburger]: "m mod 2 = (1::nat) \<longleftrightarrow> \<not> 2 dvd m " by presburger
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   468
lemma [presburger]: "m mod 2 = Suc 0 \<longleftrightarrow> \<not> 2 dvd m " by presburger
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   469
lemma [presburger]: "m mod (Suc (Suc 0)) = (1::nat) \<longleftrightarrow> \<not> 2 dvd m " by presburger
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   470
lemma [presburger]: "m mod (Suc (Suc 0)) = Suc 0 \<longleftrightarrow> \<not> 2 dvd m " by presburger
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   471
lemma [presburger]: "m mod 2 = (1::int) \<longleftrightarrow> \<not> 2 dvd m " by presburger
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   472
22801
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   473
subsection {* Code generator setup *}
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   474
text {*
22801
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   475
  Presburger arithmetic is convenient to prove some
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   476
  of the following code lemmas on integer numerals:
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   477
*}
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   478
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   479
lemma eq_Pls_Pls:
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   480
  "Numeral.Pls = Numeral.Pls \<longleftrightarrow> True" by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   481
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   482
lemma eq_Pls_Min:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   483
  "Numeral.Pls = Numeral.Min \<longleftrightarrow> False"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   484
  unfolding Pls_def Min_def by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   485
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   486
lemma eq_Pls_Bit0:
21454
a1937c51ed88 dropped eq const
haftmann
parents: 21046
diff changeset
   487
  "Numeral.Pls = Numeral.Bit k bit.B0 \<longleftrightarrow> Numeral.Pls = k"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   488
  unfolding Pls_def Bit_def bit.cases by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   489
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   490
lemma eq_Pls_Bit1:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   491
  "Numeral.Pls = Numeral.Bit k bit.B1 \<longleftrightarrow> False"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   492
  unfolding Pls_def Bit_def bit.cases by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   493
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   494
lemma eq_Min_Pls:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   495
  "Numeral.Min = Numeral.Pls \<longleftrightarrow> False"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   496
  unfolding Pls_def Min_def by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   497
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   498
lemma eq_Min_Min:
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   499
  "Numeral.Min = Numeral.Min \<longleftrightarrow> True" by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   500
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   501
lemma eq_Min_Bit0:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   502
  "Numeral.Min = Numeral.Bit k bit.B0 \<longleftrightarrow> False"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   503
  unfolding Min_def Bit_def bit.cases by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   504
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   505
lemma eq_Min_Bit1:
21454
a1937c51ed88 dropped eq const
haftmann
parents: 21046
diff changeset
   506
  "Numeral.Min = Numeral.Bit k bit.B1 \<longleftrightarrow> Numeral.Min = k"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   507
  unfolding Min_def Bit_def bit.cases by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   508
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   509
lemma eq_Bit0_Pls:
21454
a1937c51ed88 dropped eq const
haftmann
parents: 21046
diff changeset
   510
  "Numeral.Bit k bit.B0 = Numeral.Pls \<longleftrightarrow> Numeral.Pls = k"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   511
  unfolding Pls_def Bit_def bit.cases by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   512
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   513
lemma eq_Bit1_Pls:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   514
  "Numeral.Bit k bit.B1 = Numeral.Pls \<longleftrightarrow> False"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   515
  unfolding Pls_def Bit_def bit.cases  by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   516
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   517
lemma eq_Bit0_Min:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   518
  "Numeral.Bit k bit.B0 = Numeral.Min \<longleftrightarrow> False"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   519
  unfolding Min_def Bit_def bit.cases  by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   520
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   521
lemma eq_Bit1_Min:
21454
a1937c51ed88 dropped eq const
haftmann
parents: 21046
diff changeset
   522
  "(Numeral.Bit k bit.B1) = Numeral.Min \<longleftrightarrow> Numeral.Min = k"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   523
  unfolding Min_def Bit_def bit.cases  by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   524
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   525
lemma eq_Bit_Bit:
21454
a1937c51ed88 dropped eq const
haftmann
parents: 21046
diff changeset
   526
  "Numeral.Bit k1 v1 = Numeral.Bit k2 v2 \<longleftrightarrow>
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   527
    v1 = v2 \<and> k1 = k2" 
21454
a1937c51ed88 dropped eq const
haftmann
parents: 21046
diff changeset
   528
  unfolding Bit_def
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   529
  apply (cases v1)
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   530
  apply (cases v2)
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   531
  apply auto
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   532
  apply presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   533
  apply (cases v2)
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   534
  apply auto
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   535
  apply presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   536
  apply (cases v2)
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   537
  apply auto
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   538
done
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   539
22801
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   540
lemma eq_number_of:
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   541
  "(number_of k \<Colon> int) = number_of l \<longleftrightarrow> k = l" 
22801
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   542
  unfolding number_of_is_id ..
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   543
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   544
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   545
lemma less_eq_Pls_Pls:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   546
  "Numeral.Pls \<le> Numeral.Pls \<longleftrightarrow> True" by rule+
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   547
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   548
lemma less_eq_Pls_Min:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   549
  "Numeral.Pls \<le> Numeral.Min \<longleftrightarrow> False"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   550
  unfolding Pls_def Min_def by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   551
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   552
lemma less_eq_Pls_Bit:
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   553
  "Numeral.Pls \<le> Numeral.Bit k v \<longleftrightarrow> Numeral.Pls \<le> k"
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   554
  unfolding Pls_def Bit_def by (cases v) auto
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   555
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   556
lemma less_eq_Min_Pls:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   557
  "Numeral.Min \<le> Numeral.Pls \<longleftrightarrow> True"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   558
  unfolding Pls_def Min_def by presburger
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   559
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   560
lemma less_eq_Min_Min:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   561
  "Numeral.Min \<le> Numeral.Min \<longleftrightarrow> True" by rule+
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   562
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   563
lemma less_eq_Min_Bit0:
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   564
  "Numeral.Min \<le> Numeral.Bit k bit.B0 \<longleftrightarrow> Numeral.Min < k"
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   565
  unfolding Min_def Bit_def by auto
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   566
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   567
lemma less_eq_Min_Bit1:
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   568
  "Numeral.Min \<le> Numeral.Bit k bit.B1 \<longleftrightarrow> Numeral.Min \<le> k"
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   569
  unfolding Min_def Bit_def by auto
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   570
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   571
lemma less_eq_Bit0_Pls:
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   572
  "Numeral.Bit k bit.B0 \<le> Numeral.Pls \<longleftrightarrow> k \<le> Numeral.Pls"
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   573
  unfolding Pls_def Bit_def by simp
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   574
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   575
lemma less_eq_Bit1_Pls:
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   576
  "Numeral.Bit k bit.B1 \<le> Numeral.Pls \<longleftrightarrow> k < Numeral.Pls"
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   577
  unfolding Pls_def Bit_def by auto
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   578
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   579
lemma less_eq_Bit_Min:
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   580
  "Numeral.Bit k v \<le> Numeral.Min \<longleftrightarrow> k \<le> Numeral.Min"
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   581
  unfolding Min_def Bit_def by (cases v) auto
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   582
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   583
lemma less_eq_Bit0_Bit:
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   584
  "Numeral.Bit k1 bit.B0 \<le> Numeral.Bit k2 v \<longleftrightarrow> k1 \<le> k2"
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   585
  unfolding Bit_def bit.cases by (cases v) auto
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   586
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   587
lemma less_eq_Bit_Bit1:
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   588
  "Numeral.Bit k1 v \<le> Numeral.Bit k2 bit.B1 \<longleftrightarrow> k1 \<le> k2"
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   589
  unfolding Bit_def bit.cases by (cases v) auto
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   590
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   591
lemma less_eq_Bit1_Bit0:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   592
  "Numeral.Bit k1 bit.B1 \<le> Numeral.Bit k2 bit.B0 \<longleftrightarrow> k1 < k2"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   593
  unfolding Bit_def by (auto split: bit.split)
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   594
22801
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   595
lemma less_eq_number_of:
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   596
  "(number_of k \<Colon> int) \<le> number_of l \<longleftrightarrow> k \<le> l"
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   597
  unfolding number_of_is_id ..
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   598
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   599
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   600
lemma less_Pls_Pls:
23405
8993b3144358 moved lemma all_not_ex to HOL.thy ; tuned proofs
chaieb
parents: 23390
diff changeset
   601
  "Numeral.Pls < Numeral.Pls \<longleftrightarrow> False" by simp 
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   602
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   603
lemma less_Pls_Min:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   604
  "Numeral.Pls < Numeral.Min \<longleftrightarrow> False"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   605
  unfolding Pls_def Min_def  by presburger 
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   606
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   607
lemma less_Pls_Bit0:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   608
  "Numeral.Pls < Numeral.Bit k bit.B0 \<longleftrightarrow> Numeral.Pls < k"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   609
  unfolding Pls_def Bit_def by auto
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   610
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   611
lemma less_Pls_Bit1:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   612
  "Numeral.Pls < Numeral.Bit k bit.B1 \<longleftrightarrow> Numeral.Pls \<le> k"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   613
  unfolding Pls_def Bit_def by auto
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   614
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   615
lemma less_Min_Pls:
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22394
diff changeset
   616
  "Numeral.Min < Numeral.Pls \<longleftrightarrow> True"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   617
  unfolding Pls_def Min_def by presburger 
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   618
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   619
lemma less_Min_Min:
23405
8993b3144358 moved lemma all_not_ex to HOL.thy ; tuned proofs
chaieb
parents: 23390
diff changeset
   620
  "Numeral.Min < Numeral.Min \<longleftrightarrow> False"  by simp
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   621
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   622
lemma less_Min_Bit:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   623
  "Numeral.Min < Numeral.Bit k v \<longleftrightarrow> Numeral.Min < k"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   624
  unfolding Min_def Bit_def by (auto split: bit.split)
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   625
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   626
lemma less_Bit_Pls:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   627
  "Numeral.Bit k v < Numeral.Pls \<longleftrightarrow> k < Numeral.Pls"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   628
  unfolding Pls_def Bit_def by (auto split: bit.split)
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   629
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   630
lemma less_Bit0_Min:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   631
  "Numeral.Bit k bit.B0 < Numeral.Min \<longleftrightarrow> k \<le> Numeral.Min"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   632
  unfolding Min_def Bit_def by auto
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   633
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   634
lemma less_Bit1_Min:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   635
  "Numeral.Bit k bit.B1 < Numeral.Min \<longleftrightarrow> k < Numeral.Min"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   636
  unfolding Min_def Bit_def by auto
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   637
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   638
lemma less_Bit_Bit0:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   639
  "Numeral.Bit k1 v < Numeral.Bit k2 bit.B0 \<longleftrightarrow> k1 < k2"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   640
  unfolding Bit_def by (auto split: bit.split)
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   641
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   642
lemma less_Bit1_Bit:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   643
  "Numeral.Bit k1 bit.B1 < Numeral.Bit k2 v \<longleftrightarrow> k1 < k2"
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   644
  unfolding Bit_def by (auto split: bit.split)
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   645
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   646
lemma less_Bit0_Bit1:
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   647
  "Numeral.Bit k1 bit.B0 < Numeral.Bit k2 bit.B1 \<longleftrightarrow> k1 \<le> k2"
23390
01ef1135de73 Added some lemmas to default presburger simpset; tuned proofs
chaieb
parents: 23389
diff changeset
   648
  unfolding Bit_def bit.cases  by arith
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   649
22801
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   650
lemma less_number_of:
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   651
  "(number_of k \<Colon> int) < number_of l \<longleftrightarrow> k < l"
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   652
  unfolding number_of_is_id ..
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   653
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   654
lemmas pred_succ_numeral_code [code func] =
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   655
  arith_simps(5-12)
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   656
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   657
lemmas plus_numeral_code [code func] =
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   658
  arith_simps(13-17)
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   659
  arith_simps(26-27)
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   660
  arith_extra_simps(1) [where 'a = int]
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   661
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   662
lemmas minus_numeral_code [code func] =
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   663
  arith_simps(18-21)
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   664
  arith_extra_simps(2) [where 'a = int]
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   665
  arith_extra_simps(5) [where 'a = int]
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   666
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   667
lemmas times_numeral_code [code func] =
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   668
  arith_simps(22-25)
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   669
  arith_extra_simps(4) [where 'a = int]
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   670
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   671
lemmas eq_numeral_code [code func] =
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   672
  eq_Pls_Pls eq_Pls_Min eq_Pls_Bit0 eq_Pls_Bit1
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   673
  eq_Min_Pls eq_Min_Min eq_Min_Bit0 eq_Min_Bit1
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   674
  eq_Bit0_Pls eq_Bit1_Pls eq_Bit0_Min eq_Bit1_Min eq_Bit_Bit
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   675
  eq_number_of
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   676
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   677
lemmas less_eq_numeral_code [code func] = less_eq_Pls_Pls less_eq_Pls_Min less_eq_Pls_Bit
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   678
  less_eq_Min_Pls less_eq_Min_Min less_eq_Min_Bit0 less_eq_Min_Bit1
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   679
  less_eq_Bit0_Pls less_eq_Bit1_Pls less_eq_Bit_Min less_eq_Bit0_Bit less_eq_Bit_Bit1 less_eq_Bit1_Bit0
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   680
  less_eq_number_of
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   681
22394
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   682
lemmas less_numeral_code [code func] = less_Pls_Pls less_Pls_Min less_Pls_Bit0
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   683
  less_Pls_Bit1 less_Min_Pls less_Min_Min less_Min_Bit less_Bit_Pls
54ea68b5a92f tuned code theorems for ord on integers
haftmann
parents: 22026
diff changeset
   684
  less_Bit0_Min less_Bit1_Min less_Bit_Bit0 less_Bit1_Bit less_Bit0_Bit1
22801
caffcb450ef4 cleaned up code generator setup for int
haftmann
parents: 22744
diff changeset
   685
  less_number_of
20595
db6bedfba498 improved numeral handling for nbe
haftmann
parents: 20485
diff changeset
   686
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23333
diff changeset
   687
end