Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.82 KB | None | 0 0
  1. (* returns true iff r1,r2 create a critical pair *)
  2. let critical_pair (r1:rule) (r2:rule) =
  3.   let (l,_) = r1 in
  4.   let (g,_) = r2 in
  5.   let to_compare =
  6.     if (r1 <> r2)
  7.     then List.tl (fun_subterms (rename_term l))
  8.     else fun_subterms (rename_term l)
  9.   in
  10.   List.exists (fun p ->
  11.     match unification p g with
  12.     | Some _ -> printf "%s et %s sont unifiables\n"
  13.       (Pprint.pprint_term p)
  14.       (Pprint.pprint_term g); true
  15.     | None -> false
  16.   ) to_compare
  17.  
  18. (* returns true iff there exists r1 r2 that create a critical pair *)
  19. let critical system =
  20.   List.exists (fun r1 ->
  21.     List.exists (fun r2 ->
  22.       if critical_pair r1 r2
  23.       then (
  24.         printf "paire critique: %s\n%s\n"
  25.         (Pprint.pprint_rule r1)
  26.         (Pprint.pprint_rule r2); true
  27.       ) else false
  28.     ) system
  29.   ) system
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement