val sorted (#t: _) {| _: ordered t |} (l: list t) : GTot bool
val sorted (#t: _) {| _: ordered t |} (l: list t) : GTot bool
let rec sorted #t {| _: ordered t|} (l: list t): GTot bool =
  match l with
  | x::y::q -> if leq x y then sorted (y::q) else false
  | _ -> true
(*
   Copyright 2023 Microsoft Research
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
       http://www.apache.org/licenses/LICENSE-2.0
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*)

module LeftistHeap

class ordered (a:eqtype) =
{
  leq : a -> a -> bool;
  [@@@FStar.Tactics.Typeclasses.no_method]
  properties : squash (
    (forall x. leq x x) /\ // reflexivity
    (forall a b c. (leq a b /\ leq b c) ==> leq a c) /\ // transivitive
    (forall a b. (leq a b /\ leq b a) ==> a = b) /\ // antisymmetry
    (forall a b. leq a b \/ leq b a) // total
  )
}

let rec merge #t {| _: ordered t |} (a: list t) (b: list t): GTot (list t) =
  match a, b with
  | [], _ -> b
  | _, [] -> a
  | ta::qa, tb::qb -> if (leq ta tb) then ta :: (merge qa b) else tb :: (merge a qb)
/
prims.fst.checked FStar.Tactics.Typeclasses.fsti.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked
LeftistHeap.fsti
{| _: LeftistHeap.ordered t |} -> l: Prims.list t -> Prims.GTot Prims.bool
Prims.eqtype LeftistHeap.ordered Prims.list LeftistHeap.leq LeftistHeap.sorted Prims.Cons Prims.bool
let rec sorted #t {| _: ordered t |} (l: list t) : GTot bool =
  
match l with
| x :: y :: q -> if leq x y then sorted (y :: q) else false
| _ -> true