6 let build_equality term =
8 C.Implicit None, (C.Implicit None, term, C.Rel 1, Utils.Gt), [], []
19 let path_indexing_test () =
22 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Rel 3; C.Meta (1, [])]; C.Rel 5];
23 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 4]; C.Meta (1, [])];
24 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Rel 3; C.Rel 4]; C.Rel 5];
25 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 5]; C.Rel 4];
26 C.Appl [C.Rel 1; C.Meta (1, []); C.Meta (1, [])]
28 let path_strings = List.map (path_strings_of_term 0) terms in
30 List.fold_left index PSTrie.empty (List.map build_equality terms) in
32 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 4]; C.Rel 5] in
33 let matches = retrieve_generalizations table query in
34 let unifications = retrieve_unifiables table query in
35 let eq1 = build_equality (C.Appl [C.Rel 1; C.Meta (1, []); C.Meta (1, [])])
36 and eq2 = build_equality (C.Appl [C.Rel 1; C.Meta (1, []); C.Meta (2, [])]) in
37 let res1 = in_index table eq1
38 and res2 = in_index table eq2 in
39 let print_results res =
44 "(" ^ (Utils.string_of_pos p) ^ ", " ^
45 (Inference.string_of_equality e) ^ ")"
50 Printf.printf "path_strings:\n%s\n\n"
54 "{" ^ (String.concat "; " (List.map string_of_path_string l)) ^ "}"
56 Printf.printf "table:\n%s\n\n" (string_of_pstrie table);
57 Printf.printf "matches:\n%s\n\n" (print_results matches);
58 Printf.printf "unifications:\n%s\n\n" (print_results unifications);
59 Printf.printf "in_index %s: %s\n"
60 (Inference.string_of_equality eq1) (string_of_bool res1);
61 Printf.printf "in_index %s: %s\n"
62 (Inference.string_of_equality eq2) (string_of_bool res2);
69 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Rel 3; C.Meta (1, [])]; C.Rel 5]
71 C.Appl [C.Rel 1; C.Appl [C.Rel 5; C.Rel 4; C.Meta (1, [])]; C.Rel 5]
73 let res = Inference.extract_differing_subterms t1 t2 in
75 | None -> prerr_endline "NO DIFFERING SUBTERMS???"
77 Printf.printf "OK: %s, %s\n" (CicPp.ppterm t1) (CicPp.ppterm t2);
84 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Rel 3; C.Rel 4]; C.Rel 5]
86 let pos1 = Discrimination_tree.next_t [1] t in
87 let pos2 = Discrimination_tree.after_t [1] t in
88 Printf.printf "next_t 1: %s\nafter_t 1: %s\n"
89 (CicPp.ppterm (Discrimination_tree.subterm_at_pos pos1 t))
90 (CicPp.ppterm (Discrimination_tree.subterm_at_pos pos2 t));
94 let discrimination_tree_test () =
97 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Rel 3; C.Meta (1, [])]; C.Rel 5];
98 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 4]; C.Meta (1, [])];
99 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Rel 3; C.Rel 4]; C.Rel 5];
100 C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 5]; C.Rel 4];
101 C.Appl [C.Rel 10; C.Meta (5, []); C.Rel 11]
104 List.map Discrimination_tree.path_string_of_term terms in
107 Discrimination_tree.index
108 Discrimination_tree.DiscriminationTree.empty
109 (List.map build_equality terms)
112 (* C.Appl [C.Rel 1; C.Appl [C.Rel 2; C.Meta (1, []); C.Rel 4]; C.Rel 5] in *)
113 let query = C.Appl [C.Rel 10; C.Meta (14, []); C.Meta (13, [])] in
114 let matches = Discrimination_tree.retrieve_generalizations table query in
115 let unifications = Discrimination_tree.retrieve_unifiables table query in
116 let eq1 = build_equality (C.Appl [C.Rel 1; C.Meta (1, []); C.Meta (1, [])])
117 and eq2 = build_equality (C.Appl [C.Rel 1; C.Meta (1, []); C.Meta (2, [])]) in
118 let res1 = Discrimination_tree.in_index table eq1
119 and res2 = Discrimination_tree.in_index table eq2 in
120 let print_results res =
122 (Discrimination_tree.PosEqSet.fold
125 "(" ^ (Utils.string_of_pos p) ^ ", " ^
126 (Inference.string_of_equality e) ^ ")"
131 Printf.printf "path_strings:\n%s\n\n"
133 (List.map Discrimination_tree.string_of_path_string path_strings));
134 Printf.printf "table:\n%s\n\n"
135 (Discrimination_tree.string_of_discrimination_tree table);
136 Printf.printf "matches:\n%s\n\n" (print_results matches);
137 Printf.printf "unifications:\n%s\n\n" (print_results unifications);
138 Printf.printf "in_index %s: %s\n"
139 (Inference.string_of_equality eq1) (string_of_bool res1);
140 Printf.printf "in_index %s: %s\n"
141 (Inference.string_of_equality eq2) (string_of_bool res2);
146 let module C = Cic in
147 let module M = CicMetaSubst in
152 C.Appl [C.Rel 15; C.Rel 12; C.Meta (41, [])]];
154 C.Appl [C.Rel 15; C.Meta (10, []); C.Meta (11, [])];
155 C.Appl [C.Rel 15; C.Meta (10, []); C.Meta (12, [])]]
158 (43, ([], C.Appl [C.Rel 15; C.Meta (10, []); C.Meta (11, [])], C.Rel 16));
159 (10, ([], C.Rel 12, C.Rel 16));
160 (12, ([], C.Meta (41, []), C.Rel 16))
163 (43, ([], C.Appl [C.Rel 15; C.Rel 12; C.Meta (11, [])], C.Rel 16));
164 (10, ([], C.Rel 12, C.Rel 16));
165 (12, ([], C.Meta (41, []), C.Rel 16))
167 let t1 = M.apply_subst subst1 term
168 and t2 = M.apply_subst subst2 term in
169 Printf.printf "t1 = %s\nt2 = %s\n" (CicPp.ppterm t1) (CicPp.ppterm t2);
175 let module C = Cic in
177 Some (C.Name "H", C.Decl (
178 C.Prod (C.Name "z", C.Rel 3,
180 C.MutInd (HelmLibraryObjects.Logic.eq_URI, 0, []);
181 C.Rel 4; C.Rel 3; C.Rel 1])));
182 Some (C.Name "x", C.Decl (C.Rel 2));
183 Some (C.Name "y", C.Decl (C.Rel 1));
184 Some (C.Name "A", C.Decl (C.Sort C.Set))
188 C.Const (HelmLibraryObjects.Logic.eq_ind_URI, []); C.Rel 4;
190 C.Lambda (C.Name "z", C.Rel 4,
192 C.MutInd (HelmLibraryObjects.Logic.eq_URI, 0, []);
193 C.Rel 5; C.Rel 1; C.Rel 3
195 C.Appl [C.MutConstruct
196 (HelmLibraryObjects.Logic.eq_URI, 0, 1, []); (* reflexivity *)
199 (* C.Appl [C.Const (HelmLibraryObjects.Logic.sym_eq_URI, []); (\* symmetry *\) *)
200 (* C.Rel 4; C.Appl [C.Rel 1; C.Rel 2]] *)
202 C.Const (HelmLibraryObjects.Logic.eq_ind_URI, []);
204 C.Lambda (C.Name "z", C.Rel 4,
206 C.MutInd (HelmLibraryObjects.Logic.eq_URI, 0, []);
207 C.Rel 5; C.Rel 1; C.Rel 4
209 C.Appl [C.MutConstruct (HelmLibraryObjects.Logic.eq_URI, 0, 1, []);
211 C.Rel 2; C.Appl [C.Rel 1; C.Rel 2]
215 (UriManager.uri_of_string "cic:/Coq/Init/Logic/Logic_lemmas/equality/A.var",
217 (UriManager.uri_of_string "cic:/Coq/Init/Logic/Logic_lemmas/equality/x.var",
219 (UriManager.uri_of_string "cic:/Coq/Init/Logic/Logic_lemmas/equality/y.var",
223 C.Const (HelmLibraryObjects.Logic.sym_eq_URI, ens);
224 C.Appl [C.Rel 1; C.Rel 2]
227 CicTypeChecker.type_of_aux' [] context term CicUniv.empty_ugraph
229 Printf.printf "OK, %s ha tipo %s\n" (CicPp.ppterm term) (CicPp.ppterm ty);
231 CicTypeChecker.type_of_aux' [] context term2 CicUniv.empty_ugraph
233 Printf.printf "OK, %s ha tipo %s\n" (CicPp.ppterm term2) (CicPp.ppterm ty);
238 let uri = Sys.argv.(1) in
239 let t = CicUtil.term_of_uri (UriManager.uri_of_string uri) in
240 let ty, _ = CicTypeChecker.type_of_aux' [] [] t CicUniv.empty_ugraph in
241 Printf.printf "Term of %s: %s\n" uri (CicPp.ppterm t);
242 Printf.printf "type: %s\n" (CicPp.ppterm ty);
247 (* next_after ();; *)
248 (* discrimination_tree_test ();; *)
249 (* path_indexing_test ();; *)
250 (* test_subst ();; *)
251 Helm_registry.load_from "../../matita/matita.conf.xml";