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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started