Commit 419e2d0e authored by Adam Chlipala's avatar Adam Chlipala

Proofreading pass through Chapter 17

parent 19ce70ea
...@@ -209,8 +209,8 @@ Section hlist. ...@@ -209,8 +209,8 @@ Section hlist.
Variable elm : A. Variable elm : A.
Inductive member : list A -> Type := Inductive member : list A -> Type :=
| MFirst : forall ls, member (elm :: ls) | HFirst : forall ls, member (elm :: ls)
| MNext : forall x ls, member ls -> member (x :: ls). | HNext : forall x ls, member ls -> member (x :: ls).
(** Because the element [elm] that we are "searching for" in a list does not change across the constructors of [member], we simplify our definitions by making [elm] a local variable. In the definition of [member], we say that [elm] is found in any list that begins with [elm], and, if removing the first element of a list leaves [elm] present, then [elm] is present in the original list, too. The form looks much like a predicate for list membership, but we purposely define [member] in [Type] so that we may decompose its values to guide computations. (** Because the element [elm] that we are "searching for" in a list does not change across the constructors of [member], we simplify our definitions by making [elm] a local variable. In the definition of [member], we say that [elm] is found in any list that begins with [elm], and, if removing the first element of a list leaves [elm] present, then [elm] is present in the original list, too. The form looks much like a predicate for list membership, but we purposely define [member] in [Type] so that we may decompose its values to guide computations.
...@@ -223,8 +223,8 @@ Section hlist. ...@@ -223,8 +223,8 @@ Section hlist.
| nil => B elm | nil => B elm
| _ :: _ => unit | _ :: _ => unit
end) with end) with
| MFirst _ => tt | HFirst _ => tt
| MNext _ _ _ => tt | HNext _ _ _ => tt
end end
| HCons _ _ x mls' => fun mem => | HCons _ _ x mls' => fun mem =>
match mem in member ls' return (match ls' with match mem in member ls' return (match ls' with
...@@ -233,8 +233,8 @@ Section hlist. ...@@ -233,8 +233,8 @@ Section hlist.
B x' -> (member ls'' -> B elm) B x' -> (member ls'' -> B elm)
-> B elm -> B elm
end) with end) with
| MFirst _ => fun x _ => x | HFirst _ => fun x _ => x
| MNext _ _ mem' => fun _ get_mls' => get_mls' mem' | HNext _ _ mem' => fun _ get_mls' => get_mls' mem'
end x (hget mls') end x (hget mls')
end. end.
(* end thide *) (* end thide *)
...@@ -244,8 +244,8 @@ End hlist. ...@@ -244,8 +244,8 @@ End hlist.
Implicit Arguments HNil [A B]. Implicit Arguments HNil [A B].
Implicit Arguments HCons [A B x ls]. Implicit Arguments HCons [A B x ls].
Implicit Arguments MFirst [A elm ls]. Implicit Arguments HFirst [A elm ls].
Implicit Arguments MNext [A elm x ls]. Implicit Arguments HNext [A elm x ls].
(* end thide *) (* end thide *)
(** By putting the parameters [A] and [B] in [Type], we allow some very higher-order uses. For instance, one use of [hlist] is for the simple heterogeneous lists that we referred to earlier. *) (** By putting the parameters [A] and [B] in [Type], we allow some very higher-order uses. For instance, one use of [hlist] is for the simple heterogeneous lists that we referred to earlier. *)
...@@ -257,14 +257,14 @@ Definition someTypes : list Set := nat :: bool :: nil. ...@@ -257,14 +257,14 @@ Definition someTypes : list Set := nat :: bool :: nil.
Example someValues : hlist (fun T : Set => T) someTypes := Example someValues : hlist (fun T : Set => T) someTypes :=
HCons 5 (HCons true HNil). HCons 5 (HCons true HNil).
Eval simpl in hget someValues MFirst. Eval simpl in hget someValues HFirst.
(** %\vspace{-.15in}% [[ (** %\vspace{-.15in}% [[
= 5 = 5
: (fun T : Set => T) nat : (fun T : Set => T) nat
]] ]]
*) *)
Eval simpl in hget someValues (MNext MFirst). Eval simpl in hget someValues (HNext HFirst).
(** %\vspace{-.15in}% [[ (** %\vspace{-.15in}% [[
= true = true
: (fun T : Set => T) bool : (fun T : Set => T) bool
...@@ -334,7 +334,7 @@ Eval simpl in expDenote Const HNil. ...@@ -334,7 +334,7 @@ Eval simpl in expDenote Const HNil.
]] ]]
*) *)
Eval simpl in expDenote (Abs (dom := Unit) (Var MFirst)) HNil. Eval simpl in expDenote (Abs (dom := Unit) (Var HFirst)) HNil.
(** %\vspace{-.15in}% [[ (** %\vspace{-.15in}% [[
= fun x : unit => x = fun x : unit => x
: typeDenote (Arrow Unit Unit) : typeDenote (Arrow Unit Unit)
...@@ -342,21 +342,21 @@ Eval simpl in expDenote (Abs (dom := Unit) (Var MFirst)) HNil. ...@@ -342,21 +342,21 @@ Eval simpl in expDenote (Abs (dom := Unit) (Var MFirst)) HNil.
*) *)
Eval simpl in expDenote (Abs (dom := Unit) Eval simpl in expDenote (Abs (dom := Unit)
(Abs (dom := Unit) (Var (MNext MFirst)))) HNil. (Abs (dom := Unit) (Var (HNext HFirst)))) HNil.
(** %\vspace{-.15in}% [[ (** %\vspace{-.15in}% [[
= fun x _ : unit => x = fun x _ : unit => x
: typeDenote (Arrow Unit (Arrow Unit Unit)) : typeDenote (Arrow Unit (Arrow Unit Unit))
]] ]]
*) *)
Eval simpl in expDenote (Abs (dom := Unit) (Abs (dom := Unit) (Var MFirst))) HNil. Eval simpl in expDenote (Abs (dom := Unit) (Abs (dom := Unit) (Var HFirst))) HNil.
(** %\vspace{-.15in}% [[ (** %\vspace{-.15in}% [[
= fun _ x0 : unit => x0 = fun _ x0 : unit => x0
: typeDenote (Arrow Unit (Arrow Unit Unit)) : typeDenote (Arrow Unit (Arrow Unit Unit))
]] ]]
*) *)
Eval simpl in expDenote (App (Abs (Var MFirst)) Const) HNil. Eval simpl in expDenote (App (Abs (Var HFirst)) Const) HNil.
(** %\vspace{-.15in}% [[ (** %\vspace{-.15in}% [[
= tt = tt
: typeDenote Unit : typeDenote Unit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment