Definition nat_to_perm (i:nat) :=
  (match i with
  | 0 => Some None
  | 1 => Some (Some Nonempty)
  | 2 => Some (Some Readable)
  | 3 => Some (Some Writable)
  | 4 => Some (Some Freeable)
  | _ => None
  end)%nat.Definition perm_to_nat (p: option (option permission)) :=
  match p with
  | Some (None) => 0
  | Some (Some Nonempty) => 1
  | Some (Some Readable) => 2
  | Some (Some Writable) => 3
  | Some (Some Freeable) => 4
  | None => 5
  end.Definition nat_to_perm_simpl (i:nat) :=
  (match i with
  | 0 => None
  | 1 => Some Nonempty
  | 2 => Some Readable
  | 3 => Some Writable
  | 4 => Some Freeable
  | _ => None
  end)%nat.Definition perm_to_nat_simpl (p: option permission) :=
  match p with
  | None => 0
  | Some Nonempty => 1
  | Some Readable => 2
  | Some Writable => 3
  | Some Freeable => 4
  end.

(* Specifications: *)
Lemma perm_to_nat_bound: forall p, perm_to_nat p < 6.
Lemma perm_to_nat_bound_simpl: forall p, perm_to_nat_simpl p < 5.
Lemma nat_to_perm_perm_to_nat: forall p, nat_to_perm (perm_to_nat p) = p.
Lemma nat_to_perm_perm_to_nat_simpl: forall p, nat_to_perm_simpl (perm_to_nat_simpl p) = p.
Lemma finite_bounded_nat_aux_func: forall hi , konig.finite ( fun f:nat -> option (option permission) => bounded_nat_func_aux f hi).
Lemma finite_bounded_nat_aux_func_simpl: forall hi , konig.finite ( fun f:nat -> option permission => bounded_nat_func_aux f hi).
Lemma finite_bounded_nat_func: forall hi , konig.finite ( fun f:nat -> option (option permission) => bounded_nat_func' f hi).
Lemma finite_bounded_nat_func_simpl: forall hi , konig.finite ( fun f:nat -> option permission => bounded_nat_func' f hi).
Lemma finite_bounded_func: forall hi lo, konig.finite ( fun f:Z -> option (option permission) => bounded_func' f hi lo).
Lemma finite_bounded_func_simpl: forall hi lo, konig.finite ( fun f:Z -> option permission => bounded_func' f hi lo).
Lemma finite_bounded_op_func_simpl: forall hi lo, konig.finite ( fun f: option (Z -> option permission) => bounded_func_op f hi lo).
Lemma finite_bounded_op_func: forall hi lo, konig.finite ( fun f: option (Z -> option (option permission)) => bounded_func_op f hi lo).
Lemma finite_sub_maps: forall m2, @bounded_map permission m2 -> konig.finite (fun m1 => @sub_map (option permission) permission m1 m2).
Lemma fun_le_bounded_func_op: forall {A} o f hi lo, @bounded_func' A f hi lo -> fun_leq o (Some f) -> @bounded_func_op (option A) o hi lo.
Lemma finite_sub_maps_simpl: forall m2, @bounded_map permission m2 -> konig.finite (fun m1 => @sub_map permission permission m1 m2).
Lemma fun_le_bounded_func_op_simpl: forall {A} o f hi lo, @bounded_func' A f hi lo -> fun_leq o (Some f) -> @bounded_func_op A o hi lo.
Lemma fun_leq_trans: forall {A B C} f1 f2 f3, @fun_leq A B f1 f2 -> @fun_leq B C f2 f3 -> @fun_leq A C f1 f3.
Lemma sub_map_trans: forall {A B C} m1 m2 m3, @sub_map A B m1 m2 -> @sub_map B C m2 m3 -> @sub_map A C m1 m3.
Lemma same_shape_map: forall {A B} m f, @same_shape A B (PTree.map f m) m.
Lemma perm_to_nat_bound: forall p, perm_to_nat p < 6.
Lemma perm_to_nat_bound_simpl: forall p, perm_to_nat_simpl p < 5.
Lemma nat_to_perm_perm_to_nat: forall p, nat_to_perm (perm_to_nat p) = p.
Lemma nat_to_perm_perm_to_nat_simpl: forall p, nat_to_perm_simpl (perm_to_nat_simpl p) = p.
Lemma finite_bounded_nat_aux_func: forall hi , konig.finite ( fun f:nat -> option (option permission) => bounded_nat_func_aux f hi).
Lemma finite_bounded_nat_aux_func_simpl: forall hi , konig.finite ( fun f:nat -> option permission => bounded_nat_func_aux f hi).
Lemma finite_bounded_nat_func: forall hi , konig.finite ( fun f:nat -> option (option permission) => bounded_nat_func' f hi).
Lemma finite_bounded_nat_func_simpl: forall hi , konig.finite ( fun f:nat -> option permission => bounded_nat_func' f hi).
Lemma finite_bounded_func: forall hi lo, konig.finite ( fun f:Z -> option (option permission) => bounded_func' f hi lo).
Lemma finite_bounded_func_simpl: forall hi lo, konig.finite ( fun f:Z -> option permission => bounded_func' f hi lo).
Lemma finite_bounded_op_func_simpl: forall hi lo, konig.finite ( fun f: option (Z -> option permission) => bounded_func_op f hi lo).
Lemma finite_bounded_op_func: forall hi lo, konig.finite ( fun f: option (Z -> option (option permission)) => bounded_func_op f hi lo).
Lemma finite_sub_maps: forall m2, @bounded_map permission m2 -> konig.finite (fun m1 => @sub_map (option permission) permission m1 m2).
Lemma fun_le_bounded_func_op: forall {A} o f hi lo, @bounded_func' A f hi lo -> fun_leq o (Some f) -> @bounded_func_op (option A) o hi lo.
Lemma finite_sub_maps_simpl: forall m2, @bounded_map permission m2 -> konig.finite (fun m1 => @sub_map permission permission m1 m2).
Lemma fun_le_bounded_func_op_simpl: forall {A} o f hi lo, @bounded_func' A f hi lo -> fun_leq o (Some f) -> @bounded_func_op A o hi lo.