Question: OCaml : Sorted lists Consider the functions for ordered lists from the ordered list.ml le in the code-examples direc- tory of the public class repository:

OCaml :

Sorted lists

Consider the functions for ordered lists from the ordered list.ml le in the code-examples direc-

tory of the public class repository:

let rec place e l = match l with

| [ ] -> [e]

| x::xs -> if e < x then e::x::xs

else x :: (place e xs)

let rec is_elem e l = match l with

| [ ] -> false

| x::xs -> e = x || (e > x && is_elem e xs)

let rec sorted l = match l with

| [ ] -> true

| x::[] -> true

| x1::x2::xs -> x1 <= x2 && sorted (x2::xs)

Using induction, show that

sorted l => sorted (place e l)

Your proof must explicitly and clearly indicate the base case you prove, the inductive case you prove and what the inductive hypothesis provides in the proof.

Each step in your proof must be accompanied by a justication describing why that step could be taken.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!