From d513d6872096bfe51f8fa3ced917131e954130e1 Mon Sep 17 00:00:00 2001 From: Ferruccio Guidi Date: Wed, 15 Jun 2005 12:42:21 +0000 Subject: [PATCH] support for the new tactics lapply and fwd used in forward reasoning --- helm/matita/matitaEngine.ml | 15 ++++++ helm/matita/tests/fguidi.ma | 94 +++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 helm/matita/tests/fguidi.ma diff --git a/helm/matita/matitaEngine.ml b/helm/matita/matitaEngine.ml index 2ac69a575..d9297bce5 100644 --- a/helm/matita/matitaEngine.ml +++ b/helm/matita/matitaEngine.ml @@ -123,6 +123,11 @@ let tactic_of_ast = function EqualityTactics.rewrite_tac ~term:t else EqualityTactics.rewrite_back_tac ~term:t + | TacticAst.FwdSimpl (_, name) -> + Tactics.fwd_simpl ~hyp:(Cic.Name name) ~dbd:(MatitaDb.instance ()) + | TacticAst.LApply (_, term, substs) -> + let f (name, term) = Cic.Name name, term in + Tactics.lapply ~substs:(List.map f substs) term | _ -> assert false let eval_tactical status tac = @@ -488,6 +493,16 @@ let disambiguate_tactic status = function | TacticAst.Split loc -> status, TacticAst.Split loc | TacticAst.Symmetry loc -> status, TacticAst.Symmetry loc | TacticAst.Goal (loc, g) -> status, TacticAst.Goal (loc, g) + | TacticAst.FwdSimpl (loc, name) -> status, TacticAst.FwdSimpl (loc, name) + | TacticAst.LApply (loc, term, substs) -> + let f (status, substs) (name, term) = + let status, term = disambiguate_term status term in + status, (name, term) :: substs + in + let status, term = disambiguate_term status term in + let status, substs = List.fold_left f (status, []) substs in + status, TacticAst.LApply (loc, term, substs) + | x -> print_endline ("Not yet implemented:" ^ TacticAstPp.pp_tactic x); assert false diff --git a/helm/matita/tests/fguidi.ma b/helm/matita/tests/fguidi.ma new file mode 100644 index 000000000..623e327f9 --- /dev/null +++ b/helm/matita/tests/fguidi.ma @@ -0,0 +1,94 @@ +alias id "O" = "cic:/Coq/Init/Datatypes/nat.ind#xpointer(1/1/1)". +alias id "nat" = "cic:/Coq/Init/Datatypes/nat.ind#xpointer(1/1)". +alias id "S" = "cic:/Coq/Init/Datatypes/nat.ind#xpointer(1/1/2)". +alias id "le" = "cic:/matita/fguidi/le.ind#xpointer(1/1)". +alias id "False_ind" = "cic:/Coq/Init/Logic/False_ind.con". +alias id "I" = "cic:/Coq/Init/Logic/True.ind#xpointer(1/1/1)". +alias id "ex_intro" = "cic:/Coq/Init/Logic/ex.ind#xpointer(1/1/1)". + +alias symbol "and" (instance 0) = "logical and". +alias symbol "eq" (instance 0) = "leibnitz's equality". +alias symbol "exists" (instance 0) = "exists". +alias id "False" = "cic:/Coq/Init/Logic/False.ind#xpointer(1/1)". +alias id "True" = "cic:/Coq/Init/Logic/True.ind#xpointer(1/1)". + +definition is_S: nat \to Prop \def + \lambda n. match n with + [ O \Rightarrow False + | (S n) \Rightarrow True + ]. + +definition pred: nat \to nat \def + \lambda n. match n with + [ O \Rightarrow O + | (S n) \Rightarrow n + ]. + +theorem eq_gen_S_O: \forall x. (S x = O) \to \forall P:Prop. P. +intros. apply False_ind. cut (is_S O). auto. elim H. exact I. +qed. + +theorem eq_gen_S_O_cc: (\forall P:Prop. P) \to \forall x. (S x = O). +intros. auto. +qed. + +theorem eq_gen_S_S: \forall m,n. (S m) = (S n) \to m = n. +intros. cut (pred (S m)) = (pred (S n)). +assumption. elim H. auto. +qed. + +theorem eq_gen_S_S_cc: \forall m,n. m = n \to (S m) = (S n). +intros. elim H. auto. +qed. + +inductive le: nat \to nat \to Prop \def + le_zero: \forall n. (le O n) + | le_succ: \forall m, n. (le m n) \to (le (S m) (S n)). + +theorem le_refl: \forall x. (le x x). +intros. elim x. auto. auto. +qed. + +theorem le_gen_x_O_aux: \forall x, y. (le x y) \to (y =O) \to + (x = O). +intros 3. elim H. auto. apply eq_gen_S_O. exact x2. auto. +qed. + +theorem le_gen_x_O: \forall x. (le x O) \to (x = O). +intros. apply le_gen_x_O_aux. exact O. auto. auto. +qed. + +theorem le_gen_x_O_cc: \forall x. (x = O) \to (le x O). +intros. elim H. auto. +qed. + +theorem le_gen_S_x_aux: \forall m,x,y. (le y x) \to (y = S m) \to + (\exists n. x = (S n) \land (le m n)). +intros 4. elim H. +apply eq_gen_S_O. exact m. elim H1. auto. +cut x1 = m. elim Hcut. apply ex_intro. exact x2. auto. auto. +qed. + +theorem le_gen_S_x: \forall m,x. (le (S m) x) \to + (\exists n. x = (S n) \land (le m n)). +intros. apply le_gen_S_x_aux. exact (S m). auto. auto. +qed. + +theorem le_gen_S_x_cc: \forall m,x. (\exists n. x = (S n) \land (le m n)) \to + (le (S m) x). +intros. elim H. elim H1. cut (S x1) = x. elim Hcut. auto. elim H2. auto. +qed. + +theorem le_gen_S_S: \forall m,n. (le (S m) (S n)) \to (le m n). +intros. cut (\exists p. (S n) = (S p) \land (le m p)). +elim Hcut. elim H1. cut x = n. +elim Hcut1. auto. symmetry. auto. auto. +qed. + +theorem le_gen_S_S_cc: \forall m,n. (le m n) \to (le (S m) (S n)). +intros. auto. +qed. + +theorem pippo: \forall m,n. (le (S m) (S n)) \to (le m n). +intros. +lapply le_gen_S_x. \ No newline at end of file -- 2.39.2