src/HOL/Decision_Procs/langford.ML
changeset 38549 d0385f2764d8
parent 37744 3daaf23b9ab4
child 38558 32ad17fe2b9c
equal deleted inserted replaced
38548:dea0d2cca822 38549:d0385f2764d8
    28 
    28 
    29 val simp_rule = Conv.fconv_rule (Conv.arg_conv (Simplifier.rewrite (HOL_basic_ss addsimps (@{thms "ball_simps"} @ simp_thms))));
    29 val simp_rule = Conv.fconv_rule (Conv.arg_conv (Simplifier.rewrite (HOL_basic_ss addsimps (@{thms "ball_simps"} @ simp_thms))));
    30 
    30 
    31 fun basic_dloqe ctxt stupid dlo_qeth dlo_qeth_nolb dlo_qeth_noub gather ep = 
    31 fun basic_dloqe ctxt stupid dlo_qeth dlo_qeth_nolb dlo_qeth_noub gather ep = 
    32  case term_of ep of 
    32  case term_of ep of 
    33   Const("Ex",_)$_ => 
    33   Const(@{const_name "Ex"},_)$_ => 
    34    let 
    34    let 
    35      val p = Thm.dest_arg ep
    35      val p = Thm.dest_arg ep
    36      val ths = simplify (HOL_basic_ss addsimps gather) (instantiate' [] [SOME p] stupid)
    36      val ths = simplify (HOL_basic_ss addsimps gather) (instantiate' [] [SOME p] stupid)
    37      val (L,U) = 
    37      val (L,U) = 
    38        let 
    38        let 
   114  in Thm.implies_elim (Thm.implies_elim eqI thl) thr |> mk_meta_eq end;
   114  in Thm.implies_elim (Thm.implies_elim eqI thl) thr |> mk_meta_eq end;
   115 
   115 
   116 fun contains x ct = member (op aconv) (OldTerm.term_frees (term_of ct)) (term_of x);
   116 fun contains x ct = member (op aconv) (OldTerm.term_frees (term_of ct)) (term_of x);
   117 
   117 
   118 fun is_eqx x eq = case term_of eq of
   118 fun is_eqx x eq = case term_of eq of
   119    Const("op =",_)$l$r => l aconv term_of x orelse r aconv term_of x
   119    Const(@{const_name "op ="},_)$l$r => l aconv term_of x orelse r aconv term_of x
   120  | _ => false ;
   120  | _ => false ;
   121 
   121 
   122 local 
   122 local 
   123 fun proc ct = 
   123 fun proc ct = 
   124  case term_of ct of
   124  case term_of ct of
   125   Const("Ex",_)$Abs (xn,_,_) => 
   125   Const(@{const_name "Ex"},_)$Abs (xn,_,_) => 
   126    let 
   126    let 
   127     val e = Thm.dest_fun ct
   127     val e = Thm.dest_fun ct
   128     val (x,p) = Thm.dest_abs (SOME xn) (Thm.dest_arg ct)
   128     val (x,p) = Thm.dest_abs (SOME xn) (Thm.dest_arg ct)
   129     val Pp = Thm.capply @{cterm "Trueprop"} p 
   129     val Pp = Thm.capply @{cterm "Trueprop"} p 
   130     val (eqs,neqs) = List.partition (is_eqx x) (all_conjuncts p)
   130     val (eqs,neqs) = List.partition (is_eqx x) (all_conjuncts p)
   174 
   174 
   175 val grab_atom_bop =
   175 val grab_atom_bop =
   176  let
   176  let
   177   fun h bounds tm =
   177   fun h bounds tm =
   178    (case term_of tm of
   178    (case term_of tm of
   179      Const ("op =", T) $ _ $ _ =>
   179      Const (@{const_name "op ="}, T) $ _ $ _ =>
   180        if domain_type T = HOLogic.boolT then find_args bounds tm
   180        if domain_type T = HOLogic.boolT then find_args bounds tm
   181        else Thm.dest_fun2 tm
   181        else Thm.dest_fun2 tm
   182    | Const ("Not", _) $ _ => h bounds (Thm.dest_arg tm)
   182    | Const (@{const_name "Not"}, _) $ _ => h bounds (Thm.dest_arg tm)
   183    | Const ("All", _) $ _ => find_body bounds (Thm.dest_arg tm)
   183    | Const (@{const_name "All"}, _) $ _ => find_body bounds (Thm.dest_arg tm)
   184    | Const ("all", _) $ _ => find_body bounds (Thm.dest_arg tm)
   184    | Const ("all", _) $ _ => find_body bounds (Thm.dest_arg tm)
   185    | Const ("Ex", _) $ _ => find_body bounds (Thm.dest_arg tm)
   185    | Const (@{const_name "Ex"}, _) $ _ => find_body bounds (Thm.dest_arg tm)
   186    | Const ("op &", _) $ _ $ _ => find_args bounds tm
   186    | Const (@{const_name "op &"}, _) $ _ $ _ => find_args bounds tm
   187    | Const ("op |", _) $ _ $ _ => find_args bounds tm
   187    | Const (@{const_name "op |"}, _) $ _ $ _ => find_args bounds tm
   188    | Const ("op -->", _) $ _ $ _ => find_args bounds tm
   188    | Const (@{const_name "op -->"}, _) $ _ $ _ => find_args bounds tm
   189    | Const ("==>", _) $ _ $ _ => find_args bounds tm
   189    | Const ("==>", _) $ _ $ _ => find_args bounds tm
   190    | Const ("==", _) $ _ $ _ => find_args bounds tm
   190    | Const ("==", _) $ _ $ _ => find_args bounds tm
   191    | Const ("Trueprop", _) $ _ => h bounds (Thm.dest_arg tm)
   191    | Const (@{const_name "Trueprop"}, _) $ _ => h bounds (Thm.dest_arg tm)
   192    | _ => Thm.dest_fun2 tm)
   192    | _ => Thm.dest_fun2 tm)
   193   and find_args bounds tm =
   193   and find_args bounds tm =
   194     (h bounds (Thm.dest_arg tm) handle CTERM _ => h bounds (Thm.dest_arg1 tm))
   194     (h bounds (Thm.dest_arg tm) handle CTERM _ => h bounds (Thm.dest_arg1 tm))
   195  and find_body bounds b =
   195  and find_body bounds b =
   196    let val (_, b') = Thm.dest_abs (SOME (Name.bound bounds)) b
   196    let val (_, b') = Thm.dest_abs (SOME (Name.bound bounds)) b