]> matita.cs.unibo.it Git - helm.git/commitdiff
Non-linear patterns are now allowed in notations.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 25 Aug 2008 13:14:54 +0000 (13:14 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 25 Aug 2008 13:14:54 +0000 (13:14 +0000)
helm/software/components/acic_content/acic2astMatcher.ml

index d62786cc7a77316e65d11d4c8a6709bc31a42882..c711083204929699eca9756ec300d6bbbda42e2b 100644 (file)
@@ -77,9 +77,9 @@ struct
   module M = PatternMatcher.Matcher (Pattern32)
 
   let compiler rows =
-    let match_cb rows =
-      let pl, pid = try List.hd rows with Not_found -> assert false in
-      (fun matched_terms constructors ->
+    let match_cb rows matched_terms constructors =
+     HExtlib.list_findopt
+      (fun (pl,pid) ->
         let env =
           try
             List.map2
@@ -89,9 +89,23 @@ struct
                 | Ast.VarPattern name -> name, t
                 | _ -> assert false)
               pl matched_terms
-          with Invalid_argument _ -> assert false
+          with Invalid_argument _ -> assert false in
+        let rec check_non_linear_patterns =
+         function
+            [] -> true
+          | (name,t)::tl ->
+             List.for_all
+              (fun (name',t') ->
+                name <> name' ||
+                CicUtil.alpha_equivalence
+                 (Deannotate.deannotate_term t) (Deannotate.deannotate_term t')
+              ) tl && check_non_linear_patterns tl
         in
-        Some (env, constructors, pid))
+         if check_non_linear_patterns env then
+          Some (env, constructors, pid)
+         else
+          None
+      ) rows
     in
     M.compiler rows match_cb (fun () -> None)
 end