src/HOL/Integ/cooper_proof.ML
changeset 14877 28084696907f
parent 14758 af3b71a46a1c
child 14920 a7525235e20f
     1.1 --- a/src/HOL/Integ/cooper_proof.ML	Sat Jun 05 13:08:53 2004 +0200
     1.2 +++ b/src/HOL/Integ/cooper_proof.ML	Sat Jun 05 18:34:06 2004 +0200
     1.3 @@ -15,11 +15,13 @@
     1.4    val qe_impI : thm
     1.5    val qe_eqI : thm
     1.6    val qe_exI : thm
     1.7 +  val list_to_set : typ -> term list -> term
     1.8    val qe_get_terms : thm -> term * term
     1.9    val cooper_prv : Sign.sg -> term -> term -> thm
    1.10    val proof_of_evalc : Sign.sg -> term -> thm
    1.11    val proof_of_cnnf : Sign.sg -> term -> (term -> thm) -> thm
    1.12    val proof_of_linform : Sign.sg -> string list -> term -> thm
    1.13 +  val proof_of_adjustcoeffeq : Sign.sg -> term -> int -> term -> thm
    1.14    val prove_elementar : Sign.sg -> string -> term -> thm
    1.15    val thm_of : Sign.sg -> (term -> (term list * (thm list -> thm))) -> term -> thm
    1.16  end;
    1.17 @@ -365,6 +367,10 @@
    1.18  
    1.19    |_ => ([], fn [] => instantiate' [Some cboolT] [Some (cterm_of sg fm)] refl);
    1.20  
    1.21 +fun proof_of_adjustcoeffeq sg x l = thm_of sg (decomp_adjustcoeffeq sg x l);
    1.22 +
    1.23 +
    1.24 +
    1.25  (*==================================================*)
    1.26  (*   Finding rho for modd_minusinfinity             *)
    1.27  (*==================================================*)
    1.28 @@ -861,28 +867,51 @@
    1.29  (* ------------------------------------------------------------------------- *)
    1.30  
    1.31  fun cooper_prv sg (x as Free(xn,xT)) efm = let 
    1.32 +   (* lfm_thm : efm = linearized form of efm*)
    1.33     val lfm_thm = proof_of_linform sg [xn] efm
    1.34 +   (*efm2 is the linearized form of efm *) 
    1.35     val efm2 = snd(qe_get_terms lfm_thm)
    1.36 +   (* l is the lcm of all coefficients of x *)
    1.37     val l = formlcm x efm2
    1.38 -   val ac_thm = [lfm_thm , (thm_of sg (decomp_adjustcoeffeq sg x l) efm2)] MRS trans
    1.39 +   (*ac_thm: efm = efm2 with adjusted coefficients of x *)
    1.40 +   val ac_thm = [lfm_thm , (proof_of_adjustcoeffeq sg x l efm2)] MRS trans
    1.41 +   (* fm is efm2 with adjusted coefficients of x *)
    1.42     val fm = snd (qe_get_terms ac_thm)
    1.43 +  (* cfm is l dvd x & fm' where fm' is fm where l*x is replaced by x*)
    1.44     val  cfm = unitycoeff x fm
    1.45 +   (*afm is fm where c*x is replaced by 1*x or -1*x *)
    1.46     val afm = adjustcoeff x l fm
    1.47 +   (* P = %x.afm*)
    1.48     val P = absfree(xn,xT,afm)
    1.49 +   (* This simpset allows the elimination of the sets in bex {1..d} *)
    1.50     val ss = presburger_ss addsimps
    1.51       [simp_from_to] delsimps [P_eqtrue, P_eqfalse, bex_triv, insert_iff]
    1.52 +   (* uth : EX x.P(l*x) = EX x. l dvd x & P x*)
    1.53     val uth = instantiate' [] [Some (cterm_of sg P) , Some (cterm_of sg (mk_numeral l))] (unity_coeff_ex)
    1.54 +   (* e_ac_thm : Ex x. efm = EX x. fm*)
    1.55     val e_ac_thm = (forall_intr (cterm_of sg x) ac_thm) COMP (qe_exI)
    1.56 +   (* A and B set of the formula*)
    1.57     val A = aset x cfm
    1.58     val B = bset x cfm
    1.59 +   (* the divlcm (delta) of the formula*)
    1.60     val dlcm = mk_numeral (divlcm x cfm)
    1.61 +   (* Which set is smaller to generate the (hoepfully) shorter proof*)
    1.62     val cms = if ((length A) < (length B )) then "pi" else "mi"
    1.63 +   (* synthesize the proof of cooper's theorem*)
    1.64 +    (* cp_thm: EX x. cfm = Q*)
    1.65     val cp_thm = cooper_thm sg cms x cfm dlcm A B
    1.66 +   (* Exxpand the right hand side to get rid of EX j : {1..d} to get a huge disjunction*)
    1.67 +   (* exp_cp_thm: EX x.cfm = Q' , where Q' is a simplified version of Q*)
    1.68     val exp_cp_thm = refl RS (simplify ss (cp_thm RSN (2,trans)))
    1.69 +   (* lsuth = EX.P(l*x) ; rsuth = EX x. l dvd x & P x*)
    1.70     val (lsuth,rsuth) = qe_get_terms (uth)
    1.71 +   (* lseacth = EX x. efm; rseacth = EX x. fm*)
    1.72     val (lseacth,rseacth) = qe_get_terms(e_ac_thm)
    1.73 +   (* lscth = EX x. cfm; rscth = Q' *)
    1.74     val (lscth,rscth) = qe_get_terms (exp_cp_thm)
    1.75 +   (* u_c_thm: EX x. P(l*x) = Q'*)
    1.76     val  u_c_thm = [([uth,prove_elementar sg "ss" (HOLogic.mk_eq (rsuth,lscth))] MRS trans),exp_cp_thm] MRS trans
    1.77 +   (* result: EX x. efm = Q'*)
    1.78   in  ([e_ac_thm,[(prove_elementar sg "ss" (HOLogic.mk_eq (rseacth,lsuth))),u_c_thm] MRS trans] MRS trans)
    1.79     end
    1.80  |cooper_prv _ _ _ =  error "Parameters format";