Menu

[Solved]Given Following Coq Function Pleased Complete Last Coq Function Remove Zeros List Last Tes Q37085097

given the following coq function pleased complete the last coqfunction to remove all zeros from a list and the last test functionin coqInductive natlist Type: I nil natlist | cons : nat → natlist → nat list. Fixpoint length (ns: natlist) nat match ns with I ni

Fact test2: remove 0 (cons 1 nil) cons 1 nil. Proof. simpl. reflexivity. Qed Fact test3: remove0 (cons 0 (cons 1 nil)cons 1 n

Inductive natlist Type: I nil natlist | cons : nat → natlist → nat list. Fixpoint length (ns: natlist) nat match ns with I nilo I cons n ns, => 1+length ns, end Counting the Zeros of a List of Numbers) Fixpoint count0 (ns: natlist) nat match ns with O ns-1 + count。 l cons n ns’ end. count0 ns’ Removing the Zeros of a List of Numbers ) Define a function removeo: natlist natlist that removes all the zeros of a list of numbers. TO COMPLETE) Tests ) Fact testi: remove 0 n11 = nil. Proof. simpl. reflexivity. Qed. Fact test2: remove 0 (cons 1 nil) cons 1 nil. Proof. simpl. reflexivity. Qed Fact test3: remove0 (cons 0 (cons 1 nil)cons 1 nil. Proof. simpl. reflexivity. Qed Fact test4: remove 0 (cons 0 (cons 2 (cons 0 nil))) Proof. simpl. reflexivity. Qed cons 2 nil. Let list :- cons 0 (cons 1 (cons 0 (cons 2 (cons 0 (cons 3 (cons 0 nil)) Fact test: remove 0 list = cons 1 (cons 2 (cons 3 nil)). Proof . simpl. reflexivity· ged A Lemma ) Lemma remove0_length: V ns, length nscount0 ns length (remove0 ns) Proof. induction ns as n ns’ IH simpl. reflexivity simpl. * TO COMPLETE Hint: proot bycase analysis, proot by rewriting, proof by simplification ) Finally when you meet a goal that is an equality such as both sides are identical up to some basic arithmetic properties, you can use: “auto with arith” to automatically solve the goal. *) Qed Show transcribed image text Inductive natlist Type: I nil natlist | cons : nat → natlist → nat list. Fixpoint length (ns: natlist) nat match ns with I nilo I cons n ns, => 1+length ns, end Counting the Zeros of a List of Numbers) Fixpoint count0 (ns: natlist) nat match ns with O ns-1 + count。 l cons n ns’ end. count0 ns’ Removing the Zeros of a List of Numbers ) Define a function removeo: natlist natlist that removes all the zeros of a list of numbers. TO COMPLETE) Tests ) Fact testi: remove 0 n11 = nil. Proof. simpl. reflexivity. Qed.
Fact test2: remove 0 (cons 1 nil) cons 1 nil. Proof. simpl. reflexivity. Qed Fact test3: remove0 (cons 0 (cons 1 nil)cons 1 nil. Proof. simpl. reflexivity. Qed Fact test4: remove 0 (cons 0 (cons 2 (cons 0 nil))) Proof. simpl. reflexivity. Qed cons 2 nil. Let list :- cons 0 (cons 1 (cons 0 (cons 2 (cons 0 (cons 3 (cons 0 nil)) Fact test: remove 0 list = cons 1 (cons 2 (cons 3 nil)). Proof . simpl. reflexivity· ged A Lemma ) Lemma remove0_length: V ns, length nscount0 ns length (remove0 ns) Proof. induction ns as n ns’ IH simpl. reflexivity simpl. * TO COMPLETE Hint: proot bycase analysis, proot by rewriting, proof by simplification ) Finally when you meet a goal that is an equality such as both sides are identical up to some basic arithmetic properties, you can use: “auto with arith” to automatically solve the goal. *) Qed

Expert Answer


Answer to given the following coq function pleased complete the last coq function to remove all zeros from a list and the last tes… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *