aboutsummaryrefslogtreecommitdiff
path: root/src/reduce.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reduce.c')
-rw-r--r--src/reduce.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/reduce.c b/src/reduce.c
index 60fa57a..2ae6e8e 100644
--- a/src/reduce.c
+++ b/src/reduce.c
@@ -26,7 +26,8 @@ static struct term *substitute(struct term *term, struct term *substitution,
if (previous == new->hash)
return term; // nothing changed
struct term *rehashed = term_rehash_abs(term, new);
- /* term_deref_head(term->u.abs.term); */ // TODO: only for vars?
+ term_rehash_parents(rehashed);
+ term_deref_head(term->u.abs.term);
return rehashed;
} else if (term->type == APP) {
hash_t previous_lhs = term->u.app.lhs->hash;
@@ -38,6 +39,7 @@ static struct term *substitute(struct term *term, struct term *substitution,
if (previous_lhs == lhs->hash && previous_rhs == rhs->hash)
return term; // nothing changed
struct term *rehashed = term_rehash_app(term, lhs, rhs);
+ term_rehash_parents(rehashed);
return rehashed;
}
fatal("invalid type %d\n", term->type);
@@ -50,13 +52,9 @@ struct term *reduce(struct term *term)
if (!term_is_beta_redex(term))
fatal("can't reduce non-beta-redex %d\n", term->type);
- fprintf(stderr, "reducing ");
- term_print(term);
- fprintf(stderr, "\n");
-
+ /* map_delete(term->u.app.lhs->parents, term); */
+ /* map_delete(term->u.app.rhs->parents, term); */
struct term *reduced = substitute(term->u.app.lhs, term->u.app.rhs, -1);
- fprintf(stderr, "reduced ");
- term_print(reduced);
- fprintf(stderr, "\n");
+ /* term_deref_head(term); */
return reduced;
}