proof_of_evalc corrected;
authorchaieb
Fri Aug 06 17:19:50 2004 +0200 (2004-08-06)
changeset 151224b52eeb62807
parent 15121 1198032bad25
child 15123 4c49281dc9a8
proof_of_evalc corrected;
src/HOL/Integ/cooper_proof.ML
src/HOL/Tools/Presburger/cooper_proof.ML
     1.1 --- a/src/HOL/Integ/cooper_proof.ML	Fri Aug 06 17:07:04 2004 +0200
     1.2 +++ b/src/HOL/Integ/cooper_proof.ML	Fri Aug 06 17:19:50 2004 +0200
     1.3 @@ -17,7 +17,8 @@
     1.4    val qe_exI : thm
     1.5    val list_to_set : typ -> term list -> term
     1.6    val qe_get_terms : thm -> term * term
     1.7 -  val cooper_prv : Sign.sg -> term -> term -> thm
     1.8 +  val cooper_prv  : Sign.sg -> term -> term -> thm
     1.9 +  val cooper_prv2 : 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 @@ -792,8 +793,8 @@
    1.14             ((if (f ((dest_numeral s),(dest_numeral t))) 
    1.15               then prove_elementar sg "ss" (HOLogic.mk_eq(at,HOLogic.true_const)) 
    1.16               else prove_elementar sg "ss" (HOLogic.mk_eq(at, HOLogic.false_const)))  
    1.17 -		   handle _ => instantiate' [Some cboolT] [Some (cterm_of sg at)] refl
    1.18 -        | _ => instantiate' [Some cboolT] [Some (cterm_of sg at)] refl )) 
    1.19 +		   handle _ => instantiate' [Some cboolT] [Some (cterm_of sg at)] refl)
    1.20 +        | _ => instantiate' [Some cboolT] [Some (cterm_of sg at)] refl )
    1.21       |Const("Not",_)$(Const (p,_) $ s $ t) =>(  
    1.22         case assoc (operations,p) of 
    1.23           Some f => 
    1.24 @@ -920,6 +921,64 @@
    1.25     end
    1.26  |cooper_prv _ _ _ =  error "Parameters format";
    1.27  
    1.28 +(* ********************************** *)
    1.29 +(* cooper_prv2 is just copy and paste *)
    1.30 +(* And only generates proof with      *)
    1.31 +(* bset and minusinfity               *)
    1.32 +(* ********************************** *)
    1.33 +
    1.34 +
    1.35 +
    1.36 +fun cooper_prv2 sg (x as Free(xn,xT)) efm = let 
    1.37 +   (* lfm_thm : efm = linearized form of efm*)
    1.38 +   val lfm_thm = proof_of_linform sg [xn] efm
    1.39 +   (*efm2 is the linearized form of efm *) 
    1.40 +   val efm2 = snd(qe_get_terms lfm_thm)
    1.41 +   (* l is the lcm of all coefficients of x *)
    1.42 +   val l = formlcm x efm2
    1.43 +   (*ac_thm: efm = efm2 with adjusted coefficients of x *)
    1.44 +   val ac_thm = [lfm_thm , (proof_of_adjustcoeffeq sg x l efm2)] MRS trans
    1.45 +   (* fm is efm2 with adjusted coefficients of x *)
    1.46 +   val fm = snd (qe_get_terms ac_thm)
    1.47 +  (* cfm is l dvd x & fm' where fm' is fm where l*x is replaced by x*)
    1.48 +   val  cfm = unitycoeff x fm
    1.49 +   (*afm is fm where c*x is replaced by 1*x or -1*x *)
    1.50 +   val afm = adjustcoeff x l fm
    1.51 +   (* P = %x.afm*)
    1.52 +   val P = absfree(xn,xT,afm)
    1.53 +   (* This simpset allows the elimination of the sets in bex {1..d} *)
    1.54 +   val ss = presburger_ss addsimps
    1.55 +     [simp_from_to] delsimps [P_eqtrue, P_eqfalse, bex_triv, insert_iff]
    1.56 +   (* uth : EX x.P(l*x) = EX x. l dvd x & P x*)
    1.57 +   val uth = instantiate' [] [Some (cterm_of sg P) , Some (cterm_of sg (mk_numeral l))] (unity_coeff_ex)
    1.58 +   (* e_ac_thm : Ex x. efm = EX x. fm*)
    1.59 +   val e_ac_thm = (forall_intr (cterm_of sg x) ac_thm) COMP (qe_exI)
    1.60 +   (* A and B set of the formula*)
    1.61 +   val B = bset x cfm
    1.62 +   val A = []
    1.63 +   (* the divlcm (delta) of the formula*)
    1.64 +   val dlcm = mk_numeral (divlcm x cfm)
    1.65 +   (* Which set is smaller to generate the (hoepfully) shorter proof*)
    1.66 +   val cms = "mi" 
    1.67 +   (* synthesize the proof of cooper's theorem*)
    1.68 +    (* cp_thm: EX x. cfm = Q*)
    1.69 +   val cp_thm = cooper_thm sg cms x cfm dlcm A B
    1.70 +   (* Exxpand the right hand side to get rid of EX j : {1..d} to get a huge disjunction*)
    1.71 +   (* exp_cp_thm: EX x.cfm = Q' , where Q' is a simplified version of Q*)
    1.72 +   val exp_cp_thm = refl RS (simplify ss (cp_thm RSN (2,trans)))
    1.73 +   (* lsuth = EX.P(l*x) ; rsuth = EX x. l dvd x & P x*)
    1.74 +   val (lsuth,rsuth) = qe_get_terms (uth)
    1.75 +   (* lseacth = EX x. efm; rseacth = EX x. fm*)
    1.76 +   val (lseacth,rseacth) = qe_get_terms(e_ac_thm)
    1.77 +   (* lscth = EX x. cfm; rscth = Q' *)
    1.78 +   val (lscth,rscth) = qe_get_terms (exp_cp_thm)
    1.79 +   (* u_c_thm: EX x. P(l*x) = Q'*)
    1.80 +   val  u_c_thm = [([uth,prove_elementar sg "ss" (HOLogic.mk_eq (rsuth,lscth))] MRS trans),exp_cp_thm] MRS trans
    1.81 +   (* result: EX x. efm = Q'*)
    1.82 + in  ([e_ac_thm,[(prove_elementar sg "ss" (HOLogic.mk_eq (rseacth,lsuth))),u_c_thm] MRS trans] MRS trans)
    1.83 +   end
    1.84 +|cooper_prv2 _ _ _ =  error "Parameters format";
    1.85 +
    1.86  
    1.87  (* **************************************** *)
    1.88  (*    An Other Version of cooper proving    *)
     2.1 --- a/src/HOL/Tools/Presburger/cooper_proof.ML	Fri Aug 06 17:07:04 2004 +0200
     2.2 +++ b/src/HOL/Tools/Presburger/cooper_proof.ML	Fri Aug 06 17:19:50 2004 +0200
     2.3 @@ -17,7 +17,8 @@
     2.4    val qe_exI : thm
     2.5    val list_to_set : typ -> term list -> term
     2.6    val qe_get_terms : thm -> term * term
     2.7 -  val cooper_prv : Sign.sg -> term -> term -> thm
     2.8 +  val cooper_prv  : Sign.sg -> term -> term -> thm
     2.9 +  val cooper_prv2 : Sign.sg -> term -> term -> thm
    2.10    val proof_of_evalc : Sign.sg -> term -> thm
    2.11    val proof_of_cnnf : Sign.sg -> term -> (term -> thm) -> thm
    2.12    val proof_of_linform : Sign.sg -> string list -> term -> thm
    2.13 @@ -792,8 +793,8 @@
    2.14             ((if (f ((dest_numeral s),(dest_numeral t))) 
    2.15               then prove_elementar sg "ss" (HOLogic.mk_eq(at,HOLogic.true_const)) 
    2.16               else prove_elementar sg "ss" (HOLogic.mk_eq(at, HOLogic.false_const)))  
    2.17 -		   handle _ => instantiate' [Some cboolT] [Some (cterm_of sg at)] refl
    2.18 -        | _ => instantiate' [Some cboolT] [Some (cterm_of sg at)] refl )) 
    2.19 +		   handle _ => instantiate' [Some cboolT] [Some (cterm_of sg at)] refl)
    2.20 +        | _ => instantiate' [Some cboolT] [Some (cterm_of sg at)] refl )
    2.21       |Const("Not",_)$(Const (p,_) $ s $ t) =>(  
    2.22         case assoc (operations,p) of 
    2.23           Some f => 
    2.24 @@ -920,6 +921,64 @@
    2.25     end
    2.26  |cooper_prv _ _ _ =  error "Parameters format";
    2.27  
    2.28 +(* ********************************** *)
    2.29 +(* cooper_prv2 is just copy and paste *)
    2.30 +(* And only generates proof with      *)
    2.31 +(* bset and minusinfity               *)
    2.32 +(* ********************************** *)
    2.33 +
    2.34 +
    2.35 +
    2.36 +fun cooper_prv2 sg (x as Free(xn,xT)) efm = let 
    2.37 +   (* lfm_thm : efm = linearized form of efm*)
    2.38 +   val lfm_thm = proof_of_linform sg [xn] efm
    2.39 +   (*efm2 is the linearized form of efm *) 
    2.40 +   val efm2 = snd(qe_get_terms lfm_thm)
    2.41 +   (* l is the lcm of all coefficients of x *)
    2.42 +   val l = formlcm x efm2
    2.43 +   (*ac_thm: efm = efm2 with adjusted coefficients of x *)
    2.44 +   val ac_thm = [lfm_thm , (proof_of_adjustcoeffeq sg x l efm2)] MRS trans
    2.45 +   (* fm is efm2 with adjusted coefficients of x *)
    2.46 +   val fm = snd (qe_get_terms ac_thm)
    2.47 +  (* cfm is l dvd x & fm' where fm' is fm where l*x is replaced by x*)
    2.48 +   val  cfm = unitycoeff x fm
    2.49 +   (*afm is fm where c*x is replaced by 1*x or -1*x *)
    2.50 +   val afm = adjustcoeff x l fm
    2.51 +   (* P = %x.afm*)
    2.52 +   val P = absfree(xn,xT,afm)
    2.53 +   (* This simpset allows the elimination of the sets in bex {1..d} *)
    2.54 +   val ss = presburger_ss addsimps
    2.55 +     [simp_from_to] delsimps [P_eqtrue, P_eqfalse, bex_triv, insert_iff]
    2.56 +   (* uth : EX x.P(l*x) = EX x. l dvd x & P x*)
    2.57 +   val uth = instantiate' [] [Some (cterm_of sg P) , Some (cterm_of sg (mk_numeral l))] (unity_coeff_ex)
    2.58 +   (* e_ac_thm : Ex x. efm = EX x. fm*)
    2.59 +   val e_ac_thm = (forall_intr (cterm_of sg x) ac_thm) COMP (qe_exI)
    2.60 +   (* A and B set of the formula*)
    2.61 +   val B = bset x cfm
    2.62 +   val A = []
    2.63 +   (* the divlcm (delta) of the formula*)
    2.64 +   val dlcm = mk_numeral (divlcm x cfm)
    2.65 +   (* Which set is smaller to generate the (hoepfully) shorter proof*)
    2.66 +   val cms = "mi" 
    2.67 +   (* synthesize the proof of cooper's theorem*)
    2.68 +    (* cp_thm: EX x. cfm = Q*)
    2.69 +   val cp_thm = cooper_thm sg cms x cfm dlcm A B
    2.70 +   (* Exxpand the right hand side to get rid of EX j : {1..d} to get a huge disjunction*)
    2.71 +   (* exp_cp_thm: EX x.cfm = Q' , where Q' is a simplified version of Q*)
    2.72 +   val exp_cp_thm = refl RS (simplify ss (cp_thm RSN (2,trans)))
    2.73 +   (* lsuth = EX.P(l*x) ; rsuth = EX x. l dvd x & P x*)
    2.74 +   val (lsuth,rsuth) = qe_get_terms (uth)
    2.75 +   (* lseacth = EX x. efm; rseacth = EX x. fm*)
    2.76 +   val (lseacth,rseacth) = qe_get_terms(e_ac_thm)
    2.77 +   (* lscth = EX x. cfm; rscth = Q' *)
    2.78 +   val (lscth,rscth) = qe_get_terms (exp_cp_thm)
    2.79 +   (* u_c_thm: EX x. P(l*x) = Q'*)
    2.80 +   val  u_c_thm = [([uth,prove_elementar sg "ss" (HOLogic.mk_eq (rsuth,lscth))] MRS trans),exp_cp_thm] MRS trans
    2.81 +   (* result: EX x. efm = Q'*)
    2.82 + in  ([e_ac_thm,[(prove_elementar sg "ss" (HOLogic.mk_eq (rseacth,lsuth))),u_c_thm] MRS trans] MRS trans)
    2.83 +   end
    2.84 +|cooper_prv2 _ _ _ =  error "Parameters format";
    2.85 +
    2.86  
    2.87  (* **************************************** *)
    2.88  (*    An Other Version of cooper proving    *)