@@ -8,8 +8,7 @@ Expression *instantiate_lemma_type(Context *context, Expression *lemma_ty) {
88 case (FORALL_EXPRESSION ): {
99 Expression * bound_var = lemma_ty -> as .forall .bound_variable ;
1010 Expression * bound_var_ty = get_expression_type (bound_var );
11- Expression * hole = init_hole_expression (get_var_name (bound_var ),
12- bound_var_ty , context );
11+ Expression * hole = init_hole_expression (get_var_name (bound_var ), bound_var_ty , context );
1312 Expression * lemma_ty_body = lemma_ty -> as .forall .body ;
1413 // lemma_ty_body is closed under context(bound_var), which contains bound_var
1514 Expression * new_body = new_subst (bound_var , lemma_ty_body , bound_var , hole );
@@ -31,14 +30,12 @@ Expression *instantiate_lemma(Context *context, Expression *lemma) {
3130DoublyLinkedList * _list_holes (Expression * expr , DoublyLinkedList * curr ) {
3231 switch (expr -> tag ) {
3332 case (LAMBDA_EXPRESSION ): {
34- curr = _list_holes (
35- get_expression_type (expr -> as .lambda .bound_variable ), curr );
33+ curr = _list_holes (get_expression_type (expr -> as .lambda .bound_variable ), curr );
3634 curr = _list_holes (expr -> as .lambda .body , curr );
3735 return curr ;
3836 }
3937 case (FORALL_EXPRESSION ): {
40- curr = _list_holes (
41- get_expression_type (expr -> as .forall .bound_variable ), curr );
38+ curr = _list_holes (get_expression_type (expr -> as .forall .bound_variable ), curr );
4239 curr = _list_holes (expr -> as .forall .body , curr );
4340 return curr ;
4441 }
@@ -71,8 +68,7 @@ int num_holes(Expression *expr) {
7168 return num_holes ;
7269}
7370
74- Expression * _unify2 (Expression * exprA , Expression * exprB ,
75- Expression * var_to_fill ) {
71+ Expression * _unify2 (Expression * exprA , Expression * exprB , Expression * var_to_fill ) {
7672 if (exprA == exprB ) {
7773 return NULL ;
7874 }
@@ -96,14 +92,12 @@ Expression *_unify2(Expression *exprA, Expression *exprB,
9692 return NULL ;
9793 }
9894
99- Expression * new_func =
100- _unify2 (exprA -> as .app .func , exprB -> as .app .func , var_to_fill );
95+ Expression * new_func = _unify2 (exprA -> as .app .func , exprB -> as .app .func , var_to_fill );
10196 if (new_func != NULL && new_func -> tag != HOLE_EXPRESSION ) {
10297 return new_func ;
10398 }
10499
105- Expression * new_arg =
106- _unify2 (exprA -> as .app .arg , exprB -> as .app .arg , var_to_fill );
100+ Expression * new_arg = _unify2 (exprA -> as .app .arg , exprB -> as .app .arg , var_to_fill );
107101 if (new_arg != NULL ) {
108102 return new_arg ;
109103 }
@@ -115,9 +109,7 @@ Expression *_unify2(Expression *exprA, Expression *exprB,
115109 }
116110}
117111
118- Expression * instantiate_lemma_with_bindings (Expression * lemma ,
119- Expression * lemma_ty ,
120- Map * binders ) {
112+ Expression * instantiate_lemma_with_bindings (Expression * lemma , Expression * lemma_ty , Map * binders ) {
121113 Expression * final_expr = lemma ;
122114 Expression * curr_forall = lemma_ty ;
123115 while (curr_forall -> tag == FORALL_EXPRESSION ) {
@@ -128,8 +120,7 @@ Expression *instantiate_lemma_with_bindings(Expression *lemma,
128120 Context * app_ctx = (final_expr_ctx -> ctx_size >= binding_result_ctx -> ctx_size )
129121 ? final_expr_ctx
130122 : binding_result_ctx ;
131- final_expr =
132- init_app_expression_wc (final_expr , binding_result , app_ctx );
123+ final_expr = init_app_expression_wc (final_expr , binding_result , app_ctx );
133124 Expression * curr_forall_body = curr_forall -> as .forall .body ;
134125 // curr_forall_body is closed under context(binding_var), which contains binding_var
135126 curr_forall = new_subst (binding_var , curr_forall_body , binding_var , binding_result );
@@ -139,8 +130,7 @@ Expression *instantiate_lemma_with_bindings(Expression *lemma,
139130
140131UnificationResult * init_unification_result (Expression * lemma_instantiation ,
141132 DoublyLinkedList * new_goals ) {
142- UnificationResult * unification_result =
143- (UnificationResult * )malloc (sizeof (UnificationResult ));
133+ UnificationResult * unification_result = (UnificationResult * )malloc (sizeof (UnificationResult ));
144134 unification_result -> lemma_instantiation = lemma_instantiation ;
145135 unification_result -> new_goals = new_goals ;
146136 return unification_result ;
@@ -166,50 +156,41 @@ UnificationResult *eunify2(Expression *lemma, Expression *goal) {
166156 Expression * current_lemma_app_ty = get_expression_type (current_lemma_app );
167157 DoublyLinkedList * remaining_open = dll_create ();
168158 while (current_lemma_app_ty -> tag == FORALL_EXPRESSION ) {
169- Expression * bound_variable =
170- current_lemma_app_ty -> as .forall .bound_variable ;
171- Expression * hole_subst = _unify2 (
172- get_innermost_body (current_lemma_app_ty ), expr , bound_variable );
159+ Expression * bound_variable = current_lemma_app_ty -> as .forall .bound_variable ;
160+ Expression * hole_subst =
161+ _unify2 (get_innermost_body (current_lemma_app_ty ), expr , bound_variable );
173162
174163 if (hole_subst == NULL ) {
175164 Expression * hole_to_fill = init_hole_expression (
176- get_var_name (bound_variable ),
177- get_expression_type (bound_variable ), goal_context );
178- current_lemma_app = init_app_expression_wc (
179- current_lemma_app , hole_to_fill , goal_context );
165+ get_var_name (bound_variable ), get_expression_type (bound_variable ), goal_context );
166+ current_lemma_app =
167+ init_app_expression_wc (current_lemma_app , hole_to_fill , goal_context );
180168 dll_insert_at_tail (remaining_open , dll_new_node (hole_to_fill ));
181169 } else {
182- current_lemma_app = init_app_expression_wc (
183- current_lemma_app , hole_subst , goal_context );
170+ current_lemma_app = init_app_expression_wc (current_lemma_app , hole_subst , goal_context );
184171 }
185172 current_lemma_app_ty = get_expression_type (current_lemma_app );
186173 }
187174 return init_unification_result (current_lemma_app , remaining_open );
188175}
189176
190- UnificationResult * bad_unify_for_eq (Context * goal_context , Expression * lemma ,
191- Expression * expr ) {
177+ UnificationResult * bad_unify_for_eq (Context * goal_context , Expression * lemma , Expression * expr ) {
192178 Expression * current_lemma_app = lemma ;
193179 Expression * current_lemma_app_ty = get_expression_type (current_lemma_app );
194180 DoublyLinkedList * remaining_open = dll_create ();
195181 while (current_lemma_app_ty -> tag == FORALL_EXPRESSION ) {
196- Expression * current_lemma_ty_lhs =
197- _get_lhs_eq (get_innermost_body (current_lemma_app_ty ));
198- Expression * bound_variable =
199- current_lemma_app_ty -> as .forall .bound_variable ;
200- Expression * hole_subst =
201- _unify2 (current_lemma_ty_lhs , expr , bound_variable );
182+ Expression * current_lemma_ty_lhs = _get_lhs_eq (get_innermost_body (current_lemma_app_ty ));
183+ Expression * bound_variable = current_lemma_app_ty -> as .forall .bound_variable ;
184+ Expression * hole_subst = _unify2 (current_lemma_ty_lhs , expr , bound_variable );
202185
203186 if (hole_subst == NULL ) {
204187 Expression * hole_to_fill = init_hole_expression (
205- get_var_name (bound_variable ),
206- get_expression_type (bound_variable ), goal_context );
207- current_lemma_app = init_app_expression_wc (
208- current_lemma_app , hole_to_fill , goal_context );
188+ get_var_name (bound_variable ), get_expression_type (bound_variable ), goal_context );
189+ current_lemma_app =
190+ init_app_expression_wc (current_lemma_app , hole_to_fill , goal_context );
209191 dll_insert_at_tail (remaining_open , dll_new_node (hole_to_fill ));
210192 } else {
211- current_lemma_app = init_app_expression_wc (
212- current_lemma_app , hole_subst , goal_context );
193+ current_lemma_app = init_app_expression_wc (current_lemma_app , hole_subst , goal_context );
213194 }
214195 current_lemma_app_ty = get_expression_type (current_lemma_app );
215196 }
0 commit comments