]> matita.cs.unibo.it Git - helm.git/commitdiff
1. Tactic generalize ported to patterns and activated in matita.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Thu, 23 Jun 2005 12:23:04 +0000 (12:23 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Thu, 23 Jun 2005 12:23:04 +0000 (12:23 +0000)
2. slightly improved syntax for patterns
3. new test for "hand implemented" inversion (that uses induction instead of
   case analysis)

helm/matita/matita.lang
helm/matita/matitaEngine.ml
helm/matita/tests/inversion.ma [new file with mode: 0644]
helm/matita/tests/rewrite.ma

index baccdf71430c09a83f75bc22d91205a8cd3966d7..d2015ee3e4320df4c64b89274acfe09297947776 100644 (file)
@@ -77,6 +77,7 @@
     <keyword>exists</keyword>
     <keyword>fold</keyword>
     <keyword>fourier</keyword>
+    <keyword>generalize</keyword>
     <keyword>goal</keyword>
     <keyword>injection</keyword>
     <keyword>intro</keyword>
index a9c85e7d86f1ccd3b0dc6ddcb4b336ca5b725e9c..7302e3bde0ff6d5e2b5b012192e87f78fa56ad14 100644 (file)
@@ -30,8 +30,12 @@ let tactic_of_ast = function
   | TacticAst.Reflexivity _ -> Tactics.reflexivity
   | TacticAst.Assumption _ -> Tactics.assumption
   | TacticAst.Contradiction _ -> Tactics.contradiction
+(*
+  | TacticAst.Discriminate (_,id) -> Tactics.discriminate id
+*)
   | TacticAst.Exists _ -> Tactics.exists
   | TacticAst.Fourier _ -> Tactics.fourier
+  | TacticAst.Generalize (_,term,pat) -> Tactics.generalize term pat
   | TacticAst.Goal (_, n) -> Tactics.set_goal n
   | TacticAst.Left _ -> Tactics.left
   | TacticAst.Right _ -> Tactics.right
@@ -58,7 +62,6 @@ let tactic_of_ast = function
   | TacticAst.Change_pattern of 'term pattern * 'term * 'ident option
   | TacticAst.Change of 'term * 'term * 'ident option
   | TacticAst.Decompose of 'ident * 'ident list
-  | TacticAst.Discriminate of 'ident
   | TacticAst.Fold of reduction_kind * 'term
   | TacticAst.Injection of 'ident
   | TacticAst.Replace_pattern of 'term pattern * 'term
@@ -81,7 +84,6 @@ let tactic_of_ast = function
   | 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 =
   let apply_tactic tactic =
@@ -408,6 +410,10 @@ let disambiguate_tactic status = function
       let status, cic1 = disambiguate_term status what in
       let status, cic2 = disambiguate_term status with_what in
       status, TacticAst.Change (loc, cic1, cic2, ident)
+  | TacticAst.Generalize (loc,term,pattern) ->
+      let status,term = disambiguate_term status term in
+      let pattern = disambiguate_pattern status.aliases pattern in
+      status, TacticAst.Generalize(loc,term,pattern)
 (*
   (* TODO Zack a lot more of tactics to be implemented here ... *)
   | TacticAst.Change_pattern of 'term pattern * 'term * 'ident option
@@ -451,10 +457,6 @@ let disambiguate_tactic status = function
      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
 
 let rec disambiguate_tactical status = function 
   | TacticAst.Tactic (loc, tactic) -> 
diff --git a/helm/matita/tests/inversion.ma b/helm/matita/tests/inversion.ma
new file mode 100644 (file)
index 0000000..ccbc4d9
--- /dev/null
@@ -0,0 +1,22 @@
+inductive nat : Set \def
+   O : nat
+ | S : nat \to nat.
+inductive le (n:nat) : nat \to Prop \def
+   leO : le n n
+ | leS : \forall m. le n m \to le n (S m).
+
+alias symbol "eq" (instance 0) = "leibnitz's equality".
+
+theorem test_inversion: \forall n. le n O \to n=O.
+ intros.
+ cut O=O.
+  (* goal 2: 0 = 0 *)
+  goal 7. reflexivity.
+  (* goal 1 *)
+  generalize Hcut.      (* non attaccata. Dovrebbe dare 0=0 -> n=0 *)
+  apply (le_ind ? (\lambda x. O=x \to n=x) ? ? ? H).
+  intro. reflexivity.
+  simplify. intros.
+  (* manca discriminate H3 *)
+qed.
\ No newline at end of file
index 56ea93bf89bf7e663e231e0f3ae41ac5f616a3b7..e597e66ef276b9ac0a6fc20197a55e7281f0b45f 100644 (file)
@@ -6,6 +6,6 @@ theorem a:
   \forall a,b:nat.
   a = b \to b + a = a + a.
 intros.
-rewrite right H in (? ? % ?).
+rewrite right H in \vdash (? ? % ?).
 reflexivity.
 qed.
\ No newline at end of file