src/Provers/classical.ML
changeset 18688 abf0f018b5ec
parent 18643 89a7978f90e1
child 18691 a2dc15d9d6c8
equal deleted inserted replaced
18687:af605e186480 18688:abf0f018b5ec
   141   val del_context_unsafe_wrapper: string -> theory -> theory
   141   val del_context_unsafe_wrapper: string -> theory -> theory
   142   val get_claset: theory -> claset
   142   val get_claset: theory -> claset
   143   val print_local_claset: Proof.context -> unit
   143   val print_local_claset: Proof.context -> unit
   144   val get_local_claset: Proof.context -> claset
   144   val get_local_claset: Proof.context -> claset
   145   val put_local_claset: claset -> Proof.context -> Proof.context
   145   val put_local_claset: claset -> Proof.context -> Proof.context
   146   val safe_dest_global: theory attribute
   146   val safe_dest: Context.generic attribute
   147   val safe_elim_global: theory attribute
   147   val safe_elim: Context.generic attribute
   148   val safe_intro_global: theory attribute
   148   val safe_intro: Context.generic attribute
   149   val haz_dest_global: theory attribute
   149   val haz_dest: Context.generic attribute
   150   val haz_elim_global: theory attribute
   150   val haz_elim: Context.generic attribute
   151   val haz_intro_global: theory attribute
   151   val haz_intro: Context.generic attribute
   152   val rule_del_global: theory attribute
   152   val rule_del: Context.generic attribute
   153   val safe_dest_local: Proof.context attribute
       
   154   val safe_elim_local: Proof.context attribute
       
   155   val safe_intro_local: Proof.context attribute
       
   156   val haz_dest_local: Proof.context attribute
       
   157   val haz_elim_local: Proof.context attribute
       
   158   val haz_intro_local: Proof.context attribute
       
   159   val rule_del_local: Proof.context attribute
       
   160   val cla_modifiers: (Args.T list -> (Method.modifier * Args.T list)) list
   153   val cla_modifiers: (Args.T list -> (Method.modifier * Args.T list)) list
   161   val cla_meth: (claset -> tactic) -> thm list -> Proof.context -> Proof.method
   154   val cla_meth: (claset -> tactic) -> thm list -> Proof.context -> Proof.method
   162   val cla_meth': (claset -> int -> tactic) -> thm list -> Proof.context -> Proof.method
   155   val cla_meth': (claset -> int -> tactic) -> thm list -> Proof.context -> Proof.method
   163   val cla_method: (claset -> tactic) -> Method.src -> Proof.context -> Proof.method
   156   val cla_method: (claset -> tactic) -> Method.src -> Proof.context -> Proof.method
   164   val cla_method': (claset -> int -> tactic) -> Method.src -> Proof.context -> Proof.method
   157   val cla_method': (claset -> int -> tactic) -> Method.src -> Proof.context -> Proof.method
   957   context_cs ctxt (get_local_claset ctxt) (get_context_cs ctxt);
   950   context_cs ctxt (get_local_claset ctxt) (get_context_cs ctxt);
   958 
   951 
   959 
   952 
   960 (* attributes *)
   953 (* attributes *)
   961 
   954 
   962 fun change_global_cs f (thy, th) = (change_claset_of thy (fn cs => f (cs, [th])); (thy, th));
   955 fun attrib f = Attrib.declaration (fn th =>
   963 fun change_local_cs f (ctxt, th) = (LocalClaset.map (fn cs => f (cs, [th])) ctxt, th);
   956    fn Context.Theory thy => (change_claset_of thy (fn cs => f (cs, [th])); Context.Theory thy)
   964 
   957     | Context.Proof ctxt => Context.Proof (LocalClaset.map (fn cs => f (cs, [th])) ctxt));
   965 val safe_dest_global = change_global_cs (op addSDs);
   958 
   966 val safe_elim_global = change_global_cs (op addSEs);
   959 val safe_dest = attrib (op addSDs);
   967 val safe_intro_global = change_global_cs (op addSIs);
   960 val safe_elim = attrib (op addSEs);
   968 val haz_dest_global = change_global_cs (op addDs);
   961 val safe_intro = attrib (op addSIs);
   969 val haz_elim_global = change_global_cs (op addEs);
   962 val haz_dest = attrib (op addDs);
   970 val haz_intro_global = change_global_cs (op addIs);
   963 val haz_elim = attrib (op addEs);
   971 val rule_del_global = change_global_cs (op delrules) o Attrib.theory ContextRules.rule_del;
   964 val haz_intro = attrib (op addIs);
   972 
   965 val rule_del = attrib (op delrules) o ContextRules.rule_del;
   973 val safe_dest_local = change_local_cs (op addSDs);
       
   974 val safe_elim_local = change_local_cs (op addSEs);
       
   975 val safe_intro_local = change_local_cs (op addSIs);
       
   976 val haz_dest_local = change_local_cs (op addDs);
       
   977 val haz_elim_local = change_local_cs (op addEs);
       
   978 val haz_intro_local = change_local_cs (op addIs);
       
   979 val rule_del_local = change_local_cs (op delrules) o Attrib.context ContextRules.rule_del;
       
   980 
   966 
   981 
   967 
   982 (* tactics referring to the implicit claset *)
   968 (* tactics referring to the implicit claset *)
   983 
   969 
   984 (*the abstraction over the proof state delays the dereferencing*)
   970 (*the abstraction over the proof state delays the dereferencing*)
  1016 
  1002 
  1017 (* setup_attrs *)
  1003 (* setup_attrs *)
  1018 
  1004 
  1019 val setup_attrs = Attrib.add_attributes
  1005 val setup_attrs = Attrib.add_attributes
  1020  [("swapped", (swapped, swapped), "classical swap of introduction rule"),
  1006  [("swapped", (swapped, swapped), "classical swap of introduction rule"),
  1021   (destN,
  1007   (destN, Attrib.common (add_rule ContextRules.dest_query haz_dest safe_dest),
  1022    (add_rule (Attrib.theory o ContextRules.dest_query) haz_dest_global safe_dest_global,
  1008     "declaration of Classical destruction rule"),
  1023     add_rule (Attrib.context o ContextRules.dest_query) haz_dest_local safe_dest_local),
  1009   (elimN, Attrib.common (add_rule ContextRules.elim_query haz_elim safe_elim),
  1024     "declaration of destruction rule"),
  1010     "declaration of Classical elimination rule"),
  1025   (elimN,
  1011   (introN, Attrib.common (add_rule ContextRules.intro_query haz_intro safe_intro),
  1026    (add_rule (Attrib.theory o ContextRules.elim_query) haz_elim_global safe_elim_global,
  1012     "declaration of Classical introduction rule"),
  1027     add_rule (Attrib.context o ContextRules.elim_query) haz_elim_local safe_elim_local),
  1013   (ruleN, Attrib.common (del_rule rule_del),
  1028     "declaration of elimination rule"),
       
  1029   (introN,
       
  1030    (add_rule (Attrib.theory o ContextRules.intro_query) haz_intro_global safe_intro_global,
       
  1031     add_rule (Attrib.context o ContextRules.intro_query) haz_intro_local safe_intro_local),
       
  1032     "declaration of introduction rule"),
       
  1033   (ruleN, (del_rule rule_del_global, del_rule rule_del_local),
       
  1034     "remove declaration of intro/elim/dest rule")];
  1014     "remove declaration of intro/elim/dest rule")];
  1035 
  1015 
  1036 
  1016 
  1037 
  1017 
  1038 (** proof methods **)
  1018 (** proof methods **)
  1076 
  1056 
  1077 
  1057 
  1078 (* automatic methods *)
  1058 (* automatic methods *)
  1079 
  1059 
  1080 val cla_modifiers =
  1060 val cla_modifiers =
  1081  [Args.$$$ destN -- Args.bang_colon >> K ((I, safe_dest_local): Method.modifier),
  1061  [Args.$$$ destN -- Args.bang_colon >> K ((I, Attrib.context safe_dest): Method.modifier),
  1082   Args.$$$ destN -- Args.colon >> K (I, haz_dest_local),
  1062   Args.$$$ destN -- Args.colon >> K (I, Attrib.context haz_dest),
  1083   Args.$$$ elimN -- Args.bang_colon >> K (I, safe_elim_local),
  1063   Args.$$$ elimN -- Args.bang_colon >> K (I, Attrib.context safe_elim),
  1084   Args.$$$ elimN -- Args.colon >> K (I, haz_elim_local),
  1064   Args.$$$ elimN -- Args.colon >> K (I, Attrib.context haz_elim),
  1085   Args.$$$ introN -- Args.bang_colon >> K (I, safe_intro_local),
  1065   Args.$$$ introN -- Args.bang_colon >> K (I, Attrib.context safe_intro),
  1086   Args.$$$ introN -- Args.colon >> K (I, haz_intro_local),
  1066   Args.$$$ introN -- Args.colon >> K (I, Attrib.context haz_intro),
  1087   Args.del -- Args.colon >> K (I, rule_del_local)];
  1067   Args.del -- Args.colon >> K (I, Attrib.context rule_del)];
  1088 
  1068 
  1089 fun cla_meth tac prems ctxt = Method.METHOD (fn facts =>
  1069 fun cla_meth tac prems ctxt = Method.METHOD (fn facts =>
  1090   ALLGOALS (Method.insert_tac (prems @ facts)) THEN tac (local_claset_of ctxt));
  1070   ALLGOALS (Method.insert_tac (prems @ facts)) THEN tac (local_claset_of ctxt));
  1091 
  1071 
  1092 fun cla_meth' tac prems ctxt = Method.METHOD (fn facts =>
  1072 fun cla_meth' tac prems ctxt = Method.METHOD (fn facts =>