Skip to content

Instantly share code, notes, and snippets.

@larsrh
Created September 24, 2015 08:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsrh/d931ae84e48b2089d981 to your computer and use it in GitHub Desktop.
Save larsrh/d931ae84e48b2089d981 to your computer and use it in GitHub Desktop.
Scala World 2015
theory Scratch
imports Main
begin
fun insert :: "'a::linorder ⇒ 'a list ⇒ 'a list" where
"insert x [] = [x]" |
"insert x (y # ys) = (if x ≤ y then x # y # ys else y # insert x ys)"
inductive sorted :: "'a::linorder list ⇒ bool" where
empty: "sorted []" |
single: "sorted [x]" |
cons: "x⇩1 ≤ x⇩2 ⟹ sorted (x⇩2 # xs) ⟹ sorted (x⇩1 # x⇩2 # xs)"
code_pred sorted .
lemma
assumes "sorted xs"
shows "sorted (insert x xs)"
using assms
proof (induction)
case empty
show "sorted (insert x [])"
by (simp add: sorted.single)
next
case single
show ?case sorry
next
case cons
show ?case sorry
qed
export_code sorted insert in Scala
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment