Question: open list set _ option pp . structure _ projections false variables { A B C : Type } / - In the lecture we
open list
setoption ppstructureprojections false
variables A B C : Type
In the lecture we have introduced the function reverse
and the auxilliary function snoc
def snoc : list A A list A
a :a
a :: as b : a :: snoc as b
def rev : list A list A
:
a :: as : snoc rev as a
Part :
Our implementation of rev is inefficient it has On complexity.
The definition below called fastrev is efficient On
It uses an auxillary function revaux which accumulates the reversed
list in a nd variable.
def revaux : list A list A list A
bs : bs
a :: as bs : revaux as a :: bs
def fastrev l : list A : list A
: revaux l
#reduce fastrev
However we would like to show that fast rev and rev do the same.
You need to establish a lemma about revaux which you can rpve by induction.
You may use the fact that lists with form a monoid
just copy the definition and proofs from the lecture
theorem fastrevthm : as : list A fastrev as rev as :
begin
sorry,
end i have to prove this but without using tactics such as intros, simp, list.appendnil etc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
