src/FOLP/simp.ML
changeset 60774 6c28d8ed2488
parent 60756 f122140b7195
child 60789 15f3da2636f5
equal deleted inserted replaced
60773:d09c66a0ea10 60774:6c28d8ed2488
    34   val addrew    : Proof.context -> thm -> simpset -> simpset
    34   val addrew    : Proof.context -> thm -> simpset -> simpset
    35   val delcongs  : simpset * thm list -> simpset
    35   val delcongs  : simpset * thm list -> simpset
    36   val delrews   : simpset * thm list -> simpset
    36   val delrews   : simpset * thm list -> simpset
    37   val dest_ss   : simpset -> thm list * thm list
    37   val dest_ss   : simpset -> thm list * thm list
    38   val print_ss  : Proof.context -> simpset -> unit
    38   val print_ss  : Proof.context -> simpset -> unit
    39   val setauto   : simpset * (int -> tactic) -> simpset
    39   val setauto   : simpset * (Proof.context -> int -> tactic) -> simpset
    40   val ASM_SIMP_CASE_TAC : Proof.context -> simpset -> int -> tactic
    40   val ASM_SIMP_CASE_TAC : Proof.context -> simpset -> int -> tactic
    41   val ASM_SIMP_TAC      : Proof.context -> simpset -> int -> tactic
    41   val ASM_SIMP_TAC      : Proof.context -> simpset -> int -> tactic
    42   val CASE_TAC          : Proof.context -> simpset -> int -> tactic
    42   val CASE_TAC          : Proof.context -> simpset -> int -> tactic
    43   val SIMP_CASE2_TAC    : Proof.context -> simpset -> int -> tactic
    43   val SIMP_CASE2_TAC    : Proof.context -> simpset -> int -> tactic
    44   val SIMP_THM          : Proof.context -> simpset -> thm -> thm
    44   val SIMP_THM          : Proof.context -> simpset -> thm -> thm
   233 
   233 
   234 
   234 
   235 (* SIMPSET *)
   235 (* SIMPSET *)
   236 
   236 
   237 datatype simpset =
   237 datatype simpset =
   238         SS of {auto_tac: int -> tactic,
   238         SS of {auto_tac: Proof.context -> int -> tactic,
   239                congs: thm list,
   239                congs: thm list,
   240                cong_net: thm Net.net,
   240                cong_net: thm Net.net,
   241                mk_simps: Proof.context -> thm -> thm list,
   241                mk_simps: Proof.context -> thm -> thm list,
   242                simps: (thm * thm list) list,
   242                simps: (thm * thm list) list,
   243                simp_net: thm Net.net}
   243                simp_net: thm Net.net}
   244 
   244 
   245 val empty_ss = SS{auto_tac= K no_tac, congs=[], cong_net=Net.empty,
   245 val empty_ss = SS{auto_tac= K (K no_tac), congs=[], cong_net=Net.empty,
   246                   mk_simps = fn ctxt => normed_rews ctxt [], simps=[], simp_net=Net.empty};
   246                   mk_simps = fn ctxt => normed_rews ctxt [], simps=[], simp_net=Net.empty};
   247 
   247 
   248 (** Insertion of congruences and rewrites **)
   248 (** Insertion of congruences and rewrites **)
   249 
   249 
   250 (*insert a thm in a thm net*)
   250 (*insert a thm in a thm net*)
   444             then rew((lhs_net_tac ctxt anet i THEN assume_tac ctxt i) thm,
   444             then rew((lhs_net_tac ctxt anet i THEN assume_tac ctxt i) thm,
   445                      thm,ss,anet,ats,cs,false)
   445                      thm,ss,anet,ats,cs,false)
   446             else (ss,thm,anet,ats,cs);
   446             else (ss,thm,anet,ats,cs);
   447 
   447 
   448 fun try_true(thm,ss,anet,ats,cs) =
   448 fun try_true(thm,ss,anet,ats,cs) =
   449     case Seq.pull(auto_tac i thm) of
   449     case Seq.pull(auto_tac ctxt i thm) of
   450       SOME(thm',_) => (ss,thm',anet,ats,cs)
   450       SOME(thm',_) => (ss,thm',anet,ats,cs)
   451     | NONE => let val (ss0,thm0,anet0,ats0,seq,more)::cs0 = cs
   451     | NONE => let val (ss0,thm0,anet0,ats0,seq,more)::cs0 = cs
   452               in if !tracing
   452               in if !tracing
   453                  then (writeln"*** Failed to prove precondition. Normal form:";
   453                  then (writeln"*** Failed to prove precondition. Normal form:";
   454                        pr_goal_concl ctxt i thm;  writeln"")
   454                        pr_goal_concl ctxt i thm;  writeln"")
   484 let val cong_tac = net_tac ctxt cong_net
   484 let val cong_tac = net_tac ctxt cong_net
   485 in fn i =>
   485 in fn i =>
   486     (fn thm =>
   486     (fn thm =>
   487      if i <= 0 orelse Thm.nprems_of thm < i then Seq.empty
   487      if i <= 0 orelse Thm.nprems_of thm < i then Seq.empty
   488      else Seq.single(execute ctxt (ss,fl,auto_tac,cong_tac,simp_net,i,thm)))
   488      else Seq.single(execute ctxt (ss,fl,auto_tac,cong_tac,simp_net,i,thm)))
   489     THEN TRY(auto_tac i)
   489     THEN TRY(auto_tac ctxt i)
   490 end;
   490 end;
   491 
   491 
   492 fun SIMP_TAC ctxt = EXEC_TAC ctxt ([MK_EQ,SIMP_LHS,REFL,STOP],false);
   492 fun SIMP_TAC ctxt = EXEC_TAC ctxt ([MK_EQ,SIMP_LHS,REFL,STOP],false);
   493 fun SIMP_CASE_TAC ctxt = EXEC_TAC ctxt ([MK_EQ,SIMP_LHS,IF,REFL,STOP],false);
   493 fun SIMP_CASE_TAC ctxt = EXEC_TAC ctxt ([MK_EQ,SIMP_LHS,IF,REFL,STOP],false);
   494 
   494