88#include "src/common/linear_map.h"
99#include "src/kernel/beta_reduction.h"
1010#include "src/kernel/context.h"
11+ #include "src/kernel/definitional_equal.h"
1112#include "src/kernel/inductive.h"
1213#include "src/kernel/structural.h"
1314#include "src/kernel/subst.h"
@@ -1328,7 +1329,7 @@ bool is_hole(Expression *expr) { return expr->tag == HOLE_EXPRESSION; }
13281329// 3) Term does not itself contain the hole.
13291330// This does no modifications/creates no new objects.
13301331bool can_fill (Expression * hole , Expression * term ) {
1331- bool types_match = congruent_with_holes (get_expression_type (hole ), get_expression_type (term ));
1332+ bool types_match = definitional_equal (get_expression_type (hole ), get_expression_type (term ));
13321333 if (get_maybe_hole_free (term )) {
13331334 return types_match && valid_in_context (term , get_expression_context (hole ));
13341335 }
@@ -1412,71 +1413,57 @@ void fill_hole(Expression *hole, Expression *term) {
14121413 return ;
14131414 }
14141415
1415- // check if term satisfies hole type...
1416- LinearMap * alpha_equivalences = linear_map_new ();
1417- LinearMap * required_holes = linear_map_new ();
1418- bool types_match = _congruent_with_holes (get_expression_type (hole ), get_expression_type (term ),
1419- alpha_equivalences , required_holes );
1416+ bool types_match = definitional_equal (get_expression_type (hole ), get_expression_type (term ));
14201417 if (!types_match ) {
1421- linear_map_clear_free (alpha_equivalences );
1422- linear_map_clear_free (required_holes );
14231418 return ; // Todo: signal that this has failed?
14241419 }
1425-
1426- int n = required_holes -> size ;
1427- for (int i = 0 ; i < n ; i ++ ) {
1428- Expression * hole = (required_holes -> items + i )-> key ;
1429- Expression * substitute = (required_holes -> items + i )-> val ;
1430- fill_hole (hole , substitute );
1431- }
1432-
14331420 DoublyLinkedList * holepars = hole -> uplinks ;
14341421 for (int i = 0 ; i < dll_len (holepars ); i ++ ) {
14351422 Uplink * uplink = dll_at (holepars , i )-> data ;
14361423 switch (uplink -> relation ) {
14371424 case (LAMBDA_BODY ): {
14381425 Expression * ptr = (Expression * )uplink -> ptr ;
1439- ptr -> as . lambda . body = term ;
1426+ SET_LAMBDA_BODY ( ptr , term ) ;
14401427 break ;
14411428 }
14421429 case (LAMBDA_BOUND_VAR ): {
14431430 Expression * ptr = (Expression * )uplink -> ptr ;
1444- ptr -> as . lambda . bound_variable = term ;
1431+ SET_LAMBDA_BOUND_VAR ( ptr , term ) ;
14451432 break ;
14461433 }
14471434 case (APP_FUNC ): {
14481435 Expression * ptr = (Expression * )uplink -> ptr ;
1449- ptr -> as . app . func = term ;
1436+ SET_APP_FUNC ( ptr , term ) ;
14501437 break ;
14511438 }
14521439 case (APP_ARG ): {
14531440 Expression * ptr = (Expression * )uplink -> ptr ;
1454- ptr -> as . app . arg = term ;
1441+ SET_APP_ARG ( ptr , term ) ;
14551442 break ;
14561443 }
14571444 case (FORALL_BODY ): {
14581445 Expression * ptr = (Expression * )uplink -> ptr ;
1459- ptr -> as . forall . body = term ;
1446+ SET_FORALL_BODY ( ptr , term ) ;
14601447 break ;
14611448 }
14621449 case (FORALL_BOUND_VAR ): {
14631450 Expression * ptr = (Expression * )uplink -> ptr ;
1464- ptr -> as . forall . bound_variable = term ;
1451+ SET_FORALL_BOUND_VAR ( ptr , term ) ;
14651452 break ;
14661453 }
14671454 case (VAR_BODY ): {
14681455 Expression * ptr = (Expression * )uplink -> ptr ;
1469- ptr -> as . var . body = term ;
1456+ SET_VAR_BODY ( ptr , term ) ;
14701457 break ;
14711458 }
14721459 case (EXPR_TYPE ): {
14731460 Expression * ptr = (Expression * )uplink -> ptr ;
1474- ptr -> type = term ;
1461+ SET_EXPR_TYPE ( ptr , term ) ;
14751462 break ;
14761463 }
14771464 case (EXPR_CONTEXT ): {
14781465 Expression * ptr = (Expression * )uplink -> ptr ;
1479- ptr -> context = term ;
1466+ SET_EXPR_CONTEXT ( ptr , term ) ;
14801467 break ;
14811468 }
14821469 default :
@@ -1485,9 +1472,6 @@ void fill_hole(Expression *hole, Expression *term) {
14851472 break ;
14861473 }
14871474 }
1488-
1489- linear_map_clear_free (alpha_equivalences );
1490- linear_map_clear_free (required_holes );
14911475}
14921476
14931477char c_counter = 'a' ;
0 commit comments