Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Roqc/dev/tools/   (PVS Prover Version 6.0.9©)  Datei vom 15.8.2025 mit Größe 1 kB image not shown  

SSL meson.ML

  Interaktion und
PortierbarkeitSML
 


    Author:     Lawrence *
    java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

The MESON resolution proof procedure for HOL.
When making clauses, avoids using the rewriter -- instead uses RS recursively.
*)

signature MESON =
sig
  type simp_options = {if_simps : bool, let_simps : bool}
  valsimp_options_all_true:simp_options
  val trace : bool val choice_theorems : the>thm
  val max_clauses:int ConfigT
  val first_order_resolve : Proof.context -> thm -> thm -> thm
   : thm - int
  val has_too_many_clausesval  context >thm >thm
  val make_cnf: thm list -> thm -> Proof.context -> thm list * Proof.context
 val finish_cnf bool >thmlist- thm list
  val  : 
  val presimplify:   make_clauses_unsorted:Proof.->thm  - thm list
 make_nnf:simp_options- .ontext-  >thm
  val :  listlist
val :simp_options- .context - thm  -  >thm
  val skolemize : simp_options -> Proof.context -> thm -> thm
  val cong_extensionalize_thm .ontext- thm - 
  val val gocls: thm - 
  val skolemize_prems_tac: - Proof. ->  list->int-> tactic
val: Proof.ontext - thmlist >thmjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
val :Proofcontext ->thm list >thm 
  val make_horns: thm list -> thm list
 val  . > (hm - )- thm list >tactic
  val val depth_meson_tac: Proof.context -> int -> tactic
  val val prolog_step_tac': Proof.context -> thm list -> int -> java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
valskolemize_prems_tac:simp_options- .ontexttactic
  val MESON java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 51
  java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 77
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 3
:>)- .-  >tactic
  val java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  val depth_meson_tac: Proof.context -> int -> tactic
 -   java.lang.StringIndexOutOfBoundsException: Range [66, 67) out of bounds for length 66
  val iter_deepen_prolog_tac: Proof.context -> thm list 
   iter_deepen_meson_tac:Proof -  -  >
  val make_meta_clause: Proof.context valiter_deepen_limit =50;
vajava.lang.StringIndexOutOfBoundsException: Range [21, 17) out of bounds for length 43
val:.>list>int-
end   { }

M :MESON=
val =@{hmnot_allD

   { :bool let_simps }
val simp_options_all_true = {if_simps = true, let_simps =@thmimp_to_disjDjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39

val trace = Attrib.setup_config_bool \<^binding>\<open>meson_tracevalconj_exD1=@thmconj_exD1;

fun valconj_exD2={conj_exD2;

val max_clauses = val disj_exD = @{thm};

(*No known example (on 1-5-2007) needs even thirty*)thm}java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
val  disj_FalseD1@thmdisj_FalseD1;

disj_forward  { disj_forward;
val disj_forward2 =
val java.lang.StringIndexOutOfBoundsException: Range [39, 15) out of bounds for length 39
java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 43
val make_pos_goal ( ctxtfn  >
 "is :  ^ hm.string_of_thm ctxt th); ths)
val make_neg_rule' = @{thm make_neg_rule'};
val make_neg_goal = @{thm make_neg_goal};
val conj_forward = @{thm conj_forward};
val all_forward = @{thm all_forward};
val ex_forward = @{thm ex_forward};

val not_conjD = @{thm not_conjD}        else
not_disjD = @{hm not_disjD};
val not_notD = @{thm not_notD};
val not_allD = @{thm not_allD};
val not_exD = @{thm not_exD};
val imp_to_disjD = @{thm java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 25
val
val iff_to_disjD = @{thm fun make_cnf old_skolem_ths th=
val cnf old_skolem_ths ctxt (th, [])
val conj_exD1 = @{thm conj_exD1};
val conj_exD2 = @{thm conj_exD2};
val disj_exD = @{thm disj_exD};
val disj_exD1 = @{thm disj_exD1};
val disj_exD2 = @{thm disj_exD2};
val disj_assoc = @{thm disj_assoc};
val disj_comm = @{thm disj_comm};
val disj_FalseD1
val disj_FalseD2 = @{thm disj_FalseD2};


(**** Operators for forward proof ****)


(** First-order Resolution **)

(*FIXME: currently does not "rename variables apart"*)
fun first_order_resolvefun finish_cnfreflths = ths
  |    
    \<^try>\<|> map zero_var_
      let  thy= Proof_Context 
          val tmAjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          val<^><open>Truepropfor<Const_\open  <Const_><d for \close \close\<>=true
          val tenv    is_left _=false;
            Pattern.first_order_match thy (tmB, tmA)
                                          (Vartab.empty, Vartab.empty) |> snd
          val insts = Vartab.java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
      in  thA RS (infer_instantiatefun  th=
     th=>th
  | NONE    thjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10

(* Hack to make it less likely that we lose our precious bound variable names in
   "rename_bound_vars_RS" below, because of a clash. *)

val protect_prefix = "Meson_xyzzy"

fun protect_bound_var_names (t $ u) =
    java.lang.StringIndexOutOfBoundsException: Range [29, 25) out of bounds for length 29
  protect_bound_var_names A s , ')=
    Abs (protect_prefix ^ s, T, protect_bound_var_names t')
  | protect_bound_var_namesth =  (*Must check for negative literal first!*)

fun fix_bound_var_names old_t new_t =
  let
    fun quant_of \<^  handle THM _ => tryres(th, ,];
      | quant_of \<^const_name>\<open>Ball\<close> = SOME java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 0
      | quant_of \<^const_name>\<open>Ex\<close> = SOME false
      | quant_of \<^const_name>\<open>Bex\<close> = SOME false
      f \^Const_><Trueprop \C><pendisjfor_<\close  t
    val flip_quant = Option.map not
    fun some_eq (SOME x) (SOME y) = x = y
      | some_eq _ _ = false
    fun add_names quant (Const (quant_s, _) $ Abs (s, _, t')) =
        add_names quant t' #> some_eq quant (quant_of quant_s) ? cons s
      | add_names quant \<^Const_>\<open>Not for  | ok4horn \<^Const_>\<pen>Trueprop for t\<close = rigid t
      | add_names quant \<^Const_>\<open>implies for   ok4horn   ;
        add_names (flip_quant quant) t1 #> add_names quant t2
      | add_names quant (t1 $ t2) = fold (add_names quant) [t1, t2]
      | add_names _ _ = I
    fun lost_names quant =
      subtract (op =) (add_names quant new_t []) (add_names quant old_t [])
    fun aux ((t1 as Const (quant_s, _)) $ (Abs (s, T, t'))) =
      t1 $ Abs (s |> String.isPrefix protect_prefix s
                   ? perhaps (try (fn _ => hd (lost_names (quant_of quant_s)))),
                T, aux t')
      | aux (t1 $ t2) = aux t1 $ aux t2
      | aux t = t
  in aux new_t end

(* Forward proof while preserving bound variables names *)
fun rename_bound_vars_RS th rl =
  let
    val t = Thm.concl_of th
    val r = Thm.concl_of rl
    val th' = th RS Thm.rename_boundvars r (protect_bound_var_names r) rl
    val t' = Thm.concl_of th'
  in Thm.rename_boundvars t' (fix_bound_var_names t t') th' end

(*raises exception if no rules apply*)
fun tryres (th, rls) =
  let fun tryall [] = raise THM("tryres"0, th::rls)
        | tryall (rl::rls) =
          (rename_bound_vars_RS th rl handle THM _ => tryall rls)
  in  tryall rls  end;

(* Special version of "resolve_tac" that works around an explosion in the unifier.
   If the goal has the form "?P c", the danger is that resolving it against a
   property of the form "... c ... c ... c ..." will lead to a huge unification
   problem, due to the (spurious) choices between projection and imitation. The
   workaround is to instantiate "?P := (%c. ... c ... c ... c ...)" manually. *)

fun quant_resolve_tac ctxt th i st =
  case (Thm.concl_of st, Thm.prop_of th) of
    (\<^Const_>\<open>Trueprop for \<open>Var _ $ (c as Free _)\<close>\<close>, \<^Const_>\<open>Trueprop for _\<close>) =>
    let
      val cc = Thm.cterm_of ctxt c
      val ct = Thm.dest_arg (Thm.cprop_of th)
    in resolve_tac ctxt [th] i (Thm.instantiate' [] [SOME (Thm.lambda cc ct)] st) end
  | _ => resolve_tac ctxt [th] i st

(*Permits forward proof from rules that discharge assumptions. The supplied proof state st,
  e.g. from conj_forward, should have the form
    "\<lbrakk
  and the effect should be to instantiate ?P and ?Q with normalized versions of P' and Q'.*)

fun forward_res ctxt nf st =
  let
    fun tacf  ifok4horn Thm)
      |tacfprems=
        error (cat_lines
          ("Bad proof state in forward_res, please inform lcp@cl.cam.ac.uk:" ::
            Thm.string_of_thm ctxt st ::
            "Premises:" (
  in
    case Seq.pull (  a HOL
      fun add_contras crulesth  =
    | NONE => raise THM ("forward_res"0, [st])
  end;

(*Are any of the logical connectives in "bs" present in the term?*)
fun has_conns bs =
  let fun has (Const _) = false
        | has \<^Const_>\<open>Trueprop for| rots(,th   (make_horncrulesth)::
        |        | rots-,assoc_right t RS))
        |   case (Thmprop_of)of
        |         1 => = :
        |      |  = rots(, assoc_right )
     |has<Const_><open>   <openAbs(,,)\close>\close>=member(op=)bs \<const_name><openExclose>orelse p
        |
  in  has  end(java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45


 handling**java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27

fun <Const_>\<penTrueprop  P<>   java.lang.StringIndexOutOfBoundsException: Range [65, 66) out of bounds for length 65
|literals<Const_\opendisjforPQ<lose    literalsQ
  | literals \<^Const_>\<open>Not for P\<close> = [(false,P)]
  | literals P = [(true,P)];

(*number of literals in a term*)
val nliterals = length o literals;


(*** Tautology Checking ***)

fun signed_lits_aux \<^Const_>\<open>disj for P Q\<close> (poslits, neglits) =
      signed_lits_auxjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  (
  | signed_lits_aux P (poslits, neglits) = (P::poslits, neglits);

fun signed_lits th = signed_lits_auxjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

(*Literals like X=X are tautologous*)
fun taut_poslit \<^Const_>\<open>HOL.eq _ for t u\<java.lang.StringIndexOutOfBoundsException: Range [0, 56) out of bounds for length 23
  | taut_poslit \<
  |taut_poslit   falsejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

fun 
  let val (poslits
  in  exists taut_poslit poslits
      orelse
      exists (member (op aconv) neglits) (\<^term>\<open>False\<close> :: poslits)
  end
|has_reps [] =false


(*** To remove trivial negated equality literals from clauses ***)

(*They are typically functional reflexivity axioms and are the converses oftu]=( aconv )
  injectivity equivalences*)


val not_refl_disj_D =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

(*Is either term a Var that does not properly occur in the other term?*)
       java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 58
  | eliminable (u, t as Var _) = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  | eliminable _ = false;

fun refl_clause_aux 0 th = th
  | refl_clause_aux n th =
       case HOLogic.
          \<^Const_>\<open>disj for \<^Const_>\<open>disj java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 45
refl_clause_aux thRSdisj_assoc)    (*isolate an atom as first disjunct*)
        | \<^Const_>\<open   exists ( prem = has_reps rhyps(prem,]))(Thmprems_of st)
            if eliminable(t,u)
            then refl_clause_aux (n-1) (th RS not_refl_disj_D)  (*Var inequation: delete*)
            else refl_clause_aux (n-1) (th    Seq. elseSeq.st;
        | \<^Const>\<open>disj for _ _\<close> => refl_clause_aux n (th RS disj_comm)
        | _ => (*not a disjunction*) th;

fun notequal_lits_count \<^Const_>fun prolog_step_tac ctxt horns i =
  | notequal_lits_count \<^Const_>\<open>Not for \<^Const_>\<open>HOL.eq _    (assume_tac ctxt i APPEND resolve_tac ctxt horns )THENcheck_tac THEN
      TRYALL_eq_assume_tac;

(*Simplify a clause by applying reflexivity to its negated equality literals*)
fun
  let val neqs(*Sums the sizes of the subgoals, ignoring hypotheses (ancestors)*)
  in neqsth  end
  handle TERM _ => th;  (*probably dest_Trueprop on a weird theorem*)


(*** Removal of duplicate literals ***)

(*Forward proof, passing extra assumptions as theorems to the tactic*)
fun forward_res2 ctxt nf hyps st =
  case Seq.pull
        (REPEAT
         (Misc_Legacy.METAHYPS ctxt
           (fn
         st)
  of SOME(th,_) => val nnf_rls = [imp_to, iff_to_disjD, not_conjD, not_disjD,
   | NONE => raise THM("               not_impD, not_iffD, n,,not_notD];

(*Remove duplicates in P\<or>Q by assuming \<not>P in Q
  rls (initially []) accumulates assumptions of the form P==>False*)

funnodups_aux ctxt rls =nodups_auxctxt rls( disj_assoc
    handle ^>\openTrueprop\close   java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
    handle THM funmake_nnf1 ctxt th =
                           [disj_FalseD1, disj_FalseD2, asm_rl])
    handle THM _ => th;

(*Remove duplicate literals, if there are any*)
fun nodups ctxt th =
plicates(p= literals Thmp th)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
    THM(tryres",_, )>
    else th;


(*** The basic CNF transformation ***)

fun estimated_num_clauses bound t =
         forward_res ctxt (make_nnf1 ctxt)
  fun sum x y = if x < bound andalso y < bound then x+y else bound
   then x*y else bound
  
  (*Estimate the number of clauses in order to detect infeasible theorems*)handle THM(tryres,_ >th
  fun signed_nclauses b \<^Const_>\<open>Trueprop for t\<close> = signed_nclauses b t
| signed_nclauses  <>\Notfor\close (b java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
    | signed_nclausesnnf_ss also  point simprocs
        if b then sum (signed_nclauses b t) (signed_nclauses b u)
             which are needed tojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    | signed_nclauses@thmssimp_implies_def  Ball_defBex_def  if_False
         ( bt signed_nclausesb )
             else sum (signed_nclauses b t) f  (if_simps .}:simp_options)=
    | signed_nclauses(f then{thms split_ifs  [)@@ all_simps simp_thmsjava.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
        if b
             else sum (signed_nclauses (not b) t) (signed_nclauses b  "java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
| signed_nclauses b <Const_\openHOL. <>\<lose  t\close> java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
 then (*Boolean equality is if-and-only-if*)
            if b then sum (    |> fold Simplifier.add_proc
                          (prod (signed_nclauses (not b) u) (signed_nclauses [^<>close ^>o>c> <java.lang.StringIndexOutOfBoundsException: Range [95, 94) out of bounds for length 151
else ( s b )(igned_nclauses )java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
(prodsigned_nclausesnotb t signed_nclausesnot)u)
        else 1
   <><>\close]
    | signed_nclauses b \<^Const_>\<open>All _ for \<open>Abs (_,_,
   |signed_nclauses _ _ = 1(* literal *)
 in signed_nclauses true t end

fun has_too_many_clauses ctxt t =
  java.lang.StringIndexOutOfBoundsException: Range [16, 5) out of bounds for length 49
      +)t > max_cl
  end

(*Replaces universally quantified variables by FREE variables -- because
  assumptions may not contain scheme variables.  Later, generalize using Variable.export. *)

local  
  val spec_var =
    Thm.dest_arg (Thm.dest_arg  # let_simps? rewrite_rule ctxt @thmsLet_def [bs_def]
    |> Thm.term_of |java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   name_of <Const_\open>ll  for \open>Abs(x _ )<><>=x|name_of  .ujava.lang.StringIndexOutOfBoundsException: Index 103 out of bounds for length 103
  
  fun freeze_spec th ctxt =

      val ([x], java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
         (Thm.concl_of th)] ctxt;
      val spec' = spec
        |> Thm.java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
          (TVars    that
    in (th RS spec', ctxt'end
end;

funl
  let
        funaux th =
      | tryall (rl :       not (as_conns[<><>\<> (hm.prop_of)
  java.lang.StringIndexOutOfBoundsException: Range [6, 4) out of bounds for length 10

(* Conjunctive normal form, adding clauses from th in front of ths (for foldr).
  universal quantifiers andbreaks up conjunctions.
   Eliminates existential quantifiers using Skolemization theorems. *)

cnf ctxtth )java.lang.StringIndexOutOfBoundsException: Range [39, 40) out of bounds for length 39
  let val ctxt_ref = |> forward_res aux
      fun   inaux make_nnf simp_options ctxt end
        skolemize java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
        
        then nodups ctxt th :: ths (*no work to do, terminate*)
        elsecase  (OLogic.Thmconcl_of) java.lang.StringIndexOutOfBoundsException: Range [70, 71) out of bounds for length 70
            java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
                ljava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
          | \<^Const_>\<open>All _\<java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 8
                let pats=map2pat args1args2 java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
:= ctxt; cnf_aux th,ths 
          | \<^Const_>\<open>Ex _\<close> =>
               quantifier   functions)
              cnf_aux (apply_skolem_theorem (! ctxt_ref) (th, old_skolem_ths), ths)
          | \<^Const_>\<open>disj\<close> =>
             *DisjunctionofP Q  new  provingP|Q solve  
                all combinations of               >raise (
              (*There is one assumption, which gets bound to prem and then normalized via
.The form  given to   a 
                variable created by resolution with disj_forward. Since (cnf_nil prem)
                returns a LIST of theorems, we can backtrack to get all combinations.*)

              let  of
              in  Seq.list_of ((tac THEN tac) (th      (OME T p as   ) = (Abs Nameuu,T p)
          | _ => nodups ctxt th :: ths  (*no work to do*)
       cnf_nilth= th, ]java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
      val cls =
         ctxt (Thm.concl_of th) then
          (trace_msg ctxt (fn () =>
               "cnf is ignoring: " ^ Thm.string_of_thm ctxt th); ths)
        else
          cnf_aux (th, ths)
  in (cls, !ctxt_ref) end

java.lang.StringIndexOutOfBoundsException: Range [12, 3) out of bounds for length 37
  cnf old_skolem_ths ctxt (th, [])

(*Generalization, optional removal of redundant equalities, removal of tautologies.*)
fun      ( get_F_patternTt uof
  |> refl ?          p= th java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 93
  |> map|NONE= )
       java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12


(**** Generation of contrapositives ****)

fun  abs_extensionalize_conv =
   (ase .  

isjuctions to right -- make leftmost disjunct a LITERAL*)
fun  
   is_left Thmprop_ofth then assoc_right (th RS disj_assoc)
  else th;

(*Must check for negative literal first!*)
val clause_rules = [disj_assoc, make_neg_rule, make_pos_rule];

(*For ordinary resolution. *)
val resolution_clause_rules = [| _ $ _ => Conv.comb_conv (abs_extensionalize_conv

  | _ => Conv.all_conv ct)
fun make_goal th =   (*Must check for negative literal first!*)

     (ryres(h clause_rules)
  handle THM _ => tryres(th, [make_neg_goal, make_pos_goal]);

fun rigid t = not (fun try_skolemize_etc simp_options  thjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

fun ok4hornjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
   ok4horn \^Const_\open> fort<close>=rigid java.lang.StringIndexOutOfBoundsException: Range [61, 62) out of bounds for length 61
  | ok4horn _= falsejava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22

(*Create a meta-level Horn clause*)
fun make_horn Thmeq_thm_propabs_extensionalize_thmctxt th)
    |>map_filter(fn th =>th| try(skolemize simp_options ctxt)
                                  tap( NONE=>
  else th;

(*Generate Horn clauses for all contrapositives of a clause. The input, th,
  is a HOL disjunction.*)

fun add_contras crules th                                               .  )
  let fun rots (0,_) =                           _>()
        | rots (k,java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
                        rots(k-1val(,java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 28
  in case in Variable.exportjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 47
        1 => th::hcs
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 36
  end;

(*Use "theorem naming" to label the clauses*)
fun name_thms label =
    let fun java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(-,Thmput_name_hint(  string_of_int ,0 th :t)
    in  fn ths => #2 (fold_revval  =sort ( )  ;

(*Is the given disjunction an all-negative support clause?*)
is_negative  forall not  #)( (. th);

=filteris_negative;


(***** MESON PROOF PROCEDURE *****)

fun rhyps (\<^Const_>\<open>Pure.imp for \<^Const_>\<open>Trueprop for A\<closejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  | rhyps (_, As) = As  discrimination asjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

(** Detecting repeated assumptions in a subgoal **) ctxtsizefhorns =

(*The stringtree detects repeated assumptions.*)
    (hm, java.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 68

(*detects repetitions in a list of terms*)
fun has_reps [] = false
  | has_reps [_] = false
  | has_reps[t,u] = (t  u)
  | has_reps ts = (fold java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0

(*Like TRYALL eq_assume_tac, but avoids expensive THEN calls*)
fun TRYING_eq_assume_tac 0st=Seqsingle st
  | TRYING_eq_assume_tac i st =
       TRYING_eq_assume_tac (i-1) (Thm.java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 49
       handle THM _ => TRYING_eq_assume_tac (i-1)   cut_facts_tac (maps(  ctxt )THEN'

fun TRYALL_eq_assume_tac st = TRYING_eq_assume_tac (Thm.nprems_of st    REPEAT oeresolve_tac ctxt [exE]

(*Loop checking: FAIL if trying to prove the same thing twice
  -- if *ANY* subgoal has repeated literals*)

fun
  if exists (fn(*Basis of all meson-tactics.  Supplies cltac with clauses: HOL disjunctions.
  then  funMESON  mkclcltac  ctxt i st=


(* resolve_from_net_tac actually made it slower... *)

fun prolog_step_tac ctxt horns i =
Dresolve_tacctxt horns i) check_tac THEN
    TRYALL_eq_assume_tac;

(*Sums the sizes of the subgoals, ignoring hypotheses (ancestors)*)
fun addconcl remsz=size_of_term Logic.trip_assums_concl prem  sz;

fun size_of_subgoals st = fold_rev addconcl (Thm.prems_of st) 0;


(*Negation Normal Form*)
val nnf_rls = [imp_to_disjD, iff_to_disjD, not_conjD, not_disjD,
                              .FOCUS (ltac  mkcl o#prems)ctxt] ctxt 1) ist

fun ok4nnf \<^Const_>\<open>Trueprop for \<^Const_>\<open>Not for t
  |java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
 ok4nnf _ = false;

fun make_nnf1 ctxt th =
  if ok4nnf (Thm.concl_of th)
  java.lang.StringIndexOutOfBoundsException: Range [16, 6) out of bounds for length 43
    handle     ( cls =java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
        forward_res ctxt (make_nnf1 ctxt)
           (tryres(th, [conj_forward,disj_forward,all_forward,ex_forward]))
    handle THM                          Thm.no_prems,sizef)
  else th

(*The simplification removes defined quantifiers and occurrences of True and False.
  nnf_ss also includes the one-point simprocs,
  which are needed to avoid the various one-point theorems from generating junk clauses.*)

val nnf_simps =
  @{thms simp_implies_def  SELECT_GOAL TRY(safe_tac ctxt)THEN TRYALL best_meson_tac size_of_subgoals ctxt));
         if_eq_cancel cases_simp}
fun nnf_extra_simps ({if_simps, ...
  (if if_simps then @{thms split_ifs}  (if if_simps then @{thms split_ifs} 

(* FIXME: "let_simp" is probably redundant now that we also rewrite with
  "Let_def [abs_def]". *)

fun nnf_ss    fncls= EVERY [esolve_tac ctxt (gocls cls) 1, depth_prolog_tac ctxt (make_horns cls)])
  simpset_of (put_simpset     ctxt
    |> Simplifier.add_simps (
    |> fold java.lang.StringIndexOutOfBoundsException: Range [35, 23) out of bounds for length 35
      [\<^simproc>\open>defined_All\<> \^simproc>\open>\<close>, \<^simproc>\<open>neq\<close>, \<^simproc>\<open>let_simp\<close>])

val presimplified_consts =
  [\<^const_name>\<open>simp_implies\<close>, \<^const_name>  having only onejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   \<^const_name>\<open>    let   =(*0 subgoals vs 1 or more*)
\^><>\<close>]

fun presimplify (simp_options as {let_simps, ...} : simp_options) ctxt =        val nrtac =Bires.esolve_from_net_tac Bires.build_net)
  rewrite_rule ctxt (map safe_mk_meta_eq    >eq_assume_taciORELSE
  #>                 ctxthorn0s i ORELSE  (*no backtracking if unit MATCHES*)
  #> let_simps ? rewrite_rule ctxt @{thms Let_def [abs_def]}

fun make_nnf simp_options ctxt th =
  (case Thm.take_prems_of 1 java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 0
    [] => th |> presimplify simp_options     ITER_DEEPEN iter_deepen_limit Thm.no_prem horns;
  | _ => raise 

funchoice_theoremsthy=
  try (Global_Theory.get_thm thy) "Hilbert_Choice.choice" |> the_list

(* Pull existential quantifiers to front. This accomplishes Skolemization for
   clauses that arise from a subgoal. *)

fun skolemize_with_choice_theorems java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 32
  let
    fun aux th =
      if not (has_conns [\<^      []
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
      else
        tryres(th,choice_ths@
                    [conj_exD1, conj_exD2, disj_exD, disj_exD1, disj_exD2])
        |> aux
        handle THM ("tryres", _, _) =>
               tryres           val _ =trace_msgctxt(n ( =>
              | forward_res ctxt aux
               |> aux
               handle THM ("tryres", _, _) =>
                      rename_bound_vars_RS th ex_forward
                      > forward_res  aux
   [clauses:]@map Thm. )horns)

funskolemize simp_options java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
  let val thy = Proof_Context.theory_of ctxt in
    skolemize_with_choice_theorems simp_options ctxt (choice_theorems thy)
  end

exception NO_F_PATTERN of )

fun get_F_pattern T meson_tacc ths=
  let
    fun pat t u =
      let
        val ((head1, args1), (head2, args2)) = (t, u) |> apply2 strip_comb
      in
        if head1 = head2 then
          let val pats = map2 pat args1 args2 in
            case filter(is_someofst)patsof
              [(SOME T, _)] => (SOMET list_comb(   )
            | [] => (NONE, t)
            | _ => raise java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 0
          end
        else
          let val T = fastype_ofwith no contrapositives
            if can dest_funT T java.lang.StringIndexOutOfBoundsException: Range [74, 35) out of bounds for length 74
          end
      end
  in
    if T = \<^Type>\valnotEfalse =@{lemma "<>P\<Longrightarrow>  \<Longrightarrow> False" by (rule notE)};
      NONE
    else caseval notEfalse'  @lemma "P \<Longrightarrow> \<not> P \<Longrightarrow> False" by (rule notE)};
    (SOME ,  as_$_ = SOME (Abs (Name, ,p)
    | _ => NONE
  end
      thRS notEfalse handle THM _= th notEfalse';

val ext_cong_neq = @{thm ext_cong_neq}

(* Strengthens "f g \<noteq> f h" to "f g \<noteq> f h \<and> (\<exists>x. g x \<noteq> h x)". *)funmake_meta_clause ctxt th =
fun  let val fth thaw)= Misc_Legacy.freeze_thaw_robust ctxt th
  (case Thm.concl_of th of
    \<^Const_>\<open      (ero_var_indexes o Thm.varifyT_global o thaw 0 o 
      (       negated_asm_of_head o make_horn resolution_clause_rules) fth
        SOME p = end;
      | NONE => th)
  | _ => th)

(* Removes the lambdas from an equation of the form "t = (%x1 ... xn. u)". It
   would be desirable to do this symmetrically but there    name_thms "MClause#"
   proof in "Tarski" that relies on the current behavior. *)

fun abs_extensionalize_conv ctxt ct =
  (case Thm.term_of ct of
    \<^Const_>\<open>HOL.eq _ for _ \<open>Abs _\<close>\<close> =>
      ct |> (Conv.rewr_conv @{thm fun_eq_iff [THEN eq_reflection]}
             then_conv abs_extensionalize_conv ctxt)
  | _ $ _ => Conv.comb_conv (abs_extensionalize_conv ctxt) ct
  | Abs _ => Conv.abs_conv (abs_extensionalize_conv o snd) ctxt ct
  | _ => Conv.all_conv ct)

val abs_extensionalize_thm = Conv.fconv_rule o abs_extensionalize_conv

fun try_skolemize_etc simp_options ctxt th =
  let
    val th = th |> cong_extensionalize_thm ctxt
  in
    [th]
    (* Extensionalize lambdas in "th", because that makes sense and that's what
       Sledgehammer does, but also keep an unextensionalized version of "th" for
       backward compatibility. *)

    |> insert Thm.eq_thm_prop (abs_extensionalize_thm ctxt th)
    |> map_filter (fn th => th |> try (skolemize simp_options ctxt)
                               |> tap (fn NONE =>
                                          trace_msg ctxt (fn () =>
                                              "Failed to skolemize " ^
                                               Thm.string_of_thm ctxt th)
                                        | _ => ()))
  end

fun add_clauses ctxt th cls =
  let
    val (cnfs, ctxt') = ctxt
      |> Variable.declare_thm th
      |> make_cnf [] th;
  in Variable.export ctxt' ctxt cnfs @ cls end;

(*Sort clauses by number of literals*)
fun fewerlits (th1, th2) = nliterals (Thm.prop_of th1) < nliterals (Thm.prop_of th2)

(*Make clauses from a list of theorems, previously Skolemized and put into nnf.
  The resulting clauses are HOL disjunctions.*)

fun make_clauses_unsorted ctxt ths = fold_rev (add_clauses ctxt) ths [];
val make_clauses = sort (make_ord fewerlits) oo make_clauses_unsorted;

(*Convert a list of clauses (disjunctions) to Horn clauses (contrapositives)*)
fun make_horns ths =
    name_thms "Horn#"
      (distinct Thm.eq_thm_prop (fold_rev (add_contras clause_rules) ths []));

(*Could simply use nprems_of, which would count remaining subgoals -- no
  discrimination as to their size!  With BEST_FIRST, fails for problem 41.*)


fun best_prolog_tac ctxt sizef horns =
    BEST_FIRST (Thm.no_prems, sizef) (prolog_step_tac ctxt horns 1);

fun depth_prolog_tac ctxt horns =
    DEPTH_FIRST Thm.no_prems (prolog_step_tac ctxt horns 1);

(*Return all negative clauses, as possible goal clauses*)
fun gocls cls = name_thms "Goal#" (map make_goal (neg_clauses cls));

fun skolemize_prems_tac simp_options ctxt prems =
  cut_facts_tac (maps (try_skolemize_etc simp_options ctxt) prems) THEN'
    REPEAT o eresolve_tac ctxt [exE]

(*Basis of all meson-tactics.  Supplies cltac with clauses: HOL disjunctions.
  Function mkcl converts theorems to clauses.*)

fun MESON preskolem_tac mkcl cltac ctxt i st =
  SELECT_GOAL
    (EVERY [Object_Logic.atomize_prems_tac ctxt 1,
            resolve_tac ctxt @{thms ccontr} 1,
            preskolem_tac,
            Subgoal.FOCUS (fn {context = ctxt', prems = negs, ...} =>
                      EVERY1 [skolemize_prems_tac simp_options_all_true ctxt' negs,
                              Subgoal.FOCUS (cltac o mkcl o #prems) ctxt']) ctxt 1]) i st
  handle THM _ => no_tac st;    (*probably from make_meta_clause, not first-order*)


(** Best-first search versions **)

(*ths is a list of additional clauses (HOL disjunctions) to use.*)
fun best_meson_tac sizef ctxt =
  MESON all_tac (make_clauses ctxt)
    (fn cls =>
         THEN_BEST_FIRST (resolve_tac ctxt (gocls cls) 1)
                         (Thm.no_prems, sizef)
                         (prolog_step_tac ctxt (make_horns cls) 1))
    ctxt

(*First, breaks the goal into independent units*)
fun safe_best_meson_tac ctxt =
  SELECT_GOAL (TRY (safe_tac ctxt) THEN TRYALL (best_meson_tac size_of_subgoals ctxt));

(** Depth-first search version **)

fun depth_meson_tac ctxt =
  MESON all_tac (make_clauses ctxt)
    (fn cls => EVERY [resolve_tac ctxt (gocls cls) 1, depth_prolog_tac ctxt (make_horns cls)])
    ctxt

(** Iterative deepening version **)

(*This version does only one inference per call;
  having only one eq_assume_tac speeds it up!*)

fun prolog_step_tac' ctxt horns =
    let val horn0s = (*0 subgoals vs 1 or more*)
            take_prefix Thm.no_prems horns
        val nrtac = Bires.resolve_from_net_tac ctxt (Bires.build_net horns)
    in  fn i => eq_assume_tac i ORELSE
                match_tac ctxt horn0s i ORELSE  (*no backtracking if unit MATCHES*)
                ((assume_tac ctxt i APPEND nrtac i) THEN check_tac)
    end;

fun iter_deepen_prolog_tac ctxt horns =
    ITER_DEEPEN iter_deepen_limit Thm.no_prems (prolog_step_tac' ctxt horns);

fun iter_deepen_meson_tac ctxt ths = ctxt |> MESON all_tac (make_clauses ctxt)
  (fn cls =>
    (case (gocls (cls @ ths)) of
      [] => no_tac  (*no goal clauses*)
    | goes =>
        let
          val horns = make_horns (cls @ ths)
          val _ = trace_msg ctxt (fn () =>
            cat_lines ("meson method called:" ::
              map (Thm.string_of_thm ctxt) (cls @ ths) @
              ["clauses:"] @ map (Thm.string_of_thm ctxt) horns))
        in
          THEN_ITER_DEEPEN iter_deepen_limit
            (resolve_tac ctxt goes 1) Thm.no_prems (prolog_step_tac' ctxt horns)
        end));

fun meson_tac ctxt ths =
  SELECT_GOAL (TRY (safe_tac ctxt) THEN TRYALL (iter_deepen_meson_tac ctxt ths));


(**** Code to support ordinary resolution, rather than Model Elimination ****)

(*Convert a list of clauses (disjunctions) to meta-level clauses (==>),
  with no contrapositives, for ordinary resolution.*)


(*Rules to convert the head literal into a negated assumption. If the head
  literal is already negated, then using notEfalse instead of notEfalse'
  prevents a double negation.*)

val notEfalse = @{lemma "\<not> P \<Longrightarrow> P \<Longrightarrow> False" by (rule notE)};
val notEfalse' = @{lemma "P \<Longrightarrow> \<not> P \<Longrightarrow> False" by (rule notE)};

fun negated_asm_of_head th =
    th RS notEfalse handle THM _ => th RS notEfalse';

(*Converting one theorem from a disjunction to a meta-level clause*)
fun make_meta_clause ctxt th =
  let val (fth, thaw) = Misc_Legacy.freeze_thaw_robust ctxt th
  in  
      (zero_var_indexes o Thm.varifyT_global o thaw 0 o 
       negated_asm_of_head o make_horn resolution_clause_rules) fth
  end;

fun make_meta_clauses ctxt ths =
    name_thms "MClause#"
      (distinct Thm.eq_thm_prop (map (make_meta_clause ctxt) ths));

end;

Messung V0.5 in Prozent
C=91 H=98 G=94

¤ Dauer der Verarbeitung: 0.13 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.