% question-for-Yadunand-Prem.txt % CS3234, Fri 05 Apr 2024 %%%%%%%%%% This oral exam is a continuation of the midterm project. So, make a copy of midterm_project.v (naming it midterm_project_copy-for-oral-exam.v) and start editing this file after (* end of midterm_project.v *) %%%%%%%%%% The goal of this oral exam is to revisit Proposition list_reverse_acc_and_list_append_commute_with_each_other : forall (V : Type) (v1s v2s: list V), list_append V (list_reverse_acc V v2s nil) (list_reverse_acc V v1s nil) = list_reverse_acc V (list_append V v1s v2s) nil. So, copy the following proposition at the very end of midterm_project_copy-for-oral-exam.v: Proposition a_generalized_alternative : forall (V : Type) (v1s v2s v3s : list V), list_reverse_acc V (list_append V v1s v2s) v3s = nil. %%%%% a. The first thing to do is to figure out what to put instead of nil on the right-hand side, so that the equality holds. We (in the sense of you) are going to do that empirically by testing. To this end, write: Proof. Compute (let V := nat in let v1s := 11 :: 12 :: nil in let v2s := 21 :: 22 :: nil in let v3s := 31 :: 32 :: nil in list_reverse_acc V (list_append V v1s v2s) v3s = nil). Then, replace nil on the right-hand-side by an expression that does not use list_append but that only uses two occurrences of list_reverse_acc, and that is such that the equality holds. (Let us name this expression as YOUR_EXPRESSION.) Hint: use "(list_reverse_acc V ... ...)" as an accumulator for list_reverse_acc. b. To make sure, write: Compute (let V := nat in let v1s := 11 :: 12 :: nil in let v2s := 21 :: 22 :: nil in let v3s := 31 :: 32 :: nil in eqb_list nat Nat.eqb (list_reverse_acc V (list_append V v1s v2s) v3s) YOUR_EXPRESSION). Verify that the result of this computation is true. If it is false, then go back to a. and revise YOUR_EXPRESSION until the result of the computation just above is true. c. Prove this equality by induction. d. Time permitting, write: Restart. Prove these equalities not by induction, but using the many properties you have proved earlier in the file, e.g., about_list_reverse_acc_and_append, list_reverse_acc_and_list_append_commute_with_each_other, list_append_is_associative, etc. (Maybe you will need to state and prove more similar properties to carry our this proof, maybe not, who knows, this is an exploration.) %%%%%%%%%% % end of question-for-Yadunand-Prem.txt