]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/paramodulation/test_path_indexing.ml
path indexing working!
[helm.git] / helm / ocaml / paramodulation / test_path_indexing.ml
1 open Path_indexing
2
3
4 let build_equality term =
5   let module C = Cic in
6   C.Implicit None, (C.Implicit None, term, C.Rel 1, Utils.Gt), [], []
7 ;;
8
9
10 (*
11   f = Rel 1
12   g = Rel 2
13   a = Rel 3
14   b = Rel 4
15   c = Rel 5
16 *)
17 let main_test () =
18   let module C = Cic in
19   let terms = [
20     C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Rel 3; C.Meta (1, [])]; C.Rel 5];
21     C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 4]; C.Meta (1, [])];
22     C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Rel 3; C.Rel 4]; C.Rel 5];
23     C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 5]; C.Rel 4];
24     C.Appl [C.Rel 1; C.Meta (1, []); C.Meta (1, [])]
25   ] in
26   let path_strings = List.map (path_strings_of_term 0) terms in
27   let table =
28     List.fold_left index PSTrie.empty (List.map build_equality terms) in
29   let query =
30     C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 4]; C.Rel 5] in
31   let matches = retrieve_generalizations table query in
32   let unifications = retrieve_unifiables table query in
33   let print_results res =
34     String.concat "\n"
35       (PosEqSet.fold
36          (fun (p, e) l ->
37             let s = 
38               "(" ^ (Utils.string_of_pos p) ^ ", " ^
39                 (Inference.string_of_equality e) ^ ")"
40             in
41             s::l)
42          res [])
43   in
44   Printf.printf "path_strings:\n%s\n\n"
45     (String.concat "\n"
46        (List.map
47           (fun l ->
48              "{" ^ (String.concat "; " (List.map string_of_path_string l)) ^ "}"
49           ) path_strings));
50   Printf.printf "table:\n%s\n\n" (string_of_pstrie table);
51   Printf.printf "matches:\n%s\n\n" (print_results matches);
52   Printf.printf "unifications:\n%s\n" (print_results unifications)
53 ;;
54
55
56 main_test ();;