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
| 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