void test_clone_iterator() { for(int i = 0; i < 1000; ++i) { /* construct random clone, but store the list of predicates it consist of */ clone cl; clone_init(&cl); size_t num = 10; pred preds[num]; for(int i = 0; i < num; ++i) { random_pred(preds+i); clone_insert_pred(&cl, preds+i); } /* use clon iterator to extract predicates */ pred *plist; size_t sz; clone_get_predicates(&cl, &plist, &sz); /* compare that the result of clone iterator coincide with original list of * predicates */ int flag = 1; for(int i = 0; i < num; ++i) { int j; for(j = 0; j < sz; ++j) { if(pred_eq(preds+i, plist+j)) break; } if(j == sz) { flag = 0; break; } } if(flag) { for(int j = 0; j < sz; ++j) { int i; for(i = 0; i < num; ++i) { if(pred_eq(preds+i, plist+j)) break; } if(i == num) { flag = 0; break; } } } if(!flag) { printf("\nError. Clone iterator gives:\n"); clone_print_verbosely(stdout, &cl); printf("\nBut original predicates were:\n"); for(pred *p = preds; p < preds + num; ++p) { char str[pred_print_extensional_size()]; pred_print_extensional(str, p); printf("%s\n", str); } return; } free(plist); } }
bool formula_eq(Formula f1, Formula f2) { switch (f1->type) { case PRED_F: return pred_eq(f1->form.pred_f, f2); case IMPL_F: return impl_eq(f1->form.impl_f, f2); case SIGNED_F: return signed_eq(f1->form.signed_f, f2); case SAYS_F: return says_eq(f1->form.says_f, f2); case CONFIRMS_F: return confirms_eq(f1->form.confirms_f, f2); case ABS_F: return abs_eq(f1->form.abs_f, f2); default: return false; } }