src/HOL/Tools/meson.ML
changeset 15118 e2bd080c7975
parent 15032 02aed07e01bf
child 15151 429666b09783
equal deleted inserted replaced
15117:b860e444c1db 15118:e2bd080c7975
   369 (*Permute a rule's premises to move the i-th premise to the last position.*)
   369 (*Permute a rule's premises to move the i-th premise to the last position.*)
   370 fun make_last i th =
   370 fun make_last i th =
   371   let val n = nprems_of th 
   371   let val n = nprems_of th 
   372   in  if 1 <= i andalso i <= n 
   372   in  if 1 <= i andalso i <= n 
   373       then Thm.permute_prems (i-1) 1 th
   373       then Thm.permute_prems (i-1) 1 th
   374       else raise THM("make_last", i, [th])
   374       else raise THM("select_literal", i, [th])
   375   end;
   375   end;
   376 
   376 
   377 (*Maps a rule that ends "... ==> P ==> False" to "... ==> ~P" while suppressing
   377 (*Maps a rule that ends "... ==> P ==> False" to "... ==> ~P" while suppressing
   378   double-negations.*)
   378   double-negations.*)
   379 val negate_head = rewrite_rule [atomize_not, not_not RS eq_reflection];
   379 val negate_head = rewrite_rule [atomize_not, not_not RS eq_reflection];
   396 	    (fn hyps => (cut_facts_tac (map (skolemize o make_nnf) hyps) 1
   396 	    (fn hyps => (cut_facts_tac (map (skolemize o make_nnf) hyps) 1
   397                          THEN REPEAT (etac exE 1))),
   397                          THEN REPEAT (etac exE 1))),
   398 	  REPEAT_DETERM_N (length ts) o (etac thin_rl)]
   398 	  REPEAT_DETERM_N (length ts) o (etac thin_rl)]
   399      end);
   399      end);
   400 
   400 
   401 (*Top-level conversion to clauses (disjunctions). Each clause has  
   401 (*Top-level conversion to meta-level clauses. Each clause has  
   402   leading !!-bound universal variables, to express generality.*)
   402   leading !!-bound universal variables, to express generality. To get 
       
   403   disjunctions instead of meta-clauses, remove "make_meta_clauses" below.*)
   403 val make_clauses_tac = 
   404 val make_clauses_tac = 
   404   SUBGOAL
   405   SUBGOAL
   405     (fn (prop,_) =>
   406     (fn (prop,_) =>
   406      let val ts = Logic.strip_assums_hyp prop
   407      let val ts = Logic.strip_assums_hyp prop
   407      in EVERY1 
   408      in EVERY1 
   408 	 [METAHYPS
   409 	 [METAHYPS
   409 	    (fn hyps => 
   410 	    (fn hyps => 
   410               (cut_rules_tac (map forall_intr_vars (make_clauses hyps)) 1)),
   411               (cut_rules_tac
       
   412                 (map forall_intr_vars 
       
   413                   (make_meta_clauses (make_clauses hyps))) 1)),
   411 	  REPEAT_DETERM_N (length ts) o (etac thin_rl)]
   414 	  REPEAT_DETERM_N (length ts) o (etac thin_rl)]
   412      end);
   415      end);
   413 
       
   414 
   416 
   415 
   417 
   416 (** proof method setup **)
   418 (** proof method setup **)
   417 
   419 
   418 local
   420 local
   436   [("meson", Method.ctxt_args meson_meth, 
   438   [("meson", Method.ctxt_args meson_meth, 
   437     "The MESON resolution proof procedure"),
   439     "The MESON resolution proof procedure"),
   438    ("skolemize", Method.no_args skolemize_meth, 
   440    ("skolemize", Method.no_args skolemize_meth, 
   439     "Skolemization into existential quantifiers"),
   441     "Skolemization into existential quantifiers"),
   440    ("make_clauses", Method.no_args make_clauses_meth, 
   442    ("make_clauses", Method.no_args make_clauses_meth, 
   441     "Conversion to !!-quantified disjunctions")]];
   443     "Conversion to !!-quantified meta-level clauses")]];
   442 
   444 
   443 end;
   445 end;
   444 
   446 
   445 end;
   447 end;