val is_list (#t: _) (x: llist t) (l: list t) : Tot vprop (decreases l)
val is_list (#t: _) (x: llist t) (l: list t) : Tot vprop (decreases l)
let rec is_list #t (x:llist t) (l:list t)
  : Tot vprop (decreases l)
  = match l with
    | [] -> pure (x == None)
    | head::tl -> 
      exists* (v:node_ptr t) (tail:llist t).
        pure (x == Some v) **
        pts_to v { head; tail } **
        is_list tail tl
(*
   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 Pulse.Lib.LinkedList
open Pulse.Lib.Pervasives
open Pulse.Lib.Stick.Util
open FStar.List.Tot
module T = FStar.Tactics
module I = Pulse.Lib.Stick.Util
module FA = Pulse.Lib.Forall.Util

noeq
type node (t:Type0) = {
    head : t;
    tail : llist t;
}

and node_ptr (t:Type0) = ref (node t)

//A nullable pointer to a node
and llist (t:Type0) = option (node_ptr t)
/
Pulse.Lib.Stick.Util.fst.checked Pulse.Lib.Pervasives.fst.checked Pulse.Lib.Forall.Util.fst.checked Pulse.Lib.BoundedIntegers.fst.checked prims.fst.checked FStar.UInt32.fsti.checked FStar.Tactics.fst.checked FStar.Pervasives.fsti.checked FStar.List.Tot.Properties.fst.checked FStar.List.Tot.fst.checked
Pulse.Lib.LinkedList.fst
x: Pulse.Lib.LinkedList.llist t -> l: Prims.list t -> Prims.Tot Pulse.Lib.Core.vprop
Pulse.Lib.LinkedList.llist Prims.list Pulse.Lib.Core.pure Prims.eq2 FStar.Pervasives.Native.option Pulse.Lib.Reference.ref Pulse.Lib.LinkedList.node FStar.Pervasives.Native.None Pulse.Lib.Core.op_exists_Star Pulse.Lib.LinkedList.node_ptr Pulse.Lib.Core.op_Star_Star FStar.Pervasives.Native.Some Pulse.Lib.Reference.pts_to PulseCore.FractionalPermission.full_perm Pulse.Lib.LinkedList.Mknode Pulse.Lib.LinkedList.is_list Pulse.Lib.Core.vprop
let rec is_list #t (x: llist t) (l: list t) : Tot vprop (decreases l) =
  
match l with
| [] -> pure (x == None)
| head :: tl ->
  exists* (v: node_ptr t) (tail: llist t).
    (pure (x == Some v) ** pts_to v ({ head = head; tail = tail })) ** is_list tail tl