| IDENT "timeout"
| IDENT "library"
| IDENT "type"
+ | IDENT "steps"
+ | IDENT "all"
]
];
auto_params: [
(* performs steps of rewrite with the universe, obtaining if possible
* a trivial goal *)
-let solve_rewrite_tac ~automation_cache ~params:(univ,params) (proof,goal as status)=
+let solve_rewrite_tac ~automation_cache ~params:(univ,params) (proof,goal)=
let steps = int_of_string (string params "steps" "1") in
+ let use_context = bool params "use_context" true in
let universe, tables, cache =
- init_cache_and_tables ~use_library:false ~use_context:false
+ init_cache_and_tables ~use_library:false ~use_context
automation_cache univ (proof,goal)
in
let actives, passives, bag = tables in
- let _,metasenv,_subst,_,_,_ = proof in
+ let pa,metasenv,_subst,pb,pc,pd = proof in
let _,context,ty = CicUtil.lookup_meta goal metasenv in
let eq_uri = eq_of_goal ty in
let initgoal = [], metasenv, ty in
Equality.build_goal_proof
bag eq_uri proof refl newty [] context metasenv
in
+ let proofterm, _, metasenv, _ =
+ CicRefine.type_of_aux' metasenv context proofterm
+ CicUniv.oblivion_ugraph
+ in
+ let status = (pa,metasenv,_subst,pb,pc,pd), goal in
ProofEngineTypes.apply_tactic
(PrimitiveTactics.apply_tac ~term:proofterm) status
| None ->
Equality.build_goal_proof (~contextualize:false) bag
eq_uri newproof opengoal ty [] context metasenv
in
- let extended_metasenv = (maxm,context,newty)::metasenv in
+ let metasenv = (maxm,context,newty)::metasenv in
+ let proofterm, _, metasenv, _ =
+ CicRefine.type_of_aux' metasenv context proofterm
+ CicUniv.oblivion_ugraph
+ in
let extended_status =
- (curi,extended_metasenv,_subst,pbo,pty, attrs),goal in
+ (curi,metasenv,_subst,pbo,pty, attrs),goal in
let (status,newgoals) =
ProofEngineTypes.apply_tactic
(PrimitiveTactics.apply_tac ~term:proofterm)
let demodulate_tac ~dbd ~params ~automation_cache =
ProofEngineTypes.mk_tactic (demodulate_tac ~dbd ~params ~automation_cache);;
+let demodulate_tac ~dbd ~params:(_,flags as params) ~automation_cache =
+ let all = bool flags "all" false in
+ if all then
+ solve_rewrite_tac ~params ~automation_cache ()
+ else
+ demodulate_tac ~dbd ~params ~automation_cache
+;;
+
let pp_proofterm = Equality.pp_proofterm;;
let revision = "$Revision$";;
Tactics.auto ~dbd ~params:(univ, params') ~automation_cache]
| `Term just -> Tactics.apply just
| `SolveWith term ->
- Tactics.solve_rewrite ~automation_cache ~params:([term],["steps","1"]) ()
+ Tactics.solve_rewrite ~automation_cache
+ ~params:([term],["steps","1"; "use_context","false"]) ()
| `Proof ->
Tacticals.id_tac
in
;;
let rec demod bag env table goal =
- let goalproof,menv,t = goal in
+ let _,menv,t = goal in
let _, context, ugraph = env in
let res = demodulation_aux bag menv context ugraph table 0 t (~typecheck:true)in
match res with
when LibraryObjects.is_eq_URI uri ->
(try
let _ =
- Founif.unification m m context left right CicUniv.empty_ugraph
+ Founif.unification [] m context left right CicUniv.empty_ugraph
in
Yes newg
with CicUnification.UnificationFailure _ -> No [newg])
with Not_found ->
No (List.flatten (List.map (function No s -> s | _-> assert false) newg))
in
- let rec first f l =
+ let rec first f acc l =
match l with
- | [] -> None
+ | [] -> acc,None
| x::tl ->
- match f x with
- | None -> first f tl
- | Some x as ok -> ok
+ match f acc x with
+ | acc,None -> first f acc tl
+ | acc,Some x as ok -> ok
in
- let rec aux steps next goal =
- if steps = 0 then None else
+ let rec aux steps next visited goal =
+ if steps = 0 then visited, None else
let goalproof,menv,_,_,left,right = open_goal goal in
+ if (List.mem (left,right,next) visited || List.mem (right,left,next) visited)
+ then visited, None else
let do_step t =
demodulation_all_aux menv context ugraph table 0 t
in
+ let visited = (left,right,next) :: visited in
match next with
| L ->
(match do_step left with
| _::_ as res ->
(match solved goal res Utils.Right with
| No newgoals ->
- (match first (aux (steps - 1) L) newgoals with
- | Some g as success -> success
- | None -> aux steps R goal)
- | Yes newgoal -> Some newgoal)
- | [] -> aux steps R goal)
+ (match first (aux (steps - 1) L) visited newgoals with
+ | _,Some g as success -> success
+ | visited,None -> aux steps R visited goal)
+ | Yes newgoal -> visited, Some newgoal)
+ | [] -> aux steps R visited goal)
| R ->
(match do_step right with
| _::_ as res ->
(match solved goal res Utils.Left with
| No newgoals ->
- (match first (aux (steps - 1) L) newgoals with
- | Some g as success -> success
- | None -> None)
- | Yes newgoal -> Some newgoal)
- | [] -> None)
+ (match first (aux (steps - 1) L) visited newgoals with
+ | visited, Some g as success -> success
+ | visited, None as failure -> failure)
+ | Yes newgoal -> visited, Some newgoal)
+ | [] -> visited, None)
in
- aux steps L initgoal
+ let _, res = aux steps L [] initgoal in
+ res
;;
let get_stats () = "" ;;
lapply (H4 i); clear H4;
rewrite > symm_orb in ⊢ (? ? (? ? %) ?);
rewrite > distributive_orb_andb;
- autobatch paramodulation by distributive_orb_andb,symm_orb,symm_orb, Hletin, Hletin1,andb_true.
+ demodulate.
+ reflexivity.
+ (*
+ autobatch paramodulation
+ by distributive_orb_andb,symm_orb,symm_orb,
+ Hletin, Hletin1,andb_true.
+ *)
| simplify in H2 ⊢ %;
intros;
lapply (H2 i); clear H2;
- autobatch paramodulation by andb_assoc, Hletin.
+ pump 100. pump 100.
+ demodulate.
+ reflexivity.
+ (* autobatch paramodulation by andb_assoc, Hletin. *)
| simplify in H2 H4 ⊢ %;
intros;
lapply (H2 i); clear H2;
rewrite > demorgan2;
rewrite > symm_orb;
rewrite > distributive_orb_andb;
- autobatch paramodulation by symm_andb,symm_orb,andb_true,Hletin,Hletin1.
+ demodulate.
+ reflexivity.
+ (* autobatch paramodulation by symm_andb,symm_orb,andb_true,Hletin,Hletin1. *)
| simplify in H2 ⊢ %;
intros;
lapply (H2 i); clear H2;
rewrite < sym_times.
rewrite > distr_times_minus.
rewrite > plus_minus.
+lapply(plus_to_minus ??? H3); demodulate. reflexivity.
+(*
rewrite > sym_times.
rewrite < H5.
rewrite < sym_times.
apply plus_to_minus.
apply H3.
+*)
apply le_times_r.
apply lt_to_le.
apply H6.
theorem div_mod_spec_times : \forall n,m:nat.div_mod_spec ((S n)*m) (S n) m O.
intros.constructor 1.
-unfold lt.apply le_S_S.apply le_O_n.
-rewrite < plus_n_O.rewrite < sym_times.reflexivity.
+unfold lt.apply le_S_S.apply le_O_n. demodulate. reflexivity.
+(*rewrite < plus_n_O.rewrite < sym_times.reflexivity.*)
qed.
lemma div_plus_times: \forall m,q,r:nat. r < m \to (q*m+r)/ m = q.
intros.
apply (div_mod_spec_to_eq n n (n / n) (n \mod n) (S O) O).
apply div_mod_spec_div_mod.assumption.
-constructor 1.assumption.
-rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity.
+constructor 1.assumption. demodulate. reflexivity. (*
+rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity.*)
qed.
theorem eq_div_O: \forall n,m. n < m \to n / m = O.
intros.
apply (div_mod_spec_to_eq2 n n (n / n) (n \mod n) (S O) O).
apply div_mod_spec_div_mod.assumption.
-constructor 1.assumption.
-rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity.
+constructor 1.assumption. demodulate. reflexivity.(*
+rewrite < plus_n_O.simplify.rewrite < plus_n_O.reflexivity.*)
qed.
theorem mod_S: \forall n,m:nat. O < m \to S (n \mod m) < m \to
lemma lt_to_lt_O_minus : \forall m,n.
n < m \to O < m - n.
intros.
-unfold. apply le_plus_to_minus_r. unfold in H. rewrite > sym_plus.
+unfold. apply le_plus_to_minus_r. unfold in H.
+cut ((S n ≤ m) = (1 + n ≤ m)) as applyS;
+ [ rewrite < applyS; assumption;
+ | demodulate; reflexivity. ]
+(*
+rewrite > sym_plus.
rewrite < plus_n_Sm.
rewrite < plus_n_O.
assumption.
+*)
qed.
theorem lt_minus_to_plus: \forall n,m,p. (lt n (p-m)) \to (lt (n+m) p).
theorem eq_minus_plus_plus_minus: \forall n,m,p:nat. p \le m \to (n+m)-p = n+(m-p).
intros.
apply plus_to_minus.
+lapply (plus_minus_m_m ?? H); demodulate. reflexivity.
+(*
rewrite > sym_plus in \vdash (? ? ? %).
rewrite > assoc_plus.
rewrite < plus_minus_m_m.
reflexivity.assumption.
+*)
qed.
theorem eq_minus_minus_minus_plus: \forall n,m,p:nat. (n-m)-p = n-(m+p).
\forall n,m:nat. n+(n*m) = n*(S m).
intros.elim n.
simplify.reflexivity.
-simplify.apply eq_f.rewrite < H.
+simplify.
+demodulate all steps=3.
+(*
+apply eq_f.rewrite < H.
transitivity ((n1+m)+n1*m).symmetry.apply assoc_plus.
transitivity ((m+n1)+n1*m).
apply eq_f2.
apply sym_plus.
reflexivity.
apply assoc_plus.
+*)
qed.
theorem times_O_to_O: \forall n,m:nat.n*m = O \to n = O \lor m= O.
qed.
theorem times_n_SO : \forall n:nat. n = n * S O.
-intros.
+intros. demodulate. reflexivity. (*
rewrite < times_n_Sm.
rewrite < times_n_O.
rewrite < plus_n_O.
-reflexivity.
+reflexivity.*)
qed.
theorem times_SSO_n : \forall n:nat. n + n = S (S O) * n.
theorem symmetric_times : symmetric nat times.
unfold symmetric.
-intros.elim x.
-simplify.apply times_n_O.
+intros.elim x;
+ [ simplify. apply times_n_O.
+ | demodulate. reflexivity. (*
(* applyS times_n_Sm. *)
-simplify.rewrite > H.apply times_n_Sm.
+simplify.rewrite > H.apply times_n_Sm.*)]
qed.
variant sym_times : \forall n,m:nat. n*m = m*n \def
unfold distributive.
intros.elim x.
simplify.reflexivity.
-simplify.rewrite > H. rewrite > assoc_plus.rewrite > assoc_plus.
+simplify.
+demodulate all steps=16.
+(*
+rewrite > H. rewrite > assoc_plus.rewrite > assoc_plus.
apply eq_f.rewrite < assoc_plus. rewrite < (sym_plus ? z).
-rewrite > assoc_plus.reflexivity.
+rewrite > assoc_plus.reflexivity. *)
qed.
variant distr_times_plus: \forall n,m,p:nat. n*(m+p) = n*m + n*p
unfold associative.
intros.
elim x. simplify.apply refl_eq.
-simplify.rewrite < sym_times.
+simplify.
+demodulate all steps=4.
+(*
+rewrite < sym_times.
rewrite > distr_times_plus.
rewrite < sym_times.
rewrite < (sym_times (times n y) z).
rewrite < H.apply refl_eq.
+*)
qed.
variant assoc_times: \forall n,m,p:nat. (n*m)*p = n*(m*p) \def
lemma times_times: ∀x,y,z. x*(y*z) = y*(x*z).
intros.
-demodulate. reflexivity;
+demodulate. reflexivity.
(* autobatch paramodulation. *)
qed.