From 5c5b5906426f38323fc5d63f4dc634672ebd2649 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Tue, 8 Dec 2015 23:34:38 +0100 Subject: Adding an unshelve tactical. This tactical is inspired by discussions on the Coq-club list. For now it is still undocumented, and there is room left for design issues. --- proofs/proofview.ml | 33 ++++++++++++++++++++++----------- proofs/proofview.mli | 4 ++++ proofs/proofview_monad.ml | 23 ++++++++++++++--------- proofs/proofview_monad.mli | 12 ++++++++---- tactics/extratactics.ml4 | 10 ++++++++++ 5 files changed, 58 insertions(+), 24 deletions(-) diff --git a/proofs/proofview.ml b/proofs/proofview.ml index 59a64658dc..5981ad32da 100644 --- a/proofs/proofview.ml +++ b/proofs/proofview.ml @@ -32,7 +32,7 @@ type entry = (Term.constr * Term.types) list let proofview p = p.comb , p.solution -let compact el { comb; solution } = +let compact el ({ solution } as pv) = let nf = Evarutil.nf_evar solution in let size = Evd.fold (fun _ _ i -> i+1) solution 0 in let new_el = List.map (fun (t,ty) -> nf t, nf ty) el in @@ -45,7 +45,7 @@ let compact el { comb; solution } = let new_solution = Evd.raw_map_undefined apply_subst_einfo pruned_solution in let new_size = Evd.fold (fun _ _ i -> i+1) new_solution 0 in msg_info (Pp.str (Printf.sprintf "Evars: %d -> %d\n" size new_size)); - new_el, { comb; solution = new_solution } + new_el, { pv with solution = new_solution; } (** {6 Starting and querying a proof view} *) @@ -62,13 +62,13 @@ let dependent_init = let src = (Loc.ghost,Evar_kinds.GoalEvar) in (* Main routine *) let rec aux = function - | TNil sigma -> [], { solution = sigma; comb = []; } + | TNil sigma -> [], { solution = sigma; comb = []; shelf = [] } | TCons (env, sigma, typ, t) -> let (sigma, econstr ) = Evarutil.new_evar env sigma ~src ~store typ in let ret, { solution = sol; comb = comb } = aux (t sigma econstr) in let (gl, _) = Term.destEvar econstr in let entry = (econstr, typ) :: ret in - entry, { solution = sol; comb = gl :: comb; } + entry, { solution = sol; comb = gl :: comb; shelf = [] } in fun t -> let entry, v = aux t in @@ -232,6 +232,9 @@ let apply env t sp = match ans with | Nil (e, info) -> iraise (TacticFailure e, info) | Cons ((r, (state, _), status, info), _) -> + let (status, gaveup) = status in + let status = (status, state.shelf, gaveup) in + let state = { state with shelf = [] } in r, state, status, Trace.to_tree info @@ -578,7 +581,7 @@ let shelve = Comb.get >>= fun initial -> Comb.set [] >> InfoL.leaf (Info.Tactic (fun () -> Pp.str"shelve")) >> - Shelf.put initial + Shelf.modify (fun gls -> gls @ initial) (** [contained_in_info e evi] checks whether the evar [e] appears in @@ -617,7 +620,7 @@ let shelve_unifiable = let (u,n) = partition_unifiable initial.solution initial.comb in Comb.set n >> InfoL.leaf (Info.Tactic (fun () -> Pp.str"shelve_unifiable")) >> - Shelf.put u + Shelf.modify (fun gls -> gls @ u) (** [guard_no_unifiable] fails with error [UnresolvedBindings] if some goals are unifiable (see {!shelve_unifiable}) in the current focus. *) @@ -639,6 +642,14 @@ let unshelve l p = let l = undefined p.solution l in { p with comb = p.comb@l } +let with_shelf tac = + let open Proof in + Shelf.get >>= fun shelf -> + Shelf.set [] >> + tac >>= fun ans -> + Shelf.get >>= fun gls -> + Shelf.set shelf >> + tclUNIT (gls, ans) (** [goodmod p m] computes the representative of [p] modulo [m] in the interval [[0,m-1]].*) @@ -867,7 +878,7 @@ module Unsafe = struct let tclSETGOALS = Comb.set let tclEVARSADVANCE evd = - Pv.modify (fun ps -> { solution = evd; comb = undefined evd ps.comb }) + Pv.modify (fun ps -> { ps with solution = evd; comb = undefined evd ps.comb }) let tclEVARUNIVCONTEXT ctx = Pv.modify (fun ps -> { ps with solution = Evd.set_universe_context ps.solution ctx }) @@ -1085,7 +1096,7 @@ struct let sigma = CList.fold_left Unsafe.mark_as_goal_evm sigma comb in let open Proof in InfoL.leaf (Info.Tactic (fun () -> Pp.(hov 2 (str"refine"++spc()++ Hook.get pr_constrv env sigma c)))) >> - Pv.set { solution = sigma; comb; } + Pv.modify (fun ps -> { ps with solution = sigma; comb; }) end (** Useful definitions *) @@ -1164,7 +1175,7 @@ module V82 = struct let sgs = CList.flatten goalss in let sgs = undefined evd sgs in InfoL.leaf (Info.Tactic (fun () -> Pp.str"")) >> - Pv.set { solution = evd; comb = sgs; } + Pv.set { ps with solution = evd; comb = sgs; } with e when catchable_exception e -> let (e, info) = Errors.push e in tclZERO ~info e @@ -1176,7 +1187,7 @@ module V82 = struct Pv.modify begin fun ps -> let map g s = GoalV82.nf_evar s g in let (goals,evd) = Evd.Monad.List.map map ps.comb ps.solution in - { solution = evd; comb = goals; } + { ps with solution = evd; comb = goals; } end let has_unresolved_evar pv = @@ -1221,7 +1232,7 @@ module V82 = struct let of_tactic t gls = try - let init = { solution = gls.Evd.sigma ; comb = [gls.Evd.it] } in + let init = { shelf = []; solution = gls.Evd.sigma ; comb = [gls.Evd.it] } in let (_,final,_,_) = apply (GoalV82.env gls.Evd.sigma gls.Evd.it) t init in { Evd.sigma = final.solution ; it = final.comb } with Logic_monad.TacticFailure e as src -> diff --git a/proofs/proofview.mli b/proofs/proofview.mli index 927df33a0c..659b783cb2 100644 --- a/proofs/proofview.mli +++ b/proofs/proofview.mli @@ -303,6 +303,10 @@ val guard_no_unifiable : unit tactic goals of p *) val unshelve : Goal.goal list -> proofview -> proofview +(** [with_shelf tac] executes [tac] and returns its result together with the set + of goals shelved by [tac]. The current shelf is unchanged. *) +val with_shelf : 'a tactic -> (Goal.goal list * 'a) tactic + (** If [n] is positive, [cycle n] puts the [n] first goal last. If [n] is negative, then it puts the [n] last goals first.*) val cycle : int -> unit tactic diff --git a/proofs/proofview_monad.ml b/proofs/proofview_monad.ml index 6e68cd2e45..a9faf0a833 100644 --- a/proofs/proofview_monad.ml +++ b/proofs/proofview_monad.ml @@ -157,8 +157,11 @@ end (** Type of proof views: current [evar_map] together with the list of focused goals. *) -type proofview = { solution : Evd.evar_map; comb : Goal.goal list } - +type proofview = { + solution : Evd.evar_map; + comb : Goal.goal list; + shelf : Goal.goal list; +} (** {6 Instantiation of the logic monad} *) @@ -171,10 +174,10 @@ module P = struct type e = bool (** Status (safe/unsafe) * shelved goals * given up *) - type w = bool * Evar.t list * Evar.t list + type w = bool * Evar.t list - let wunit = true , [] , [] - let wprod (b1,s1,g1) (b2,s2,g2) = b1 && b2 , s1@s2 , g1@g2 + let wunit = true , [] + let wprod (b1, g1) (b2, g2) = b1 && b2 , g1@g2 type u = Info.state @@ -226,19 +229,21 @@ module Env : State with type t := Environ.env = struct end module Status : Writer with type t := bool = struct - let put s = Logical.put (s,[],[]) + let put s = Logical.put (s, []) end -module Shelf : Writer with type t = Evar.t list = struct +module Shelf : State with type t = Evar.t list = struct (* spiwack: I don't know why I cannot substitute ([:=]) [t] with a type expression. *) type t = Evar.t list - let put sh = Logical.put (true,sh,[]) + let get = Logical.map (fun {shelf} -> shelf) Pv.get + let set c = Pv.modify (fun pv -> { pv with shelf = c }) + let modify f = Pv.modify (fun pv -> { pv with shelf = f pv.shelf }) end module Giveup : Writer with type t = Evar.t list = struct (* spiwack: I don't know why I cannot substitute ([:=]) [t] with a type expression. *) type t = Evar.t list - let put gs = Logical.put (true,[],gs) + let put gs = Logical.put (true, gs) end (** Lens and utilies pertaining to the info trace *) diff --git a/proofs/proofview_monad.mli b/proofs/proofview_monad.mli index d2a2e55fb1..a172259170 100644 --- a/proofs/proofview_monad.mli +++ b/proofs/proofview_monad.mli @@ -68,15 +68,19 @@ end (** Type of proof views: current [evar_map] together with the list of focused goals. *) -type proofview = { solution : Evd.evar_map; comb : Goal.goal list } +type proofview = { + solution : Evd.evar_map; + comb : Goal.goal list; + shelf : Goal.goal list; +} (** {6 Instantiation of the logic monad} *) module P : sig type s = proofview * Environ.env - (** Status (safe/unsafe) * shelved goals * given up *) - type w = bool * Evar.t list * Evar.t list + (** Status (safe/unsafe) * given up *) + type w = bool * Evar.t list val wunit : w val wprod : w -> w -> w @@ -123,7 +127,7 @@ module Status : Writer with type t := bool (** Lens to the list of goals which have been shelved during the execution of the tactic. *) -module Shelf : Writer with type t = Evar.t list +module Shelf : State with type t = Evar.t list (** Lens to the list of goals which were given up during the execution of the tactic. *) diff --git a/tactics/extratactics.ml4 b/tactics/extratactics.ml4 index 9ffcd2dcff..1355499e48 100644 --- a/tactics/extratactics.ml4 +++ b/tactics/extratactics.ml4 @@ -21,6 +21,7 @@ open Util open Evd open Equality open Misctypes +open Proofview.Notations DECLARE PLUGIN "extratactics" @@ -864,6 +865,15 @@ TACTIC EXTEND shelve_unifiable [ Proofview.shelve_unifiable ] END +(* Unshelves the goal shelved by the tactic. *) +TACTIC EXTEND unshelve +| [ "unshelve" tactic(t) ] -> + [ + Proofview.with_shelf (Tacinterp.eval_tactic t) >>= fun (gls, ()) -> + Proofview.Unsafe.tclNEWGOALS gls + ] +END + (* Command to add every unshelved variables to the focus *) VERNAC COMMAND EXTEND Unshelve [ "Unshelve" ] -- cgit v1.2.3 From 8ea758fbb392e270e6a8d2287dbb5b0455d99368 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Wed, 9 Dec 2015 11:56:52 +0100 Subject: Fixing parsing of the unshelve tactical. Now [unshelve tac1; tac2] is parsed as [(unshelve tac1); tac2]. --- tactics/extratactics.ml4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tactics/extratactics.ml4 b/tactics/extratactics.ml4 index 1355499e48..827d2e25a6 100644 --- a/tactics/extratactics.ml4 +++ b/tactics/extratactics.ml4 @@ -867,7 +867,7 @@ END (* Unshelves the goal shelved by the tactic. *) TACTIC EXTEND unshelve -| [ "unshelve" tactic(t) ] -> +| [ "unshelve" tactic0(t) ] -> [ Proofview.with_shelf (Tacinterp.eval_tactic t) >>= fun (gls, ()) -> Proofview.Unsafe.tclNEWGOALS gls -- cgit v1.2.3 From 11eedd379d4b27e73a1999c0aacc2056311e8ba9 Mon Sep 17 00:00:00 2001 From: Pierre-Marie Pédrot Date: Wed, 9 Dec 2015 12:01:32 +0100 Subject: The unshelve tactical now takes future goals into account. --- proofs/proofview.ml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/proofs/proofview.ml b/proofs/proofview.ml index 5981ad32da..452f27ff2b 100644 --- a/proofs/proofview.ml +++ b/proofs/proofview.ml @@ -644,12 +644,18 @@ let unshelve l p = let with_shelf tac = let open Proof in - Shelf.get >>= fun shelf -> - Shelf.set [] >> + Pv.get >>= fun pv -> + let { shelf; solution } = pv in + Pv.set { pv with shelf = []; solution = Evd.reset_future_goals solution } >> tac >>= fun ans -> - Shelf.get >>= fun gls -> - Shelf.set shelf >> - tclUNIT (gls, ans) + Pv.get >>= fun npv -> + let { shelf = gls; solution = sigma } = npv in + let gls' = Evd.future_goals sigma in + let fgoals = Evd.future_goals solution in + let pgoal = Evd.principal_future_goal solution in + let sigma = Evd.restore_future_goals sigma fgoals pgoal in + Pv.set { npv with shelf; solution = sigma } >> + tclUNIT (CList.rev_append gls' gls, ans) (** [goodmod p m] computes the representative of [p] modulo [m] in the interval [[0,m-1]].*) -- cgit v1.2.3 From 8e7803224eeb32e83600905c2c855e32e7bf8ffb Mon Sep 17 00:00:00 2001 From: Gregory Malecha Date: Mon, 9 Nov 2015 16:22:18 -0800 Subject: bug fixes to vm computation + test cases. --- kernel/cbytegen.ml | 2 +- kernel/vm.mli | 3 + test-suite/kernel/vm-univ.v | 145 -------------------------------- test-suite/success/vm_univ_poly.v | 141 +++++++++++++++++++++++++++++++ test-suite/success/vm_univ_poly_match.v | 28 ++++++ 5 files changed, 173 insertions(+), 146 deletions(-) delete mode 100644 test-suite/kernel/vm-univ.v create mode 100644 test-suite/success/vm_univ_poly.v create mode 100644 test-suite/success/vm_univ_poly_match.v diff --git a/kernel/cbytegen.ml b/kernel/cbytegen.ml index 1f7cc3c7a6..67745d887b 100644 --- a/kernel/cbytegen.ml +++ b/kernel/cbytegen.ml @@ -175,7 +175,7 @@ let comp_env_cofix ndef arity rfv = let push_param n sz r = { r with nb_stack = r.nb_stack + n; - in_stack = add_param n (sz - r.nb_uni_stack) r.in_stack } + in_stack = add_param n sz r.in_stack } (* [push_local sz r] add a new variable on the stack at position [sz] *) let push_local sz r = diff --git a/kernel/vm.mli b/kernel/vm.mli index 43a42eb9c4..6e9579aa46 100644 --- a/kernel/vm.mli +++ b/kernel/vm.mli @@ -48,8 +48,11 @@ type whd = | Vatom_stk of atom * stack | Vuniv_level of Univ.universe_level +(** For debugging purposes only *) + val pr_atom : atom -> Pp.std_ppcmds val pr_whd : whd -> Pp.std_ppcmds +val pr_stack : stack -> Pp.std_ppcmds (** Constructors *) diff --git a/test-suite/kernel/vm-univ.v b/test-suite/kernel/vm-univ.v deleted file mode 100644 index 1bdba3c68d..0000000000 --- a/test-suite/kernel/vm-univ.v +++ /dev/null @@ -1,145 +0,0 @@ -(* Basic tests *) -Polymorphic Definition pid {T : Type} (x : T) : T := x. -(* -Definition _1 : pid true = true := - @eq_refl _ true <: pid true = true. - -Polymorphic Definition a_type := Type. - -Definition _2 : a_type@{i} = Type@{i} := - @eq_refl _ Type@{i} <: a_type@{i} = Type@{i}. - -Polymorphic Definition FORALL (T : Type) (P : T -> Prop) : Prop := - forall x : T, P x. - -Polymorphic Axiom todo : forall {T:Type}, T -> T. - -Polymorphic Definition todo' (T : Type) := @todo T. - -Definition _3 : @todo'@{Set} = @todo@{Set} := - @eq_refl _ (@todo@{Set}) <: @todo'@{Set} = @todo@{Set}. -*) - -(* Inductive Types *) -Inductive sumbool (A B : Prop) : Set := -| left : A -> sumbool A B -| right : B -> sumbool A B. - -Definition x : sumbool True False := left _ _ I. - -Definition sumbool_copy {A B : Prop} (H : sumbool A B) : sumbool A B := - match H with - | left _ _ x => left _ _ x - | right _ _ x => right _ _ x - end. - -Definition _4 : sumbool_copy x = x := - @eq_refl _ x <: sumbool_copy x = x. - -(* Polymorphic Inductive Types *) -Polymorphic Inductive poption (T : Type@{i}) : Type@{i} := -| PSome : T -> poption@{i} T -| PNone : poption@{i} T. - -Polymorphic Definition poption_default {T : Type@{i}} (p : poption@{i} T) (x : T) : T := - match p with - | @PSome _ y => y - | @PNone _ => x - end. - -Polymorphic Inductive plist (T : Type@{i}) : Type@{i} := -| pnil -| pcons : T -> plist@{i} T -> plist@{i} T. - -Arguments pnil {_}. -Arguments pcons {_} _ _. - -Section pmap. - Context {T : Type@{i}} {U : Type@{j}} (f : T -> U). - - Polymorphic Fixpoint pmap (ls : plist@{i} T) : plist@{j} U := - match ls with - | @pnil _ => @pnil _ - | @pcons _ l ls => @pcons@{j} U (f l) (pmap@{i j} ls) - end. -End pmap. - -Universe Ubool. -Inductive tbool : Type@{Ubool} := ttrue | tfalse. - - -Eval vm_compute in pmap pid (pcons true (pcons false pnil)). -Eval vm_compute in pmap (fun x => match x with - | pnil => true - | pcons _ _ => false - end) (pcons pnil (pcons (pcons false pnil) pnil)). -Eval vm_compute in pmap (fun x => x -> Type) (pcons tbool (pcons (plist tbool) pnil)). - -Polymorphic Inductive Tree (T : Type@{i}) : Type@{i} := -| Empty -| Branch : plist@{i} (Tree@{i} T) -> Tree@{i} T. - -Section pfold. - Context {T : Type@{i}} {U : Type@{u}} (f : T -> U -> U). - - Polymorphic Fixpoint pfold (acc : U) (ls : plist@{i} T) : U := - match ls with - | pnil => acc - | pcons a b => pfold (f a acc) b - end. -End pfold. - -Polymorphic Inductive nat : Type@{i} := -| O -| S : nat -> nat. - -Fixpoint nat_max (a b : nat) : nat := - match a , b with - | O , b => b - | a , O => a - | S a , S b => S (nat_max a b) - end. - -Polymorphic Fixpoint height {T : Type@{i}} (t : Tree@{i} T) : nat := - match t with - | Empty _ => O - | Branch _ ls => S (pfold nat_max O (pmap height ls)) - end. - -Polymorphic Fixpoint repeat {T : Type@{i}} (n : nat) (v : T) : plist@{i} T := - match n with - | O => pnil - | S n => pcons v (repeat n v) - end. - -Polymorphic Fixpoint big_tree (n : nat) : Tree@{i} nat := - match n with - | O => @Empty nat - | S n' => Branch _ (repeat n' (big_tree n')) - end. - -Eval compute in height (big_tree (S (S (S O)))). - -Let big := S (S (S (S (S O)))). -Polymorphic Definition really_big := (S@{i} (S (S (S (S (S (S (S (S (S O)))))))))). - -Time Definition _5 : height (@Empty nat) = O := - @eq_refl nat O <: height (@Empty nat) = O. - -Time Definition _6 : height@{Set} (@Branch nat pnil) = S O := - @eq_refl nat@{Set} (S@{Set} O@{Set}) <: height@{Set} (@Branch nat pnil) = S O. - -Time Definition _7 : height (big_tree big) = big := - @eq_refl nat big <: height (big_tree big) = big. - -Time Definition _8 : height (big_tree really_big) = really_big := - @eq_refl nat@{Set} (S@{Set} - (S@{Set} - (S@{Set} - (S@{Set} - (S@{Set} - (S@{Set} (S@{Set} (S@{Set} (S@{Set} (S@{Set} O@{Set})))))))))) - <: - @eq nat@{Set} - (@height nat@{Set} (big_tree really_big@{Set})) - really_big@{Set}. diff --git a/test-suite/success/vm_univ_poly.v b/test-suite/success/vm_univ_poly.v new file mode 100644 index 0000000000..58fa39743d --- /dev/null +++ b/test-suite/success/vm_univ_poly.v @@ -0,0 +1,141 @@ +(* Basic tests *) +Polymorphic Definition pid {T : Type} (x : T) : T := x. +(* +Definition _1 : pid true = true := + @eq_refl _ true <: pid true = true. + +Polymorphic Definition a_type := Type. + +Definition _2 : a_type@{i} = Type@{i} := + @eq_refl _ Type@{i} <: a_type@{i} = Type@{i}. + +Polymorphic Definition FORALL (T : Type) (P : T -> Prop) : Prop := + forall x : T, P x. + +Polymorphic Axiom todo : forall {T:Type}, T -> T. + +Polymorphic Definition todo' (T : Type) := @todo T. + +Definition _3 : @todo'@{Set} = @todo@{Set} := + @eq_refl _ (@todo@{Set}) <: @todo'@{Set} = @todo@{Set}. +*) + +(* Inductive Types *) +Inductive sumbool (A B : Prop) : Set := +| left : A -> sumbool A B +| right : B -> sumbool A B. + +Definition x : sumbool True False := left _ _ I. + +Definition sumbool_copy {A B : Prop} (H : sumbool A B) : sumbool A B := + match H with + | left _ _ x => left _ _ x + | right _ _ x => right _ _ x + end. + +Definition _4 : sumbool_copy x = x := + @eq_refl _ x <: sumbool_copy x = x. + +(* Polymorphic Inductive Types *) +Polymorphic Inductive poption@{i} (T : Type@{i}) : Type@{i} := +| PSome : T -> poption@{i} T +| PNone : poption@{i} T. + +Polymorphic Definition poption_default@{i} {T : Type@{i}} (p : poption@{i} T) (x : T) : T := + match p with + | @PSome _ y => y + | @PNone _ => x + end. + +Polymorphic Inductive plist@{i} (T : Type@{i}) : Type@{i} := +| pnil +| pcons : T -> plist@{i} T -> plist@{i} T. + +Arguments pnil {_}. +Arguments pcons {_} _ _. + +Polymorphic Definition pmap@{i j} + {T : Type@{i}} {U : Type@{j}} (f : T -> U) := + fix pmap (ls : plist@{i} T) : plist@{j} U := + match ls with + | @pnil _ => @pnil _ + | @pcons _ l ls => @pcons@{j} U (f l) (pmap@{i j} ls) + end. + +Universe Ubool. +Inductive tbool : Type@{Ubool} := ttrue | tfalse. + + +Eval vm_compute in pmap pid (pcons true (pcons false pnil)). +Eval vm_compute in pmap (fun x => match x with + | pnil => true + | pcons _ _ => false + end) (pcons pnil (pcons (pcons false pnil) pnil)). +Eval vm_compute in pmap (fun x => x -> Type) (pcons tbool (pcons (plist tbool) pnil)). + +Polymorphic Inductive Tree@{i} (T : Type@{i}) : Type@{i} := +| Empty +| Branch : plist@{i} (Tree@{i} T) -> Tree@{i} T. + +Polymorphic Definition pfold@{i u} + {T : Type@{i}} {U : Type@{u}} (f : T -> U -> U) := + fix pfold (acc : U) (ls : plist@{i} T) : U := + match ls with + | pnil => acc + | pcons a b => pfold (f a acc) b + end. + +Polymorphic Inductive nat@{i} : Type@{i} := +| O +| S : nat -> nat. + +Polymorphic Fixpoint nat_max@{i} (a b : nat@{i}) : nat@{i} := + match a , b with + | O , b => b + | a , O => a + | S a , S b => S (nat_max a b) + end. + +Polymorphic Fixpoint height@{i} {T : Type@{i}} (t : Tree@{i} T) : nat@{i} := + match t return nat@{i} with + | Empty _ => O + | Branch _ ls => S@{i} (pfold@{i i} nat_max O (pmap height ls)) + end. + +Polymorphic Fixpoint repeat@{i} {T : Type@{i}} (n : nat@{i}) (v : T) : plist@{i} T := + match n return plist@{i} T with + | O => pnil + | S n => pcons@{i} v (repeat n v) + end. + +Polymorphic Fixpoint big_tree@{i} (n : nat@{i}) : Tree@{i} nat@{i} := + match n with + | O => @Empty nat@{i} + | S n' => Branch@{i} nat@{i} (repeat@{i} n' (big_tree@{i} n')) + end. + +Eval compute in height (big_tree (S (S (S O)))). + +Let big := S (S (S (S (S O)))). +Polymorphic Definition really_big@{i} := (S@{i} (S (S (S (S (S (S (S (S (S O)))))))))). + +Time Definition _5 : height (@Empty nat) = O := + @eq_refl nat O <: height (@Empty nat) = O. + +Time Definition _6 : height@{Set} (@Branch nat pnil) = S O := + @eq_refl nat@{Set} (S@{Set} O@{Set}) <: @eq nat@{Set} (height@{Set} (@Branch@{Set} nat@{Set} (@pnil@{Set} (Tree@{Set} nat@{Set})))) (S@{Set} O@{Set}). + +Time Definition _7 : height (big_tree big) = big := + @eq_refl nat big <: height (big_tree big) = big. + +Time Definition _8 : height (big_tree really_big) = really_big := + @eq_refl nat@{Set} (S@{Set} + (S@{Set} + (S@{Set} + (S@{Set} + (S@{Set} + (S@{Set} (S@{Set} (S@{Set} (S@{Set} (S@{Set} O@{Set})))))))))) + <: + @eq nat@{Set} + (@height nat@{Set} (big_tree really_big@{Set})) + really_big@{Set}. diff --git a/test-suite/success/vm_univ_poly_match.v b/test-suite/success/vm_univ_poly_match.v new file mode 100644 index 0000000000..abe6d0fe07 --- /dev/null +++ b/test-suite/success/vm_univ_poly_match.v @@ -0,0 +1,28 @@ +Set Dump Bytecode. +Set Printing Universes. +Set Printing All. + +Polymorphic Class Applicative@{d c} (T : Type@{d} -> Type@{c}) := +{ pure : forall {A : Type@{d}}, A -> T A + ; ap : forall {A B : Type@{d}}, T (A -> B) -> T A -> T B +}. + +Universes Uo Ua. + +Eval compute in @pure@{Uo Ua}. + +Global Instance Applicative_option : Applicative@{Uo Ua} option := +{| pure := @Some + ; ap := fun _ _ f x => + match f , x with + | Some f , Some x => Some (f x) + | _ , _ => None + end +|}. + +Definition foo := ap (ap (pure plus) (pure 1)) (pure 1). + +Print foo. + + +Eval vm_compute in foo. -- cgit v1.2.3 From 36cbe8fa3bd20469b45b299f66e88e03768a81af Mon Sep 17 00:00:00 2001 From: Gregory Malecha Date: Fri, 27 Nov 2015 16:40:34 -0800 Subject: a few edits to the universe polymorphism section of the manual --- doc/refman/Universes.tex | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/refman/Universes.tex b/doc/refman/Universes.tex index f47973601b..ea3cca77ed 100644 --- a/doc/refman/Universes.tex +++ b/doc/refman/Universes.tex @@ -11,8 +11,8 @@ \end{flushleft} This section describes the universe polymorphic extension of Coq. -Universe polymorphism allows writing generic definitions making use of -universes and reuse them at different and sometimes incompatible levels. +Universe polymorphism makes it possible to write generic definitions making use of +universes and reuse them at different and sometimes incompatible universe levels. A standard example of the difference between universe \emph{polymorphic} and \emph{monomorphic} definitions is given by the identity function: @@ -64,10 +64,10 @@ the application it is instantiated at \texttt{Top.3} while in the argument position it is instantiated at \texttt{Top.4}. This definition is only valid as long as \texttt{Top.4} is strictly smaller than \texttt{Top.3}, as show by the constraints. Note that this definition is -monomorphic (not universe polymorphic), so in turn the two universes are -actually global levels. +monomorphic (not universe polymorphic), so the two universes +(in this case \texttt{Top.3} and \texttt{Top.4}) are actually global levels. -Inductive types can also be declared universes polymorphic, on universes +Inductive types can also be declared universes polymorphic on universes appearing in their parameters or fields. A typical example is given by monoids: @@ -79,7 +79,7 @@ Print Monoid. The \texttt{Monoid}'s carrier universe is polymorphic, hence it is possible to instantiate it for example with \texttt{Monoid} itself. -First we build the trivial unit monoid, in \texttt{Set}: +First we build the trivial unit monoid in \texttt{Set}: \begin{coq_example} Definition unit_monoid : Monoid := {| mon_car := unit; mon_unit := tt; mon_op x y := tt |}. @@ -197,7 +197,7 @@ universes and explicitly instantiate polymorphic definitions. \comindex{Universe} \label{UniverseCmd}} -In the monorphic case, this command declare a new global universe named +In the monorphic case, this command declares a new global universe named {\ident}. It supports the polymorphic flag only in sections, meaning the universe quantification will be discharged on each section definition independently. @@ -206,7 +206,7 @@ independently. \comindex{Constraint} \label{ConstraintCmd}} -This command declare a new constraint between named universes. +This command declares a new constraint between named universes. The order relation can be one of $<$, $\le$ or $=$. If consistent, the constraint is then enforced in the global environment. Like \texttt{Universe}, it can be used with the \texttt{Polymorphic} prefix -- cgit v1.2.3 From ce9e7c2a842d7ec7734b58af64de9283de963e37 Mon Sep 17 00:00:00 2001 From: Emilio Jesus Gallego Arias Date: Fri, 4 Dec 2015 19:25:08 +0100 Subject: Replace Unix.readdir by Sys.readdir in dir cache. This makes the function sightly more portable. --- lib/system.ml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/system.ml b/lib/system.ml index 2e35a98f7f..91b2f5afaf 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -67,16 +67,8 @@ module StrSet = Set.Make(StrMod) let dirmap = ref StrMap.empty let make_dir_table dir = - let b = ref StrSet.empty in - let a = Unix.opendir dir in - (try - while true do - let s = Unix.readdir a in - if s.[0] != '.' then b := StrSet.add s !b - done - with - | End_of_file -> ()); - Unix.closedir a; !b + let filter_dotfiles s f = if f.[0] = '.' then s else StrSet.add f s in + Array.fold_left filter_dotfiles StrSet.empty (Sys.readdir dir) let exists_in_dir_respecting_case dir bf = let contents, cached = -- cgit v1.2.3 From 9d45d45f3a8718581a001af4576ca87feb741073 Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Wed, 9 Dec 2015 14:56:17 +0100 Subject: Remove remaining occurrences of Unix.readdir. --- lib/system.ml | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/lib/system.ml b/lib/system.ml index 91b2f5afaf..f860bd2f7e 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -11,12 +11,11 @@ open Pp open Errors open Util -open Unix (* All subdirectories, recursively *) let exists_dir dir = - try let _ = closedir (opendir dir) in true with Unix_error _ -> false + try Sys.is_directory dir with Sys_error _ -> false let skipped_dirnames = ref ["CVS"; "_darcs"] @@ -31,24 +30,15 @@ let all_subdirs ~unix_path:root = let l = ref [] in let add f rel = l := (f, rel) :: !l in let rec traverse dir rel = - let dirh = opendir dir in - try - while true do - let f = readdir dirh in - if ok_dirname f then - let file = Filename.concat dir f in - try - begin match (stat file).st_kind with - | S_DIR -> - let newrel = rel @ [f] in - add file newrel; - traverse file newrel - | _ -> () - end - with Unix_error (e,s1,s2) -> () - done - with End_of_file -> - closedir dirh + Array.iter (fun f -> + if ok_dirname f then + let file = Filename.concat dir f in + if Sys.is_directory file then begin + let newrel = rel @ [f] in + add file newrel; + traverse file newrel + end) + (Sys.readdir dir) in if exists_dir root then traverse root []; List.rev !l -- cgit v1.2.3 From 38e70af82d33de8e977b9b7e347ff501fcd5c2d8 Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Wed, 9 Dec 2015 15:14:10 +0100 Subject: Print Assumptions: improve detection of case on an axiom of False The name in the return clause has no semantic meaning, we must not look at it. --- toplevel/assumptions.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toplevel/assumptions.ml b/toplevel/assumptions.ml index a6bd968efc..a71588fe05 100644 --- a/toplevel/assumptions.ml +++ b/toplevel/assumptions.ml @@ -158,7 +158,7 @@ let rec traverse current ctx accu t = match kind_of_term t with | Case (_,oty,c,[||]) -> (* non dependent match on an inductive with no constructors *) begin match Constr.(kind oty, kind c) with - | Lambda(Anonymous,_,oty), Const (kn, _) + | Lambda(_,_,oty), Const (kn, _) when Vars.noccurn 1 oty && not (Declareops.constant_has_body (lookup_constant kn)) -> let body () = Global.body_of_constant_body (lookup_constant kn) in -- cgit v1.2.3 From 5cdf3cfc8ddfb9854534fadc1a08019e9c472590 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 4 Oct 2015 08:16:54 +0200 Subject: RefMan, ch. 4: Fixing the definition of terms considered in the section. --- doc/refman/RefMan-cic.tex | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 9d79f7cac3..ef7b99d6a8 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -176,9 +176,11 @@ in a theory where inductive objects are represented by terms. \subsection{Terms} -Terms are built from variables, constants, constructors, -abstraction, application, local declarations bindings (``let-in'' -expressions) and product. +Terms are built from sorts, variables, constant, +%constructors, inductive types, +abstraction, application, local definitions, +%case analysis, fixpoints, cofixpoints +and products. From a syntactic point of view, types cannot be distinguished from terms, except that they cannot start by an abstraction, and that if a term is @@ -188,9 +190,11 @@ More precisely the language of the {\em Calculus of Inductive Constructions} is built from the following rules: \begin{enumerate} -\item the sorts {\sf Set, Prop, Type} are terms. -\item names for global constants of the environment are terms. -\item variables are terms. +\item the sorts {\Set}, {\Prop}, ${\Type(i)}$ are terms. +\item variables are terms +\item constants are terms. +%\item constructors are terms. +%\item inductive types are terms. \item if $x$ is a variable and $T$, $U$ are terms then $\forall~x:T,U$ ($\kw{forall}~x:T,U$ in \Coq{} concrete syntax) is a term. If $x$ occurs in $U$, $\forall~x:T,U$ reads as {\it ``for all x of type T, @@ -212,6 +216,9 @@ More precisely the language of the {\em Calculus of Inductive term which denotes the term $U$ where the variable $x$ is locally bound to $T$. This stands for the common ``let-in'' construction of functional programs such as ML or Scheme. +%\item case ... +%\item fixpoint ... +%\item cofixpoint ... \end{enumerate} \paragraph{Notations.} Application associates to the left such that -- cgit v1.2.3 From 5f156b28c84a86a978ab150ab5bbac5ad928ada5 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 4 Oct 2015 08:19:43 +0200 Subject: RefMan, ch. 4: Consistently using "constant" for names assumed or defined in global environment and "variable" for names assumed or defined in local context. --- doc/refman/RefMan-cic.tex | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index ef7b99d6a8..ca3a6135d8 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -250,7 +250,8 @@ a global environment (see below) and a local context. \paragraph{Local context.} A {\em local context} is an ordered list of -declarations of variables. The declaration of some variable $x$ is +declarations of names which we call {\em variables}. +The declaration of some variable $x$ is either a local assumption, written $x:T$ ($T$ is a type) or a local definition, written $x:=t:T$. We use brackets to write local contexts. A typical example is $[x:T;y:=u:U;z:V]$. Notice that the variables @@ -289,11 +290,11 @@ definitions, but also declarations of inductive objects. Inductive objects thems (see Section~\ref{Cic-inductive-definitions}). A global assumption will be represented in the global environment as -\Assum{\Gamma}{c}{T} which means that $c$ is assumed of some type $T$ -well-defined in some local context $\Gamma$. A global definition will -be represented in the global environment as \Def{\Gamma}{c}{t}{T} which means -that $c$ is a constant which is valid in some local context $\Gamma$ whose -value is $t$ and type is $T$. +\Assum{\Gamma}{c}{T} which assumes the name $c$ to be of some type $T$ +valid in some local context $\Gamma$. A global definition will +be represented in the global environment as \Def{\Gamma}{c}{t}{T} which defines +the name $c$ to have value $t$ and type $T$, both valid in $\Gamma$. +We shall call such names {\em constants}. The rules for inductive definitions (see section \ref{Cic-inductive-definitions}) have to be considered as assumption @@ -405,7 +406,7 @@ called $\iota$-reduction and is more precisely studied in \paragraph[$\delta$-reduction.]{$\delta$-reduction.\label{delta}\index{delta-reduction@$\delta$-reduction}} -We may have defined variables in local contexts or constants in the global +We may have variables defined in local contexts or constants defined in the global environment. It is legal to identify such a reference with its value, that is to expand (or unfold) it into its value. This reduction is called $\delta$-reduction and shows as follows. -- cgit v1.2.3 From ef7264aa6106d0257e1a34f4ecf765279d9b602e Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 4 Oct 2015 08:22:47 +0200 Subject: RefMan, ch. 4: Removing confusing paragraph "Constants": in it, constants are yet given another definition; the reference to other presentation is more confusing than helpful to me. --- doc/refman/RefMan-cic.tex | 52 ++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index ca3a6135d8..3b8a8fee11 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -148,31 +148,33 @@ constraints must remain acyclic. Typing expressions that violate the acyclicity of the graph of constraints results in a \errindex{Universe inconsistency} error (see also Section~\ref{PrintingUniverses}). -\subsection{Constants} - -Constants refers to -objects in the global environment. These constants may denote previously -defined objects, but also objects related to inductive definitions -(either the type itself or one of its constructors or destructors). - -\medskip\noindent {\bf Remark. } In other presentations of \CIC, -the inductive objects are not seen as -external declarations but as first-class terms. Usually the -definitions are also completely ignored. This is a nice theoretical -point of view but not so practical. An inductive definition is -specified by a possibly huge set of declarations, clearly we want to -share this specification among the various inductive objects and not -to duplicate it. So the specification should exist somewhere and the -various objects should refer to it. We choose one more level of -indirection where the objects are just represented as constants and -the environment gives the information on the kind of object the -constant refers to. - -\medskip -Our inductive objects will be manipulated as constants declared in the -environment. This roughly corresponds to the way they are actually -implemented in the \Coq\ system. It is simple to map this presentation -in a theory where inductive objects are represented by terms. +%% HH: This looks to me more like source of confusion than helpful + +%% \subsection{Constants} + +%% Constants refers to +%% objects in the global environment. These constants may denote previously +%% defined objects, but also objects related to inductive definitions +%% (either the type itself or one of its constructors or destructors). + +%% \medskip\noindent {\bf Remark. } In other presentations of \CIC, +%% the inductive objects are not seen as +%% external declarations but as first-class terms. Usually the +%% definitions are also completely ignored. This is a nice theoretical +%% point of view but not so practical. An inductive definition is +%% specified by a possibly huge set of declarations, clearly we want to +%% share this specification among the various inductive objects and not +%% to duplicate it. So the specification should exist somewhere and the +%% various objects should refer to it. We choose one more level of +%% indirection where the objects are just represented as constants and +%% the environment gives the information on the kind of object the +%% constant refers to. + +%% \medskip +%% Our inductive objects will be manipulated as constants declared in the +%% environment. This roughly corresponds to the way they are actually +%% implemented in the \Coq\ system. It is simple to map this presentation +%% in a theory where inductive objects are represented by terms. \subsection{Terms} -- cgit v1.2.3 From cd31e372c6fb25769c26879f2f65f1937d098b87 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 4 Oct 2015 08:43:19 +0200 Subject: RefMan, ch. 4: Unify capitalization of "calculus of inductive constructions". --- doc/refman/RefMan-ext.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-ext.tex b/doc/refman/RefMan-ext.tex index a2be25c3ba..a718a26ea5 100644 --- a/doc/refman/RefMan-ext.tex +++ b/doc/refman/RefMan-ext.tex @@ -289,7 +289,7 @@ To deactivate the printing of projections, use The option {\tt Set Primitive Projections} turns on the use of primitive projections when defining subsequent records. Primitive projections -extended the calculus of inductive constructions with a new binary term +extended the Calculus of Inductive Constructions with a new binary term constructor {\tt r.(p)} representing a primitive projection p applied to a record object {\tt r} (i.e., primitive projections are always applied). Even if the record type has parameters, these do not appear at -- cgit v1.2.3 From 75896eaaf60ce947e1fbc5a795ca5969bb1e4fae Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 4 Oct 2015 08:47:15 +0200 Subject: RefMan, ch. 4: Dropping the "Co" which noone uses in "(Co)Inductive". --- doc/refman/RefMan-cic.tex | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 3b8a8fee11..2bf5bb357e 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -2,20 +2,22 @@ \label{Cic} \index{Cic@\textsc{CIC}} \index{pCic@p\textsc{CIC}} -\index{Calculus of (Co)Inductive Constructions}} +\index{Calculus of Inductive Constructions}} The underlying formal language of {\Coq} is a {\em Calculus of - Constructions} with {\em Inductive Definitions}. It is presented in -this chapter. + Constructions} with {\em Inductive Definitions}, also featuring a +universe hierarchy and coinductive types. Its inference rules are +presented in this chapter. + For {\Coq} version V7, this Calculus was known as the -{\em Calculus of (Co)Inductive Constructions}\index{Calculus of - (Co)Inductive Constructions} (\iCIC\ in short). +{\em Calculus of Inductive Constructions}\index{Calculus of + Inductive Constructions} (\iCIC\ in short). The underlying calculus of {\Coq} version V8.0 and up is a weaker calculus where the sort \Set{} satisfies predicative rules. We call this calculus the -{\em Predicative Calculus of (Co)Inductive +{\em Predicative Calculus of Inductive Constructions}\index{Predicative Calculus of - (Co)Inductive Constructions} (\pCIC\ in short). + Inductive Constructions} (\pCIC\ in short). In Section~\ref{impredicativity} we give the extra-rules for \iCIC. A compiling option of \Coq{} allows type-checking theories in this extended system. -- cgit v1.2.3 From 650ed1278160c2d6dae7914703c8755ab54e095c Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 4 Oct 2015 21:16:17 +0200 Subject: RefMan, ch. 4: Reformulating introduction of the chapter on CIC, being clearer that the version depends on the version of Coq. Also renouncing to the "Predicative" and "(Co)" in the name, since after all, usage seems to continue calling the language of Coq Calculus of Inductive Constructions and to consider the Set predicative vs Set impredicative, as well as the presence of coinduction, as flavors of the CIC. --- doc/common/macros.tex | 3 +-- doc/refman/RefMan-cic.tex | 65 +++++++++++++++++++++++++---------------------- doc/refman/biblio.bib | 25 +++++++++++++++--- 3 files changed, 57 insertions(+), 36 deletions(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index 0e820008ed..573c3c812e 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -97,8 +97,7 @@ \newcommand{\camlpppp}{\textsc{Camlp4}} \newcommand{\emacs}{\textsc{GNU Emacs}} \newcommand{\ProofGeneral}{\textsc{Proof General}} -\newcommand{\CIC}{\pCIC} -\newcommand{\pCIC}{p\textsc{Cic}} +\newcommand{\CIC}{\textsc{Cic}} \newcommand{\iCIC}{\textsc{Cic}} \newcommand{\FW}{\ensuremath{F_{\omega}}} \newcommand{\Program}{\textsc{Program}} diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 2bf5bb357e..a06e7acbad 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -5,22 +5,29 @@ \index{Calculus of Inductive Constructions}} The underlying formal language of {\Coq} is a {\em Calculus of - Constructions} with {\em Inductive Definitions}, also featuring a -universe hierarchy and coinductive types. Its inference rules are -presented in this chapter. - -For {\Coq} version V7, this Calculus was known as the -{\em Calculus of Inductive Constructions}\index{Calculus of - Inductive Constructions} (\iCIC\ in short). -The underlying calculus of {\Coq} version V8.0 and up is a weaker - calculus where the sort \Set{} satisfies predicative rules. -We call this calculus the -{\em Predicative Calculus of Inductive - Constructions}\index{Predicative Calculus of - Inductive Constructions} (\pCIC\ in short). -In Section~\ref{impredicativity} we give the extra-rules for \iCIC. A - compiling option of \Coq{} allows type-checking theories in this - extended system. + Inductive Constructions} (\CIC) whose inference rules are presented in +this chapter. + +The {\CIC} implemented in {\Coq} +takes its name from Coquand and Paulin's {\em Calculus of + Inductive Constructions}~\cite{CoPa89} which itself extends +Coquand-Huet's {\em Calculus of + Constructions}~\cite{CoHu85a,CoHu85b,CoHu86,Coq85} with a universe +hierarchy~\cite{Coq86,Luo90,Hue88b} and a generic presentation of +inductive types à la Martin-L\"of~\cite{MaL84,Dyb91}. First implemented in +{\Coq} version 5.0, it incorporated coinductive +types~\cite{Coquand93,Gim96} from {\Coq} version 5.10. It +progressively extended with various new features such as local +definitions (since {\Coq} version 7.0), universe polymorphism (since +{\Coq} version 8.1 for inductive types and version 8.5 for full +polymorphism), recursively non-uniform parameters (since {\Coq} version 8.1), +some $\eta$-rules (for dependent product in {\Coq} +version 8.4, for record types in {\Coq} version 8.5), and other +refinements in the expressiveness of fixpoints and inductive types. +Up to version 7.4, the {\CIC} implemented in {\Coq} +had an impredicative sort {\Set}. Since {\Coq} version 8.0, the sort +{\Set} is predicative by default, with an option to make it +impredicative (see Section~\ref{impredicativity}). In \CIC\, all objects have a {\em type}. There are types for functions (or programs), there are atomic types (especially datatypes)... but also @@ -28,29 +35,25 @@ types for proofs and types for the types themselves. Especially, any object handled in the formalism must belong to a type. For instance, the statement {\it ``for all x, P''} is not allowed in type theory; you must say instead: {\it ``for all x -belonging to T, P''}. The expression {\it ``x belonging to T''} is -written {\it ``x:T''}. One also says: {\it ``x has type T''}. +of type T, P''}. The expression {\it ``x of type T''} is +written {\it ``x:T''}. Informally, {\it ``x:T''} can be thought as +{\it ``x belongs to T''}. The terms of {\CIC} are detailed in Section~\ref{Terms}. -In \CIC\, there is an internal reduction mechanism. In particular, it +In \CIC, there is an internal reduction mechanism. In particular, it can decide if two programs are {\em intentionally} equal (one says {\em convertible}). Convertibility is presented in section \ref{convertibility}. -The remaining sections are concerned with the type-checking of terms. -The beginner can skip them. - The reader seeking a background on the Calculus of Inductive -Constructions may read several papers. Giménez and Castéran~\cite{GimCas05} +Constructions may read several papers. In addition to the references given above, Giménez and Castéran~\cite{GimCas05} provide an introduction to inductive and co-inductive definitions in Coq. In -their book~\cite{CoqArt}, Bertot and Castéran give a precise +their book~\cite{CoqArt}, Bertot and Castéran give a description of the \CIC{} based on numerous practical examples. Barras~\cite{Bar99}, Werner~\cite{Wer94} and -Paulin-Mohring~\cite{Moh97} are the most recent theses dealing with -Inductive Definitions. Coquand-Huet~\cite{CoHu85a,CoHu85b,CoHu86} -introduces the Calculus of Constructions. Coquand-Paulin~\cite{CoPa89} -extended this calculus to inductive definitions. The {\CIC} is a +Paulin-Mohring~\cite{Moh97} are dealing with +Inductive Definitions. The {\CIC} is a formulation of type theory including the possibility of inductive constructions, Barendregt~\cite{Bar91} studies the modern form of type theory. @@ -1701,11 +1704,11 @@ More information on co-inductive definitions can be found in~\cite{Gimenez95b,Gim98,GimCas05}. %They are described in Chapter~\ref{Co-inductives}. -\section[\iCIC : the Calculus of Inductive Construction with - impredicative \Set]{\iCIC : the Calculus of Inductive Construction with +\section[The Calculus of Inductive Construction with + impredicative \Set]{The Calculus of Inductive Construction with impredicative \Set\label{impredicativity}} -\Coq{} can be used as a type-checker for \iCIC{}, the original +\Coq{} can be used as a type-checker for the Calculus of Inductive Constructions with an impredicative sort \Set{} by using the compiler option \texttt{-impredicative-set}. diff --git a/doc/refman/biblio.bib b/doc/refman/biblio.bib index d78ce4f2c6..6f789b081c 100644 --- a/doc/refman/biblio.bib +++ b/doc/refman/biblio.bib @@ -288,9 +288,14 @@ s}, @InProceedings{Coquand93, author = {Th. Coquand}, - title = {{Infinite Objects in Type Theory}}, + booktitle = {Types for Proofs and Programs}, + editor = {H. Barendregt and T. Nipokow}, + publisher = SV, + series = LNCS, + title = {{Infinite objects in Type Theory}}, + volume = {806}, year = {1993}, - crossref = {Nijmegen93} + pages = {62-78} } @inproceedings{Corbineau08types, @@ -540,6 +545,13 @@ s}, year = {1994} } +@PhDThesis{Gim96, + author = {E. Gim\'enez}, + title = {Un calcul des constructions infinies et son application \'a la v\'erification de syst\`emes communicants}, + school = {\'Ecole Normale Sup\'erieure de Lyon}, + year = {1996} +} + @TechReport{Gim98, author = {E. Gim\'enez}, title = {A Tutorial on Recursive Types in Coq}, @@ -660,6 +672,13 @@ s}, year = {1989} } +@Unpublished{Hue88b, + author = {G. Huet}, + title = {Extending the Calculus of Constructions with Type:Type}, + year = 1988, + note = {Unpublished} +} + @Book{Hue89, editor = {G. Huet}, publisher = {Addison-Wesley}, @@ -1366,4 +1385,4 @@ Languages}, timestamp = {Thu, 17 Nov 2011 13:33:48 +0100}, biburl = {http://dblp.uni-trier.de/rec/bib/conf/cpp/BoespflugDG11}, bibsource = {dblp computer science bibliography, http://dblp.org} -} \ No newline at end of file +} -- cgit v1.2.3 From e7c38a5516246b751b89535594075f6f95a243fd Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 4 Oct 2015 22:17:46 +0200 Subject: RefMan, ch. 4: In chapter 4 about CIC, renounced to keep a local context for discharge in global declarations. Discharge now done on a global declaration. Hence removed Def and Assum which were only partially used (e.g. in rules Def and Assum but not in delta-conversion, nor in rule Const). Added discharge rule over definitions using let-in. It replaces the "substitution" rule since about 7.0. --- doc/common/macros.tex | 1 + doc/refman/RefMan-cic.tex | 92 ++++++++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index 573c3c812e..f785a85bbc 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -412,6 +412,7 @@ \newcommand{\Fix}[2]{\mbox{\tt Fix}~#1\{#2\}} \newcommand{\CoFix}[2]{\mbox{\tt CoFix}~#1\{#2\}} \newcommand{\With}[2]{\mbox{\tt ~with~}} +\newcommand{\letin}[3]{\kw{let}~#1:=#2~\kw{in}~#3} \newcommand{\subst}[3]{#1\{#2/#3\}} \newcommand{\substs}[4]{#1\{(#2/#3)_{#4}\}} \newcommand{\Sort}{\mbox{$\cal S$}} diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index a06e7acbad..52003dc34f 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -297,10 +297,10 @@ definitions, but also declarations of inductive objects. Inductive objects thems (see Section~\ref{Cic-inductive-definitions}). A global assumption will be represented in the global environment as -\Assum{\Gamma}{c}{T} which assumes the name $c$ to be of some type $T$ -valid in some local context $\Gamma$. A global definition will -be represented in the global environment as \Def{\Gamma}{c}{t}{T} which defines -the name $c$ to have value $t$ and type $T$, both valid in $\Gamma$. +$(c:T)$ which assumes the name $c$ to be of some type $T$. +A global definition will +be represented in the global environment as $c:=t:T$ which defines +the name $c$ to have value $t$ and type $T$. We shall call such names {\em constants}. The rules for inductive definitions (see section @@ -342,10 +342,10 @@ be derived from the following rules. \frac{\WTEG{t}{T}~~~~x \not\in \Gamma % \cup E }{\WFE{\Gamma::(x:=t:T)}}} -\item[Def] \inference{\frac{\WTEG{t}{T}~~~c \notin E \cup \Gamma} - {\WF{E;\Def{\Gamma}{c}{t}{T}}{\Gamma}}} -\item[Assum] \inference{\frac{\WTEG{T}{s}~~~~s \in \Sort~~~~c \notin E \cup \Gamma} - {\WF{E;\Assum{\Gamma}{c}{T}}{\Gamma}}} +\item[Def] \inference{\frac{\WTE{}{t}{T}~~~c \notin E} + {\WF{E;c:=t:T}{}}} + \item[Assum] \inference{\frac{\WTE{}{T}{s}~~~~s \in \Sort~~~~c \notin E} + {\WF{E;c:T}{}}} \item[Ax] \index{Typing rules!Ax} \inference{\frac{\WFE{\Gamma}}{\WTEG{\Prop}{\Type(p)}}~~~~~ \frac{\WFE{\Gamma}}{\WTEG{\Set}{\Type(q)}}} @@ -372,7 +372,7 @@ be derived from the following rules. {\WTEG{(t\ u)}{\subst{T}{x}{u}}}} \item[Let]\index{Typing rules!Let} \inference{\frac{\WTEG{t}{T}~~~~ \WTE{\Gamma::(x:=t:T)}{u}{U}} - {\WTEG{\kw{let}~x:=t~\kw{in}~u}{\subst{U}{x}{t}}}} + {\WTEG{\letin{x}{t:T}{u}}{\subst{U}{x}{t}}}} \end{description} \Rem We may have $\kw{let}~x:=t~\kw{in}~u$ @@ -528,51 +528,55 @@ Because these rules correspond to elementary operations in the \Coq\ engine used in the discharge mechanism at the end of a section, we state them explicitly. -\paragraph{Mechanism of substitution.} +% This is obsolete: Abstraction over defined constants actually uses a +% let-in since there are let-ins in Coq -One rule which can be proved valid, is to replace a term $c$ by its -value in the global environment. As we defined the substitution of a term for -a variable in a term, one can define the substitution of a term for a -constant. One easily extends this substitution to local contexts and global -environments. +%% \paragraph{Mechanism of substitution.} -\paragraph{Substitution Property:} -\inference{\frac{\WF{E;\Def{\Gamma}{c}{t}{T}; F}{\Delta}} - {\WF{E; \subst{F}{c}{t}}{\subst{\Delta}{c}{t}}}} +%% One rule which can be proved valid, is to replace a term $c$ by its +%% value in the global environment. As we defined the substitution of a term for +%% a variable in a term, one can define the substitution of a term for a +%% constant. One easily extends this substitution to local contexts and global +%% environments. +%% \paragraph{Substitution Property:} +%% \inference{\frac{\WF{E;c:=t:T; E'}{\Gamma}} +%% {\WF{E; \subst{E'}{c}{t}}{\subst{\Gamma}{c}{t}}}} \paragraph{Abstraction.} -One can modify the local context of definition of a constant $c$ by -abstracting a constant with respect to the last variable $x$ of its -defining local context. For doing that, we need to check that the constants -appearing in the body of the declaration do not depend on $x$, we need -also to modify the reference to the constant $c$ in the global environment -and local context by explicitly applying this constant to the variable $x$. -Because of the rules for building global environments and terms we know the -variable $x$ is available at each stage where $c$ is mentioned. - -\paragraph{Abstracting property:} - \inference{\frac{\WF{E; \Def{\Gamma::(x:U)}{c}{t}{T}; - F}{\Delta}~~~~\WFE{\Gamma}} - {\WF{E;\Def{\Gamma}{c}{\lb x:U\mto t}{\forall~x:U,T}; - \subst{F}{c}{(c~x)}}{\subst{\Delta}{c}{(c~x)}}}} +One can modify the definition of a constant $c$ by generalizing it +over a previously assumed constant $c'$. For doing that, we need +to modify the reference to $c$ in the subsequent global environment +and local context by explicitly applying this constant to the constant $c'$. -\paragraph{Pruning the local context.} -We said the judgment \WFE{\Gamma} means that the defining local contexts of -constants in $E$ are included in $\Gamma$. If one abstracts or -substitutes the constants with the above rules then it may happen -that the local context $\Gamma$ is now bigger than the one needed for -defining the constants in $E$. Because defining local contexts are growing -in $E$, the minimum local context needed for defining the constants in $E$ -is the same as the one for the last constant. One can consequently -derive the following property. +\paragraph{First abstracting property:} + \inference{\frac{\WF{E;c':U;E';c:=t:T;E''}{\Gamma}} + {\WF{E;c':U;E';c:=\lb x:U\mto \subst{t}{c'}{x}:\forall~x:U,\subst{T}{c'}{x}; + \subst{E''}{c}{(c~c')}}{\subst{\Gamma}{c}{(c~c')}}}} -\paragraph{Pruning property:} -\inference{\frac{\WF{E; \Def{\Delta}{c}{t}{T}}{\Gamma}} - {\WF{E;\Def{\Delta}{c}{t}{T}}{\Delta}}} +One can similarly modify the definition of a constant $c$ by generalizing it +over a previously defined constant $c'$. +\paragraph{Second abstracting property:} + \inference{\frac{\WF{E;c':=u:U;E';c:=t:T;E''}{\Gamma}} + {\WF{E;c':=u:U;E';c:=(\letin{x}{u:U}{\subst{t}{c'}{x}}):\subst{T}{c'}{u}; + E''}{\Gamma}}} +\paragraph{Pruning the local context.} +If one abstracts or substitutes constants with the above rules then it +may happen that some declared or defined constant does not occur any +more in the subsequent global environment and in the local context. One can +consequently derive the following property. + +\paragraph{First pruning property:} +\inference{\frac{\WF{E;c:U;E'}{\Gamma} \qquad c \mbox{ does not occur in $E'$ and $\Gamma$}} + {\WF{E;E'}{\Gamma}}} + +\paragraph{Second pruning property:} +\inference{\frac{\WF{E;c:=u:U;E'}{\Gamma} \qquad c \mbox{ does not occur in $E'$ and $\Gamma$}} + {\WF{E;E'}{\Gamma}}} + \section[Inductive Definitions]{Inductive Definitions\label{Cic-inductive-definitions}} A (possibly mutual) inductive definition is specified by giving the -- cgit v1.2.3 From 779c314c28abbff3d9fc1fca9a2c75dc7e103a1c Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Tue, 6 Oct 2015 11:45:02 +0200 Subject: RefMan, ch. 4: Reference Manual: more on the "in pattern" clause and "@qualid pattern". --- doc/refman/Cases.tex | 4 +++- doc/refman/RefMan-gal.tex | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/doc/refman/Cases.tex b/doc/refman/Cases.tex index 4238bf6a57..a95d8114ff 100644 --- a/doc/refman/Cases.tex +++ b/doc/refman/Cases.tex @@ -521,6 +521,8 @@ I have a copy of {\tt b} in type {\tt listn 0} resp {\tt listn (S n')}. % \end{coq_example} \paragraph{Patterns in {\tt in}} +\label{match-in-patterns} + If the type of the matched term is more precise than an inductive applied to variables, arguments of the inductive in the {\tt in} branch can be more complicated patterns than a variable. @@ -530,7 +532,7 @@ become impossible branches. In an impossible branch, you can answer anything but {\tt False\_rect unit} has the advantage to be subterm of anything. % ??? -To be concrete: the tail function can be written: +To be concrete: the {\tt tail} function can be written: \begin{coq_example} Definition tail n (v: listn (S n)) := match v in listn (S m) return listn m with diff --git a/doc/refman/RefMan-gal.tex b/doc/refman/RefMan-gal.tex index e49c82d8fd..f631c3717c 100644 --- a/doc/refman/RefMan-gal.tex +++ b/doc/refman/RefMan-gal.tex @@ -311,7 +311,7 @@ called \CIC). The formal presentation of {\CIC} is given in Chapter {\annotation} & ::= & {\tt \{ struct} {\ident} {\tt \}} \\ &&\\ {\caseitem} & ::= & {\term} \zeroone{{\tt as} \name} - \zeroone{{\tt in} \pattern} \\ + \zeroone{{\tt in} \qualid \sequence{\pattern}{}} \\ &&\\ {\ifitem} & ::= & \zeroone{{\tt as} {\name}} {\returntype} \\ &&\\ @@ -322,7 +322,7 @@ called \CIC). The formal presentation of {\CIC} is given in Chapter {\multpattern} & ::= & \nelist{\pattern}{\tt ,}\\ &&\\ {\pattern} & ::= & {\qualid} \nelist{\pattern}{} \\ - & $|$ & {\tt @} {\qualid} \sequence{\pattern}{} \\ + & $|$ & {\tt @} {\qualid} \nelist{\pattern}{} \\ & $|$ & {\pattern} {\tt as} {\ident} \\ & $|$ & {\pattern} {\tt \%} {\ident} \\ @@ -609,17 +609,20 @@ the type of each branch can depend on the type dependencies specific to the branch and the whole pattern-matching expression has a type determined by the specific dependencies in the type of the term being matched. This dependency of the return type in the annotations of the -inductive type is expressed using a {\tt -``in~I~\_~$\ldots$~\_~\ident$_1$~$\ldots$~\ident$_n$}'' clause, where +inductive type is expressed using a + ``in~I~\_~$\ldots$~\_~\pattern$_1$~$\ldots$~\pattern$_n$'' clause, where \begin{itemize} \item $I$ is the inductive type of the term being matched; -\item the names \ident$_i$'s correspond to the arguments of the -inductive type that carry the annotations: the return type is dependent -on them; - -\item the {\_}'s denote the family parameters of the inductive type: +\item the {\_}'s are matching the parameters of the inductive type: the return type is not dependent on them. + +\item the \pattern$_i$'s are matching the annotations of the inductive + type: the return type is dependent on them + +\item in the basic case which we describe below, each \pattern$_i$ is a + name \ident$_i$; see \ref{match-in-patterns} for the general case + \end{itemize} For instance, in the following example: -- cgit v1.2.3 From ba00ffda884142fdd1b4d8b0888d3c9a35457c99 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Tue, 6 Oct 2015 19:45:38 +0200 Subject: RefMan, ch. 4: a few clarifications, thanks to Matej. There is still something buggy in explaining the interpretation of "match" as "case": we need typing to reconstruct the types of the x and y1..yn from the "as x in I ... y1..yn" clause. --- doc/refman/RefMan-cic.tex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 52003dc34f..aa4483759e 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -497,7 +497,7 @@ The conversion rule is now exactly: \paragraph[Normal form.]{Normal form.\index{Normal form}\label{Normal-form}\label{Head-normal-form}\index{Head normal form}} A term which cannot be any more reduced is said to be in {\em normal form}. There are several ways (or strategies) to apply the reduction -rule. Among them, we have to mention the {\em head reduction} which +rules. Among them, we have to mention the {\em head reduction} which will play an important role (see Chapter~\ref{Tactics}). Any term can be written as $\lb x_1:T_1\mto \ldots \lb x_k:T_k \mto (t_0\ t_1\ldots t_n)$ where @@ -967,7 +967,7 @@ Inductive exType (P:Type->Prop) : Type From {\Coq} version 8.1, inductive families declared in {\Type} are polymorphic over their arguments in {\Type}. -If $A$ is an arity and $s$ a sort, we write $A_{/s}$ for the arity +If $A$ is an arity of some sort and $s$ is a sort, we write $A_{/s}$ for the arity obtained from $A$ by replacing its sort with $s$. Especially, if $A$ is well-typed in some global environment and local context, then $A_{/s}$ is typable by typability of all products in the Calculus of Inductive Constructions. @@ -1260,13 +1260,13 @@ compact notation: \paragraph[Allowed elimination sorts.]{Allowed elimination sorts.\index{Elimination sorts}} An important question for building the typing rule for \kw{match} is -what can be the type of $P$ with respect to the type of the inductive +what can be the type of $\lb a x \mto P$ with respect to the type of the inductive definitions. We define now a relation \compat{I:A}{B} between an inductive definition $I$ of type $A$ and an arity $B$. This relation states that an object in the inductive definition $I$ can be eliminated for -proving a property $P$ of type $B$. +proving a property $\lb a x \mto P$ of type $B$. The case of inductive definitions in sorts \Set\ or \Type{} is simple. There is no restriction on the sort of the predicate to be -- cgit v1.2.3 From 19a3cb9cf627e593026a675ff7201bb1dc8e3574 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Tue, 6 Oct 2015 19:49:57 +0200 Subject: RefMan, ch. 4: Avoiding using "inductive family" which is not defined. Using consistently "inductive types". --- doc/refman/RefMan-cic.tex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index aa4483759e..174f318fed 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -631,7 +631,7 @@ the value over the parameter. In the case of inductive definitions we have to handle the abstraction over several objects. One possible way to do that would be to define the type \List\ -inductively as being an inductive family of type $\Set\ra\Set$: +inductively as being an inductive type of type $\Set\ra\Set$: \[\NInd{}{\List:\Set\ra\Set}{\Nil:(\forall A:\Set,\List~A), \cons : (\forall A:\Set, A \ra \List~A \ra \List~A)}\] There are drawbacks to this point of view. The @@ -961,10 +961,10 @@ Inductive exType (P:Type->Prop) : Type %is recursive or not. We shall write the type $(x:_R T)C$ if it is %a recursive argument and $(x:_P T)C$ if the argument is not recursive. -\paragraph[Sort-polymorphism of inductive families.]{Sort-polymorphism of inductive families.\index{Sort-polymorphism of inductive families}} +\paragraph[Sort-polymorphism of inductive types.]{Sort-polymorphism of inductive types.\index{Sort-polymorphism of inductive types}} \label{Sort-polymorphism-inductive} -From {\Coq} version 8.1, inductive families declared in {\Type} are +From {\Coq} version 8.1, inductive types declared in {\Type} are polymorphic over their arguments in {\Type}. If $A$ is an arity of some sort and $s$ is a sort, we write $A_{/s}$ for the arity @@ -1057,7 +1057,7 @@ predicative {\Set}. More precisely, an empty or small singleton inductive definition (i.e. an inductive definition of which all inductive types are singleton -- see paragraph~\ref{singleton}) is set in -{\Prop}, a small non-singleton inductive family is set in {\Set} (even +{\Prop}, a small non-singleton inductive type is set in {\Set} (even in case {\Set} is impredicative -- see Section~\ref{impredicativity}), and otherwise in the {\Type} hierarchy. % TODO: clarify the case of a partial application ?? -- cgit v1.2.3 From 6beb39ff5e8e52692cc008e4b43ee28ecf792f8a Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 9 Oct 2015 14:45:23 +0200 Subject: RefMan, ch. 4: Moving section on discharge after inductive types. --- doc/refman/RefMan-cic.tex | 116 +++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 174f318fed..3b0a204e3b 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -375,7 +375,7 @@ be derived from the following rules. {\WTEG{\letin{x}{t:T}{u}}{\subst{U}{x}{t}}}} \end{description} -\Rem We may have $\kw{let}~x:=t~\kw{in}~u$ +\Rem We may have $\letin{x}{t:T}{u}$ well-typed without having $((\lb x:T\mto u)~t)$ well-typed (where $T$ is a type of $t$). This is because the value $t$ associated to $x$ may be used in a conversion rule (see Section~\ref{conv-rules}). @@ -520,63 +520,6 @@ $u_i$ can be reducible. Similar notions of head-normal forms involving $\delta$, $\iota$ and $\zeta$ reductions or any combination of those can also be defined. -\section{Derived rules for global environments} - -From the original rules of the type system, one can derive new rules -which change the local context of definition of objects in the global environment. -Because these rules correspond to elementary operations in the \Coq\ -engine used in the discharge mechanism at the end of a section, we -state them explicitly. - -% This is obsolete: Abstraction over defined constants actually uses a -% let-in since there are let-ins in Coq - -%% \paragraph{Mechanism of substitution.} - -%% One rule which can be proved valid, is to replace a term $c$ by its -%% value in the global environment. As we defined the substitution of a term for -%% a variable in a term, one can define the substitution of a term for a -%% constant. One easily extends this substitution to local contexts and global -%% environments. - -%% \paragraph{Substitution Property:} -%% \inference{\frac{\WF{E;c:=t:T; E'}{\Gamma}} -%% {\WF{E; \subst{E'}{c}{t}}{\subst{\Gamma}{c}{t}}}} - -\paragraph{Abstraction.} - -One can modify the definition of a constant $c$ by generalizing it -over a previously assumed constant $c'$. For doing that, we need -to modify the reference to $c$ in the subsequent global environment -and local context by explicitly applying this constant to the constant $c'$. - -\paragraph{First abstracting property:} - \inference{\frac{\WF{E;c':U;E';c:=t:T;E''}{\Gamma}} - {\WF{E;c':U;E';c:=\lb x:U\mto \subst{t}{c'}{x}:\forall~x:U,\subst{T}{c'}{x}; - \subst{E''}{c}{(c~c')}}{\subst{\Gamma}{c}{(c~c')}}}} - -One can similarly modify the definition of a constant $c$ by generalizing it -over a previously defined constant $c'$. - -\paragraph{Second abstracting property:} - \inference{\frac{\WF{E;c':=u:U;E';c:=t:T;E''}{\Gamma}} - {\WF{E;c':=u:U;E';c:=(\letin{x}{u:U}{\subst{t}{c'}{x}}):\subst{T}{c'}{u}; - E''}{\Gamma}}} - -\paragraph{Pruning the local context.} -If one abstracts or substitutes constants with the above rules then it -may happen that some declared or defined constant does not occur any -more in the subsequent global environment and in the local context. One can -consequently derive the following property. - -\paragraph{First pruning property:} -\inference{\frac{\WF{E;c:U;E'}{\Gamma} \qquad c \mbox{ does not occur in $E'$ and $\Gamma$}} - {\WF{E;E'}{\Gamma}}} - -\paragraph{Second pruning property:} -\inference{\frac{\WF{E;c:=u:U;E'}{\Gamma} \qquad c \mbox{ does not occur in $E'$ and $\Gamma$}} - {\WF{E;E'}{\Gamma}}} - \section[Inductive Definitions]{Inductive Definitions\label{Cic-inductive-definitions}} A (possibly mutual) inductive definition is specified by giving the @@ -1701,6 +1644,63 @@ Abort. The principles of mutual induction can be automatically generated using the {\tt Scheme} command described in Section~\ref{Scheme}. +\section{Derived rules for global environments} + +From the original rules of the type system, one can derive new rules +which change the local context of definition of objects in the global environment. +Because these rules correspond to elementary operations in the \Coq\ +engine used in the discharge mechanism at the end of a section, we +state them explicitly. + +% This is obsolete: Abstraction over defined constants actually uses a +% let-in since there are let-ins in Coq + +%% \paragraph{Mechanism of substitution.} + +%% One rule which can be proved valid, is to replace a term $c$ by its +%% value in the global environment. As we defined the substitution of a term for +%% a variable in a term, one can define the substitution of a term for a +%% constant. One easily extends this substitution to local contexts and global +%% environments. + +%% \paragraph{Substitution Property:} +%% \inference{\frac{\WF{E;c:=t:T; E'}{\Gamma}} +%% {\WF{E; \subst{E'}{c}{t}}{\subst{\Gamma}{c}{t}}}} + +\paragraph{Abstraction.} + +One can modify the definition of a constant $c$ by generalizing it +over a previously assumed constant $c'$. For doing that, we need +to modify the reference to $c$ in the subsequent global environment +and local context by explicitly applying this constant to the constant $c'$. + +\paragraph{First abstracting property:} + \inference{\frac{\WF{E;c':U;E';c:=t:T;E''}{\Gamma}} + {\WF{E;c':U;E';c:=\lb x:U\mto \subst{t}{c'}{x}:\forall~x:U,\subst{T}{c'}{x}; + \subst{E''}{c}{(c~c')}}{\subst{\Gamma}{c}{(c~c')}}}} + +One can similarly modify the definition of a constant $c$ by generalizing it +over a previously defined constant $c'$. + +\paragraph{Second abstracting property:} + \inference{\frac{\WF{E;c':=u:U;E';c:=t:T;E''}{\Gamma}} + {\WF{E;c':=u:U;E';c:=(\letin{x}{u:U}{\subst{t}{c'}{x}}):\subst{T}{c'}{u}; + E''}{\Gamma}}} + +\paragraph{Pruning the local context.} +If one abstracts or substitutes constants with the above rules then it +may happen that some declared or defined constant does not occur any +more in the subsequent global environment and in the local context. One can +consequently derive the following property. + +\paragraph{First pruning property:} +\inference{\frac{\WF{E;c:U;E'}{\Gamma} \qquad c \mbox{ does not occur in $E'$ and $\Gamma$}} + {\WF{E;E'}{\Gamma}}} + +\paragraph{Second pruning property:} +\inference{\frac{\WF{E;c:=u:U;E'}{\Gamma} \qquad c \mbox{ does not occur in $E'$ and $\Gamma$}} + {\WF{E;E'}{\Gamma}}} + \section{Co-inductive types} The implementation contains also co-inductive definitions, which are types inhabited by infinite objects. -- cgit v1.2.3 From 8654b03544f0efe4b418a0afdc871ff84784ff83 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 9 Oct 2015 15:57:52 +0200 Subject: RefMan, ch. 4: Adding discharging of inductive types. --- doc/common/macros.tex | 1 + doc/refman/RefMan-cic.tex | 60 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index f785a85bbc..88770affbc 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -363,6 +363,7 @@ \newcommand{\myifthenelse}[3]{\kw{if} ~ #1 ~\kw{then} ~ #2 ~ \kw{else} ~ #3} \newcommand{\fun}[2]{\item[]{\tt {#1}}. \quad\\ #2} \newcommand{\WF}[2]{\ensuremath{{\cal W\!F}(#1)[#2]}} +\newcommand{\WFTWOLINES}[2]{\ensuremath{{\cal W\!F}\begin{array}{l}(#1)\\\mbox{}[{#2}]\end{array}}} \newcommand{\WFE}[1]{\WF{E}{#1}} \newcommand{\WT}[4]{\ensuremath{#1[#2] \vdash #3 : #4}} \newcommand{\WTE}[3]{\WT{E}{#1}{#2}{#3}} diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 3b0a204e3b..6b75fa5216 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1644,13 +1644,12 @@ Abort. The principles of mutual induction can be automatically generated using the {\tt Scheme} command described in Section~\ref{Scheme}. -\section{Derived rules for global environments} +\section{Admissible rules for global environments} -From the original rules of the type system, one can derive new rules -which change the local context of definition of objects in the global environment. -Because these rules correspond to elementary operations in the \Coq\ -engine used in the discharge mechanism at the end of a section, we -state them explicitly. +From the original rules of the type system, one can show the +admissibility of rules which change the local context of definition of +objects in the global environment. We show here the admissible rules +that are used used in the discharge mechanism at the end of a section. % This is obsolete: Abstraction over defined constants actually uses a % let-in since there are let-ins in Coq @@ -1669,23 +1668,48 @@ state them explicitly. \paragraph{Abstraction.} -One can modify the definition of a constant $c$ by generalizing it -over a previously assumed constant $c'$. For doing that, we need -to modify the reference to $c$ in the subsequent global environment -and local context by explicitly applying this constant to the constant $c'$. +One can modify a global declaration by generalizing it over a +previously assumed constant $c$. For doing that, we need to modify the +reference to the global declaration in the subsequent global +environment and local context by explicitly applying this constant to +the constant $c'$. + +Below, if $\Gamma$ is a context of the form +$[y_1:A_1;\ldots;y_n:A_n]$, we write $\forall +x:U,\subst{\Gamma}{c}{x}$ to mean +$[y_1:\forall~x:U,\subst{A_1}{c}{x};\ldots;y_n:\forall~x:U,\subst{A_n}{c}{x}]$ +and +$\subst{E}{|\Gamma|}{|\Gamma|c}$. +to mean the parallel substitution +$\subst{\subst{E}{y_1}{(y_1~c)}\ldots}{y_n}{(y_n~c)}$. \paragraph{First abstracting property:} - \inference{\frac{\WF{E;c':U;E';c:=t:T;E''}{\Gamma}} - {\WF{E;c':U;E';c:=\lb x:U\mto \subst{t}{c'}{x}:\forall~x:U,\subst{T}{c'}{x}; - \subst{E''}{c}{(c~c')}}{\subst{\Gamma}{c}{(c~c')}}}} + \inference{\frac{\WF{E;c:U;E';c':=t:T;E''}{\Gamma}} + {\WF{E;c:U;E';c':=\lb x:U\mto \subst{t}{c}{x}:\forall~x:U,\subst{T}{c}{x}; + \subst{E''}{c'}{(c'~c)}}{\subst{\Gamma}{c}{(c~c')}}}} -One can similarly modify the definition of a constant $c$ by generalizing it -over a previously defined constant $c'$. + \inference{\frac{\WF{E;c:U;E';c':T;E''}{\Gamma}} + {\WF{E;c:U;E';c':\forall~x:U,\subst{T}{c}{x}; + \subst{E''}{c'}{(c'~c)}}{\subst{\Gamma}{c}{(c~c')}}}} + + \inference{\frac{\WF{E;c:U;E';\Ind{}{p}{\Gamma_I}{\Gamma_C};E''}{\Gamma}} + {\WFTWOLINES{E;c:U;E';\Ind{}{p+1}{\forall x:U,\subst{\Gamma_I}{c}{x}}{\forall x:U,\subst{\Gamma_C}{c}{x}};\subst{E''}{|\Gamma_I,\Gamma_C|}{|\Gamma_I,\Gamma_C|~c}}{\subst{\Gamma}{|\Gamma_I,\Gamma_C|}{|\Gamma_I,\Gamma_C|~c}}}} + +One can similarly modify a global declaration by generalizing it over +a previously defined constant~$c'$. Below, if $\Gamma$ is a context +of the form $[y_1:A_1;\ldots;y_n:A_n]$, we write $ +\subst{\Gamma}{c}{u}$ to mean +$[y_1:\subst{A_1}{c}{u};\ldots;y_n:\subst{A_n}{c}{u}]$. \paragraph{Second abstracting property:} - \inference{\frac{\WF{E;c':=u:U;E';c:=t:T;E''}{\Gamma}} - {\WF{E;c':=u:U;E';c:=(\letin{x}{u:U}{\subst{t}{c'}{x}}):\subst{T}{c'}{u}; - E''}{\Gamma}}} + \inference{\frac{\WF{E;c:=u:U;E';c':=t:T;E''}{\Gamma}} + {\WF{E;c:=u:U;E';c':=(\letin{x}{u:U}{\subst{t}{c}{x}}):\subst{T}{c}{u};E''}{\Gamma}}} + + \inference{\frac{\WF{E;c:=u:U;E';c':T;E''}{\Gamma}} + {\WF{E;c:=u:U;E';c':\subst{T}{c}{u};E''}{\Gamma}}} + + \inference{\frac{\WF{E;c:=u:U;E';\Ind{}{p}{\Gamma_I}{\Gamma_C};E''}{\Gamma}} + {\WF{E;c:=u:U;E';\Ind{}{p}{\subst{\Gamma_I}{c}{u}}{\subst{\Gamma_C}{c}{u}};E''}{\Gamma}}} \paragraph{Pruning the local context.} If one abstracts or substitutes constants with the above rules then it -- cgit v1.2.3 From b94bdd32024675b546642c710539f8d583df4e94 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 18 Oct 2015 21:07:27 +0200 Subject: RefMan, ch. 4: Removing the local context of inductive definitions. --- doc/common/macros.tex | 4 +- doc/refman/RefMan-cic.tex | 101 +++++++++++++++++++++++----------------------- 2 files changed, 52 insertions(+), 53 deletions(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index 88770affbc..ff13ec4557 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -393,9 +393,9 @@ \newcommand{\CIPI}[1]{\CIP{#1}{I}{P}} \newcommand{\CIF}[1]{\mbox{$\{#1\}_{f_1.. f_n}$}} %BEGIN LATEX -\newcommand{\NInd}[3]{\mbox{{\sf Ind}$(#1)(\begin{array}[t]{@{}l}#2:=#3 +\newcommand{\NInd}[3]{\mbox{{\sf Ind}$(\begin{array}[t]{@{}l}#2:=#3 \,)\end{array}$}} -\newcommand{\Ind}[4]{\mbox{{\sf Ind}$(#1)[#2](\begin{array}[t]{@{}l@{}}#3:=#4 +\newcommand{\Ind}[4]{\mbox{{\sf Ind}$[#2](\begin{array}[t]{@{}l@{}}#3:=#4 \,)\end{array}$}} %END LATEX %HEVEA \newcommand{\NInd}[3]{\mbox{{\sf Ind}$(#1)(#2:=#3\,)$}} diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 6b75fa5216..a41e1f398b 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -531,7 +531,7 @@ definitions, one for constructors). Stating the rules for inductive definitions in their general form needs quite tedious definitions. We shall try to give a concrete -understanding of the rules by precising them on running examples. We +understanding of the rules by illustrating them on running examples. We take as examples the type of natural numbers, the type of parameterized lists over a type $A$, the relation which states that a list has some given length and the mutual inductive definition of trees and @@ -539,36 +539,38 @@ forests. \subsection{Representing an inductive definition} \subsubsection{Inductive definitions without parameters} -As for constants, inductive definitions can be defined in a non-empty +As for constants, inductive definitions must be defined in a non-empty local context. \\ -We write \NInd{\Gamma}{\Gamma_I}{\Gamma_C} an inductive -definition valid in a local context $\Gamma$, a +We write \NInd{}{\Gamma_I}{\Gamma_C} for an inductive +definition with a context of type definitions $\Gamma_I$ and a context of constructors $\Gamma_C$. \paragraph{Examples.} The inductive declaration for the type of natural numbers will be: \[\NInd{}{\nat:\Set}{\nO:\nat,\nS:\nat\ra\nat}\] -In a local context with a variable $A:\Set$, the lists of elements in $A$ are +In a context with assumption $A:\Set$, the lists of elements in $A$ are represented by: -\[\NInd{A:\Set}{\List:\Set}{\Nil:\List,\cons : A \ra \List \ra +\[\NInd{}{\List:\Set}{\Nil:\List,\cons : A \ra \List \ra \List}\] - Assuming - $\Gamma_I$ is $[I_1:A_1;\ldots;I_k:A_k]$, and $\Gamma_C$ is - $[c_1:C_1;\ldots;c_n:C_n]$, the general typing rules are, - for $1\leq j\leq k$ and $1\leq i\leq n$: +%% Assuming +%% $\Gamma_I$ is $[I_1:A_1;\ldots;I_k:A_k]$, and $\Gamma_C$ is +%% $[c_1:C_1;\ldots;c_n:C_n]$, the general typing rules are, +%% for $1\leq j\leq k$ and $1\leq i\leq n$: -\bigskip -\inference{\frac{\NInd{\Gamma}{\Gamma_I}{\Gamma_C} \in E}{(I_j:A_j) \in E}} +%% \bigskip -\inference{\frac{\NInd{\Gamma}{\Gamma_I}{\Gamma_C} \in E}{(c_i:C_i) \in E}} +%% \item[Ind] \index{Typing rules!Ind} +%% \inference{\frac{\NInd{}{\Gamma_I}{\Gamma_C} \in E}{(I_j:A_j) \in E}} +%% \item[Constr] \index{Typing rules!Constr} + +%% \inference{\frac{\NInd{}{\Gamma_I}{\Gamma_C} \in E}{(c_i:C_i) \in E}} \subsubsection{Inductive definitions with parameters} -We have to slightly complicate the representation above in order to handle -the delicate problem of parameters. +We have refine the representation above in order to handle parameters. Let us explain that on the example of \List. With the above definition, the type \List\ can only be used in a global environment where we -have a variable $A:\Set$. Generally one want to consider lists of +have a variable $A:\Set$. Generally one wants to consider lists of elements in different types. For constants this is easily done by abstracting the value over the parameter. In the case of inductive definitions we have to handle the abstraction over several objects. @@ -648,22 +650,22 @@ parameters. Formally the representation of an inductive declaration will be -\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C} for an inductive -definition valid in a local context $\Gamma$ with $p$ parameters, a +\Ind{}{p}{\Gamma_I}{\Gamma_C} for an inductive +definition with $p$ parameters, a context of definitions $\Gamma_I$ and a context of constructors $\Gamma_C$. -The definition \Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C} will be -well-formed exactly when \NInd{\Gamma}{\Gamma_I}{\Gamma_C} is and +The definition \Ind{}{p}{\Gamma_I}{\Gamma_C} will be +well-formed exactly when \NInd{}{\Gamma_I}{\Gamma_C} is and when $p$ is (less or equal than) the number of parameters in -\NInd{\Gamma}{\Gamma_I}{\Gamma_C}. +\NInd{}{\Gamma_I}{\Gamma_C}. \paragraph{Examples} The declaration for parameterized lists is: \[\Ind{}{1}{\List:\Set\ra\Set}{\Nil:(\forall A:\Set,\List~A),\cons : (\forall A:\Set, A \ra \List~A \ra \List~A)}\] -The declaration for the length of lists is: +The declaration for an inductive type specifying the length of lists is: \[\Ind{}{1}{\Length:\forall A:\Set, (\List~A)\ra \nat\ra\Prop} {\LNil:\forall A:\Set, \Length~A~(\Nil~A)~\nO,\\ \LCons :\forall A:\Set,\forall a:A, \forall l:(\List~A),\forall n:\nat, (\Length~A~l~n)\ra (\Length~A~(\cons~A~a~l)~(\nS~n))}\] @@ -674,7 +676,7 @@ The declaration for a mutual inductive definition of forests and trees is: \emptyf:\forest,\consf:\tree \ra \forest \ra \forest\-}\] These representations are the ones obtained as the result of the \Coq\ -declaration: +declarations: \begin{coq_example*} Inductive nat : Set := | O : nat @@ -731,16 +733,13 @@ We have to give the type of constants in a global environment $E$ which contains an inductive declaration. \begin{description} -\item[Ind-Const] Assuming - $\Gamma_I$ is $[I_1:A_1;\ldots;I_k:A_k]$, and $\Gamma_C$ is - $[c_1:C_1;\ldots;c_n:C_n]$, - -\inference{\frac{\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C} \in E - ~~j=1\ldots k}{(I_j:A_j) \in E}} - -\inference{\frac{\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C} \in E - ~~~~i=1.. n} - {(c_i:C_i) \in E}} +\item[Ind] \index{Typing rules!Ind} +\inference{\frac{\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E}{(I_j:A_j) \in E}} +\inference{\frac{\WFE{\Gamma}~~~~\NInd{}{\Gamma_I}{\Gamma_C} \in E}{\WTEG{I_j}{A_j}}} +\item[Constr] \index{Typing rules!Constr} + +\inference{\frac{\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E}{(c_i:C_i) \in E}} +\inference{\frac{\WFE{\Gamma}~~~~\NInd{}{\Gamma_I}{\Gamma_C} \in E}{\WTEG{c_i}{C_i}}} \end{description} \paragraph{Example.} @@ -846,20 +845,20 @@ inductive definition. \begin{description} \item[W-Ind] Let $E$ be a global environment and - $\Gamma,\Gamma_P,\Gamma_I,\Gamma_C$ are contexts such that + $\Gamma_P,\Gamma_I,\Gamma_C$ are contexts such that $\Gamma_I$ is $[I_1:\forall \Gamma_P,A_1;\ldots;I_k:\forall \Gamma_P,A_k]$ and $\Gamma_C$ is $[c_1:\forall \Gamma_P,C_1;\ldots;c_n:\forall \Gamma_P,C_n]$. \inference{ \frac{ - (\WTE{\Gamma;\Gamma_P}{A_j}{s'_j})_{j=1\ldots k} - ~~ (\WTE{\Gamma;\Gamma_I;\Gamma_P}{C_i}{s_{q_i}})_{i=1\ldots n} + (\WTE{\Gamma_P}{A_j}{s'_j})_{j=1\ldots k} + ~~ (\WTE{\Gamma_I;\Gamma_P}{C_i}{s_{q_i}})_{i=1\ldots n} } - {\WF{E;\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C}}{\Gamma}}} + {\WF{E;\Ind{}{p}{\Gamma_I}{\Gamma_C}}{\Gamma}}} provided that the following side conditions hold: \begin{itemize} \item $k>0$ and all of $I_j$ and $c_i$ are distinct names for $j=1\ldots k$ and $i=1\ldots n$, -\item $p$ is the number of parameters of \NInd{\Gamma}{\Gamma_I}{\Gamma_C} +\item $p$ is the number of parameters of \NInd{}{\Gamma_I}{\Gamma_C} and $\Gamma_P$ is the context of parameters, \item for $j=1\ldots k$ we have that $A_j$ is an arity of sort $s_j$ and $I_j \notin \Gamma \cup E$, @@ -871,7 +870,7 @@ provided that the following side conditions hold: One can remark that there is a constraint between the sort of the arity of the inductive type and the sort of the type of its constructors which will always be satisfied for the impredicative sort -(\Prop) but may fail to define inductive definition +{\Prop} but may fail to define inductive definition on sort \Set{} and generate constraints between universes for inductive definitions in the {\Type} hierarchy. @@ -917,7 +916,7 @@ by typability of all products in the Calculus of Inductive Constructions. The following typing rule is added to the theory. \begin{description} -\item[Ind-Family] Let $\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C}$ be an +\item[Ind-Family] Let $\Ind{}{p}{\Gamma_I}{\Gamma_C}$ be an inductive definition. Let $\Gamma_P = [p_1:P_1;\ldots;p_{p}:P_{p}]$ be its local context of parameters, $\Gamma_I = [I_1:\forall \Gamma_P,A_1;\ldots;I_k:\forall \Gamma_P,A_k]$ its context of @@ -937,13 +936,13 @@ The following typing rule is added to the theory. \inference{\frac {\left\{\begin{array}{l} -\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C} \in E\\ -(E[\Gamma] \vdash q_l : P'_l)_{l=1\ldots r}\\ +\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E\\ +(E[] \vdash q_l : P'_l)_{l=1\ldots r}\\ (\WTEGLECONV{P'_l}{\subst{P_l}{p_u}{q_u}_{u=1\ldots l-1}})_{l=1\ldots r}\\ 1 \leq j \leq k \end{array} \right.} -{E[\Gamma] \vdash (I_j\,q_1\,\ldots\,q_r:\forall [p_{r+1}:P_{r+1};\ldots;p_{p}:P_{p}], (A_j)_{/s_j})} +{E[] \vdash (I_j\,q_1\,\ldots\,q_r:\forall [p_{r+1}:P_{r+1};\ldots;p_{p}:P_{p}], (A_j)_{/s_j})} } provided that the following side conditions hold: @@ -955,7 +954,7 @@ $P_l$ arity implies $P'_l$ arity since $\WTEGLECONV{P'_l}{ \subst{P_l}{p_u}{q_u} \item there are sorts $s_i$, for $1 \leq i \leq k$ such that, for $\Gamma_{I'} = [I_1:\forall \Gamma_{P'},(A_1)_{/s_1};\ldots;I_k:\forall \Gamma_{P'},(A_k)_{/s_k}]$ -we have $(\WTE{\Gamma;\Gamma_{I'};\Gamma_{P'}}{C_i}{s_{q_i}})_{i=1\ldots n}$; +we have $(\WTE{\Gamma_{I'};\Gamma_{P'}}{C_i}{s_{q_i}})_{i=1\ldots n}$; \item the sorts are such that all eliminations, to {\Prop}, {\Set} and $\Type(j)$, are allowed (see section~\ref{elimdep}). \end{itemize} @@ -965,12 +964,12 @@ Notice that if $I_j\,q_1\,\ldots\,q_r$ is typable using the rules {\bf Ind-Const} and {\bf App}, then it is typable using the rule {\bf Ind-Family}. Conversely, the extended theory is not stronger than the theory without {\bf Ind-Family}. We get an equiconsistency result by -mapping each $\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C}$ occurring into a +mapping each $\Ind{}{p}{\Gamma_I}{\Gamma_C}$ occurring into a given derivation into as many different inductive types and constructors as the number of different (partial) replacements of sorts, needed for this derivation, in the parameters that are arities (this is possible -because $\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C}$ well-formed implies -that $\Ind{\Gamma}{p}{\Gamma_{I'}}{\Gamma_{C'}}$ is well-formed and +because $\Ind{}{p}{\Gamma_I}{\Gamma_C}$ well-formed implies +that $\Ind{}{p}{\Gamma_{I'}}{\Gamma_{C'}}$ is well-formed and has the same allowed eliminations, where $\Gamma_{I'}$ is defined as above and $\Gamma_{C'} = [c_1:\forall \Gamma_{P'},C_1;\ldots;c_n:\forall \Gamma_{P'},C_n]$). That is, @@ -980,7 +979,7 @@ sorts among the types of parameters, and to each signature is associated a new inductive definition with fresh names. Conversion is preserved as any (partial) instance $I_j\,q_1\,\ldots\,q_r$ or $C_i\,q_1\,\ldots\,q_r$ is mapped to the names chosen in the specific -instance of $\Ind{\Gamma}{p}{\Gamma_I}{\Gamma_C}$. +instance of $\Ind{}{p}{\Gamma_I}{\Gamma_C}$. \newcommand{\Single}{\mbox{\textsf{Set}}} @@ -1396,7 +1395,7 @@ following typing rule {\WTEG{\Case{P}{c}{f_1|\ldots |f_l}}{(P\ t_1\ldots t_s\ c)}}}%\\[3mm] provided $I$ is an inductive type in a declaration -\Ind{\Delta}{r}{\Gamma_I}{\Gamma_C} with +\Ind{}{r}{\Gamma_I}{\Gamma_C} with $\Gamma_C = [c_1:C_1;\ldots;c_n:C_n]$ and $c_{p_1}\ldots c_{p_l}$ are the only constructors of $I$. \end{description} @@ -1511,7 +1510,7 @@ syntactically recognized as structurally smaller than $y_{k_i}$ The definition of being structurally smaller is a bit technical. One needs first to define the notion of {\em recursive arguments of a constructor}\index{Recursive arguments}. -For an inductive definition \Ind{\Gamma}{r}{\Gamma_I}{\Gamma_C}, +For an inductive definition \Ind{}{r}{\Gamma_I}{\Gamma_C}, the type of a constructor $c$ has the form $\forall p_1:P_1,\ldots \forall p_r:P_r, \forall x_1:T_1, \ldots \forall x_r:T_r, (I_j~p_1\ldots @@ -1522,7 +1521,7 @@ which one of the $I_l$ occurs. The main rules for being structurally smaller are the following:\\ Given a variable $y$ of type an inductive definition in a declaration -\Ind{\Gamma}{r}{\Gamma_I}{\Gamma_C} +\Ind{}{r}{\Gamma_I}{\Gamma_C} where $\Gamma_I$ is $[I_1:A_1;\ldots;I_k:A_k]$, and $\Gamma_C$ is $[c_1:C_1;\ldots;c_n:C_n]$. The terms structurally smaller than $y$ are: -- cgit v1.2.3 From a9fd632cfa7377aebdcb03ee015384d09ba6bd98 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Mon, 19 Oct 2015 16:27:53 +0200 Subject: RefMan, ch. 4: Misc. local improvements and typesetting. --- doc/refman/RefMan-cic.tex | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index a41e1f398b..baef635933 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -48,7 +48,7 @@ says {\em convertible}). Convertibility is presented in section The reader seeking a background on the Calculus of Inductive Constructions may read several papers. In addition to the references given above, Giménez and Castéran~\cite{GimCas05} provide -an introduction to inductive and co-inductive definitions in Coq. In +an introduction to inductive and co-inductive definitions in {\Coq}. In their book~\cite{CoqArt}, Bertot and Castéran give a description of the \CIC{} based on numerous practical examples. Barras~\cite{Bar99}, Werner~\cite{Wer94} and @@ -120,15 +120,15 @@ Formally, we call {\Sort} the set of sorts which is defined by: \index{Set@{\Set}} The sorts enjoy the following properties\footnote{In the Reference - Manual of versions of Coq prior to 8.4, the level of {\Type} typing - {\Prop} and {\Set} was numbered $0$. From Coq 8.4, it started to be + Manual of versions of {\Coq} prior to 8.4, the level of {\Type} typing + {\Prop} and {\Set} was numbered $0$. From {\Coq} 8.4, it started to be numbered $1$ so as to be able to leave room for re-interpreting {\Set} in the hierarchy as {\Type$(0)$}. This change also put the reference manual in accordance with the internal conventions adopted in the implementation.}: {\Prop:\Type$(1)$}, {\Set:\Type$(1)$} and {\Type$(i)$:\Type$(i+1)$}. -The user will never mention explicitly the index $i$ when referring to +The user does not have to mention explicitly the index $i$ when referring to the universe \Type$(i)$. One only writes \Type. The system itself generates for each instance of \Type\ a new index for the universe and checks that the constraints between these @@ -203,14 +203,14 @@ More precisely the language of the {\em Calculus of Inductive %\item constructors are terms. %\item inductive types are terms. \item if $x$ is a variable and $T$, $U$ are terms then $\forall~x:T,U$ - ($\kw{forall}~x:T,U$ in \Coq{} concrete syntax) is a term. If $x$ + ($\kw{forall}~x:T,~U$ in \Coq{} concrete syntax) is a term. If $x$ occurs in $U$, $\forall~x:T,U$ reads as {\it ``for all x of type T, U''}. As $U$ depends on $x$, one says that $\forall~x:T,U$ is a {\em dependent product}. If $x$ doesn't occurs in $U$ then $\forall~x:T,U$ reads as {\it ``if T then U''}. A non dependent product can be written: $T \rightarrow U$. \item if $x$ is a variable and $T$, $U$ are terms then $\lb x:T \mto U$ - ($\kw{fun}~x:T\Ra U$ in \Coq{} concrete syntax) is a term. This is a + ($\kw{fun}~x:T~ {\tt =>}~ U$ in \Coq{} concrete syntax) is a term. This is a notation for the $\lambda$-abstraction of $\lambda$-calculus\index{lambda-calculus@$\lambda$-calculus} \cite{Bar81}. The term $\lb x:T \mto U$ is a function which maps @@ -249,11 +249,11 @@ variable $x$ in a term $u$ is defined as usual. The resulting term is written $\subst{u}{x}{t}$. -\section[Typed terms]{Typed terms\label{Typed-terms}} +\section[Typing rules]{Typing rules\label{Typed-terms}} As objects of type theory, terms are subjected to {\em type discipline}. The well typing of a term depends on -a global environment (see below) and a local context. +a global environment and a local context. \paragraph{Local context.} A {\em local context} is an ordered list of @@ -375,7 +375,7 @@ be derived from the following rules. {\WTEG{\letin{x}{t:T}{u}}{\subst{U}{x}{t}}}} \end{description} -\Rem We may have $\letin{x}{t:T}{u}$ +\Rem We may have $\kw{let}~x:=t~\kw{in}~u$ well-typed without having $((\lb x:T\mto u)~t)$ well-typed (where $T$ is a type of $t$). This is because the value $t$ associated to $x$ may be used in a conversion rule (see Section~\ref{conv-rules}). @@ -628,7 +628,7 @@ But the following definition has $0$ parameters: %$\NInd{}{\List:\Set\ra\Set}{\Nil:(A:\Set)(\List~A),\cons : (A:\Set)A % \ra (\List~A\ra A) \ra (\List~A)}$.} \paragraph{Concrete syntax.} -In the Coq system, the local context of parameters is given explicitly +In the {\Coq} system, the local context of parameters is given explicitly after the name of the inductive definitions and is shared between the arities and the type of constructors. % The vernacular declaration of polymorphic trees and forests will be:\\ @@ -906,7 +906,7 @@ Inductive exType (P:Type->Prop) : Type \paragraph[Sort-polymorphism of inductive types.]{Sort-polymorphism of inductive types.\index{Sort-polymorphism of inductive types}} \label{Sort-polymorphism-inductive} -From {\Coq} version 8.1, inductive types declared in {\Type} are +Inductive types declared in {\Type} are polymorphic over their arguments in {\Type}. If $A$ is an arity of some sort and $s$ is a sort, we write $A_{/s}$ for the arity @@ -1113,7 +1113,7 @@ at the computational level it implements a generic operator for doing primitive recursion over the structure. But this operator is rather tedious to implement and use. We choose in -this version of Coq to factorize the operator for primitive recursion +this version of {\Coq} to factorize the operator for primitive recursion into two more primitive operations as was first suggested by Th. Coquand in~\cite{Coq92}. One is the definition by pattern-matching. The second one is a definition by guarded fixpoints. -- cgit v1.2.3 From c033eb2624b5b25ddf4c2c35d700c46eba86e27d Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 18 Oct 2015 22:09:07 +0200 Subject: RefMan, ch. 4: Rephrasing and moving paragraph on the double reading proof/program of the syntax. --- doc/refman/RefMan-cic.tex | 46 +++++++++++++++++++++++++++++++--------------- doc/refman/biblio.bib | 9 +++++++++ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index baef635933..b09367a2a9 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -68,21 +68,6 @@ a mutual recursive way and also because similar constructions can be applied to both terms and types and consequently can share the same syntactic structure. -Consider for instance the $\ra$ constructor and assume \nat\ is the -type of natural numbers. Then $\ra$ is used both to denote -$\nat\ra\nat$ which is the type of functions from \nat\ to \nat, and -to denote $\nat \ra \Prop$ which is the type of unary predicates over -the natural numbers. Consider abstraction which builds functions. It -serves to build ``ordinary'' functions as $\kw{fun}~x:\nat \Ra ({\tt mult} ~x~x)$ (assuming {\tt mult} is already defined) but may build also -predicates over the natural numbers. For instance $\kw{fun}~x:\nat \Ra -(x=x)$ will -represent a predicate $P$, informally written in mathematics -$P(x)\equiv x=x$. If $P$ has type $\nat \ra \Prop$, $(P~x)$ is a -proposition, furthermore $\kw{forall}~x:\nat,(P~x)$ will represent the type of -functions which associate to each natural number $n$ an object of -type $(P~n)$ and consequently represent proofs of the formula -``$\forall x.P(x)$''. - \subsection[Sorts]{Sorts\label{Sorts} \index{Sorts}} When manipulated as terms, types have themselves a type which is called a sort. @@ -248,6 +233,37 @@ The notion of substituting a term $t$ to free occurrences of a variable $x$ in a term $u$ is defined as usual. The resulting term is written $\subst{u}{x}{t}$. +\paragraph[The logical vs programming readings.]{The logical vs programming readings.} + +The constructions of the {\CIC} can be used to express both logical +and programming notions, accordingly to the Curry-Howard +correspondence between proofs and programs, and between propositions +and types~\cite{Cur58,How80,Bru72}. + +For instance, let us assume that \nat\ is the type of natural numbers +with zero element written $0$ and that ${\tt True}$ is the always true +proposition. Then $\ra$ is used both to denote $\nat\ra\nat$ which is +the type of functions from \nat\ to \nat, to denote ${\tt True}\ra{\tt + True}$ which is an implicative proposition, to denote $\nat \ra +\Prop$ which is the type of unary predicates over the natural numbers, +etc. + +Let us assume that ${\tt mult}$ is a function of type $\nat\ra\nat\ra +\nat$ and ${\tt eqnat}$ a predicate of type $\nat\ra\nat\ra \Prop$. +The $\lambda$-abstraction can serve to build ``ordinary'' functions as +in $\lambda x:\nat.({\tt mult}~x~x)$ (i.e. $\kw{fun}~x:\nat ~{\tt =>}~ +{\tt mult} ~x~x$ in {\Coq} notation) but may build also predicates +over the natural numbers. For instance $\lambda x:\nat.({\tt eqnat}~ +x~0)$ (i.e. $\kw{fun}~x:\nat ~{\tt =>}~ {\tt eqnat}~ x~0$ in {\Coq} +notation) will represent the predicate of one variable $x$ which +asserts the equality of $x$ with $0$. This predicate has type $\nat +\ra \Prop$ and it can be applied to any expression of type ${\nat}$, +say $t$, to give an object $P~t$ of type \Prop, namely a proposition. + +Furthermore $\kw{forall}~x:\nat,\,P\;x$ will represent the type of +functions which associate to each natural number $n$ an object of type +$(P~n)$ and consequently represent the type of proofs of the formula +``$\forall x.\,P(x)$''. \section[Typing rules]{Typing rules\label{Typed-terms}} diff --git a/doc/refman/biblio.bib b/doc/refman/biblio.bib index 6f789b081c..70ee1f41f0 100644 --- a/doc/refman/biblio.bib +++ b/doc/refman/biblio.bib @@ -328,6 +328,15 @@ s}, year = {1994} } +@book{Cur58, + author = {Haskell B. Curry and Robert Feys and William Craig}, + title = {Combinatory Logic}, + volume = 1, + publisher = "North-Holland", + year = 1958, + note = {{\S{9E}}}, +} + @InProceedings{Del99, author = {Delahaye, D.}, title = {Information Retrieval in a Coq Proof Library using -- cgit v1.2.3 From 08857b1f4455e942aeba456affdb0f61eaa4266a Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Thu, 22 Oct 2015 16:22:34 +0200 Subject: Smoothing the introduction and section Terms. --- doc/refman/RefMan-cic.tex | 66 +++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index b09367a2a9..a97fce8700 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -29,22 +29,6 @@ had an impredicative sort {\Set}. Since {\Coq} version 8.0, the sort {\Set} is predicative by default, with an option to make it impredicative (see Section~\ref{impredicativity}). -In \CIC\, all objects have a {\em type}. There are types for functions (or -programs), there are atomic types (especially datatypes)... but also -types for proofs and types for the types themselves. -Especially, any object handled in the formalism must belong to a -type. For instance, the statement {\it ``for all x, P''} is not -allowed in type theory; you must say instead: {\it ``for all x -of type T, P''}. The expression {\it ``x of type T''} is -written {\it ``x:T''}. Informally, {\it ``x:T''} can be thought as -{\it ``x belongs to T''}. -The terms of {\CIC} are detailed in Section~\ref{Terms}. - -In \CIC, there is an internal reduction mechanism. In particular, it -can decide if two programs are {\em intentionally} equal (one -says {\em convertible}). Convertibility is presented in section -\ref{convertibility}. - The reader seeking a background on the Calculus of Inductive Constructions may read several papers. In addition to the references given above, Giménez and Castéran~\cite{GimCas05} provide @@ -60,20 +44,26 @@ theory. \section[The terms]{The terms\label{Terms}} -In most type theories, one usually makes a syntactic distinction -between types and terms. This is not the case for \CIC\ which defines -both types and terms in the same syntactical structure. This is -because the type-theory itself forces terms and types to be defined in -a mutual recursive way and also because similar constructions can be -applied to both terms and types and consequently can share the same -syntactic structure. +The expressions of the {\CIC} are {\em terms} and all terms have a {\em type}. +There are types for functions (or +programs), there are atomic types (especially datatypes)... but also +types for proofs and types for the types themselves. +Especially, any object handled in the formalism must belong to a +type. For instance, universal quantification is relative to a type and +takes the form {\it ``for all x +of type T, P''}. The expression {\it ``x of type T''} is +written {\it ``x:T''}. Informally, {\it ``x:T''} can be thought as +{\it ``x belongs to T''}. + +The types of types are {\em sorts}. Types and sorts are themselves +terms so that terms, types and sorts are all components of a common +syntactic language of terms which is described in +Section~\label{cic:terms} but, first, we describe sorts. \subsection[Sorts]{Sorts\label{Sorts} \index{Sorts}} -When manipulated as terms, types have themselves a type which is called a sort. - -There is an infinite well-founded typing hierarchy of sorts whose base -sorts are {\Prop} and {\Set}. +All sorts have a type and there is an infinite well-founded +typing hierarchy of sorts whose base sorts are {\Prop} and {\Set}. The sort {\Prop} intends to be the type of logical propositions. If $M$ is a logical proposition then it denotes the class of terms @@ -167,6 +157,7 @@ inconsistency} error (see also Section~\ref{PrintingUniverses}). %% in a theory where inductive objects are represented by terms. \subsection{Terms} +\label{cic:terms} Terms are built from sorts, variables, constant, %constructors, inductive types, @@ -175,23 +166,22 @@ abstraction, application, local definitions, and products. From a syntactic point of view, types cannot be distinguished from terms, -except that they cannot start by an abstraction, and that if a term is -a sort or a product, it should be a type. +except that they cannot start by an abstraction or a constructor. More precisely the language of the {\em Calculus of Inductive - Constructions} is built from the following rules: + Constructions} is built from the following rules. \begin{enumerate} \item the sorts {\Set}, {\Prop}, ${\Type(i)}$ are terms. -\item variables are terms -\item constants are terms. -%\item constructors are terms. -%\item inductive types are terms. +\item variables, hereafter ranged over by letters $x$, $y$, etc., are terms +\item constants, hereafter ranged over by letters $c$, $d$, etc., are terms. +%\item constructors, hereafter ranged over by letter $C$, are terms. +%\item inductive types, hereafter ranged over by letter $I$, are terms. \item if $x$ is a variable and $T$, $U$ are terms then $\forall~x:T,U$ ($\kw{forall}~x:T,~U$ in \Coq{} concrete syntax) is a term. If $x$ occurs in $U$, $\forall~x:T,U$ reads as {\it ``for all x of type T, U''}. As $U$ depends on $x$, one says that $\forall~x:T,U$ is a - {\em dependent product}. If $x$ doesn't occurs in $U$ then + {\em dependent product}. If $x$ does not occur in $U$ then $\forall~x:T,U$ reads as {\it ``if T then U''}. A non dependent product can be written: $T \rightarrow U$. \item if $x$ is a variable and $T$, $U$ are terms then $\lb x:T \mto U$ @@ -199,7 +189,7 @@ More precisely the language of the {\em Calculus of Inductive notation for the $\lambda$-abstraction of $\lambda$-calculus\index{lambda-calculus@$\lambda$-calculus} \cite{Bar81}. The term $\lb x:T \mto U$ is a function which maps - elements of $T$ to $U$. + elements of $T$ to the expression $U$. \item if $T$ and $U$ are terms then $(T\ U)$ is a term ($T~U$ in \Coq{} concrete syntax). The term $(T\ U)$ reads as {\it ``T applied to U''}. @@ -400,6 +390,10 @@ may be used in a conversion rule (see Section~\ref{conv-rules}). \label{conv-rules}} \paragraph[$\beta$-reduction.]{$\beta$-reduction.\label{beta}\index{beta-reduction@$\beta$-reduction}} +In \CIC, there is an internal reduction mechanism. In particular, it +can decide if two programs are {\em intentionally} equal (one +says {\em convertible}). Convertibility is described in this section. + We want to be able to identify some terms as we can identify the application of a function to a given argument with its result. For instance the identity function over a given type $T$ can be written -- cgit v1.2.3 From f1f19693f16a914b167ebcb18e96aac25a582920 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 23 Oct 2015 17:56:15 +0200 Subject: fix --- doc/refman/RefMan-cic.tex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index a97fce8700..f0046ffe6a 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -388,12 +388,13 @@ may be used in a conversion rule (see Section~\ref{conv-rules}). \section[Conversion rules]{Conversion rules\index{Conversion rules} \label{conv-rules}} -\paragraph[$\beta$-reduction.]{$\beta$-reduction.\label{beta}\index{beta-reduction@$\beta$-reduction}} In \CIC, there is an internal reduction mechanism. In particular, it can decide if two programs are {\em intentionally} equal (one says {\em convertible}). Convertibility is described in this section. +\paragraph[$\beta$-reduction.]{$\beta$-reduction.\label{beta}\index{beta-reduction@$\beta$-reduction}} + We want to be able to identify some terms as we can identify the application of a function to a given argument with its result. For instance the identity function over a given type $T$ can be written -- cgit v1.2.3 From da46d24c2645add913e187ebfc76590140ecd6ff Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Thu, 22 Oct 2015 16:43:33 +0200 Subject: Reformulating subtyping in a way closer to implementation. --- doc/refman/RefMan-cic.tex | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index f0046ffe6a..ac62abbe55 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -353,9 +353,9 @@ be derived from the following rules. \item[Assum] \inference{\frac{\WTE{}{T}{s}~~~~s \in \Sort~~~~c \notin E} {\WF{E;c:T}{}}} \item[Ax] \index{Typing rules!Ax} -\inference{\frac{\WFE{\Gamma}}{\WTEG{\Prop}{\Type(p)}}~~~~~ -\frac{\WFE{\Gamma}}{\WTEG{\Set}{\Type(q)}}} -\inference{\frac{\WFE{\Gamma}~~~~i}~ U$ in \Coq{} concrete syntax) is a term. This is a +\item if $x$ is a variable and $T$, $u$ are terms then $\lb x:T \mto u$ + ($\kw{fun}~x:T~ {\tt =>}~ u$ in \Coq{} concrete syntax) is a term. This is a notation for the $\lambda$-abstraction of $\lambda$-calculus\index{lambda-calculus@$\lambda$-calculus} - \cite{Bar81}. The term $\lb x:T \mto U$ is a function which maps - elements of $T$ to the expression $U$. -\item if $T$ and $U$ are terms then $(T\ U)$ is a term - ($T~U$ in \Coq{} concrete syntax). The term $(T\ - U)$ reads as {\it ``T applied to U''}. -\item if $x$ is a variable, and $T$, $U$ are terms then - $\kw{let}~x:=T~\kw{in}~U$ is a - term which denotes the term $U$ where the variable $x$ is locally - bound to $T$. This stands for the common ``let-in'' construction of - functional programs such as ML or Scheme. + \cite{Bar81}. The term $\lb x:T \mto u$ is a function which maps + elements of $T$ to the expression $u$. +\item if $t$ and $u$ are terms then $(t\ u)$ is a term + ($t~u$ in \Coq{} concrete syntax). The term $(t\ + u)$ reads as {\it ``t applied to u''}. +\item if $x$ is a variable, and $t$, $T$ and $u$ are terms then + $\kw{let}~x:=t:T~\kw{in}~u$ is a + term which denotes the term $u$ where the variable $x$ is locally + bound to $t$ of type $T$. This stands for the common ``let-in'' + construction of functional programs such as ML or Scheme. %\item case ... %\item fixpoint ... %\item cofixpoint ... @@ -208,9 +208,9 @@ $(t\;t_1\;t_2\ldots t_n)$ represents $(\ldots ((t\;t_1)\;t_2)\ldots t_n)$. The products and arrows associate to the right such that $\forall~x:A,B\ra C\ra D$ represents $\forall~x:A,(B\ra (C\ra D))$. One uses sometimes $\forall~x~y:A,B$ or -$\lb x~y:A\mto B$ to denote the abstraction or product of several variables +$\lb x~y:A\mto t$ to denote the abstraction or product of several variables of the same type. The equivalent formulation is $\forall~x:A, \forall y:A,B$ or -$\lb x:A \mto \lb y:A \mto B$ +$\lb x:A \mto \lb y:A \mto t$ \paragraph{Free variables.} The notion of free variables is defined as usual. In the expressions @@ -379,7 +379,7 @@ be derived from the following rules. {\WTEG{\letin{x}{t:T}{u}}{\subst{U}{x}{t}}}} \end{description} -\Rem We may have $\kw{let}~x:=t~\kw{in}~u$ +\Rem We may have $\kw{let}~x:=t:T~\kw{in}~u$ well-typed without having $((\lb x:T\mto u)~t)$ well-typed (where $T$ is a type of $t$). This is because the value $t$ associated to $x$ may be used in a conversion rule (see Section~\ref{conv-rules}). -- cgit v1.2.3 From 899b701462fa056a22f997ae22c5ef7c1d247673 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Thu, 22 Oct 2015 21:01:29 +0200 Subject: Starting revising inductive types session --- doc/refman/RefMan-cic.tex | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 8e1a1766e5..5002b905c7 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -534,11 +534,11 @@ reductions or any combination of those can also be defined. \section[Inductive Definitions]{Inductive Definitions\label{Cic-inductive-definitions}} A (possibly mutual) inductive definition is specified by giving the -names and the type of the inductive sets or families to be -defined and the names and types of the constructors of the inductive -predicates. An inductive declaration in the global environment can -consequently be represented with two local contexts (one for inductive -definitions, one for constructors). +names and types of the inductive types to be +defined and the names and types of the constructors of the inductive types. +An inductive declaration in the global environment can +consequently be represented with two local contexts, one for the types +one for the constructors. Stating the rules for inductive definitions in their general form needs quite tedious definitions. We shall try to give a concrete -- cgit v1.2.3 From 5330263aaccb3ba9e7fcb8fada0737491fd99645 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 23 Oct 2015 17:51:06 +0200 Subject: Removing note on shifting the hierarchy by 1 in 8.4, which makes things more complicated than needed. --- doc/refman/RefMan-cic.tex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 5002b905c7..08e962ebe2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -94,13 +94,14 @@ Formally, we call {\Sort} the set of sorts which is defined by: \index{Prop@{\Prop}} \index{Set@{\Set}} -The sorts enjoy the following properties\footnote{In the Reference +The sorts enjoy the following properties%\footnote{In the Reference Manual of versions of {\Coq} prior to 8.4, the level of {\Type} typing {\Prop} and {\Set} was numbered $0$. From {\Coq} 8.4, it started to be numbered $1$ so as to be able to leave room for re-interpreting {\Set} in the hierarchy as {\Type$(0)$}. This change also put the reference manual in accordance with the internal conventions adopted - in the implementation.}: {\Prop:\Type$(1)$}, {\Set:\Type$(1)$} and + in the implementation.}% +: {\Prop:\Type$(1)$}, {\Set:\Type$(1)$} and {\Type$(i)$:\Type$(i+1)$}. The user does not have to mention explicitly the index $i$ when referring to -- cgit v1.2.3 From 17ca1e516bee3148ea7e3f272a443836c4949fc5 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 23 Oct 2015 17:54:48 +0200 Subject: Changing representation of prod over two Type: since the rule needs subtyping anyway to manage the Set and Prop cases, why not to simplify it by using subtyping also for managing Type. --- doc/refman/RefMan-cic.tex | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 08e962ebe2..7986648fb9 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -95,12 +95,12 @@ Formally, we call {\Sort} the set of sorts which is defined by: \index{Set@{\Set}} The sorts enjoy the following properties%\footnote{In the Reference - Manual of versions of {\Coq} prior to 8.4, the level of {\Type} typing - {\Prop} and {\Set} was numbered $0$. From {\Coq} 8.4, it started to be - numbered $1$ so as to be able to leave room for re-interpreting - {\Set} in the hierarchy as {\Type$(0)$}. This change also put the - reference manual in accordance with the internal conventions adopted - in the implementation.}% + %% Manual of versions of {\Coq} prior to 8.4, the level of {\Type} typing + %% {\Prop} and {\Set} was numbered $0$. From {\Coq} 8.4, it started to be + %% numbered $1$ so as to be able to leave room for re-interpreting + %% {\Set} in the hierarchy as {\Type$(0)$}. This change also put the + %% reference manual in accordance with the internal conventions adopted + %% in the implementation.} : {\Prop:\Type$(1)$}, {\Set:\Type$(1)$} and {\Type$(i)$:\Type$(i+1)$}. @@ -366,9 +366,9 @@ be derived from the following rules. \inference{\frac{\WTEG{T}{s}~~~~s \in\{\Prop, \Set\}~~~~~~ \WTE{\Gamma::(x:T)}{U}{\Set}} { \WTEG{\forall~x:T,U}{\Set}}} -\inference{\frac{\WTEG{T}{\Type(i)}~~~~i\leq k~~~ - \WTE{\Gamma::(x:T)}{U}{\Type(j)}~~~j \leq k} - {\WTEG{\forall~x:T,U}{\Type(k)}}} +\inference{\frac{\WTEG{T}{\Type(i)}~~~~ + \WTE{\Gamma::(x:T)}{U}{\Type(i)}} + {\WTEG{\forall~x:T,U}{\Type(i)}}} \item[Lam]\index{Typing rules!Lam} \inference{\frac{\WTEG{\forall~x:T,U}{s}~~~~ \WTE{\Gamma::(x:T)}{t}{U}} {\WTEG{\lb x:T\mto t}{\forall x:T, U}}} -- cgit v1.2.3 From 41061d0dc42afe19b520059f36a98d4ec870825f Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 09:05:48 +0100 Subject: CLEANUP PROPOSITION: Duplicate information was removed and replaced with a reference to the corresponding chapter. --- doc/refman/RefMan-cic.tex | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 7986648fb9..c481b3adba 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -5,42 +5,9 @@ \index{Calculus of Inductive Constructions}} The underlying formal language of {\Coq} is a {\em Calculus of - Inductive Constructions} (\CIC) whose inference rules are presented in -this chapter. - -The {\CIC} implemented in {\Coq} -takes its name from Coquand and Paulin's {\em Calculus of - Inductive Constructions}~\cite{CoPa89} which itself extends -Coquand-Huet's {\em Calculus of - Constructions}~\cite{CoHu85a,CoHu85b,CoHu86,Coq85} with a universe -hierarchy~\cite{Coq86,Luo90,Hue88b} and a generic presentation of -inductive types à la Martin-L\"of~\cite{MaL84,Dyb91}. First implemented in -{\Coq} version 5.0, it incorporated coinductive -types~\cite{Coquand93,Gim96} from {\Coq} version 5.10. It -progressively extended with various new features such as local -definitions (since {\Coq} version 7.0), universe polymorphism (since -{\Coq} version 8.1 for inductive types and version 8.5 for full -polymorphism), recursively non-uniform parameters (since {\Coq} version 8.1), -some $\eta$-rules (for dependent product in {\Coq} -version 8.4, for record types in {\Coq} version 8.5), and other -refinements in the expressiveness of fixpoints and inductive types. -Up to version 7.4, the {\CIC} implemented in {\Coq} -had an impredicative sort {\Set}. Since {\Coq} version 8.0, the sort -{\Set} is predicative by default, with an option to make it -impredicative (see Section~\ref{impredicativity}). - -The reader seeking a background on the Calculus of Inductive -Constructions may read several papers. In addition to the references given above, Giménez and Castéran~\cite{GimCas05} -provide -an introduction to inductive and co-inductive definitions in {\Coq}. In -their book~\cite{CoqArt}, Bertot and Castéran give a -description of the \CIC{} based on numerous practical examples. -Barras~\cite{Bar99}, Werner~\cite{Wer94} and -Paulin-Mohring~\cite{Moh97} are dealing with -Inductive Definitions. The {\CIC} is a -formulation of type theory including the possibility of inductive -constructions, Barendregt~\cite{Bar91} studies the modern form of type -theory. +Inductive Constructions} (\CIC) whose inference rules are presented in +this chapter. The history of this formalism as well as pointers to related work +are provided in a separate chapter; see {\em Credits}. \section[The terms]{The terms\label{Terms}} -- cgit v1.2.3 From b23331eb03f2640e85bd65277c15a4bcc692b90c Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 09:50:11 +0100 Subject: ENH: citation --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index c481b3adba..2c0f155388 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -44,7 +44,7 @@ function types over these data types. {\Prop} and {\Set} themselves can be manipulated as ordinary terms. Consequently they also have a type. Because assuming simply -that {\Set} has type {\Set} leads to an inconsistent theory, the +that {\Set} has type {\Set} leads to an inconsistent theory~\cite{Coq86}, the language of {\CIC} has infinitely many sorts. There are, in addition to {\Set} and {\Prop} a hierarchy of universes {\Type$(i)$} for any integer $i$. -- cgit v1.2.3 From e9db7237481e529f796d603f98965ca01e439386 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 09:52:53 +0100 Subject: CLEANUP PROPOSITION: Duplicate information was removed and replaced with a reference to the corresponding section. --- doc/refman/RefMan-cic.tex | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 2c0f155388..834c8273a5 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -60,16 +60,7 @@ Formally, we call {\Sort} the set of sorts which is defined by: \index{Type@{\Type}} \index{Prop@{\Prop}} \index{Set@{\Set}} - -The sorts enjoy the following properties%\footnote{In the Reference - %% Manual of versions of {\Coq} prior to 8.4, the level of {\Type} typing - %% {\Prop} and {\Set} was numbered $0$. From {\Coq} 8.4, it started to be - %% numbered $1$ so as to be able to leave room for re-interpreting - %% {\Set} in the hierarchy as {\Type$(0)$}. This change also put the - %% reference manual in accordance with the internal conventions adopted - %% in the implementation.} -: {\Prop:\Type$(1)$}, {\Set:\Type$(1)$} and -{\Type$(i)$:\Type$(i+1)$}. +Their properties are defined in Section~\ref{subtyping-rules}. The user does not have to mention explicitly the index $i$ when referring to the universe \Type$(i)$. One only writes \Type. The -- cgit v1.2.3 From 0117f54f3e3678f348f8ed84c8444dc614ce8298 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 10:03:30 +0100 Subject: COMMENT: to do --- doc/refman/RefMan-cic.tex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 834c8273a5..505587988c 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -62,6 +62,11 @@ Formally, we call {\Sort} the set of sorts which is defined by: \index{Set@{\Set}} Their properties are defined in Section~\ref{subtyping-rules}. +% TODO: Somewhere in the document we should explain: +% - what concrete actions (in *.v files) cause creation of new universes +% - different kinds of relationships between universes (i.e. "max" and "succ") +% - what are all the actions (in *.v files) from which those relationships arise + The user does not have to mention explicitly the index $i$ when referring to the universe \Type$(i)$. One only writes \Type. The system itself generates for each instance of \Type\ a new -- cgit v1.2.3 From 950dace27c3233f740b2031c9d99cb3f155aefbf Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 10:22:37 +0100 Subject: ENH: Index anchor repositioning. Originally, when user clicked in index on "Type", he landed on an incorrect page (immediatelly following the page which actually contains the definition of "Type"). --- doc/refman/RefMan-cic.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 505587988c..702adc2326 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -56,10 +56,10 @@ sets, namely the sorts {\Set} and {\Type$(j)$} for $j}~ u$ in \Coq{} concrete syntax) is a term. This is a notation for the $\lambda$-abstraction of diff --git a/doc/refman/RefMan-gal.tex b/doc/refman/RefMan-gal.tex index f631c3717c..0e758bcab6 100644 --- a/doc/refman/RefMan-gal.tex +++ b/doc/refman/RefMan-gal.tex @@ -468,8 +468,8 @@ proposition $B$ or the functional dependent product from $A$ to $B$ (a construction usually written $\Pi_{x:A}.B$ in set theory). Non dependent product types have a special notation: ``$A$ {\tt ->} -$B$'' stands for ``{\tt forall \_:}$A${\tt ,}~$B$''. The non dependent -product is used both to denote the propositional implication and +$B$'' stands for ``{\tt forall \_:}$A${\tt ,}~$B$''. The {\em non dependent +product} is used both to denote the propositional implication and function types. \subsection{Applications -- cgit v1.2.3 From 8f96f8194608c99ad8efa201c24b527dbc530537 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 12:08:49 +0100 Subject: CLEANUP PROPOSITION: The removed paragraph is not essential for this chapter. That kind of information is more appropriate for Section 1.2. --- doc/refman/RefMan-cic.tex | 9 --------- 1 file changed, 9 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index b1becba3f5..ed7889e480 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -178,15 +178,6 @@ More precisely the language of the {\em Calculus of Inductive %\item cofixpoint ... \end{enumerate} -\paragraph{Notations.} Application associates to the left such that -$(t\;t_1\;t_2\ldots t_n)$ represents $(\ldots ((t\;t_1)\;t_2)\ldots t_n)$. The -products and arrows associate to the right such that $\forall~x:A,B\ra C\ra -D$ represents $\forall~x:A,(B\ra (C\ra D))$. One uses sometimes -$\forall~x~y:A,B$ or -$\lb x~y:A\mto t$ to denote the abstraction or product of several variables -of the same type. The equivalent formulation is $\forall~x:A, \forall y:A,B$ or -$\lb x:A \mto \lb y:A \mto t$ - \paragraph{Free variables.} The notion of free variables is defined as usual. In the expressions $\lb x:T\mto U$ and $\forall x:T, U$ the occurrences of $x$ in $U$ -- cgit v1.2.3 From 1372e075c52aa2dad547a42eaf9aba1f83a7abb1 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 13:47:27 +0100 Subject: CLEANUP PROPOSITION: this sentence does not help us to better understand the semantics of the language --- doc/refman/RefMan-cic.tex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index ed7889e480..fb6a5bff83 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -181,8 +181,7 @@ More precisely the language of the {\em Calculus of Inductive \paragraph{Free variables.} The notion of free variables is defined as usual. In the expressions $\lb x:T\mto U$ and $\forall x:T, U$ the occurrences of $x$ in $U$ -are bound. They are represented by de Bruijn indexes in the internal -structure of terms. +are bound. \paragraph[Substitution.]{Substitution.\index{Substitution}} The notion of substituting a term $t$ to free occurrences of a -- cgit v1.2.3 From 3cebb15d999e6e26a98339ecb6fa7e62fdcf6a88 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 13:59:14 +0100 Subject: CLEANUP PROPOSITION: 'declaration' --> 'local declaration' If, below, we speak about 'global declarations', here it makes sense to speak about 'local declaration'. --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index fb6a5bff83..04df208ee2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -228,7 +228,7 @@ a global environment and a local context. \paragraph{Local context.} A {\em local context} is an ordered list of -declarations of names which we call {\em variables}. +local declarations of names which we call {\em variables}. The declaration of some variable $x$ is either a local assumption, written $x:T$ ($T$ is a type) or a local definition, written $x:=t:T$. We use brackets to write local contexts. A -- cgit v1.2.3 From cdd31465cee9ea8bef2a253280ee8a9647ecc01d Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 14:05:50 +0100 Subject: SILENT: the anchor for the 'Local context' was moved to a more appropriate place. --- doc/refman/RefMan-cic.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 04df208ee2..690bdad950 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -226,7 +226,7 @@ As objects of type theory, terms are subjected to {\em type discipline}. The well typing of a term depends on a global environment and a local context. -\paragraph{Local context.} +\paragraph{Local context.\index{Local context}} A {\em local context} is an ordered list of local declarations of names which we call {\em variables}. The declaration of some variable $x$ is @@ -241,7 +241,7 @@ $x:=t:T$, we also write $(x:=t:T) \in \Gamma$. For the rest of the chapter, the notation $\Gamma::(y:T)$ (resp. $\Gamma::(y:=t:T)$) denotes the local context $\Gamma$ enriched with the declaration $y:T$ (resp. $y:=t:T$). The -notation $[]$ denotes the empty local context. \index{Local context} +notation $[]$ denotes the empty local context. % Does not seem to be used further... % Si dans l'explication WF(E)[Gamma] concernant les constantes -- cgit v1.2.3 From 0a5ee78c32b5f48d8f90de1ff073e250db5033d6 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 14:39:31 +0100 Subject: ENH: 'Global Index' was enriched. These notions: - local assumption - local definition - global assumption - global definition are now indexed. --- doc/refman/RefMan-cic.tex | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 690bdad950..b0205b7e9e 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -228,9 +228,9 @@ a global environment and a local context. \paragraph{Local context.\index{Local context}} A {\em local context} is an ordered list of -local declarations of names which we call {\em variables}. +{\em local declarations\index{declaration!local}} of names which we call {\em variables\index{variable}}. The declaration of some variable $x$ is -either a local assumption, written $x:T$ ($T$ is a type) or a local definition, +either a {\em local assumption\index{assumption!local}}, written $x:T$ ($T$ is a type) or a {\em local definition\index{definition!local}}, written $x:=t:T$. We use brackets to write local contexts. A typical example is $[x:T;y:=u:U;z:V]$. Notice that the variables declared in a local context must be distinct. If $\Gamma$ declares some $x$, @@ -262,9 +262,9 @@ declaration $y:T$ such that $x$ is free in $T$. %Because we are manipulating global declarations (global constants and global %assumptions), we also need to consider a global environment $E$. -A {\em global environment} is an ordered list of global declarations. -Global declarations are either global assumptions or global -definitions, but also declarations of inductive objects. Inductive objects themselves declares both inductive or coinductive types and constructors +A {\em global environment} is an ordered list of {\em global declarations\index{declaration!global}}. +Global declarations are either {\em global assumptions\index{assumption!global}} or {\em global +definitions\index{definition!global}}, but also declarations of inductive objects. Inductive objects themselves declares both inductive or coinductive types and constructors (see Section~\ref{Cic-inductive-definitions}). A global assumption will be represented in the global environment as -- cgit v1.2.3 From 9f6ca170331a4f883cae20531bdced9eee663c59 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 14:42:15 +0100 Subject: CLEANUP PROPOSITION: removal of a definition of a concept that is not used further in the text --- doc/refman/RefMan-cic.tex | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index b0205b7e9e..73fd4a1182 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -255,9 +255,6 @@ notation $[]$ denotes the empty local context. % $|\Delta|$ for the length of the context $\Delta$, that is for the number % of declarations (assumptions or definitions) in $\Delta$. -A variable $x$ is said to be free in $\Gamma$ if $\Gamma$ contains a -declaration $y:T$ such that $x$ is free in $T$. - \paragraph[Global environment.]{Global environment.\index{Global environment}} %Because we are manipulating global declarations (global constants and global %assumptions), we also need to consider a global environment $E$. -- cgit v1.2.3 From 84d2f601da36e002cf752e9099244499c13bfa73 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 14:45:34 +0100 Subject: GRAMMAR --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 73fd4a1182..89c771238c 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -261,7 +261,7 @@ notation $[]$ denotes the empty local context. A {\em global environment} is an ordered list of {\em global declarations\index{declaration!global}}. Global declarations are either {\em global assumptions\index{assumption!global}} or {\em global -definitions\index{definition!global}}, but also declarations of inductive objects. Inductive objects themselves declares both inductive or coinductive types and constructors +definitions\index{definition!global}}, but also declarations of inductive objects. Inductive objects themselves declare both inductive or coinductive types and constructors (see Section~\ref{Cic-inductive-definitions}). A global assumption will be represented in the global environment as -- cgit v1.2.3 From 13ebbb8ab04036298d288b47a4664379173e6e3c Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 14:48:37 +0100 Subject: TYPOGRAPHY --- doc/refman/RefMan-cic.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 89c771238c..1804ebd9ce 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -264,14 +264,14 @@ Global declarations are either {\em global assumptions\index{assumption!global}} definitions\index{definition!global}}, but also declarations of inductive objects. Inductive objects themselves declare both inductive or coinductive types and constructors (see Section~\ref{Cic-inductive-definitions}). -A global assumption will be represented in the global environment as +A {\em global assumption} will be represented in the global environment as $(c:T)$ which assumes the name $c$ to be of some type $T$. -A global definition will +A {\em global definition} will be represented in the global environment as $c:=t:T$ which defines the name $c$ to have value $t$ and type $T$. We shall call such names {\em constants}. -The rules for inductive definitions (see section +The rules for inductive definitions (see Section \ref{Cic-inductive-definitions}) have to be considered as assumption rules to which the following definitions apply: if the name $c$ is declared in $E$, we write $c \in E$ and if $c:T$ or $c:=t:T$ is -- cgit v1.2.3 From 678f41f598f38c9c0ef7c587f7b876437a6d06d8 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 15:02:04 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 1804ebd9ce..56e9a27790 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -312,6 +312,7 @@ be derived from the following rules. {\WF{E;c:T}{}}} \item[W-Global-Def] \inference{\frac{\WTE{}{t}{T}~~~c \notin E} {\WF{E;c:=t:T}{}}} +% QUESTION: Why, in case of W-Local-Assum and W-Global-Assum we need s ∈ S hypothesis. \item[Ax] \index{Typing rules!Ax} \inference{\frac{\WFE{\Gamma}}{\WTEG{\Prop}{\Type(1)}}~~~~~ \frac{\WFE{\Gamma}}{\WTEG{\Set}{\Type(1)}}} -- cgit v1.2.3 From e13fed125d22e58e39487a3aa227416e1f2ba329 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 15:13:25 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 56e9a27790..22cec45cc2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -313,6 +313,10 @@ be derived from the following rules. \item[W-Global-Def] \inference{\frac{\WTE{}{t}{T}~~~c \notin E} {\WF{E;c:=t:T}{}}} % QUESTION: Why, in case of W-Local-Assum and W-Global-Assum we need s ∈ S hypothesis. +% QUESTION: At the moment, enrichment of a local context is denoted with ∷ +% whereas enrichment of the global environment is denoted with ; +% Is it necessary to use two different notations? +% Couldn't we use ∷ also for enrichment of the global context? \item[Ax] \index{Typing rules!Ax} \inference{\frac{\WFE{\Gamma}}{\WTEG{\Prop}{\Type(1)}}~~~~~ \frac{\WFE{\Gamma}}{\WTEG{\Set}{\Type(1)}}} -- cgit v1.2.3 From e31bc1fc036969454a5577758444b91174209b5c Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 15:44:25 +0100 Subject: TYPOGRAPHY: Each of the three 'Ax' and 'Prod' rules now has a unique name. --- doc/refman/RefMan-cic.tex | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 22cec45cc2..db26568c5a 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -317,21 +317,25 @@ be derived from the following rules. % whereas enrichment of the global environment is denoted with ; % Is it necessary to use two different notations? % Couldn't we use ∷ also for enrichment of the global context? -\item[Ax] \index{Typing rules!Ax} -\inference{\frac{\WFE{\Gamma}}{\WTEG{\Prop}{\Type(1)}}~~~~~ -\frac{\WFE{\Gamma}}{\WTEG{\Set}{\Type(1)}}} +\item[Ax-Prop] \index{Typing rules!Ax-Prop} +\inference{\frac{\WFE{\Gamma}}{\WTEG{\Prop}{\Type(1)}}} +\item[Ax-Set] \index{Typing rules!Ax-Set} +\inference{\frac{\WFE{\Gamma}}{\WTEG{\Set}{\Type(1)}}} +\item[Ax-Type] \index{Typing rules!Ax-Type} \inference{\frac{\WFE{\Gamma}}{\WTEG{\Type(i)}{\Type(i+1)}}} \item[Var]\index{Typing rules!Var} \inference{\frac{ \WFE{\Gamma}~~~~~(x:T) \in \Gamma~~\mbox{or}~~(x:=t:T) \in \Gamma~\mbox{for some $t$}}{\WTEG{x}{T}}} \item[Const] \index{Typing rules!Const} \inference{\frac{\WFE{\Gamma}~~~~(c:T) \in E~~\mbox{or}~~(c:=t:T) \in E~\mbox{for some $t$} }{\WTEG{c}{T}}} -\item[Prod] \index{Typing rules!Prod} +\item[Prod-Prop] \index{Typing rules!Prod-Prop} \inference{\frac{\WTEG{T}{s}~~~~s \in \Sort~~~ \WTE{\Gamma::(x:T)}{U}{\Prop}} { \WTEG{\forall~x:T,U}{\Prop}}} +\item[Prod-Set] \index{Typing rules!Prod-Set} \inference{\frac{\WTEG{T}{s}~~~~s \in\{\Prop, \Set\}~~~~~~ \WTE{\Gamma::(x:T)}{U}{\Set}} { \WTEG{\forall~x:T,U}{\Set}}} +\item[Prod-Type] \index{Typing rules!Prod-Type} \inference{\frac{\WTEG{T}{\Type(i)}~~~~ \WTE{\Gamma::(x:T)}{U}{\Type(i)}} {\WTEG{\forall~x:T,U}{\Type(i)}}} -- cgit v1.2.3 From 4beb1ee596afaf4ab4ebea9a89bb3ade7bbbe13d Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 17:32:36 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index db26568c5a..fe32cb7266 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -354,6 +354,7 @@ be derived from the following rules. well-typed without having $((\lb x:T\mto u)~t)$ well-typed (where $T$ is a type of $t$). This is because the value $t$ associated to $x$ may be used in a conversion rule (see Section~\ref{conv-rules}). +% QUESTION: I do not understand. How would that be possible? \section[Conversion rules]{Conversion rules\index{Conversion rules} \label{conv-rules}} -- cgit v1.2.3 From c56035c2850fe09fc5ef6389e58de28109ad5a93 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 17:33:54 +0100 Subject: TYPOGRAPHY: getting rid of an extra space --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index fe32cb7266..a008bd19a5 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -411,7 +411,7 @@ called $\zeta$-reduction and shows as follows. $$\WTEGRED{\kw{let}~x:=u~\kw{in}~t}{\triangleright_{\zeta}}{\subst{t}{x}{u}}$$ -\paragraph{$\eta$-conversion. +\paragraph{$\eta$-conversion.% \label{eta} \index{eta-conversion@$\eta$-conversion} %\index{eta-reduction@$\eta$-reduction} -- cgit v1.2.3 From a388e5401c2f83f4068314087e67d751acb59d17 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 29 Oct 2015 17:34:05 +0100 Subject: GRAMMAR --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index a008bd19a5..b7bbf7125f 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -416,7 +416,7 @@ $$\WTEGRED{\kw{let}~x:=u~\kw{in}~t}{\triangleright_{\zeta}}{\subst{t}{x}{u}}$$ \index{eta-conversion@$\eta$-conversion} %\index{eta-reduction@$\eta$-reduction} } -An other important concept is $\eta$-conversion. It is to identify any +Another important concept is $\eta$-conversion. It is to identify any term $t$ of functional type $\forall x:T, U$ with its so-called $\eta$-expansion $\lb x:T\mto (t\ x)$ for $x$ an arbitrary variable name fresh in $t$. -- cgit v1.2.3 From 32d7eb310f348bf4fcc6222de75bc5b423c9787e Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 30 Oct 2015 12:52:05 +0100 Subject: CLEANUP: the explanation of why eta-reduction is a bad idea was rephrased --- doc/refman/RefMan-cic.tex | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index b7bbf7125f..229c01b5d2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -411,24 +411,28 @@ called $\zeta$-reduction and shows as follows. $$\WTEGRED{\kw{let}~x:=u~\kw{in}~t}{\triangleright_{\zeta}}{\subst{t}{x}{u}}$$ -\paragraph{$\eta$-conversion.% -\label{eta} -\index{eta-conversion@$\eta$-conversion} +\paragraph{$\eta$-expansion.% +\label{eta}% +\index{eta-expansion@$\eta$-expansion}% %\index{eta-reduction@$\eta$-reduction} -} -Another important concept is $\eta$-conversion. It is to identify any +}% +Another important concept is $\eta$-expansion. It is legal to identify any term $t$ of functional type $\forall x:T, U$ with its so-called $\eta$-expansion $\lb x:T\mto (t\ x)$ for $x$ an arbitrary variable name fresh in $t$. -The notion of $\eta$-reduction ${\lb x:T\mto (t\ x)}{\;\triangleright\;}{t}$ -(for $x$ not occurring in $t$) is not type-sound because of subtyping -(think about $\lb x:\Type(1)\mto (f x)$ of type $\forall -x:\Type(1), \Type(1)$ for $f$ of type $\forall x:\Type(2), -\Type(1)$). On the other side, $\eta$-expansion requires to know $T$ -and hence requires types. Hence, neither $\eta$-expansion nor -$\eta$-reduction can be type-safely considered on terms we do not know -the type. However, $\eta$ can be used as a conversion rule. +\Rem We deliberately do not define $\eta$-reduction: +\def\noeta{\hskip-.1em\not\triangleright_\eta} +$$\lb x:T\mto (t\ x)\hskip.1em\noeta\hskip.3em t$$ +This is because, in general, the type of $t$ need not to be convertible to the type of $\lb x:T\mto (t\ x)$. +E.g., if we take $f$ such that: +$$f\hskip.5em:\hskip.5em\forall x:Type(2),Type(1)$$ +then +$$\lb x:Type(1),(f\, x)\hskip.5em:\hskip.5em\forall x:Type(1),Type(1)$$ +We could not allow +$$\lb x:Type(1),(f\,x)\hskip.5em\noeta\hskip.6em f$$ +because the type of the reduced term $\forall x:Type(2),Type(1)$ +would not be convertible to the type of the original term $\forall x:Type(1),Type(1)$. \paragraph[Convertibility.]{Convertibility.\label{convertibility} \index{beta-reduction@$\beta$-reduction}\index{iota-reduction@$\iota$-reduction}\index{delta-reduction@$\delta$-reduction}\index{zeta-reduction@$\zeta$-reduction}} -- cgit v1.2.3 From 73985c85792da06857199311834962f6a417e71c Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 30 Oct 2015 16:31:42 +0100 Subject: ENH: a small remark about Prod1 and Prod2 typing-rules was added --- doc/refman/RefMan-cic.tex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 229c01b5d2..764f1189ba 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -349,7 +349,14 @@ be derived from the following rules. \inference{\frac{\WTEG{t}{T}~~~~ \WTE{\Gamma::(x:=t:T)}{u}{U}} {\WTEG{\letin{x}{t:T}{u}}{\subst{U}{x}{t}}}} \end{description} - + +\Rem Prod$_1$ and Prod$_2$ typing-rules make sense if we consider the semantic +difference between {\Prop} and {\Set}: +\begin{itemize} + \item All values of a type that has a sort {\Set} are extractable. + \item No values of a type that has a sort {\Prop} are extractable. +\end{itemize} + \Rem We may have $\kw{let}~x:=t:T~\kw{in}~u$ well-typed without having $((\lb x:T\mto u)~t)$ well-typed (where $T$ is a type of $t$). This is because the value $t$ associated to $x$ -- cgit v1.2.3 From c5b3e7ff66e1675aaec7be5e0ee6772e88250991 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 30 Oct 2015 16:50:00 +0100 Subject: ENH: the concept of 'inductive declaration' was added to the 'Global Index' --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 764f1189ba..7fd5b23039 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -519,7 +519,7 @@ reductions or any combination of those can also be defined. A (possibly mutual) inductive definition is specified by giving the names and types of the inductive types to be defined and the names and types of the constructors of the inductive types. -An inductive declaration in the global environment can +An {\em inductive declaration\index{declaration!inductive}} in the global environment can consequently be represented with two local contexts, one for the types one for the constructors. -- cgit v1.2.3 From 47377fa44143d409331dd7d0c662e6ebb34d9f4f Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 14:41:37 +0100 Subject: ENH: The beginning of Section 4.5 (Inductive declarations) was changed in order to make it more concrete and more comprehensible. This ver --- doc/common/macros.tex | 2 +- doc/refman/RefMan-cic.tex | 380 ++++++++++++++++++++++------------------------ 2 files changed, 185 insertions(+), 197 deletions(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index ff13ec4557..fb9190a162 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -260,7 +260,7 @@ \newcommand{\Length}{\mbox{\textsf{Length}}} \newcommand{\length}{\mbox{\textsf{length}}} \newcommand{\LengthA}{\mbox {\textsf{Length\_A}}} -\newcommand{\List}{\mbox{\textsf{List}}} +\newcommand{\List}{\mbox{\textsf{list}}} \newcommand{\ListA}{\mbox{\textsf{List\_A}}} \newcommand{\LNil}{\mbox{\textsf{Lnil}}} \newcommand{\LCons}{\mbox{\textsf{Lcons}}} diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 7fd5b23039..f4d107ed8a 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -514,213 +514,201 @@ $u_i$ can be reducible. Similar notions of head-normal forms involving $\delta$, $\iota$ and $\zeta$ reductions or any combination of those can also be defined. -\section[Inductive Definitions]{Inductive Definitions\label{Cic-inductive-definitions}} - -A (possibly mutual) inductive definition is specified by giving the -names and types of the inductive types to be -defined and the names and types of the constructors of the inductive types. -An {\em inductive declaration\index{declaration!inductive}} in the global environment can -consequently be represented with two local contexts, one for the types -one for the constructors. - -Stating the rules for inductive definitions in their general form -needs quite tedious definitions. We shall try to give a concrete -understanding of the rules by illustrating them on running examples. We -take as examples the type of natural numbers, the type of -parameterized lists over a type $A$, the relation which states that -a list has some given length and the mutual inductive definition of trees and -forests. - -\subsection{Representing an inductive definition} -\subsubsection{Inductive definitions without parameters} -As for constants, inductive definitions must be defined in a non-empty -local context. \\ -We write \NInd{}{\Gamma_I}{\Gamma_C} for an inductive -definition with a -context of type definitions $\Gamma_I$ and a context of constructors -$\Gamma_C$. -\paragraph{Examples.} -The inductive declaration for the type of natural numbers will be: -\[\NInd{}{\nat:\Set}{\nO:\nat,\nS:\nat\ra\nat}\] -In a context with assumption $A:\Set$, the lists of elements in $A$ are -represented by: -\[\NInd{}{\List:\Set}{\Nil:\List,\cons : A \ra \List \ra - \List}\] -%% Assuming -%% $\Gamma_I$ is $[I_1:A_1;\ldots;I_k:A_k]$, and $\Gamma_C$ is -%% $[c_1:C_1;\ldots;c_n:C_n]$, the general typing rules are, -%% for $1\leq j\leq k$ and $1\leq i\leq n$: - -%% \bigskip - -%% \item[Ind] \index{Typing rules!Ind} -%% \inference{\frac{\NInd{}{\Gamma_I}{\Gamma_C} \in E}{(I_j:A_j) \in E}} -%% \item[Constr] \index{Typing rules!Constr} - -%% \inference{\frac{\NInd{}{\Gamma_I}{\Gamma_C} \in E}{(c_i:C_i) \in E}} - -\subsubsection{Inductive definitions with parameters} - -We have refine the representation above in order to handle parameters. -Let us explain that on the example of \List. With the above definition, -the type \List\ can only be used in a global environment where we -have a variable $A:\Set$. Generally one wants to consider lists of -elements in different types. For constants this is easily done by abstracting -the value over the parameter. In the case of inductive definitions we -have to handle the abstraction over several objects. - -One possible way to do that would be to define the type \List\ -inductively as being an inductive type of type $\Set\ra\Set$: -\[\NInd{}{\List:\Set\ra\Set}{\Nil:(\forall A:\Set,\List~A), - \cons : (\forall A:\Set, A \ra \List~A \ra \List~A)}\] -There are drawbacks to this point of view. The -information which says that for any $A$, $(\List~A)$ is an inductively defined -\Set\ has been lost. -So we introduce two important definitions. - -\paragraph{Inductive parameters, real arguments.} -An inductive definition $\NInd{\Gamma}{\Gamma_I}{\Gamma_C}$ admits -$r$ inductive parameters if each type of constructors $(c:C)$ in -$\Gamma_C$ is such that -\[C\equiv \forall -p_1:P_1,\ldots,\forall p_r:P_r,\forall a_1:A_1, \ldots \forall a_n:A_n, -(I~p_1~\ldots p_r~t_1\ldots t_q)\] -with $I$ one of the inductive definitions in $\Gamma_I$. -We say that $q$ is the number of real arguments of the constructor -$c$. -\paragraph{Context of parameters.} -If an inductive definition $\NInd{\Gamma}{\Gamma_I}{\Gamma_C}$ admits -$r$ inductive parameters, then there exists a local context $\Gamma_P$ of -size $r$, such that $\Gamma_P=[p_1:P_1;\ldots;p_r:P_r]$ and -if $(t:A) \in \Gamma_I,\Gamma_C$ then $A$ can be written as -$\forall p_1:P_1,\ldots \forall p_r:P_r,A'$. -We call $\Gamma_P$ the local context of parameters of the inductive -definition and use the notation $\forall \Gamma_P,A'$ for the term $A$. -\paragraph{Remark.} -If we have a term $t$ in an instance of an -inductive definition $I$ which starts with a constructor $c$, then the -$r$ first arguments of $c$ (the parameters) can be deduced from the -type $T$ of $t$: these are exactly the $r$ first arguments of $I$ in -the head normal form of $T$. -\paragraph{Examples.} -The \List{} definition has $1$ parameter: -\[\NInd{}{\List:\Set\ra\Set}{\Nil:(\forall A:\Set, \List~A), - \cons : (\forall A:\Set, A \ra \List~A \ra \List~A)}\] -This is also the case for this more complex definition where there is -a recursive argument on a different instance of \List: -\[\NInd{}{\List:\Set\ra\Set}{\Nil:(\forall A:\Set, \List~A), - \cons : (\forall A:\Set, A \ra \List~(A \ra A) \ra \List~A)}\] -But the following definition has $0$ parameters: -\[\NInd{}{\List:\Set\ra\Set}{\Nil:(\forall A:\Set, \List~A), - \cons : (\forall A:\Set, A \ra \List~A \ra \List~(A*A))}\] - -%\footnote{ -%The interested reader may compare the above definition with the two -%following ones which have very different logical meaning:\\ -%$\NInd{}{\List:\Set}{\Nil:\List,\cons : (A:\Set)A -% \ra \List \ra \List}$ \\ -%$\NInd{}{\List:\Set\ra\Set}{\Nil:(A:\Set)(\List~A),\cons : (A:\Set)A -% \ra (\List~A\ra A) \ra (\List~A)}$.} -\paragraph{Concrete syntax.} -In the {\Coq} system, the local context of parameters is given explicitly -after the name of the inductive definitions and is shared between the -arities and the type of constructors. -% The vernacular declaration of polymorphic trees and forests will be:\\ -% \begin{coq_example*} -% Inductive Tree (A:Set) : Set := -% Node : A -> Forest A -> Tree A -% with Forest (A : Set) : Set := -% Empty : Forest A -% | Cons : Tree A -> Forest A -> Forest A -% \end{coq_example*} -% will correspond in our formalism to: -% \[\NInd{}{{\tt Tree}:\Set\ra\Set;{\tt Forest}:\Set\ra \Set} -% {{\tt Node} : \forall A:\Set, A \ra {\tt Forest}~A \ra {\tt Tree}~A, -% {\tt Empty} : \forall A:\Set, {\tt Forest}~A, -% {\tt Cons} : \forall A:\Set, {\tt Tree}~A \ra {\tt Forest}~A \ra -% {\tt Forest}~A}\] -We keep track in the syntax of the number of -parameters. - -Formally the representation of an inductive declaration -will be -\Ind{}{p}{\Gamma_I}{\Gamma_C} for an inductive -definition with $p$ parameters, a -context of definitions $\Gamma_I$ and a context of constructors -$\Gamma_C$. - -The definition \Ind{}{p}{\Gamma_I}{\Gamma_C} will be -well-formed exactly when \NInd{}{\Gamma_I}{\Gamma_C} is and -when $p$ is (less or equal than) the number of parameters in -\NInd{}{\Gamma_I}{\Gamma_C}. - -\paragraph{Examples} -The declaration for parameterized lists is: -\[\Ind{}{1}{\List:\Set\ra\Set}{\Nil:(\forall A:\Set,\List~A),\cons : - (\forall A:\Set, A \ra \List~A \ra \List~A)}\] - -The declaration for an inductive type specifying the length of lists is: -\[\Ind{}{1}{\Length:\forall A:\Set, (\List~A)\ra \nat\ra\Prop} - {\LNil:\forall A:\Set, \Length~A~(\Nil~A)~\nO,\\ - \LCons :\forall A:\Set,\forall a:A, \forall l:(\List~A),\forall n:\nat, (\Length~A~l~n)\ra (\Length~A~(\cons~A~a~l)~(\nS~n))}\] - -The declaration for a mutual inductive definition of forests and trees is: -\[\NInd{}{\tree:\Set,\forest:\Set} - {\\~~\node:\forest \ra \tree, - \emptyf:\forest,\consf:\tree \ra \forest \ra \forest\-}\] - -These representations are the ones obtained as the result of the \Coq\ -declarations: -\begin{coq_example*} +\section[Inductive definitions]{Inductive Definitions\label{Cic-inductive-definitions}} + +% Here we assume that the reader knows what is an inductive definition. + +Formally, we can represent any {\em inductive definition\index{definition!inductive}} as \Ind{}{p}{\Gamma_I}{\Gamma_C} where: +\begin{itemize} + \item $\Gamma_I$ determines the names and types of inductive types; + \item $\Gamma_C$ determines the names and types of constructors of these inductive types; + \item $p$ determines the number of parameters of these inductive types. +\end{itemize} +These inductive definitions, together with global assumptions and global definitions, then form the global environment. +\vskip.5em +\noindent Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$ +such that each $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as: +$\forall\Gamma_P, T^\prime$. +\vskip.5em +\noindent $\Gamma_P$ is called {\em context of parameters\index{context of parameters}}. + +\subsection*{Examples} + +If we take the following inductive definition (denoted in concrete syntax): +\begin{coq_example} +Inductive bool : Set := + | true : bool + | false : bool. +\end{coq_example} +then: +\def\colon{@{\hskip.5em:\hskip.5em}} +\def\GammaI{\left[\begin{array}{r \colon l} + \bool & \Set + \end{array} + \right]} +\def\GammaC{\left[\begin{array}{r \colon l} + \true & \bool\\ + \false & \bool + \end{array} + \right]} +\newcommand\ind[3]{$\mathsf{Ind}~[#1]\left(\hskip-.4em + \begin{array}{r @{\mathrm{~:=~}} l} + #2 & #3 \\ + \end{array} + \hskip-.4em + \right)$} +\begin{itemize} + \item $p = 0$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ +\end{itemize} +and thus it enriches the global environment with the following entry: +\vskip.5em +\ind{p}{\Gamma_I}{\Gamma_C} +\vskip.5em +\noindent that is: +\vskip.5em +\ind{0}{\GammaI}{\GammaC} +\vskip.5em +\noindent In this case, $\Gamma_P=[\,]$. + +\vskip1em\hrule\vskip1em + +\noindent If we take the followig inductive definition: +\begin{coq_example} Inductive nat : Set := | O : nat | S : nat -> nat. -Inductive list (A:Set) : Set := +\end{coq_example} +then: +\def\GammaI{\left[\begin{array}{r \colon l} + \nat & \Set + \end{array} + \right]} +\def\GammaC{\left[\begin{array}{r \colon l} + \nO & \nat\\ + \nS & \nat\rightarrow\nat + \end{array} + \right]} +\begin{itemize} + \item $p = 0$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ +\end{itemize} +and thus it enriches the global environment with the following entry: +\vskip.5em +\ind{p}{\Gamma_I}{\Gamma_C} +\vskip.5em +\noindent that is: +\vskip.5em +\ind{0}{\GammaI}{\GammaC} +\vskip.5em +\noindent In this case, $\Gamma_P=[\,]$. + +\vskip1em\hrule\vskip1em + +\noindent If we take the following inductive definition: +\begin{coq_example} +Inductive list (A : Type) : Type := | nil : list A | cons : A -> list A -> list A. -\end{coq_example*} -\begin{coq_example*} -Inductive Length (A:Set) : list A -> nat -> Prop := +\end{coq_example} +then: +\def\GammaI{\left[\begin{array}{r \colon l} + \List & \Type\rightarrow\Type + \end{array} + \right]} +\def\GammaC{\left[\begin{array}{r \colon l} + \Nil & \forall~A\!:\!\Type,~\List~A\\ + \cons & \forall~A\!:\!\Type,~A\rightarrow\List~A\rightarrow\List~A + \end{array} + \right]} +\begin{itemize} + \item $p = 1$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ +\end{itemize} +and thus it enriches the global environment with the following entry: +\vskip.5em +\ind{p}{\Gamma_I}{\Gamma_C} +\vskip.5em +\noindent that is: +\vskip.5em +\ind{1}{\GammaI}{\GammaC} +\vskip.5em +\noindent In this case, $\Gamma_P=[A:\Type]$. + +\vskip1em\hrule\vskip1em + +\noindent If we take the following inductive definition: +\begin{coq_example} +Inductive Length (A : Type) : list A -> nat -> Prop := | Lnil : Length A (nil A) O - | Lcons : - forall (a:A) (l:list A) (n:nat), - Length A l n -> Length A (cons A a l) (S n). + | Lcons : forall (a:A) (l:list A) (n:nat), + Length A l n -> Length A (cons A a l) (S n). +\end{coq_example} +then: +\def\GammaI{\left[\begin{array}{r \colon l} + \Length & \forall~A\!:\!\Type,~\List~A\rightarrow\nat\rightarrow\Prop + \end{array} + \right]} +\def\GammaC{\left[\begin{array}{r c l} + \LNil & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\Length~A~(\Nil~A)~\nO\\ + \LCons & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ + & & \Length~A~l~n\rightarrow \Length~A~(\cons~A~a~l)~(\nS~n) + \end{array} + \right]} +\begin{itemize} + \item $p = 1$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ +\end{itemize} +and thus it enriches the global environment with the following entry: +\vskip.5em +\ind{p}{\Gamma_I}{\Gamma_C} +%\vskip.5em +%\noindent that is: +%\vskip.5em +%\ind{1}{\GammaI}{\GammaC} +\vskip.5em +\noindent In this case, $\Gamma_P=[A:\Type]$. + +\vskip1em\hrule\vskip1em + +\noindent If we take the following inductive definition: +\begin{coq_example} Inductive tree : Set := - node : forest -> tree + | node : forest -> tree with forest : Set := | emptyf : forest | consf : tree -> forest -> forest. -\end{coq_example*} -% The inductive declaration in \Coq\ is slightly different from the one -% we described theoretically. The difference is that in the type of -% constructors the inductive definition is explicitly applied to the -% parameters variables. -The \Coq\ type-checker verifies that all -parameters are applied in the correct manner in the conclusion of the -type of each constructors: - -In particular, the following definition will not be accepted because -there is an occurrence of \List\ which is not applied to the parameter -variable in the conclusion of the type of {\tt cons'}: -\begin{coq_eval} -Set Printing Depth 50. -\end{coq_eval} -% (********** The following is not correct and should produce **********) -% (********* Error: The 1st argument of list' must be A in ... *********) -\begin{coq_example} -Fail Inductive list' (A:Set) : Set := - | nil' : list' A - | cons' : A -> list' A -> list' (A*A). \end{coq_example} -Since \Coq{} version 8.1, there is no restriction about parameters in -the types of arguments of constructors. The following definition is -valid: -\begin{coq_example} -Inductive list' (A:Set) : Set := - | nil' : list' A - | cons' : A -> list' (A->A) -> list' A. -\end{coq_example} - +then: +\def\GammaI{\left[\begin{array}{r \colon l} + \tree & \Set\\ + \forest & \Set + \end{array} + \right]} +\def\GammaC{\left[\begin{array}{r \colon l} + \node & \forest\rightarrow\tree\\ + \emptyf & \forest\\ + \consf & \tree\rightarrow\forest\rightarrow\forest + \end{array} + \right]} +\begin{itemize} + \item $p = 0$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ +\end{itemize} +and thus it enriches the global environment with the following entry: +\vskip.5em +\ind{p}{\Gamma_I}{\Gamma_C} +\vskip.5em +\noindent that is: +\vskip.5em +\ind{0}{\GammaI}{\GammaC} +\vskip.5em +\noindent In this case, $\Gamma_P=[\,]$. \subsection{Types of inductive objects} We have to give the type of constants in a global environment $E$ which -- cgit v1.2.3 From 42bc6762952b2d4996e26285720b3e556a63c96d Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 15:25:20 +0100 Subject: QUESTION: Cannot we simplify the presentation of "Ind" and "Constr" typing rules like this? --- doc/refman/RefMan-cic.tex | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index f4d107ed8a..2eb79ce842 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -716,12 +716,9 @@ contains an inductive declaration. \begin{description} \item[Ind] \index{Typing rules!Ind} -\inference{\frac{\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E}{(I_j:A_j) \in E}} -\inference{\frac{\WFE{\Gamma}~~~~\NInd{}{\Gamma_I}{\Gamma_C} \in E}{\WTEG{I_j}{A_j}}} + \inference{\frac{\WFE{\Gamma}\hskip2em\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E\hskip2em(a:A)\in\Gamma_I}{\WTEG{a}{A}}} \item[Constr] \index{Typing rules!Constr} - -\inference{\frac{\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E}{(c_i:C_i) \in E}} -\inference{\frac{\WFE{\Gamma}~~~~\NInd{}{\Gamma_I}{\Gamma_C} \in E}{\WTEG{c_i}{C_i}}} + \inference{\frac{\WFE{\Gamma}\hskip2em\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E\hskip2em(c:C)\in\Gamma_C}{\WTEG{c}{C}}} \end{description} \paragraph{Example.} -- cgit v1.2.3 From 089f2195aa0d0351b5692a8b4c947c7652d148b0 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 15:31:56 +0100 Subject: SILENT: s/coq_example/coq_example*/ --- doc/refman/RefMan-cic.tex | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 2eb79ce842..574ef33c2d 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -535,11 +535,11 @@ $\forall\Gamma_P, T^\prime$. \subsection*{Examples} If we take the following inductive definition (denoted in concrete syntax): -\begin{coq_example} +\begin{coq_example*} Inductive bool : Set := | true : bool | false : bool. -\end{coq_example} +\end{coq_example*} then: \def\colon{@{\hskip.5em:\hskip.5em}} \def\GammaI{\left[\begin{array}{r \colon l} @@ -575,11 +575,11 @@ and thus it enriches the global environment with the following entry: \vskip1em\hrule\vskip1em \noindent If we take the followig inductive definition: -\begin{coq_example} +\begin{coq_example*} Inductive nat : Set := | O : nat | S : nat -> nat. -\end{coq_example} +\end{coq_example*} then: \def\GammaI{\left[\begin{array}{r \colon l} \nat & \Set @@ -608,11 +608,11 @@ and thus it enriches the global environment with the following entry: \vskip1em\hrule\vskip1em \noindent If we take the following inductive definition: -\begin{coq_example} +\begin{coq_example*} Inductive list (A : Type) : Type := | nil : list A | cons : A -> list A -> list A. -\end{coq_example} +\end{coq_example*} then: \def\GammaI{\left[\begin{array}{r \colon l} \List & \Type\rightarrow\Type @@ -641,12 +641,12 @@ and thus it enriches the global environment with the following entry: \vskip1em\hrule\vskip1em \noindent If we take the following inductive definition: -\begin{coq_example} +\begin{coq_example*} Inductive Length (A : Type) : list A -> nat -> Prop := | Lnil : Length A (nil A) O | Lcons : forall (a:A) (l:list A) (n:nat), Length A l n -> Length A (cons A a l) (S n). -\end{coq_example} +\end{coq_example*} then: \def\GammaI{\left[\begin{array}{r \colon l} \Length & \forall~A\!:\!\Type,~\List~A\rightarrow\nat\rightarrow\Prop @@ -676,13 +676,13 @@ and thus it enriches the global environment with the following entry: \vskip1em\hrule\vskip1em \noindent If we take the following inductive definition: -\begin{coq_example} +\begin{coq_example*} Inductive tree : Set := | node : forest -> tree with forest : Set := | emptyf : forest | consf : tree -> forest -> forest. -\end{coq_example} +\end{coq_example*} then: \def\GammaI{\left[\begin{array}{r \colon l} \tree & \Set\\ -- cgit v1.2.3 From bc78fc26204d638f789597e2892d95483918f187 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 16:13:20 +0100 Subject: CLEANUP: Presentation of examples was changed to make them more comprehensible. --- doc/refman/RefMan-cic.tex | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 574ef33c2d..cc69355d4a 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -722,12 +722,27 @@ contains an inductive declaration. \end{description} \paragraph{Example.} -We have $(\List:\Set \ra \Set), (\cons:\forall~A:\Set,A\ra(\List~A)\ra -(\List~A))$, \\ -$(\Length:\forall~A:\Set, (\List~A)\ra\nat\ra\Prop)$, $\tree:\Set$ and $\forest:\Set$. - -From now on, we write $\ListA$ instead of $(\List~A)$ and $\LengthA$ -for $(\Length~A)$. +Provided that our environment $E$ contains inductive definitions we showed before, +these two inference rules above enable us to conclude that: +\vskip.5em +\def\prefix{E[\Gamma]\vdash\hskip.25em} +$\begin{array}{@{} l} + \prefix\bool : \Set\\ + \prefix\true : \bool\\ + \prefix\false : \bool\\ + \prefix\nat : \Set\\ + \prefix\nO : \nat\\ + \prefix\nS : \nat\ra\nat\\ + \prefix\List : \Type\rightarrow\Type\\ + \prefix\Nil : \forall~A\!:\!\Type,~\List~A\\ + \prefix\cons : \forall~A\!:\!\Type,~A\rightarrow\List~A\rightarrow\List~A\\ + \prefix\Length : \forall~A\!:\!\Type,~\List~A\rightarrow\nat\rightarrow\Prop\\ + \prefix\LNil : \forall~A\!:\!\Type,~\Length~A~(\Nil~A)~\nO\\ + \begin{array}{l l} + \hskip-.5em\prefix\LCons :\hskip-.5em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ + & \Length~A~l~n\rightarrow \Length~A~(\cons~A~a~l)~(\nS~n) + \end{array} + \end{array}$ %\paragraph{Parameters.} %%The parameters introduce a distortion between the inside specification -- cgit v1.2.3 From 42347ebd180f10b738f628bae904b5773a0150ac Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 16:15:38 +0100 Subject: COMMENT: to do --- doc/refman/RefMan-cic.tex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index cc69355d4a..8f03cafd14 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -760,7 +760,9 @@ $\begin{array}{@{} l} \subsection{Well-formed inductive definitions} We cannot accept any inductive declaration because some of them lead -to inconsistent systems. We restrict ourselves to definitions which +to inconsistent systems. +% TODO: The statement above deserves explanation. +We restrict ourselves to definitions which satisfy a syntactic criterion of positivity. Before giving the formal rules, we need a few definitions: -- cgit v1.2.3 From f37c09e169b11ed683aeb9147c402b9980a6706c Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 16:28:13 +0100 Subject: TYPOGRAPHY --- doc/refman/RefMan-cic.tex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 8f03cafd14..8f50c1c323 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -771,14 +771,16 @@ rules, we need a few definitions: A type $T$ is an {\em arity of sort $s$}\index{Arity} if it converts to the sort $s$ or to a product $\forall~x:T,U$ with $U$ an arity of sort $s$. (For instance $A\ra \Set$ or $\forall~A:\Prop,A\ra -\Prop$ are arities of sort respectively \Set\ and \Prop). A {\em type +\Prop$ are arities of sort respectively \Set\ and \Prop). +\vskip.5em +\noindent A {\em type of constructor of $I$}\index{Type of constructor} is either a term $(I~t_1\ldots ~t_n)$ or $\fa x:T,C$ with $C$ recursively a {\em type of constructor of $I$}. \smallskip -The type of constructor $T$ will be said to {\em satisfy the positivity +\noindent The type of constructor $T$ will be said to {\em satisfy the positivity condition} for a constant $X$ in the following cases: \begin{itemize} -- cgit v1.2.3 From 6ce8d9b4b99afca623408e7052d5e6aaf72bb4ab Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 16:38:52 +0100 Subject: TYPOGRAPHY --- doc/refman/RefMan-cic.tex | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 8f50c1c323..eaf400f263 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -158,7 +158,7 @@ More precisely the language of the {\em Calculus of Inductive U''}. As $U$ depends on $x$, one says that $\forall~x:T,U$ is a {\em dependent product}. If $x$ does not occur in $U$ then $\forall~x:T,U$ reads as {\it ``if T then U''}. A {\em non dependent - product} can be written: $T \rightarrow U$. + product} can be written: $T \ra U$. \item if $x$ is a variable and $T$, $u$ are terms then $\lb x:T \mto u$ ($\kw{fun}~x:T~ {\tt =>}~ u$ in \Coq{} concrete syntax) is a term. This is a notation for the $\lambda$-abstraction of @@ -587,7 +587,7 @@ then: \right]} \def\GammaC{\left[\begin{array}{r \colon l} \nO & \nat\\ - \nS & \nat\rightarrow\nat + \nS & \nat\ra\nat \end{array} \right]} \begin{itemize} @@ -615,12 +615,12 @@ Inductive list (A : Type) : Type := \end{coq_example*} then: \def\GammaI{\left[\begin{array}{r \colon l} - \List & \Type\rightarrow\Type + \List & \Type\ra\Type \end{array} \right]} \def\GammaC{\left[\begin{array}{r \colon l} \Nil & \forall~A\!:\!\Type,~\List~A\\ - \cons & \forall~A\!:\!\Type,~A\rightarrow\List~A\rightarrow\List~A + \cons & \forall~A\!:\!\Type,~A\ra\List~A\ra\List~A \end{array} \right]} \begin{itemize} @@ -649,13 +649,13 @@ Inductive Length (A : Type) : list A -> nat -> Prop := \end{coq_example*} then: \def\GammaI{\left[\begin{array}{r \colon l} - \Length & \forall~A\!:\!\Type,~\List~A\rightarrow\nat\rightarrow\Prop + \Length & \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop \end{array} \right]} \def\GammaC{\left[\begin{array}{r c l} \LNil & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\Length~A~(\Nil~A)~\nO\\ \LCons & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ - & & \Length~A~l~n\rightarrow \Length~A~(\cons~A~a~l)~(\nS~n) + & & \Length~A~l~n\ra \Length~A~(\cons~A~a~l)~(\nS~n) \end{array} \right]} \begin{itemize} @@ -690,9 +690,9 @@ then: \end{array} \right]} \def\GammaC{\left[\begin{array}{r \colon l} - \node & \forest\rightarrow\tree\\ + \node & \forest\ra\tree\\ \emptyf & \forest\\ - \consf & \tree\rightarrow\forest\rightarrow\forest + \consf & \tree\ra\forest\ra\forest \end{array} \right]} \begin{itemize} @@ -733,14 +733,14 @@ $\begin{array}{@{} l} \prefix\nat : \Set\\ \prefix\nO : \nat\\ \prefix\nS : \nat\ra\nat\\ - \prefix\List : \Type\rightarrow\Type\\ + \prefix\List : \Type\ra\Type\\ \prefix\Nil : \forall~A\!:\!\Type,~\List~A\\ - \prefix\cons : \forall~A\!:\!\Type,~A\rightarrow\List~A\rightarrow\List~A\\ - \prefix\Length : \forall~A\!:\!\Type,~\List~A\rightarrow\nat\rightarrow\Prop\\ + \prefix\cons : \forall~A\!:\!\Type,~A\ra\List~A\ra\List~A\\ + \prefix\Length : \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop\\ \prefix\LNil : \forall~A\!:\!\Type,~\Length~A~(\Nil~A)~\nO\\ \begin{array}{l l} \hskip-.5em\prefix\LCons :\hskip-.5em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ - & \Length~A~l~n\rightarrow \Length~A~(\cons~A~a~l)~(\nS~n) + & \Length~A~l~n\ra \Length~A~(\cons~A~a~l)~(\nS~n) \end{array} \end{array}$ -- cgit v1.2.3 From 10f9c82c38c6eb01e64ab9a8fa233300568c18d4 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 16:39:28 +0100 Subject: ENH: adding a definition of the concept "_ is an arity". There already exists a definition of the following concept: "_ is an arity of sort _" I was not 100% sure what the following concept (used later in the text) means: "_ is an arity" so I added this (simple) definition in order to avoid possible confusion. --- doc/refman/RefMan-cic.tex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index eaf400f263..deaa1047c8 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -773,6 +773,9 @@ to the sort $s$ or to a product $\forall~x:T,U$ with $U$ an arity of sort $s$. (For instance $A\ra \Set$ or $\forall~A:\Prop,A\ra \Prop$ are arities of sort respectively \Set\ and \Prop). \vskip.5em +\noindent A type $T$ is an {\em arity} if there is a $s\in\Sort$ +such that $T$ is an arity of sort $s$. +\vskip.5em \noindent A {\em type of constructor of $I$}\index{Type of constructor} is either a term $(I~t_1\ldots ~t_n)$ or $\fa x:T,C$ with $C$ recursively -- cgit v1.2.3 From fdb02e793da45a37355050342109da1be4a49c89 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 16:58:39 +0100 Subject: TYPOGRAPHY: Examples of "arity" concept(s) were put to a separate \paragraph{...} --- doc/refman/RefMan-cic.tex | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index deaa1047c8..2fa9c59a86 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -766,16 +766,23 @@ We restrict ourselves to definitions which satisfy a syntactic criterion of positivity. Before giving the formal rules, we need a few definitions: -\paragraph[Definitions]{Definitions\index{Positivity}\label{Positivity}} - -A type $T$ is an {\em arity of sort $s$}\index{Arity} if it converts +\paragraph[Definition]{Definition\index{Arity}\label{Arity}} +A type $T$ is an {\em arity of sort $s$} if it converts to the sort $s$ or to a product $\forall~x:T,U$ with $U$ an arity -of sort $s$. (For instance $A\ra \Set$ or $\forall~A:\Prop,A\ra -\Prop$ are arities of sort respectively \Set\ and \Prop). -\vskip.5em -\noindent A type $T$ is an {\em arity} if there is a $s\in\Sort$ +of sort $s$. + +\paragraph[Examples]{Examples} +$A\ra \Set$ is an arity of sort $\Set$. +$\forall~A:\Prop,A\ra \Prop$ is an arity of sort \Prop. + +\paragraph[Definition]{Definition} +A type $T$ is an {\em arity} if there is a $s\in\Sort$ such that $T$ is an arity of sort $s$. -\vskip.5em + +\paragraph[Examples]{Examples} +$A\ra \Set$ and $\forall~A:\Prop,A\ra \Prop$ are arities. + +\paragraph[Definition]{Definition\index{Positivity}\label{Positivity}} \noindent A {\em type of constructor of $I$}\index{Type of constructor} is either a term $(I~t_1\ldots ~t_n)$ or $\fa x:T,C$ with $C$ recursively -- cgit v1.2.3 From 1231781cf36d94858abc1a73a55fbba543209d4c Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 2 Nov 2015 17:11:01 +0100 Subject: ENH: examples --- doc/refman/RefMan-cic.tex | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 2fa9c59a86..d0bffa06e7 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -782,15 +782,17 @@ such that $T$ is an arity of sort $s$. \paragraph[Examples]{Examples} $A\ra \Set$ and $\forall~A:\Prop,A\ra \Prop$ are arities. -\paragraph[Definition]{Definition\index{Positivity}\label{Positivity}} -\noindent A {\em type - of constructor of $I$}\index{Type of constructor} is either a term +\paragraph[Definition]{Definition\index{type of constructor}} +A {\em type of constructor of $I$}\index{Type of constructor} is either a term $(I~t_1\ldots ~t_n)$ or $\fa x:T,C$ with $C$ recursively a {\em type of constructor of $I$}. -\smallskip +\paragraph[Examples]{Examples} +$\nat$ and $\nat\ra\nat$ are types of constructors of $\nat$.\\ +$\forall A:\Type,\List~A$ and $\forall A:\Type,A\ra\List~A\ra\List~A$ are constructors of $\List$. -\noindent The type of constructor $T$ will be said to {\em satisfy the positivity +\paragraph[Definition]{Definition\index{Positivity}\label{Positivity}} +The type of constructor $T$ will be said to {\em satisfy the positivity condition} for a constant $X$ in the following cases: \begin{itemize} -- cgit v1.2.3 From 6a66f087bdb773465ce55f8cac040158f07c8d5c Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 10:07:16 +0100 Subject: ALPHA-CONVERSION: s/Length/has_length/g --- doc/common/macros.tex | 8 +++--- doc/refman/RefMan-cic.tex | 62 +++++++++++++++++++++++------------------------ 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index fb9190a162..1ac29b1553 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -257,13 +257,13 @@ \newcommand{\forest}{\mbox{\textsf{forest}}} \newcommand{\from}{\mbox{\textsf{from}}} \newcommand{\hd}{\mbox{\textsf{hd}}} -\newcommand{\Length}{\mbox{\textsf{Length}}} +\newcommand{\haslength}{\mbox{\textsf{has\_length}}} \newcommand{\length}{\mbox{\textsf{length}}} -\newcommand{\LengthA}{\mbox {\textsf{Length\_A}}} +\newcommand{\haslengthA}{\mbox {\textsf{has\_length~A}}} \newcommand{\List}{\mbox{\textsf{list}}} \newcommand{\ListA}{\mbox{\textsf{List\_A}}} -\newcommand{\LNil}{\mbox{\textsf{Lnil}}} -\newcommand{\LCons}{\mbox{\textsf{Lcons}}} +\newcommand{\nilhl}{\mbox{\textsf{nil\_hl}}} +\newcommand{\conshl}{\mbox{\textsf{cons\_hl}}} \newcommand{\nat}{\mbox{\textsf{nat}}} \newcommand{\nO}{\mbox{\textsf{O}}} \newcommand{\nS}{\mbox{\textsf{S}}} diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index d0bffa06e7..bbf6372846 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -642,20 +642,20 @@ and thus it enriches the global environment with the following entry: \noindent If we take the following inductive definition: \begin{coq_example*} -Inductive Length (A : Type) : list A -> nat -> Prop := - | Lnil : Length A (nil A) O - | Lcons : forall (a:A) (l:list A) (n:nat), - Length A l n -> Length A (cons A a l) (S n). +Inductive has_length (A : Type) : list A -> nat -> Prop := + | nil_hl : has_length A (nil A) O + | cons_hl : forall (a:A) (l:list A) (n:nat), + has_length A l n -> has_length A (cons A a l) (S n). \end{coq_example*} then: \def\GammaI{\left[\begin{array}{r \colon l} - \Length & \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop + \haslength & \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop \end{array} \right]} \def\GammaC{\left[\begin{array}{r c l} - \LNil & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\Length~A~(\Nil~A)~\nO\\ - \LCons & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ - & & \Length~A~l~n\ra \Length~A~(\cons~A~a~l)~(\nS~n) + \nilhl & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\haslength~A~(\Nil~A)~\nO\\ + \conshl & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ + & & \haslength~A~l~n\ra \haslength~A~(\cons~A~a~l)~(\nS~n) \end{array} \right]} \begin{itemize} @@ -736,11 +736,11 @@ $\begin{array}{@{} l} \prefix\List : \Type\ra\Type\\ \prefix\Nil : \forall~A\!:\!\Type,~\List~A\\ \prefix\cons : \forall~A\!:\!\Type,~A\ra\List~A\ra\List~A\\ - \prefix\Length : \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop\\ - \prefix\LNil : \forall~A\!:\!\Type,~\Length~A~(\Nil~A)~\nO\\ + \prefix\haslength : \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop\\ + \prefix\nilhl : \forall~A\!:\!\Type,~\haslength~A~(\Nil~A)~\nO\\ \begin{array}{l l} - \hskip-.5em\prefix\LCons :\hskip-.5em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ - & \Length~A~l~n\ra \Length~A~(\cons~A~a~l)~(\nS~n) + \hskip-.5em\prefix\conshl :\hskip-.5em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ + & \haslength~A~l~n\ra \haslength~A~(\cons~A~a~l)~(\nS~n) \end{array} \end{array}$ @@ -752,10 +752,10 @@ $\begin{array}{@{} l} %%typing rules where the inductive objects are seen as objects %%abstracted with respect to the parameters. -%In the definition of \List\ or \Length\, $A$ is a parameter because -%what is effectively inductively defined is $\ListA$ or $\LengthA$ for +%In the definition of \List\ or \haslength\, $A$ is a parameter because +%what is effectively inductively defined is $\ListA$ or $\haslengthA$ for %a given $A$ which is constant in the type of constructors. But when -%we define $(\LengthA~l~n)$, $l$ and $n$ are not parameters because the +%we define $(\haslengthA~l~n)$, $l$ and $n$ are not parameters because the %constructors manipulate different instances of this family. \subsection{Well-formed inductive definitions} @@ -1099,21 +1099,21 @@ fixed point of this recursive equation. This says that we are only manipulating finite objects. This analysis provides induction principles. -For instance, in order to prove $\forall l:\ListA,(\LengthA~l~(\length~l))$ +For instance, in order to prove $\forall l:\ListA,(\haslengthA~l~(\length~l))$ it is enough to prove: -\noindent $(\LengthA~(\Nil~A)~(\length~(\Nil~A)))$ and +\noindent $(\haslengthA~(\Nil~A)~(\length~(\Nil~A)))$ and \smallskip -$\forall a:A, \forall l:\ListA, (\LengthA~l~(\length~l)) \ra -(\LengthA~(\cons~A~a~l)~(\length~(\cons~A~a~l)))$. +$\forall a:A, \forall l:\ListA, (\haslengthA~l~(\length~l)) \ra +(\haslengthA~(\cons~A~a~l)~(\length~(\cons~A~a~l)))$. \smallskip \noindent which given the conversion equalities satisfied by \length\ is the same as proving: -$(\LengthA~(\Nil~A)~\nO)$ and $\forall a:A, \forall l:\ListA, -(\LengthA~l~(\length~l)) \ra -(\LengthA~(\cons~A~a~l)~(\nS~(\length~l)))$. +$(\haslengthA~(\Nil~A)~\nO)$ and $\forall a:A, \forall l:\ListA, +(\haslengthA~l~(\length~l)) \ra +(\haslengthA~(\cons~A~a~l)~(\nS~(\length~l)))$. One conceptually simple way to do that, following the basic scheme proposed by Martin-L\"of in his Intuitionistic Type Theory, is to @@ -1370,15 +1370,15 @@ For $\ListA$ the type of $P$ will be $\ListA\ra s$ for $s \in \Sort$. \\ $ \CI{(\cons~A)}{P} \equiv \forall a:A, \forall l:\ListA,(P~(\cons~A~a~l))$. -For $\LengthA$, the type of $P$ will be -$\forall l:\ListA,\forall n:\nat, (\LengthA~l~n)\ra \Prop$ and the expression -\CI{(\LCons~A)}{P} is defined as:\\ +For $\haslengthA$, the type of $P$ will be +$\forall l:\ListA,\forall n:\nat, (\haslengthA~l~n)\ra \Prop$ and the expression +\CI{(\conshl~A)}{P} is defined as:\\ $\forall a:A, \forall l:\ListA, \forall n:\nat, \forall -h:(\LengthA~l~n), (P~(\cons~A~a~l)~(\nS~n)~(\LCons~A~a~l~n~l))$.\\ +h:(\haslengthA~l~n), (P~(\cons~A~a~l)~(\nS~n)~(\conshl~A~a~l~n~l))$.\\ If $P$ does not depend on its third argument, we find the more natural expression:\\ $\forall a:A, \forall l:\ListA, \forall n:\nat, -(\LengthA~l~n)\ra(P~(\cons~A~a~l)~(\nS~n))$. +(\haslengthA~l~n)\ra(P~(\cons~A~a~l)~(\nS~n))$. \paragraph{Typing rule.} @@ -1411,7 +1411,7 @@ only constructors of $I$. \end{description} \paragraph{Example.} -For \List\ and \Length\ the typing rules for the {\tt match} expression +For \List\ and \haslength\ the typing rules for the {\tt match} expression are (writing just $t:M$ instead of \WTEG{t}{M}, the global environment and local context being the same in all the judgments). @@ -1421,11 +1421,11 @@ local context being the same in all the judgments). \[\frac{ \begin{array}[b]{@{}c@{}} -H:(\LengthA~L~N) \\ P:\forall l:\ListA, \forall n:\nat, (\LengthA~l~n)\ra +H:(\haslengthA~L~N) \\ P:\forall l:\ListA, \forall n:\nat, (\haslengthA~l~n)\ra \Prop\\ - f_1:(P~(\Nil~A)~\nO~\LNil) \\ + f_1:(P~(\Nil~A)~\nO~\nilhl) \\ f_2:\forall a:A, \forall l:\ListA, \forall n:\nat, \forall - h:(\LengthA~l~n), (P~(\cons~A~a~n)~(\nS~n)~(\LCons~A~a~l~n~h)) + h:(\haslengthA~l~n), (P~(\cons~A~a~n)~(\nS~n)~(\conshl~A~a~l~n~h)) \end{array}} {\Case{P}{H}{f_1~|~f_2}:(P~L~N~H)}\] -- cgit v1.2.3 From 754bc95497ccf903391e5aa1cfda45cb59ad7927 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 10:23:19 +0100 Subject: ENH: new example: "even" --- doc/common/macros.tex | 5 +++++ doc/refman/RefMan-cic.tex | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index 1ac29b1553..0ea2ed650b 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -280,6 +280,11 @@ \newcommand{\Type}{\mbox{\textsf{Type}}} \newcommand{\unfold}{\mbox{\textsf{unfold}}} \newcommand{\zeros}{\mbox{\textsf{zeros}}} +\newcommand{\even}{\mbox{\textsf{even}}} +\newcommand{\odd}{\mbox{\textsf{even}}} +\newcommand{\evenO}{\mbox{\textsf{even\_O}}} +\newcommand{\evenS}{\mbox{\textsf{even\_S}}} +\newcommand{\oddS}{\mbox{\textsf{odd\_S}}} %%%%%%%%% % Misc. % diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index bbf6372846..101c4e5036 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -640,6 +640,42 @@ and thus it enriches the global environment with the following entry: \vskip1em\hrule\vskip1em +\noindent If we take the following inductive definition: +\begin{coq_example*} +Inductive even : nat -> Prop := + | even_O : even 0 + | even_S : forall n, odd n -> even (S n) +with odd : nat -> Prop := + | odd_S : forall n, even n -> odd (S n). +\end{coq_example*} +then: +\def\GammaI{\left[\begin{array}{r \colon l} + \even & \nat\ra\Prop \\ + \odd & \nat\ra\Prop + \end{array} + \right]} +\def\GammaC{\left[\begin{array}{r \colon l} + \evenO & \even~\nO \\ + \evenS & \forall n : \nat, \odd~n \ra \even~(\nS~n) + \end{array} + \right]} +\begin{itemize} + \item $p = 1$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ +\end{itemize} +and thus it enriches the global environment with the following entry: +\vskip.5em +\ind{p}{\Gamma_I}{\Gamma_C} +\vskip.5em +\noindent that is: +\vskip.5em +\ind{1}{\GammaI}{\GammaC} +\vskip.5em +\noindent In this case, $\Gamma_P=[A:\Type]$. + +\vskip1em\hrule\vskip1em + \noindent If we take the following inductive definition: \begin{coq_example*} Inductive has_length (A : Type) : list A -> nat -> Prop := -- cgit v1.2.3 From 6c9f5450f476da94aa70df93c5a6368b98e73e90 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 10:37:16 +0100 Subject: CLEANUP: superfluous examples were removed --- doc/common/macros.tex | 2 +- doc/refman/RefMan-cic.tex | 20 +++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index 0ea2ed650b..a6240ad284 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -281,7 +281,7 @@ \newcommand{\unfold}{\mbox{\textsf{unfold}}} \newcommand{\zeros}{\mbox{\textsf{zeros}}} \newcommand{\even}{\mbox{\textsf{even}}} -\newcommand{\odd}{\mbox{\textsf{even}}} +\newcommand{\odd}{\mbox{\textsf{odd}}} \newcommand{\evenO}{\mbox{\textsf{even\_O}}} \newcommand{\evenS}{\mbox{\textsf{even\_S}}} \newcommand{\oddS}{\mbox{\textsf{odd\_S}}} diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 101c4e5036..d3e8755a85 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -763,21 +763,11 @@ these two inference rules above enable us to conclude that: \vskip.5em \def\prefix{E[\Gamma]\vdash\hskip.25em} $\begin{array}{@{} l} - \prefix\bool : \Set\\ - \prefix\true : \bool\\ - \prefix\false : \bool\\ - \prefix\nat : \Set\\ - \prefix\nO : \nat\\ - \prefix\nS : \nat\ra\nat\\ - \prefix\List : \Type\ra\Type\\ - \prefix\Nil : \forall~A\!:\!\Type,~\List~A\\ - \prefix\cons : \forall~A\!:\!\Type,~A\ra\List~A\ra\List~A\\ - \prefix\haslength : \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop\\ - \prefix\nilhl : \forall~A\!:\!\Type,~\haslength~A~(\Nil~A)~\nO\\ - \begin{array}{l l} - \hskip-.5em\prefix\conshl :\hskip-.5em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ - & \haslength~A~l~n\ra \haslength~A~(\cons~A~a~l)~(\nS~n) - \end{array} + \prefix\even : \nat\ra\Prop\\ + \prefix\odd : \nat\ra\Prop\\ + \prefix\evenO : \even~\nO\\ + \prefix\evenS : \forall~n:\nat, \odd~n \ra \even~(\nS~n)\\ + \prefix\oddS : \forall~n:\nat, \even~n \ra \odd~(\nS~n) \end{array}$ %\paragraph{Parameters.} -- cgit v1.2.3 From 4570133034c9457a4d641449a522c29a8f029a55 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 10:45:04 +0100 Subject: FIX: commit 315f771 --- doc/refman/RefMan-cic.tex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index d3e8755a85..d3b4f3af7c 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -59,7 +59,9 @@ Formally, we call {\Sort} the set of sorts which is defined by: \index{Prop@{\Prop}}% \index{Set@{\Set}}% \[\Sort \equiv \{\Prop,\Set,\Type(i)\;|\; i \in \NN\} \] -Their properties are defined in Section~\ref{subtyping-rules}. +Their properties, such as: +{\Prop:\Type$(1)$}, {\Set:\Type$(1)$}, and {\Type$(i)$:\Type$(i+1)$}, +are defined in Section~\ref{subtyping-rules}. % TODO: Somewhere in the document we should explain: % - what concrete actions (in *.v files) cause creation of new universes -- cgit v1.2.3 From 8b559623f8f2539836069a7352498a5e2c4784e6 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 11:27:35 +0100 Subject: COMMENT: to do --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index d3b4f3af7c..f7a6470f9c 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -184,6 +184,7 @@ More precisely the language of the {\em Calculus of Inductive The notion of free variables is defined as usual. In the expressions $\lb x:T\mto U$ and $\forall x:T, U$ the occurrences of $x$ in $U$ are bound. +% TODO: what is the best play to say that "terms are considered equal up to α-conversion"? \paragraph[Substitution.]{Substitution.\index{Substitution}} The notion of substituting a term $t$ to free occurrences of a -- cgit v1.2.3 From f07348e606882ddb0d69029bde82be3106335f21 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 11:39:54 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index f7a6470f9c..5df70a8e97 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -305,6 +305,7 @@ local context $\Gamma$ and a term $T$ such that the judgment \WTEG{t}{T} can be derived from the following rules. \begin{description} \item[W-Empty] \inference{\WF{[]}{}} +% QUESTION: Why in W-Local-Assum and W-Local-Def we do not need x ∉ E hypothesis? \item[W-Local-Assum] % Ce n'est pas vrai : x peut apparaitre plusieurs fois dans Gamma \inference{\frac{\WTEG{T}{s}~~~~s \in \Sort~~~~x \not\in \Gamma % \cup E }{\WFE{\Gamma::(x:T)}}} -- cgit v1.2.3 From ee629d65f2d36544b0e5c8afb657933ef19c296d Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 11:40:20 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 5df70a8e97..45613e03af 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -312,6 +312,7 @@ be derived from the following rules. \item[W-Local-Def] \inference{\frac{\WTEG{t}{T}~~~~x \not\in \Gamma % \cup E }{\WFE{\Gamma::(x:=t:T)}}} +% QUESTION: Why in W-Global-Assum and W-Global-Def we do not need x ∉ Γ hypothesis? \item[W-Global-Assum] \inference{\frac{\WTE{}{T}{s}~~~~s \in \Sort~~~~c \notin E} {\WF{E;c:T}{}}} \item[W-Global-Def] \inference{\frac{\WTE{}{t}{T}~~~c \notin E} -- cgit v1.2.3 From 420e750c4ef3be1d562e1729e5ec6adf94795913 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 18 Nov 2015 16:36:22 +0100 Subject: CLEANUP: the definition of "type of constructor" was rephrased in order to make it more clear --- doc/refman/RefMan-cic.tex | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 45613e03af..d05e3dd9e8 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -814,9 +814,12 @@ such that $T$ is an arity of sort $s$. $A\ra \Set$ and $\forall~A:\Prop,A\ra \Prop$ are arities. \paragraph[Definition]{Definition\index{type of constructor}} -A {\em type of constructor of $I$}\index{Type of constructor} is either a term -$(I~t_1\ldots ~t_n)$ or $\fa x:T,C$ with $C$ recursively -a {\em type of constructor of $I$}. +We say that $T$ is a {\em type of constructor of $I$\index{type of constructor}} +in one of the following two cases: +\begin{itemize} + \item $T$ is $(I~t_1\ldots ~t_n)$ + \item $T$ is $\forall x:U,T^\prime$ where $T^\prime$ is also a type of constructor of $I$ +\end{itemize} \paragraph[Examples]{Examples} $\nat$ and $\nat\ra\nat$ are types of constructors of $\nat$.\\ -- cgit v1.2.3 From 27c19fffda5c5b1f119a1b2115915b330fdfe1ba Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 13:25:42 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index d05e3dd9e8..c3dc80b1a6 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -828,6 +828,7 @@ $\forall A:\Type,\List~A$ and $\forall A:\Type,A\ra\List~A\ra\List~A$ are constr \paragraph[Definition]{Definition\index{Positivity}\label{Positivity}} The type of constructor $T$ will be said to {\em satisfy the positivity condition} for a constant $X$ in the following cases: +% QUESTION: Why is this property called "positivity"? \begin{itemize} \item $T=(X~t_1\ldots ~t_n)$ and $X$ does not occur free in -- cgit v1.2.3 From fc73973844f848fafb61b6aa39a327e95f09c129 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 13:28:57 +0100 Subject: CLEANUP: s/List_A/List~A/g --- doc/common/macros.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index a6240ad284..2271a8f134 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -261,7 +261,7 @@ \newcommand{\length}{\mbox{\textsf{length}}} \newcommand{\haslengthA}{\mbox {\textsf{has\_length~A}}} \newcommand{\List}{\mbox{\textsf{list}}} -\newcommand{\ListA}{\mbox{\textsf{List\_A}}} +\newcommand{\ListA}{\mbox{\textsf{List}~A}} \newcommand{\nilhl}{\mbox{\textsf{nil\_hl}}} \newcommand{\conshl}{\mbox{\textsf{cons\_hl}}} \newcommand{\nat}{\mbox{\textsf{nat}}} -- cgit v1.2.3 From 5a155b13b6a6820a1c0417025c67170a3e22fedc Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 13:32:59 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index c3dc80b1a6..c15ee9ffdd 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -820,6 +820,9 @@ in one of the following two cases: \item $T$ is $(I~t_1\ldots ~t_n)$ \item $T$ is $\forall x:U,T^\prime$ where $T^\prime$ is also a type of constructor of $I$ \end{itemize} +% QUESTION: Are we above sufficiently precise? +% Shouldn't we say also what is "n"? +% "n" couldn't be "0", could it? \paragraph[Examples]{Examples} $\nat$ and $\nat\ra\nat$ are types of constructors of $\nat$.\\ -- cgit v1.2.3 From c5a7d2bec3232625dcb50cfc3a3d6d5abcb81ff0 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 3 Nov 2015 16:59:08 +0100 Subject: ENH: examples for 'strict positivity' were expanded --- doc/common/macros.tex | 4 ++- doc/refman/RefMan-cic.tex | 72 +++++++++++++++++++++++++++++++++++------ doc/refman/Reference-Manual.tex | 1 + 3 files changed, 66 insertions(+), 11 deletions(-) diff --git a/doc/common/macros.tex b/doc/common/macros.tex index 2271a8f134..3b12f259b6 100644 --- a/doc/common/macros.tex +++ b/doc/common/macros.tex @@ -261,7 +261,7 @@ \newcommand{\length}{\mbox{\textsf{length}}} \newcommand{\haslengthA}{\mbox {\textsf{has\_length~A}}} \newcommand{\List}{\mbox{\textsf{list}}} -\newcommand{\ListA}{\mbox{\textsf{List}~A}} +\newcommand{\ListA}{\mbox{\textsf{list}}~\ensuremath{A}} \newcommand{\nilhl}{\mbox{\textsf{nil\_hl}}} \newcommand{\conshl}{\mbox{\textsf{cons\_hl}}} \newcommand{\nat}{\mbox{\textsf{nat}}} @@ -285,6 +285,8 @@ \newcommand{\evenO}{\mbox{\textsf{even\_O}}} \newcommand{\evenS}{\mbox{\textsf{even\_S}}} \newcommand{\oddS}{\mbox{\textsf{odd\_S}}} +\newcommand{\Prod}{\mbox{\textsf{prod}}} +\newcommand{\Pair}{\mbox{\textsf{pair}}} %%%%%%%%% % Misc. % diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index c15ee9ffdd..1c374e9397 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -876,16 +876,68 @@ any $u_i$ the type $V$ satisfies the nested positivity condition for $X$ \end{itemize} -\paragraph{Example} - -$X$ occurs strictly positively in $A\ra X$ or $X*A$ or $({\tt list}~ -X)$ but not in $X \ra A$ or $(X \ra A)\ra A$ nor $({\tt neg}~X)$ -assuming the notion of product and lists were already defined and {\tt - neg} is an inductive definition with declaration \Ind{}{A:\Set}{{\tt - neg}:\Set}{{\tt neg}:(A\ra{\tt False}) \ra {\tt neg}}. Assuming -$X$ has arity ${\tt nat \ra Prop}$ and {\tt ex} is the inductively -defined existential quantifier, the occurrence of $X$ in ${\tt (ex~ - nat~ \lb n:nat\mto (X~ n))}$ is also strictly positive. +\newcommand\vv{\textSFxi} % │ +\newcommand\hh{\textSFx} % ─ +\newcommand\vh{\textSFviii} % ├ +\newcommand\hv{\textSFii} % └ +\newlength\framecharacterwidth +\settowidth\framecharacterwidth{\hh} +\newcommand\ws{\hbox{}\hskip\the\framecharacterwidth} +\newcommand\ruleref[1]{\hskip.25em\dots\hskip.2em{\em (bullet #1)}} +\paragraph{Example}~\\ +\vskip-.5em +\noindent$X$ occurs strictly positively in $A\ra X$\ruleref5\\ +\vv\\ +\vh\hh\ws $X$does not occur in $A$\ruleref3\\ +\vv\\ +\hv\hh\ws $X$ occurs strictly positively in $X$\ruleref4 +\paragraph{Example}~\\ +\vskip-.5em +\noindent $X$ occurs strictly positively in $X*A$\\ +\vv\\ +\hv\hh $X$ occurs strictly positively in $(\Prod~X~A)$\ruleref6\\ +\ws\ws\vv\\ +\ws\ws\vv\ws\verb|Inductive prod (A B : Type) : Type :=|\\ +\ws\ws\vv\ws\verb| pair : A -> B -> prod A B.|\\ +\ws\ws\vv\\ +\ws\ws\vh\hh $X$ does not occur in any (real) arguments of $\Prod$ in the original term $(\Prod~X~A)$\\ +\ws\ws\vv\\ +\ws\ws\hv\ws the (instantiated) type $\Prod~X~A$ of constructor $\Pair$,\\ +\ws\ws\ws\ws satisfies the nested positivity condition for $X$\ruleref7\\ +\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\hv\ws $X$ does not occur in any (real) arguments of $(\Prod~X~A)$ +\paragraph{Example}~\\ +\vskip-.5em +\noindent $X$ occurs strictly positively in $\ListA$\ruleref6\\ +\vv\\ +\vv\ws\verb|Inductive list (A:Type) : Type :=|\\ +\vv\ws\verb$ | nil : list A$\\ +\vv\ws\verb$ | cons : A -> list A -> list A$\\ +\vv\\ +\vh\hh $X$ does not occur in any arguments of $\List$\\ +\vv\\ +\hv\hh\ws Every instantiated constructor of $\ListA$ satisfies the nested positivity condition for $X$\\ +\ws\ws\ws\vv\\ +\ws\ws\ws\vh\hh\ws concerning type $\ListA$ of constructor $\Nil$:\\ +\ws\ws\ws\vv\ws\ws Type $\ListA$ of constructor $\Nil$ satisfies the nested positivity condition for $X$\\ +\ws\ws\ws\vv\ws\ws because $X$ does not appear in any (real) arguments of the type of that constructor\\ +\ws\ws\ws\vv\ws\ws (primarily because $\List$ does not have any (real) arguments)\ruleref7\\ +\ws\ws\ws\vv\\ +\ws\ws\ws\hv\hh\ws concerning type $\forall~A\ra\ListA\ra\ListA$ of constructor $\cons$:\\ +\ws\ws\ws\ws\ws\ws Type $\forall~A:\Type,A\ra\ListA\ra\ListA$ of constructor $\cons$\\ +\ws\ws\ws\ws\ws\ws satisfies the nested positivity condition for $X$\ruleref8\\ +\ws\ws\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\Type$\ruleref3\\ +\ws\ws\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $A\ra\ListA\ra\ListA$\ruleref8\\ +\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $A$\ruleref3\\ +\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA\ra\ListA$\ruleref8\\ +\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\ws $X$ occurs only strictly positively in $\ListA$\ruleref3\\ +\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 \paragraph{Correctness rules.} We shall now describe the rules allowing the introduction of a new diff --git a/doc/refman/Reference-Manual.tex b/doc/refman/Reference-Manual.tex index ac28e0ba03..cb5d2ecb54 100644 --- a/doc/refman/Reference-Manual.tex +++ b/doc/refman/Reference-Manual.tex @@ -20,6 +20,7 @@ \usepackage{headers} % in this directory \usepackage{multicol} \usepackage{xspace} +\usepackage{pmboxdraw} % for coqide \ifpdf % si on est pas en pdflatex -- cgit v1.2.3 From 7fb0ac951bbc8081642448cab92def3540ee2f3f Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 14:55:52 +0100 Subject: COMMENT: questions --- doc/refman/RefMan-cic.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 1c374e9397..28c1c66453 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -835,6 +835,7 @@ condition} for a constant $X$ in the following cases: \begin{itemize} \item $T=(X~t_1\ldots ~t_n)$ and $X$ does not occur free in +% QUESTIONS: What is the meaning of 'n' above? any $t_i$ \item $T=\forall~x:U,V$ and $X$ occurs only strictly positively in $U$ and the type $V$ satisfies the positivity condition for $X$ @@ -846,10 +847,12 @@ following cases: \begin{itemize} \item $X$ does not occur in $T$ \item $T$ converts to $(X~t_1 \ldots ~t_n)$ and $X$ does not occur in +% QUESTIONS: What is the meaning of 'n' above? any of $t_i$ \item $T$ converts to $\forall~x:U,V$ and $X$ does not occur in type $U$ but occurs strictly positively in type $V$ \item $T$ converts to $(I~a_1 \ldots ~a_m ~ t_1 \ldots ~t_p)$ where +% QUESTIONS: What is the meaning of 'p' above? $I$ is the name of an inductive declaration of the form $\Ind{\Gamma}{m}{I:A}{c_1:\forall p_1:P_1,\ldots \forall p_m:P_m,C_1;\ldots;c_n:\forall p_1:P_1,\ldots \forall @@ -872,6 +875,7 @@ cases: \item $T=(I~b_1\ldots b_m~u_1\ldots ~u_{p})$, $I$ is an inductive definition with $m$ parameters and $X$ does not occur in any $u_i$ +% QUESTIONS: What is the meaning of 'p' above? \item $T=\forall~x:U,V$ and $X$ occurs only strictly positively in $U$ and the type $V$ satisfies the nested positivity condition for $X$ \end{itemize} -- cgit v1.2.3 From d0d4eb3aedc2d971a1ab4182ac5e4ee3ac741427 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 18:54:07 +0100 Subject: FIX: making sure that my previous edits do not break HTML generation --- doc/refman/RefMan-cic.tex | 87 ++++++++++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 31 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 28c1c66453..00ba0091ee 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -434,15 +434,34 @@ $\eta$-expansion $\lb x:T\mto (t\ x)$ for $x$ an arbitrary variable name fresh in $t$. \Rem We deliberately do not define $\eta$-reduction: -\def\noeta{\hskip-.1em\not\triangleright_\eta} -$$\lb x:T\mto (t\ x)\hskip.1em\noeta\hskip.3em t$$ +\begin{latexonly} + $$\lb x:T\mto (t\ x)\not\triangleright_\eta\hskip.3em t$$ +\end{latexonly} +\begin{htmlonly} + $$\lb x:T\mto (t\ x)~\not\triangleright_\eta~t$$ +\end{htmlonly} This is because, in general, the type of $t$ need not to be convertible to the type of $\lb x:T\mto (t\ x)$. E.g., if we take $f$ such that: -$$f\hskip.5em:\hskip.5em\forall x:Type(2),Type(1)$$ +\begin{latexonly} + $$f\hskip.5em:\hskip.5em\forall x:Type(2),Type(1)$$ +\end{latexonly} +\begin{htmlonly} + $$f~:~\forall x:Type(2),Type(1)$$ +\end{htmlonly} then -$$\lb x:Type(1),(f\, x)\hskip.5em:\hskip.5em\forall x:Type(1),Type(1)$$ +\begin{latexonly} + $$\lb x:Type(1),(f\, x)\hskip.5em:\hskip.5em\forall x:Type(1),Type(1)$$ +\end{latexonly} +\begin{htmlonly} + $$\lb x:Type(1),(f\, x)~:~\forall x:Type(1),Type(1)$$ +\end{htmlonly} We could not allow -$$\lb x:Type(1),(f\,x)\hskip.5em\noeta\hskip.6em f$$ +\begin{latexonly} + $$\lb x:Type(1),(f\,x)\hskip.4em\not\triangleright_\eta\hskip.6em f$$ +\end{latexonly} +\begin{htmlonly} + $$\lb x:Type(1),(f\,x)~\not\triangleright_\eta~f$$ +\end{htmlonly} because the type of the reduced term $\forall x:Type(2),Type(1)$ would not be convertible to the type of the original term $\forall x:Type(1),Type(1)$. @@ -530,13 +549,14 @@ Formally, we can represent any {\em inductive definition\index{definition!induct \item $p$ determines the number of parameters of these inductive types. \end{itemize} These inductive definitions, together with global assumptions and global definitions, then form the global environment. -\vskip.5em + \noindent Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$ such that each $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as: $\forall\Gamma_P, T^\prime$. -\vskip.5em + \noindent $\Gamma_P$ is called {\em context of parameters\index{context of parameters}}. +\begin{latexonly} \subsection*{Examples} If we take the following inductive definition (denoted in concrete syntax): @@ -547,35 +567,35 @@ Inductive bool : Set := \end{coq_example*} then: \def\colon{@{\hskip.5em:\hskip.5em}} -\def\GammaI{\left[\begin{array}{r \colon l} - \bool & \Set - \end{array} - \right]} -\def\GammaC{\left[\begin{array}{r \colon l} - \true & \bool\\ - \false & \bool - \end{array} - \right]} \newcommand\ind[3]{$\mathsf{Ind}~[#1]\left(\hskip-.4em \begin{array}{r @{\mathrm{~:=~}} l} #2 & #3 \\ \end{array} \hskip-.4em \right)$} -\begin{itemize} - \item $p = 0$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ -\end{itemize} -and thus it enriches the global environment with the following entry: -\vskip.5em -\ind{p}{\Gamma_I}{\Gamma_C} -\vskip.5em -\noindent that is: -\vskip.5em -\ind{0}{\GammaI}{\GammaC} -\vskip.5em -\noindent In this case, $\Gamma_P=[\,]$. + \def\GammaI{\left[\begin{array}{r \colon l} + \bool & \Set + \end{array} + \right]} + \def\GammaC{\left[\begin{array}{r \colon l} + \true & \bool\\ + \false & \bool + \end{array} + \right]} + \begin{itemize} + \item $p = 0$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ + \end{itemize} + and thus it enriches the global environment with the following entry: + \vskip.5em + \ind{p}{\Gamma_I}{\Gamma_C} + \vskip.5em + \noindent that is: + \vskip.5em + \ind{0}{\GammaI}{\GammaC} + \vskip.5em + \noindent In this case, $\Gamma_P=[\,]$. \vskip1em\hrule\vskip1em @@ -608,7 +628,7 @@ and thus it enriches the global environment with the following entry: \vskip.5em \ind{0}{\GammaI}{\GammaC} \vskip.5em -\noindent In this case, $\Gamma_P=[\,]$. +\noindent In this case, $\Gamma_P=[~]$. \vskip1em\hrule\vskip1em @@ -750,6 +770,7 @@ and thus it enriches the global environment with the following entry: \ind{0}{\GammaI}{\GammaC} \vskip.5em \noindent In this case, $\Gamma_P=[\,]$. +\end{latexonly} \subsection{Types of inductive objects} We have to give the type of constants in a global environment $E$ which @@ -762,6 +783,7 @@ contains an inductive declaration. \inference{\frac{\WFE{\Gamma}\hskip2em\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E\hskip2em(c:C)\in\Gamma_C}{\WTEG{c}{C}}} \end{description} +\begin{latexonly} \paragraph{Example.} Provided that our environment $E$ contains inductive definitions we showed before, these two inference rules above enable us to conclude that: @@ -774,6 +796,7 @@ $\begin{array}{@{} l} \prefix\evenS : \forall~n:\nat, \odd~n \ra \even~(\nS~n)\\ \prefix\oddS : \forall~n:\nat, \even~n \ra \odd~(\nS~n) \end{array}$ +\end{latexonly} %\paragraph{Parameters.} %%The parameters introduce a distortion between the inside specification @@ -880,6 +903,7 @@ any $u_i$ the type $V$ satisfies the nested positivity condition for $X$ \end{itemize} +\begin{latexonly} \newcommand\vv{\textSFxi} % │ \newcommand\hh{\textSFx} % ─ \newcommand\vh{\textSFviii} % ├ @@ -942,6 +966,7 @@ the type $V$ satisfies the nested positivity condition for $X$ \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\ws $X$ occurs only strictly positively in $\ListA$\ruleref3\\ \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 +\end{latexonly} \paragraph{Correctness rules.} We shall now describe the rules allowing the introduction of a new -- cgit v1.2.3 From 70e705a47f435e1453d889177a426d89dacda07b Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 18:54:17 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 00ba0091ee..1013084702 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -969,6 +969,10 @@ the type $V$ satisfies the nested positivity condition for $X$ \end{latexonly} \paragraph{Correctness rules.} +% QUESTION: For a related problem, in case of global definitions +% and global assumptions, we used the term "well-formedness". +% Couldn't we continue to use the term also here? +% Does it make sense to use a different name, i.e. "correctness" in this case? We shall now describe the rules allowing the introduction of a new inductive definition. -- cgit v1.2.3 From 1200468d82136ab3279bbe18da8fa0ba4e4cc8c4 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 19:23:40 +0100 Subject: FIX: removing a reference to \Gamma, because it is undefined --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 1013084702..51a0068b03 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -994,7 +994,7 @@ provided that the following side conditions hold: \item $p$ is the number of parameters of \NInd{}{\Gamma_I}{\Gamma_C} and $\Gamma_P$ is the context of parameters, \item for $j=1\ldots k$ we have that $A_j$ is an arity of sort $s_j$ and $I_j - \notin \Gamma \cup E$, + \notin E$, \item for $i=1\ldots n$ we have that $C_i$ is a type of constructor of $I_{q_i}$ which satisfies the positivity condition for $I_1 \ldots I_k$ and $c_i \notin \Gamma \cup E$. -- cgit v1.2.3 From d62af5e39af63387f60dd0a92d9fbfd65974fcae Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 19:24:41 +0100 Subject: COMMENT: to do --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 51a0068b03..bacd62b776 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -999,6 +999,7 @@ provided that the following side conditions hold: $I_{q_i}$ which satisfies the positivity condition for $I_1 \ldots I_k$ and $c_i \notin \Gamma \cup E$. \end{itemize} +% TODO: justify the above constraints \end{description} One can remark that there is a constraint between the sort of the arity of the inductive type and the sort of the type of its -- cgit v1.2.3 From 2b7368ae43fefb6f151b7032b351f0da796f6cc3 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 19:26:26 +0100 Subject: COMMENT: to do --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index bacd62b776..ddd9f075ef 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1024,6 +1024,7 @@ The same definition on \Set{} is not allowed and fails: Fail Inductive exSet (P:Set->Prop) : Set := exS_intro : forall X:Set, P X -> exSet P. \end{coq_example} +% TODO: add the description of the 'Fail' command to the reference manual It is possible to declare the same inductive definition in the universe \Type. The \texttt{exType} inductive definition has type $(\Type_i \ra\Prop)\ra -- cgit v1.2.3 From 5edfac63b6feb0b8d6ddad47a4ca9c8b5905b03a Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 19:31:05 +0100 Subject: COMMENT: questions --- doc/refman/RefMan-cic.tex | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index ddd9f075ef..b862db3204 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1910,7 +1910,36 @@ impredicative system for sort \Set{} become: {\compat{I:\Set}{I\ra s}}} \end{description} +% QUESTION: Why, when I add this definition: +% +% Inductive foo : Type := . +% +% Coq claims that the type of 'foo' is 'Prop'? + +% QUESTION: If I add this definition: +% +% Inductive bar (A:Type) : Type := . +% +% then Coq claims that 'bar' has type 'Type → Prop' where I would expect 'Type → Type' with appropriate constraint. +% QUESTION: If I add this definition: +% +% Inductive foo (A:Type) : Type := +% | foo1 : foo A +% | foo2 : foo A. +% +% then Coq claims that 'foo' has type 'Type → Set'. +% Why? + +% NOTE: If I add this definition: +% +% Inductive foo (A:Type) : Type := +% | foo1 : foo A +% | foo2 : A → foo A. +% +% then Coq claims, as expected, that: +% +% foo : Type → Type. %%% Local Variables: %%% mode: latex -- cgit v1.2.3 From 760765859cb74930ac8fd14fc1a241aa8ae20aa0 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 19:41:25 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index b862db3204..9e49481e23 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1007,6 +1007,7 @@ constructors which will always be satisfied for the impredicative sort {\Prop} but may fail to define inductive definition on sort \Set{} and generate constraints between universes for inductive definitions in the {\Type} hierarchy. +% QUESTION: which 'constraint' are we above referring to? \paragraph{Examples.} It is well known that existential quantifier can be encoded as an -- cgit v1.2.3 From 1a51c868d6f342c094f2d9f0b8101d6c13720537 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 4 Nov 2015 19:48:18 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 9e49481e23..adaa20de86 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1044,6 +1044,7 @@ Inductive exType (P:Type->Prop) : Type Inductive types declared in {\Type} are polymorphic over their arguments in {\Type}. +% QUESTION: Just arguments? Not also over the parameters? If $A$ is an arity of some sort and $s$ is a sort, we write $A_{/s}$ for the arity obtained from $A$ by replacing its sort with $s$. Especially, if $A$ -- cgit v1.2.3 From 90ae0897e80106194795e179d580da0d1118aaf2 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 09:14:23 +0100 Subject: CLEANUP PROPOSITION: s/local context of parameters/context of parameters --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index adaa20de86..6f0e952ce6 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1055,7 +1055,7 @@ The following typing rule is added to the theory. \begin{description} \item[Ind-Family] Let $\Ind{}{p}{\Gamma_I}{\Gamma_C}$ be an inductive definition. Let $\Gamma_P = [p_1:P_1;\ldots;p_{p}:P_{p}]$ - be its local context of parameters, $\Gamma_I = [I_1:\forall + be its context of parameters, $\Gamma_I = [I_1:\forall \Gamma_P,A_1;\ldots;I_k:\forall \Gamma_P,A_k]$ its context of definitions and $\Gamma_C = [c_1:\forall \Gamma_P,C_1;\ldots;c_n:\forall \Gamma_P,C_n]$ its context of -- cgit v1.2.3 From 02b64e2d6c69996f95fa7bbcaf228e4848ad69f4 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 10:09:01 +0100 Subject: CLEANUP PROPOSITION: superfluous parentheses were removed --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 6f0e952ce6..a5832450ce 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1079,7 +1079,7 @@ The following typing rule is added to the theory. 1 \leq j \leq k \end{array} \right.} -{E[] \vdash (I_j\,q_1\,\ldots\,q_r:\forall [p_{r+1}:P_{r+1};\ldots;p_{p}:P_{p}], (A_j)_{/s_j})} +{E[] \vdash I_j\,q_1\,\ldots\,q_r:\forall [p_{r+1}:P_{r+1};\ldots;p_{p}:P_{p}], (A_j)_{/s_j}} } provided that the following side conditions hold: -- cgit v1.2.3 From a90487b5b377c1eadcc4bbb373ad489b4d236a7f Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 10:43:04 +0100 Subject: GRAMMAR --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index a5832450ce..14a5e12fc5 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1160,7 +1160,7 @@ hence, if \texttt{option} is applied to a type in {\Set}, the result is in {\Set}. Note that if \texttt{option} is applied to a type in {\Prop}, then, the result is not set in \texttt{Prop} but in \texttt{Set} still. This is because \texttt{option} is not a singleton type (see -section~\ref{singleton}) and it would loose the elimination to {\Set} and +section~\ref{singleton}) and it would lose the elimination to {\Set} and {\Type} if set in {\Prop}. \begin{coq_example} -- cgit v1.2.3 From 2a5edc8ab15e556c6ee1741ffefb6869736feada Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 13:09:32 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 14a5e12fc5..ea1be67ee9 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1094,6 +1094,7 @@ $P_l$ arity implies $P'_l$ arity since $\WTEGLECONV{P'_l}{ \subst{P_l}{p_u}{q_u} we have $(\WTE{\Gamma_{I'};\Gamma_{P'}}{C_i}{s_{q_i}})_{i=1\ldots n}$; \item the sorts are such that all eliminations, to {\Prop}, {\Set} and $\Type(j)$, are allowed (see section~\ref{elimdep}). +% QUESTION: How should I interpret the above side-condition, when I am trying to show that 'list nat : Set'? \end{itemize} \end{description} -- cgit v1.2.3 From 3600dbb0546a910cda3996b5226bd7a6800d3040 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 13:46:40 +0100 Subject: TYPESETTING --- doc/refman/RefMan-cic.tex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index ea1be67ee9..001ce54f8c 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -962,10 +962,10 @@ the type $V$ satisfies the nested positivity condition for $X$ \ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $A$\ruleref3\\ \ws\ws\ws\ws\ws\ws\ws\ws\vv\\ \ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA\ra\ListA$\ruleref8\\ -\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\ws $X$ occurs only strictly positively in $\ListA$\ruleref3\\ -\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 +\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\ListA$\ruleref3\\ +\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ +\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 \end{latexonly} \paragraph{Correctness rules.} -- cgit v1.2.3 From cd60731dae4e7627588027fe1c1aa60a2ae44594 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 14:09:54 +0100 Subject: FIX: removing references to Γ which is not defined in a given context --- doc/refman/RefMan-cic.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 001ce54f8c..37ca23417d 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1075,7 +1075,7 @@ The following typing rule is added to the theory. {\left\{\begin{array}{l} \Ind{}{p}{\Gamma_I}{\Gamma_C} \in E\\ (E[] \vdash q_l : P'_l)_{l=1\ldots r}\\ -(\WTEGLECONV{P'_l}{\subst{P_l}{p_u}{q_u}_{u=1\ldots l-1}})_{l=1\ldots r}\\ +(\WTELECONV{}{P'_l}{\subst{P_l}{p_u}{q_u}_{u=1\ldots l-1}})_{l=1\ldots r}\\ 1 \leq j \leq k \end{array} \right.} @@ -1087,7 +1087,7 @@ provided that the following side conditions hold: \begin{itemize} \item $\Gamma_{P'}$ is the context obtained from $\Gamma_P$ by replacing each $P_l$ that is an arity with $P'_l$ for $1\leq l \leq r$ (notice that -$P_l$ arity implies $P'_l$ arity since $\WTEGLECONV{P'_l}{ \subst{P_l}{p_u}{q_u}_{u=1\ldots l-1}}$); +$P_l$ arity implies $P'_l$ arity since $\WTELECONV{}{P'_l}{ \subst{P_l}{p_u}{q_u}_{u=1\ldots l-1}}$); \item there are sorts $s_i$, for $1 \leq i \leq k$ such that, for $\Gamma_{I'} = [I_1:\forall \Gamma_{P'},(A_1)_{/s_1};\ldots;I_k:\forall \Gamma_{P'},(A_k)_{/s_k}]$ -- cgit v1.2.3 From 763723a144877582b9a5013b1c32a64de8e27db5 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 14:45:06 +0100 Subject: COMMENT: questions and to do --- doc/refman/RefMan-cic.tex | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 37ca23417d..1781d96fe5 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1098,6 +1098,8 @@ we have $(\WTE{\Gamma_{I'};\Gamma_{P'}}{C_i}{s_{q_i}})_{i=1\ldots n}$; \end{itemize} \end{description} +% QUESTION: Do we need the following paragraph? +% (I find it confusing.) Notice that if $I_j\,q_1\,\ldots\,q_r$ is typable using the rules {\bf Ind-Const} and {\bf App}, then it is typable using the rule {\bf Ind-Family}. Conversely, the extended theory is not stronger than the @@ -1206,6 +1208,8 @@ Because we need to keep a consistent theory and also we prefer to keep a strongly normalizing reduction, we cannot accept any sort of recursion (even terminating). So the basic idea is to restrict ourselves to primitive recursive functions and functionals. +% TODO: it may be worthwhile to show the consequences of lifting +% those restrictions. For instance, assuming a parameter $A:\Set$ exists in the local context, we want to build a function \length\ of type $\ListA\ra \nat$ which @@ -1925,6 +1929,14 @@ impredicative system for sort \Set{} become: % % then Coq claims that 'bar' has type 'Type → Prop' where I would expect 'Type → Type' with appropriate constraint. +% QUESTION: If I add this definition: +% +% Inductive foo (A:Type) : Type := +% | foo1 : foo A +% +% then Coq claims that 'foo' has type 'Type → Prop'. +% Why? + % QUESTION: If I add this definition: % % Inductive foo (A:Type) : Type := -- cgit v1.2.3 From 5d32732cdf110e44a51cf6a23a8972f015e3fc88 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 15:05:47 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 1781d96fe5..9e5f18f52a 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1258,6 +1258,11 @@ But this operator is rather tedious to implement and use. We choose in this version of {\Coq} to factorize the operator for primitive recursion into two more primitive operations as was first suggested by Th. Coquand in~\cite{Coq92}. One is the definition by pattern-matching. The second one is a definition by guarded fixpoints. +% QUESTION: Shouldn't we, instead, include a more straightforward argument: +% +% http://matej-kosik.github.io/www/doc/coq/notes/24__match_and_fix.html +% +% ? \subsubsection[The {\tt match\ldots with \ldots end} construction.]{The {\tt match\ldots with \ldots end} construction.\label{Caseexpr} \index{match@{\tt match\ldots with\ldots end}}} -- cgit v1.2.3 From d95fd157ac6600f4784de44ef558c4880aed624b Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 15:25:50 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 9e5f18f52a..f69b402783 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1246,6 +1246,11 @@ same as proving: $(\haslengthA~(\Nil~A)~\nO)$ and $\forall a:A, \forall l:\ListA, (\haslengthA~l~(\length~l)) \ra (\haslengthA~(\cons~A~a~l)~(\nS~(\length~l)))$. +% QUESTION: Wouldn't something like: +% +% http://matej-kosik.github.io/www/doc/coq/notes/25__has_length.html +% +% be more comprehensible? One conceptually simple way to do that, following the basic scheme proposed by Martin-L\"of in his Intuitionistic Type Theory, is to -- cgit v1.2.3 From 0ad9953cfacda53dea9b08f3b5b60ee5531b0850 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 15:42:17 +0100 Subject: CLEANUP: removing duplicate paragraph --- doc/refman/RefMan-cic.tex | 6 ------ 1 file changed, 6 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index f69b402783..bea0079a5c 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1272,12 +1272,6 @@ in~\cite{Coq92}. One is the definition by pattern-matching. The second one is a \subsubsection[The {\tt match\ldots with \ldots end} construction.]{The {\tt match\ldots with \ldots end} construction.\label{Caseexpr} \index{match@{\tt match\ldots with\ldots end}}} -The basic idea of this operator is that we have an object -$m$ in an inductive type $I$ and we want to prove a property -which possibly depends on $m$. For this, it is enough to prove the -property for $m = (c_i~u_1\ldots u_{p_i})$ for each constructor of $I$. - - The basic idea of this operator is that we have an object $m$ in an inductive type $I$ and we want to prove a property which possibly depends on $m$. For this, it is enough to prove the -- cgit v1.2.3 From 42039fff68ea24ad3fff58d17d79195faa0ee3e7 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 15:46:06 +0100 Subject: FIX: "u_p" was not defined --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index bea0079a5c..34f55fa004 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1284,7 +1284,7 @@ In this expression, if $m$ eventually happens to evaluate to $(c_i~u_1\ldots u_{p_i})$ then the expression will behave as specified in its $i$-th branch and it will reduce to $f_i$ where the $x_{i1}$\ldots $x_{ip_i}$ are replaced -by the $u_1\ldots u_p$ according to the $\iota$-reduction. +by the $u_1\ldots u_{p_i}$ according to the $\iota$-reduction. Actually, for type-checking a \kw{match\ldots with\ldots end} expression we also need to know the predicate $P$ to be proved by case -- cgit v1.2.3 From 435c8b0fdf3c01d2618d1ffbbfe2321250326420 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:01:00 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 34f55fa004..148c4505c0 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1306,7 +1306,23 @@ The \kw{in} part can be omitted if the result type does not depend on the arguments of $I$. Note that the arguments of $I$ corresponding to parameters \emph{must} be \verb!_!, because the result type is not generalized to -all possible values of the parameters. The other arguments of $I$ +all possible values of the parameters. +% QUESTION: The last sentence above does not seem to be accurate. +% +% Imagine: +% +% Definition foo (A:Type) (a:A) (l : list A) := +% match l return A with +% | nil => a +% | cons _ _ _ => a +% end. +% +% There, the term in the return-clause happily refer to the parameter of 'l' +% and Coq does not protest. +% +% So I am not sure if I really understand why parameters cannot be bound +% in as-clause. +The other arguments of $I$ (sometimes called indices in the litterature) have to be variables ($a$ above) and these variables can occur in $P$ and bound in it. The expression after \kw{in} -- cgit v1.2.3 From 7028d08eb6e08d1a1af7f8e99f2e9edd880b8da2 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:04:59 +0100 Subject: ENH: improving precision --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 148c4505c0..f6e9152ca2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1295,7 +1295,7 @@ one corresponds to object $m$. \Coq{} can sometimes infer this predicate but sometimes not. The concrete syntax for describing this predicate uses the \kw{as\ldots in\ldots return} construction. For instance, let us assume that $I$ is an unary predicate with one -parameter. The predicate is made explicit using the syntax: +parameter and one argument. The predicate is made explicit using the syntax: \[\kw{match}~m~\kw{as}~ x~ \kw{in}~ I~\verb!_!~a~ \kw{return}~ P ~\kw{with}~ (c_1~x_{11}~...~x_{1p_1}) \Ra f_1 ~|~\ldots~|~ (c_n~x_{n1}~...~x_{np_n}) \Ra f_n \kw{end}\] -- cgit v1.2.3 From 3ecbc485d8e00a14aa643a34a448289d0014c7a8 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:08:47 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index f6e9152ca2..dee31cf86d 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1323,7 +1323,9 @@ all possible values of the parameters. % So I am not sure if I really understand why parameters cannot be bound % in as-clause. The other arguments of $I$ -(sometimes called indices in the litterature) have to be variables +(sometimes called indices in the litterature) +% QUESTION: in which literature? +have to be variables ($a$ above) and these variables can occur in $P$ and bound in it. The expression after \kw{in} must be seen as an \emph{inductive type pattern}. Notice that -- cgit v1.2.3 From 62005786bdb2e117442230c99ed8922e2c6eed81 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:08:55 +0100 Subject: GRAMMAR --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index dee31cf86d..2c1aedc407 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1323,7 +1323,7 @@ all possible values of the parameters. % So I am not sure if I really understand why parameters cannot be bound % in as-clause. The other arguments of $I$ -(sometimes called indices in the litterature) +(sometimes called indices in the literature) % QUESTION: in which literature? have to be variables ($a$ above) and these variables can occur in $P$ and bound in it. -- cgit v1.2.3 From 740d35edcb1caf599dfbb956efd0f10aa310b5ae Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:10:26 +0100 Subject: CLEANUP: unnecessary --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 2c1aedc407..b3a9925b97 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1326,7 +1326,7 @@ The other arguments of $I$ (sometimes called indices in the literature) % QUESTION: in which literature? have to be variables -($a$ above) and these variables can occur in $P$ and bound in it. +($a$ above) and these variables can occur in $P$. The expression after \kw{in} must be seen as an \emph{inductive type pattern}. Notice that expansion of implicit arguments and notations apply to this pattern. -- cgit v1.2.3 From 4e8a02a38635cb33ecee78736a2661d169d52046 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:18:27 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index b3a9925b97..c54481e874 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1373,6 +1373,9 @@ We define now a relation \compat{I:A}{B} between an inductive definition $I$ of type $A$ and an arity $B$. This relation states that an object in the inductive definition $I$ can be eliminated for proving a property $\lb a x \mto P$ of type $B$. +% QUESTION: Is it necessary to explain the meaning of [I:A|B] in such a complicated way? +% Couldn't we just say that: "relation [I:A|B] defines which types can we choose as 'result types' +% with respect to the type of the matched object". The case of inductive definitions in sorts \Set\ or \Type{} is simple. There is no restriction on the sort of the predicate to be -- cgit v1.2.3 From d139d73949ee7ab6c070cac98f1af23431967ab0 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:21:56 +0100 Subject: ENH: a forward reference to a place where the concept of "allowed elimination sorts" is actually used --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index c54481e874..49e1649316 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1376,6 +1376,7 @@ proving a property $\lb a x \mto P$ of type $B$. % QUESTION: Is it necessary to explain the meaning of [I:A|B] in such a complicated way? % Couldn't we just say that: "relation [I:A|B] defines which types can we choose as 'result types' % with respect to the type of the matched object". +We use this concept to formulate the hypothesis of the typing rule for the match-construct. The case of inductive definitions in sorts \Set\ or \Type{} is simple. There is no restriction on the sort of the predicate to be -- cgit v1.2.3 From bce5332773276bca755dd47608dd13ae09016ded Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:29:48 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 49e1649316..9cb52dba28 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1395,6 +1395,8 @@ $I$. s_1 \in \{\Set,\Type(j)\}, s_2 \in \Sort}{\compat{I:s_1}{I\ra s_2}}} \end{description} +% QUESTION: What kind of value is represented by "x" in the "numerator"? +% There, "x" is unbound. Isn't it? The case of Inductive definitions of sort \Prop{} is a bit more complicated, because of our interpretation of this sort. The only -- cgit v1.2.3 From 55fee343ecbb6e510aa9c2729627fe7a758f384b Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:31:57 +0100 Subject: CLEANUP: originally, we talked about "B" as an "arity" --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 9cb52dba28..5a8dcfc245 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1372,7 +1372,7 @@ definitions. We define now a relation \compat{I:A}{B} between an inductive definition $I$ of type $A$ and an arity $B$. This relation states that an object in the inductive definition $I$ can be eliminated for -proving a property $\lb a x \mto P$ of type $B$. +proving a property $\lb a x \mto P$ of arity $B$. % QUESTION: Is it necessary to explain the meaning of [I:A|B] in such a complicated way? % Couldn't we just say that: "relation [I:A|B] defines which types can we choose as 'result types' % with respect to the type of the matched object". -- cgit v1.2.3 From 1caa0c61b7dfd535d4b2026e83933746de19291a Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:42:26 +0100 Subject: TYPOGRAPHY --- doc/refman/RefMan-cic.tex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 5a8dcfc245..79756eb2fd 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1392,8 +1392,7 @@ $I$. \item[Prod] \inference{\frac{\compat{(I~x):A'}{B'}} {\compat{I:\forall x:A, A'}{\forall x:A, B'}}} \item[{\Set} \& \Type] \inference{\frac{ - s_1 \in \{\Set,\Type(j)\}, - s_2 \in \Sort}{\compat{I:s_1}{I\ra s_2}}} + s_1 \in \{\Set,\Type(j)\}~~~~~~~~s_2 \in \Sort}{\compat{I:s_1}{I\ra s_2}}} \end{description} % QUESTION: What kind of value is represented by "x" in the "numerator"? % There, "x" is unbound. Isn't it? -- cgit v1.2.3 From f427a920e6fa31b145578c53d8853266cd215a26 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 16:43:58 +0100 Subject: COMMENT: note --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 79756eb2fd..7c38a54ea6 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1396,6 +1396,7 @@ $I$. \end{description} % QUESTION: What kind of value is represented by "x" in the "numerator"? % There, "x" is unbound. Isn't it? +% NOTE: Above, "Set" is subsumed in "Type(0)" so, strictly speaking, we wouldn't need to mention in explicitely. The case of Inductive definitions of sort \Prop{} is a bit more complicated, because of our interpretation of this sort. The only -- cgit v1.2.3 From 6a54c04d60038fbf5b617ee76bb59216ff4038d4 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 17:20:23 +0100 Subject: GRAMMAR --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 7c38a54ea6..611782b4f6 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1450,7 +1450,7 @@ a logical property of a computational object. In the same spirit, elimination on $P$ of type $I\ra \Type$ cannot be allowed because it trivially implies the elimination on $P$ of type $I\ra \Set$ by cumulativity. It also implies that there -is two proofs of the same property which are provably different, +are two proofs of the same property which are provably different, contradicting the proof-irrelevance property which is sometimes a useful axiom: \begin{coq_example} -- cgit v1.2.3 From c3973cc972cd1474fb4bad308197d64634a518dc Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 17:23:45 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 611782b4f6..9e11d66ab5 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1464,6 +1464,7 @@ predicate $P$ of type $I\ra \Type$ leads to a paradox when applied to impredicative inductive definition like the second-order existential quantifier \texttt{exProp} defined above, because it give access to the two projections on this type. +% QUESTION: I did not get the point of the paragraph above. %\paragraph{Warning: strong elimination} %\index{Elimination!Strong elimination} -- cgit v1.2.3 From 0e7a91379a49be9874ce1669f3058fa0ae1194bb Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 5 Nov 2015 19:33:33 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 9e11d66ab5..6cd84cfc6e 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1396,6 +1396,10 @@ $I$. \end{description} % QUESTION: What kind of value is represented by "x" in the "numerator"? % There, "x" is unbound. Isn't it? +% The rule does not fully justify the following (plausible) argument: +% +% http://matej-kosik.github.io/www/doc/coq/notes/26__allowed_elimination_sorts.html +% % NOTE: Above, "Set" is subsumed in "Type(0)" so, strictly speaking, we wouldn't need to mention in explicitely. The case of Inductive definitions of sort \Prop{} is a bit more -- cgit v1.2.3 From c372f60433da664431a394153eaf8dbcd6f15f07 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 11:38:51 +0100 Subject: CLEANUP: removing a superfluous index --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 6cd84cfc6e..23d86cbbc1 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1524,7 +1524,7 @@ We define a new type \CI{c:C}{P} which represents the type of the branch corresponding to the $c:C$ constructor. \[ \begin{array}{ll} -\CI{c:(I_i~p_1\ldots p_r\ t_1 \ldots t_p)}{P} &\equiv (P~t_1\ldots ~t_p~c) \\[2mm] +\CI{c:(I~p_1\ldots p_r\ t_1 \ldots t_p)}{P} &\equiv (P~t_1\ldots ~t_p~c) \\[2mm] \CI{c:\forall~x:T,C}{P} &\equiv \forall~x:T,\CI{(c~x):C}{P} \end{array} \] -- cgit v1.2.3 From 4ac0855b28c2e266f4fe2646a00754d907c3e6b3 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 13:20:17 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 23d86cbbc1..db80d79109 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1514,6 +1514,59 @@ Extraction eq_rec. An empty definition has no constructors, in that case also, elimination on any sort is allowed. +% QUESTION: +% +% In Coq, this works: +% +% Check match 42 as x return match x with +% | O => nat +% | _ => bool +% end +% with +% | O => 42 +% | _ => true +% end. +% +% Also this works: +% +% Check let foo := 42 in +% match foo return match foo with +% | O => nat +% | _ => bool +% end +% with +% | O => 42 +% | _ => true +% end. +% +% But here: +% +% Definition foo := 42. +% Check match foo return match foo with +% | O => nat +% | _ => bool +% end +% with +% | O => 42 +% | _ => true +% end. +% +% Coq complains: +% +% Error: +% The term "42" has type "nat" while it is expected to have type +% "match foo with +% | 0 => nat +% | S _ => bool +% end". +% +% However, the Reference Manual says that: +% +% "Remark that when the term being matched is a variable, the as clause can +% be omitted and the term being matched can serve itself as binding name in the return type." +% +% so I do not understand why, in this case, Coq produces a given error message. + \paragraph{Type of branches.} Let $c$ be a term of type $C$, we assume $C$ is a type of constructor for an inductive definition $I$. Let $P$ be a term that represents the -- cgit v1.2.3 From 8efc7854332a3376a0e7ec348545cff83829a70e Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 14:36:38 +0100 Subject: CLEANUP: We decided to call these guys E[Γ] ⊢ (Γi := Γc) as inductive definition. --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index db80d79109..1cb0a7318e 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1622,7 +1622,7 @@ following typing rule (\WTEG{f_i}{\CI{(c_{p_i}~q_1\ldots q_r)}{P}})_{i=1\ldots l}} {\WTEG{\Case{P}{c}{f_1|\ldots |f_l}}{(P\ t_1\ldots t_s\ c)}}}%\\[3mm] -provided $I$ is an inductive type in a declaration +provided $I$ is an inductive type in a definition \Ind{}{r}{\Gamma_I}{\Gamma_C} with $\Gamma_C = [c_1:C_1;\ldots;c_n:C_n]$ and $c_{p_1}\ldots c_{p_l}$ are the only constructors of $I$. -- cgit v1.2.3 From 38fc8566ab59bcf67e6eeaf5860ce97cfab38e74 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 15:09:34 +0100 Subject: CLEANUP PROPOSITION: does it make sense to refer to 'I' as 'inductive definition'? Doesn't make more sense to refer to it as 'inductive type'? --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 1cb0a7318e..87ef046fa4 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1569,7 +1569,7 @@ elimination on any sort is allowed. \paragraph{Type of branches.} Let $c$ be a term of type $C$, we assume $C$ is a type of constructor -for an inductive definition $I$. Let $P$ be a term that represents the +for an inductive type $I$. Let $P$ be a term that represents the property to be proved. We assume $r$ is the number of parameters. -- cgit v1.2.3 From f7051cd4eb4cefc4b2ec04c8c29369dcaf0062f2 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 15:18:35 +0100 Subject: ENH: define the meaning of 'p' --- doc/refman/RefMan-cic.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 87ef046fa4..91c1418546 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1571,7 +1571,7 @@ elimination on any sort is allowed. Let $c$ be a term of type $C$, we assume $C$ is a type of constructor for an inductive type $I$. Let $P$ be a term that represents the property to be proved. -We assume $r$ is the number of parameters. +We assume $r$ is the number of parameters and $p$ is the number of arguments. We define a new type \CI{c:C}{P} which represents the type of the branch corresponding to the $c:C$ constructor. @@ -1584,7 +1584,7 @@ branch corresponding to the $c:C$ constructor. We write \CI{c}{P} for \CI{c:C}{P} with $C$ the type of $c$. \paragraph{Examples.} -For $\ListA$ the type of $P$ will be $\ListA\ra s$ for $s \in \Sort$. \\ +For $\List \nat$ the type of $P$ will be $\ListA\ra s$ for $s \in \Sort$. \\ $ \CI{(\cons~A)}{P} \equiv \forall a:A, \forall l:\ListA,(P~(\cons~A~a~l))$. -- cgit v1.2.3 From 56abd3ce281e3fd8f3df27597c6348d6ab033b64 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 16:58:22 +0100 Subject: ENH: existing example was expanded --- doc/refman/RefMan-cic.tex | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 91c1418546..d2bae76f61 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1584,9 +1584,12 @@ branch corresponding to the $c:C$ constructor. We write \CI{c}{P} for \CI{c:C}{P} with $C$ the type of $c$. \paragraph{Examples.} -For $\List \nat$ the type of $P$ will be $\ListA\ra s$ for $s \in \Sort$. \\ -$ \CI{(\cons~A)}{P} \equiv -\forall a:A, \forall l:\ListA,(P~(\cons~A~a~l))$. +For $\List~\nat$ the type of $P$ will be $\List~\nat\ra s$ for $s \in \Sort$. \\ +$ \CI{(\cons~\nat)}{P} + \equiv\CI{(\cons~\nat) : (\nat\ra\List~\nat\ra\List~\nat)}{P} \equiv\\ + \equiv\forall n:\nat, \CI{(\cons~\nat~n) : \List~\nat\ra\List~\nat)}{P} \equiv\\ + \equiv\forall n:\nat, \forall l:\List~\nat, \CI{(\cons~\nat~n~l) : \List~\nat)}{P} \equiv\\ +\equiv\forall n:\nat, \forall l:\List~\nat,(P~(\cons~\nat~n~l))$. For $\haslengthA$, the type of $P$ will be $\forall l:\ListA,\forall n:\nat, (\haslengthA~l~n)\ra \Prop$ and the expression -- cgit v1.2.3 From a388d599ba461cf35b40c3850d593f5e9bb71d3d Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 16:58:44 +0100 Subject: CLEANUP: Existing example was removed. We have expanded the example above. For consistency reasons, it would make sense to do the same also for this example. However, due to the size of the terms, it is hard to typeset it nicely. I propose to remove it. --- doc/refman/RefMan-cic.tex | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index d2bae76f61..87d6f1d28e 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1591,16 +1591,6 @@ $ \CI{(\cons~\nat)}{P} \equiv\forall n:\nat, \forall l:\List~\nat, \CI{(\cons~\nat~n~l) : \List~\nat)}{P} \equiv\\ \equiv\forall n:\nat, \forall l:\List~\nat,(P~(\cons~\nat~n~l))$. -For $\haslengthA$, the type of $P$ will be -$\forall l:\ListA,\forall n:\nat, (\haslengthA~l~n)\ra \Prop$ and the expression -\CI{(\conshl~A)}{P} is defined as:\\ -$\forall a:A, \forall l:\ListA, \forall n:\nat, \forall -h:(\haslengthA~l~n), (P~(\cons~A~a~l)~(\nS~n)~(\conshl~A~a~l~n~l))$.\\ -If $P$ does not depend on its third argument, we find the more natural -expression:\\ -$\forall a:A, \forall l:\ListA, \forall n:\nat, -(\haslengthA~l~n)\ra(P~(\cons~A~a~l)~(\nS~n))$. - \paragraph{Typing rule.} Our very general destructor for inductive definition enjoys the -- cgit v1.2.3 From 59b4ea72a6896e05c4b6094b10b9a294b0322e53 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 18:55:49 +0100 Subject: ENH: an existing example was further expanded. --- doc/refman/RefMan-cic.tex | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 87d6f1d28e..edf7840fdd 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1583,13 +1583,42 @@ branch corresponding to the $c:C$ constructor. \] We write \CI{c}{P} for \CI{c:C}{P} with $C$ the type of $c$. -\paragraph{Examples.} -For $\List~\nat$ the type of $P$ will be $\List~\nat\ra s$ for $s \in \Sort$. \\ +\paragraph{Example.} +The following term in concrete syntax: +\begin{verbatim} +match t as l return P' with +| nil _ => t1 +| cons _ hd tl => t2 +end +\end{verbatim} +can be represented in abstract syntax as $$\Case{P}{t}{f_1\,|\,f_2}$$ +where +\begin{eqnarray*} + P & = & \lambda~l~.~P^\prime\\ + f_1 & = & t_1\\ + f_2 & = & \lambda~(hd:\nat)~.~\lambda~(tl:\List~\nat)~.~t_2 +\end{eqnarray*} +According to the definition: +\begin{latexonly}\vskip.5em\noindent\end{latexonly}% +\begin{htmlonly} + +\end{htmlonly} +$ \CI{(\Nil~\nat)}{P} \equiv \CI{(\Nil~\nat) : (\List~\nat)}{P} \equiv (P~(\Nil~\nat))$ +\begin{latexonly}\vskip.5em\noindent\end{latexonly}% +\begin{htmlonly} + +\end{htmlonly} $ \CI{(\cons~\nat)}{P} \equiv\CI{(\cons~\nat) : (\nat\ra\List~\nat\ra\List~\nat)}{P} \equiv\\ \equiv\forall n:\nat, \CI{(\cons~\nat~n) : \List~\nat\ra\List~\nat)}{P} \equiv\\ \equiv\forall n:\nat, \forall l:\List~\nat, \CI{(\cons~\nat~n~l) : \List~\nat)}{P} \equiv\\ \equiv\forall n:\nat, \forall l:\List~\nat,(P~(\cons~\nat~n~l))$. +\begin{latexonly}\vskip.5em\noindent\end{latexonly}% +\begin{htmlonly} + +\end{htmlonly} +Given some $P$, then \CI{(\Nil~\nat)}{P} represents the expected type of $f_1$, and +\CI{(\cons~\nat)}{P} represents the expected type of $f_2$. \paragraph{Typing rule.} -- cgit v1.2.3 From 793a5842cf7adeff60c380738a7d4bd3430e926a Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 19:49:05 +0100 Subject: ENH: existing example was changed so that it is now linked to the results shown in the previous example --- doc/refman/RefMan-cic.tex | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index edf7840fdd..d512df3b78 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1651,13 +1651,17 @@ only constructors of $I$. \end{description} \paragraph{Example.} -For \List\ and \haslength\ the typing rules for the {\tt match} expression -are (writing just $t:M$ instead of \WTEG{t}{M}, the global environment and -local context being the same in all the judgments). -\[\frac{l:\ListA~~P:\ListA\ra s~~~f_1:(P~(\Nil~A))~~ - f_2:\forall a:A, \forall l:\ListA, (P~(\cons~A~a~l))} - {\Case{P}{l}{f_1~|~f_2}:(P~l)}\] +Below is a typing rule for the term shown in the previous example: +\inference{ + \frac{% + \WTEG{t}{(\List~\nat)}~~~~% + \WTEG{P}{B}~~~~% + \compat{(\List~\nat)}{B}~~~~% + \WTEG{f_1}{\CI{(\Nil~\nat)}{P}}~~~~% + \WTEG{f_2}{\CI{(\cons~\nat)}{P}}% + } +{\WTEG{\Case{P}{t}{f_1|f_2}}{(P~t)}}} \[\frac{ \begin{array}[b]{@{}c@{}} -- cgit v1.2.3 From 07b9d5bc3c54e849b95f2b8dd223896e64614954 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Fri, 6 Nov 2015 19:50:08 +0100 Subject: CLEANUP PROPOSITION: existing example was removed because it is not urgently needed --- doc/refman/RefMan-cic.tex | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index d512df3b78..e5307ef1ec 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1663,16 +1663,6 @@ Below is a typing rule for the term shown in the previous example: } {\WTEG{\Case{P}{t}{f_1|f_2}}{(P~t)}}} -\[\frac{ - \begin{array}[b]{@{}c@{}} -H:(\haslengthA~L~N) \\ P:\forall l:\ListA, \forall n:\nat, (\haslengthA~l~n)\ra - \Prop\\ - f_1:(P~(\Nil~A)~\nO~\nilhl) \\ - f_2:\forall a:A, \forall l:\ListA, \forall n:\nat, \forall - h:(\haslengthA~l~n), (P~(\cons~A~a~n)~(\nS~n)~(\conshl~A~a~l~n~h)) - \end{array}} - {\Case{P}{H}{f_1~|~f_2}:(P~L~N~H)}\] - \paragraph[Definition of $\iota$-reduction.]{Definition of $\iota$-reduction.\label{iotared} \index{iota-reduction@$\iota$-reduction}} We still have to define the $\iota$-reduction in the general case. -- cgit v1.2.3 From 43816ce712054c07cb04452821570054aff3dc44 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 15:37:39 +0100 Subject: CLEANUP PROPOSITION: rephrasing the original idea in a simpler way --- doc/refman/RefMan-cic.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index e5307ef1ec..2a4ccfed87 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -242,7 +242,7 @@ either $x:T$ is an assumption in $\Gamma$ or that there exists some $t$ such that $x:=t:T$ is a definition in $\Gamma$. If $\Gamma$ defines some $x:=t:T$, we also write $(x:=t:T) \in \Gamma$. For the rest of the chapter, the -notation $\Gamma::(y:T)$ (resp. $\Gamma::(y:=t:T)$) denotes the local context +notation $\Gamma::(y:T)$ (resp.\ $\Gamma::(y:=t:T)$) denotes the local context $\Gamma$ enriched with the declaration $y:T$ (resp. $y:=t:T$). The notation $[]$ denotes the empty local context. @@ -1708,7 +1708,7 @@ The typing rule is the expected one for a fixpoint. \end{description} Any fixpoint definition cannot be accepted because non-normalizing terms -will lead to proofs of absurdity. +allow proofs of absurdity. The basic scheme of recursion that should be allowed is the one needed for defining primitive -- cgit v1.2.3 From 33c0d3b95bdf0ff1fdd2d6dbe7088e48c2fa6f67 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 16:01:27 +0100 Subject: GRAMMAR: added punctuation --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 2a4ccfed87..092dba46b4 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1738,7 +1738,7 @@ The first stage is to precise on which argument the fixpoint will be decreasing. The type of this argument should be an inductive definition. -For doing this the syntax of fixpoints is extended and becomes +For doing this, the syntax of fixpoints is extended and becomes \[\Fix{f_i}{f_1/k_1:A_1:=t_1 \ldots f_n/k_n:A_n:=t_n}\] where $k_i$ are positive integers. Each $A_i$ should be a type (reducible to a term) starting with at least -- cgit v1.2.3 From 2cb48a3fe5a8cd435e4e0ad6990e5ee5e6079fa5 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 16:17:44 +0100 Subject: COMMENT: to do --- doc/refman/RefMan-cic.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 092dba46b4..3d56dcac60 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1745,6 +1745,8 @@ Each $A_i$ should be a type (reducible to a term) starting with at least $k_i$ products $\forall y_1:B_1,\ldots \forall y_{k_i}:B_{k_i}, A'_i$ and $B_{k_i}$ being an instance of an inductive definition. +% TODO: We should probably define somewhere explicitely, what we mean by +% "x is an instance of an inductive type I". Now in the definition $t_i$, if $f_j$ occurs then it should be applied to at least $k_j$ arguments and the $k_j$-th argument should be -- cgit v1.2.3 From fc8e19c82a24fea551b47a99bb68f6f64fc16a01 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 17:30:07 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 3d56dcac60..8c8537cfb2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1747,6 +1747,8 @@ and $B_{k_i}$ being an instance of an inductive definition. % TODO: We should probably define somewhere explicitely, what we mean by % "x is an instance of an inductive type I". +% +% QUESTION: So, $k_i$ is the index of the argument on which $f_i$ is decreasing? Now in the definition $t_i$, if $f_j$ occurs then it should be applied to at least $k_j$ arguments and the $k_j$-th argument should be -- cgit v1.2.3 From 02be0f4e071c12800177eecdb067949dcce3b174 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 18:06:41 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 8c8537cfb2..1a17f3f35f 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1764,7 +1764,9 @@ $\forall p_1:P_1,\ldots \forall p_r:P_r, \forall x_1:T_1, \ldots \forall x_r:T_r, (I_j~p_1\ldots p_r~t_1\ldots t_s)$ the recursive arguments will correspond to $T_i$ in which one of the $I_l$ occurs. - +% QUESTION: The last sentence above really fully make sense. +% Isn't some word missing? +% Maybe "if"? The main rules for being structurally smaller are the following:\\ Given a variable $y$ of type an inductive -- cgit v1.2.3 From 0f97c5d4429e1f191b89125caa1ed652b0f19c79 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 18:08:01 +0100 Subject: TYPOGRAPHY --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 1a17f3f35f..66111fa708 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1776,7 +1776,7 @@ where $\Gamma_I$ is $[I_1:A_1;\ldots;I_k:A_k]$, and $\Gamma_C$ is $[c_1:C_1;\ldots;c_n:C_n]$. The terms structurally smaller than $y$ are: \begin{itemize} -\item $(t~u), \lb x:u \mto t$ when $t$ is structurally smaller than $y$ . +\item $(t~u)$ and $\lb x:u \mto t$ when $t$ is structurally smaller than $y$. \item \Case{P}{c}{f_1\ldots f_n} when each $f_i$ is structurally smaller than $y$. \\ If $c$ is $y$ or is structurally smaller than $y$, its type is an inductive -- cgit v1.2.3 From cbdceb06359e10a4cad7f9ec5a505d0afcd76677 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 18:22:59 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 66111fa708..3cb0b95700 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1782,6 +1782,7 @@ The terms structurally smaller than $y$ are: If $c$ is $y$ or is structurally smaller than $y$, its type is an inductive definition $I_p$ part of the inductive declaration corresponding to $y$. + % QUESTION: What does the above sentence mean? Each $f_i$ corresponds to a type of constructor $C_q \equiv \forall p_1:P_1,\ldots,\forall p_r:P_r, \forall y_1:B_1, \ldots \forall y_k:B_k, (I~a_1\ldots a_k)$ and can consequently be -- cgit v1.2.3 From 6d5a8e69517276d1d13275533aee9fceb42b9d13 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 18:26:59 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 3cb0b95700..736affe940 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1792,6 +1792,9 @@ The terms structurally smaller than $y$ are: in $g_i$ corresponding to recursive arguments $B_i$ (the ones in which one of the $I_l$ occurs) are structurally smaller than $y$. \end{itemize} +% QUESTION: How could one show, that some of the functions defined below are "guarded" +% in a sense of the definition given above. +% E.g., how could I show that "p" in "plus" below is structurally smaller than "n"? The following definitions are correct, we enter them using the {\tt Fixpoint} command as described in Section~\ref{Fixpoint} and show the internal representation. -- cgit v1.2.3 From 55fe005b2141a69ffd9589568f8b854075174d56 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 18:49:37 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 736affe940..29e4f256bb 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1858,6 +1858,7 @@ reflexivity. \begin{coq_eval} Abort. \end{coq_eval} +% QUESTION: What are we trying to say with the above examples? % La disparition de Program devrait rendre la construction Match obsolete % \subsubsection{The {\tt Match \ldots with \ldots end} expression} -- cgit v1.2.3 From 796c433f5da19511ddc5de3d2cbec878ac3d25fc Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Sat, 7 Nov 2015 23:59:30 +0100 Subject: COMMENT: question --- doc/refman/RefMan-cic.tex | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 29e4f256bb..39b7d4f156 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1828,6 +1828,7 @@ The reduction for fixpoints is: \[ (\Fix{f_i}{F}~a_1\ldots a_{k_i}) \triangleright_{\iota} \substs{t_i}{f_k}{\Fix{f_k}{F}}{k=1\ldots n} ~a_1\ldots a_{k_i}\] +% QUESTION: Is it wise to use \iota for twice with two different meanings? when $a_{k_i}$ starts with a constructor. This last restriction is needed in order to keep strong normalization and corresponds to the reduction for primitive recursive operators. -- cgit v1.2.3 From 67d0db55d55dd2c650a33f11794e8a6747fc518b Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 9 Nov 2015 16:33:12 +0100 Subject: DONE --- doc/refman/RefMan-cic.tex | 216 ++++------------------------------------------ 1 file changed, 16 insertions(+), 200 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 39b7d4f156..2f4016d71e 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -63,11 +63,6 @@ Their properties, such as: {\Prop:\Type$(1)$}, {\Set:\Type$(1)$}, and {\Type$(i)$:\Type$(i+1)$}, are defined in Section~\ref{subtyping-rules}. -% TODO: Somewhere in the document we should explain: -% - what concrete actions (in *.v files) cause creation of new universes -% - different kinds of relationships between universes (i.e. "max" and "succ") -% - what are all the actions (in *.v files) from which those relationships arise - The user does not have to mention explicitly the index $i$ when referring to the universe \Type$(i)$. One only writes \Type. The system itself generates for each instance of \Type\ a new @@ -94,17 +89,6 @@ constraints must remain acyclic. Typing expressions that violate the acyclicity of the graph of constraints results in a \errindex{Universe inconsistency} error (see also Section~\ref{PrintingUniverses}). -% TODO: The concept of 'universe inconsistency' deserves more attention. -% Somewhere in the document we should: -% - give concrete examples when universe inconsistency arises -% - explain why it arised -% - how can a user identify the "vicious cycle". - -% QUESTION: Is the presentation of universes as totally ordered a necessary or advantageous step? - -% QUESTION: Shouldn't the explanation of universes in this chapter -% be consolidatd with Chapter 29: Polymorphic Universes? - %% HH: This looks to me more like source of confusion than helpful %% \subsection{Constants} @@ -184,7 +168,6 @@ More precisely the language of the {\em Calculus of Inductive The notion of free variables is defined as usual. In the expressions $\lb x:T\mto U$ and $\forall x:T, U$ the occurrences of $x$ in $U$ are bound. -% TODO: what is the best play to say that "terms are considered equal up to α-conversion"? \paragraph[Substitution.]{Substitution.\index{Substitution}} The notion of substituting a term $t$ to free occurrences of a @@ -241,10 +224,11 @@ we write $x \in \Gamma$. By writing $(x:T) \in \Gamma$ we mean that either $x:T$ is an assumption in $\Gamma$ or that there exists some $t$ such that $x:=t:T$ is a definition in $\Gamma$. If $\Gamma$ defines some $x:=t:T$, we also write $(x:=t:T) \in \Gamma$. -For the rest of the chapter, the -notation $\Gamma::(y:T)$ (resp.\ $\Gamma::(y:=t:T)$) denotes the local context -$\Gamma$ enriched with the declaration $y:T$ (resp. $y:=t:T$). The -notation $[]$ denotes the empty local context. +For the rest of the chapter, the $\Gamma::(y:T)$ denotes the local context +$\Gamma$ enriched with the local assumption $y:T$. +Similarly, $\Gamma::(y:=t:T)$ denotes the local context +$\Gamma$ enriched with the local definition $(y:=t:T)$. +The notation $[]$ denotes the empty local context. % Does not seem to be used further... % Si dans l'explication WF(E)[Gamma] concernant les constantes @@ -305,23 +289,16 @@ local context $\Gamma$ and a term $T$ such that the judgment \WTEG{t}{T} can be derived from the following rules. \begin{description} \item[W-Empty] \inference{\WF{[]}{}} -% QUESTION: Why in W-Local-Assum and W-Local-Def we do not need x ∉ E hypothesis? \item[W-Local-Assum] % Ce n'est pas vrai : x peut apparaitre plusieurs fois dans Gamma \inference{\frac{\WTEG{T}{s}~~~~s \in \Sort~~~~x \not\in \Gamma % \cup E }{\WFE{\Gamma::(x:T)}}} \item[W-Local-Def] \inference{\frac{\WTEG{t}{T}~~~~x \not\in \Gamma % \cup E }{\WFE{\Gamma::(x:=t:T)}}} -% QUESTION: Why in W-Global-Assum and W-Global-Def we do not need x ∉ Γ hypothesis? \item[W-Global-Assum] \inference{\frac{\WTE{}{T}{s}~~~~s \in \Sort~~~~c \notin E} {\WF{E;c:T}{}}} \item[W-Global-Def] \inference{\frac{\WTE{}{t}{T}~~~c \notin E} {\WF{E;c:=t:T}{}}} -% QUESTION: Why, in case of W-Local-Assum and W-Global-Assum we need s ∈ S hypothesis. -% QUESTION: At the moment, enrichment of a local context is denoted with ∷ -% whereas enrichment of the global environment is denoted with ; -% Is it necessary to use two different notations? -% Couldn't we use ∷ also for enrichment of the global context? \item[Ax-Prop] \index{Typing rules!Ax-Prop} \inference{\frac{\WFE{\Gamma}}{\WTEG{\Prop}{\Type(1)}}} \item[Ax-Set] \index{Typing rules!Ax-Set} @@ -366,7 +343,6 @@ difference between {\Prop} and {\Set}: well-typed without having $((\lb x:T\mto u)~t)$ well-typed (where $T$ is a type of $t$). This is because the value $t$ associated to $x$ may be used in a conversion rule (see Section~\ref{conv-rules}). -% QUESTION: I do not understand. How would that be possible? \section[Conversion rules]{Conversion rules\index{Conversion rules} \label{conv-rules}} @@ -815,7 +791,6 @@ $\begin{array}{@{} l} \subsection{Well-formed inductive definitions} We cannot accept any inductive declaration because some of them lead to inconsistent systems. -% TODO: The statement above deserves explanation. We restrict ourselves to definitions which satisfy a syntactic criterion of positivity. Before giving the formal rules, we need a few definitions: @@ -843,9 +818,6 @@ in one of the following two cases: \item $T$ is $(I~t_1\ldots ~t_n)$ \item $T$ is $\forall x:U,T^\prime$ where $T^\prime$ is also a type of constructor of $I$ \end{itemize} -% QUESTION: Are we above sufficiently precise? -% Shouldn't we say also what is "n"? -% "n" couldn't be "0", could it? \paragraph[Examples]{Examples} $\nat$ and $\nat\ra\nat$ are types of constructors of $\nat$.\\ @@ -854,11 +826,9 @@ $\forall A:\Type,\List~A$ and $\forall A:\Type,A\ra\List~A\ra\List~A$ are constr \paragraph[Definition]{Definition\index{Positivity}\label{Positivity}} The type of constructor $T$ will be said to {\em satisfy the positivity condition} for a constant $X$ in the following cases: -% QUESTION: Why is this property called "positivity"? \begin{itemize} \item $T=(X~t_1\ldots ~t_n)$ and $X$ does not occur free in -% QUESTIONS: What is the meaning of 'n' above? any $t_i$ \item $T=\forall~x:U,V$ and $X$ occurs only strictly positively in $U$ and the type $V$ satisfies the positivity condition for $X$ @@ -870,12 +840,10 @@ following cases: \begin{itemize} \item $X$ does not occur in $T$ \item $T$ converts to $(X~t_1 \ldots ~t_n)$ and $X$ does not occur in -% QUESTIONS: What is the meaning of 'n' above? any of $t_i$ \item $T$ converts to $\forall~x:U,V$ and $X$ does not occur in type $U$ but occurs strictly positively in type $V$ \item $T$ converts to $(I~a_1 \ldots ~a_m ~ t_1 \ldots ~t_p)$ where -% QUESTIONS: What is the meaning of 'p' above? $I$ is the name of an inductive declaration of the form $\Ind{\Gamma}{m}{I:A}{c_1:\forall p_1:P_1,\ldots \forall p_m:P_m,C_1;\ldots;c_n:\forall p_1:P_1,\ldots \forall @@ -898,7 +866,6 @@ cases: \item $T=(I~b_1\ldots b_m~u_1\ldots ~u_{p})$, $I$ is an inductive definition with $m$ parameters and $X$ does not occur in any $u_i$ -% QUESTIONS: What is the meaning of 'p' above? \item $T=\forall~x:U,V$ and $X$ occurs only strictly positively in $U$ and the type $V$ satisfies the nested positivity condition for $X$ \end{itemize} @@ -969,10 +936,6 @@ the type $V$ satisfies the nested positivity condition for $X$ \end{latexonly} \paragraph{Correctness rules.} -% QUESTION: For a related problem, in case of global definitions -% and global assumptions, we used the term "well-formedness". -% Couldn't we continue to use the term also here? -% Does it make sense to use a different name, i.e. "correctness" in this case? We shall now describe the rules allowing the introduction of a new inductive definition. @@ -999,7 +962,6 @@ provided that the following side conditions hold: $I_{q_i}$ which satisfies the positivity condition for $I_1 \ldots I_k$ and $c_i \notin \Gamma \cup E$. \end{itemize} -% TODO: justify the above constraints \end{description} One can remark that there is a constraint between the sort of the arity of the inductive type and the sort of the type of its @@ -1007,7 +969,6 @@ constructors which will always be satisfied for the impredicative sort {\Prop} but may fail to define inductive definition on sort \Set{} and generate constraints between universes for inductive definitions in the {\Type} hierarchy. -% QUESTION: which 'constraint' are we above referring to? \paragraph{Examples.} It is well known that existential quantifier can be encoded as an @@ -1025,7 +986,6 @@ The same definition on \Set{} is not allowed and fails: Fail Inductive exSet (P:Set->Prop) : Set := exS_intro : forall X:Set, P X -> exSet P. \end{coq_example} -% TODO: add the description of the 'Fail' command to the reference manual It is possible to declare the same inductive definition in the universe \Type. The \texttt{exType} inductive definition has type $(\Type_i \ra\Prop)\ra @@ -1044,7 +1004,6 @@ Inductive exType (P:Type->Prop) : Type Inductive types declared in {\Type} are polymorphic over their arguments in {\Type}. -% QUESTION: Just arguments? Not also over the parameters? If $A$ is an arity of some sort and $s$ is a sort, we write $A_{/s}$ for the arity obtained from $A$ by replacing its sort with $s$. Especially, if $A$ @@ -1093,13 +1052,10 @@ $P_l$ arity implies $P'_l$ arity since $\WTELECONV{}{P'_l}{ \subst{P_l}{p_u}{q_u \Gamma_{P'},(A_1)_{/s_1};\ldots;I_k:\forall \Gamma_{P'},(A_k)_{/s_k}]$ we have $(\WTE{\Gamma_{I'};\Gamma_{P'}}{C_i}{s_{q_i}})_{i=1\ldots n}$; \item the sorts are such that all eliminations, to {\Prop}, {\Set} and - $\Type(j)$, are allowed (see section~\ref{elimdep}). -% QUESTION: How should I interpret the above side-condition, when I am trying to show that 'list nat : Set'? + $\Type(j)$, are allowed (see Section~\ref{allowedeleminationofsorts}). \end{itemize} \end{description} -% QUESTION: Do we need the following paragraph? -% (I find it confusing.) Notice that if $I_j\,q_1\,\ldots\,q_r$ is typable using the rules {\bf Ind-Const} and {\bf App}, then it is typable using the rule {\bf Ind-Family}. Conversely, the extended theory is not stronger than the @@ -1142,7 +1098,6 @@ singleton -- see paragraph~\ref{singleton}) is set in {\Prop}, a small non-singleton inductive type is set in {\Set} (even in case {\Set} is impredicative -- see Section~\ref{impredicativity}), and otherwise in the {\Type} hierarchy. -% TODO: clarify the case of a partial application ?? Note that the side-condition about allowed elimination sorts in the rule~{\bf Ind-Family} is just to avoid to recompute the allowed @@ -1208,8 +1163,6 @@ Because we need to keep a consistent theory and also we prefer to keep a strongly normalizing reduction, we cannot accept any sort of recursion (even terminating). So the basic idea is to restrict ourselves to primitive recursive functions and functionals. -% TODO: it may be worthwhile to show the consequences of lifting -% those restrictions. For instance, assuming a parameter $A:\Set$ exists in the local context, we want to build a function \length\ of type $\ListA\ra \nat$ which @@ -1246,11 +1199,6 @@ same as proving: $(\haslengthA~(\Nil~A)~\nO)$ and $\forall a:A, \forall l:\ListA, (\haslengthA~l~(\length~l)) \ra (\haslengthA~(\cons~A~a~l)~(\nS~(\length~l)))$. -% QUESTION: Wouldn't something like: -% -% http://matej-kosik.github.io/www/doc/coq/notes/25__has_length.html -% -% be more comprehensible? One conceptually simple way to do that, following the basic scheme proposed by Martin-L\"of in his Intuitionistic Type Theory, is to @@ -1263,11 +1211,6 @@ But this operator is rather tedious to implement and use. We choose in this version of {\Coq} to factorize the operator for primitive recursion into two more primitive operations as was first suggested by Th. Coquand in~\cite{Coq92}. One is the definition by pattern-matching. The second one is a definition by guarded fixpoints. -% QUESTION: Shouldn't we, instead, include a more straightforward argument: -% -% http://matej-kosik.github.io/www/doc/coq/notes/24__match_and_fix.html -% -% ? \subsubsection[The {\tt match\ldots with \ldots end} construction.]{The {\tt match\ldots with \ldots end} construction.\label{Caseexpr} \index{match@{\tt match\ldots with\ldots end}}} @@ -1307,24 +1250,9 @@ omitted if the result type does not depend on the arguments of $I$. Note that the arguments of $I$ corresponding to parameters \emph{must} be \verb!_!, because the result type is not generalized to all possible values of the parameters. -% QUESTION: The last sentence above does not seem to be accurate. -% -% Imagine: -% -% Definition foo (A:Type) (a:A) (l : list A) := -% match l return A with -% | nil => a -% | cons _ _ _ => a -% end. -% -% There, the term in the return-clause happily refer to the parameter of 'l' -% and Coq does not protest. -% -% So I am not sure if I really understand why parameters cannot be bound -% in as-clause. The other arguments of $I$ (sometimes called indices in the literature) -% QUESTION: in which literature? +% NOTE: e.g. http://www.qatar.cmu.edu/~sacchini/papers/types08.pdf have to be variables ($a$ above) and these variables can occur in $P$. The expression after \kw{in} @@ -1364,6 +1292,7 @@ compact notation: % \mbox{\tt =>}~ \false} \paragraph[Allowed elimination sorts.]{Allowed elimination sorts.\index{Elimination sorts}} +\label{allowedeleminationofsorts} An important question for building the typing rule for \kw{match} is what can be the type of $\lb a x \mto P$ with respect to the type of the inductive @@ -1373,34 +1302,26 @@ We define now a relation \compat{I:A}{B} between an inductive definition $I$ of type $A$ and an arity $B$. This relation states that an object in the inductive definition $I$ can be eliminated for proving a property $\lb a x \mto P$ of arity $B$. -% QUESTION: Is it necessary to explain the meaning of [I:A|B] in such a complicated way? -% Couldn't we just say that: "relation [I:A|B] defines which types can we choose as 'result types' -% with respect to the type of the matched object". +% TODO: The meaning of [I:A|B] relation is not trivial, +% but I do not think that we must explain it in as complicated way as we do above. We use this concept to formulate the hypothesis of the typing rule for the match-construct. -The case of inductive definitions in sorts \Set\ or \Type{} is simple. -There is no restriction on the sort of the predicate to be -eliminated. - \paragraph{Notations.} The \compat{I:A}{B} is defined as the smallest relation satisfying the following rules: We write \compat{I}{B} for \compat{I:A}{B} where $A$ is the type of $I$. +The case of inductive definitions in sorts \Set\ or \Type{} is simple. +There is no restriction on the sort of the predicate to be +eliminated. + \begin{description} \item[Prod] \inference{\frac{\compat{(I~x):A'}{B'}} {\compat{I:\forall x:A, A'}{\forall x:A, B'}}} \item[{\Set} \& \Type] \inference{\frac{ s_1 \in \{\Set,\Type(j)\}~~~~~~~~s_2 \in \Sort}{\compat{I:s_1}{I\ra s_2}}} \end{description} -% QUESTION: What kind of value is represented by "x" in the "numerator"? -% There, "x" is unbound. Isn't it? -% The rule does not fully justify the following (plausible) argument: -% -% http://matej-kosik.github.io/www/doc/coq/notes/26__allowed_elimination_sorts.html -% -% NOTE: Above, "Set" is subsumed in "Type(0)" so, strictly speaking, we wouldn't need to mention in explicitely. The case of Inductive definitions of sort \Prop{} is a bit more complicated, because of our interpretation of this sort. The only @@ -1468,7 +1389,6 @@ predicate $P$ of type $I\ra \Type$ leads to a paradox when applied to impredicative inductive definition like the second-order existential quantifier \texttt{exProp} defined above, because it give access to the two projections on this type. -% QUESTION: I did not get the point of the paragraph above. %\paragraph{Warning: strong elimination} %\index{Elimination!Strong elimination} @@ -1514,59 +1434,6 @@ Extraction eq_rec. An empty definition has no constructors, in that case also, elimination on any sort is allowed. -% QUESTION: -% -% In Coq, this works: -% -% Check match 42 as x return match x with -% | O => nat -% | _ => bool -% end -% with -% | O => 42 -% | _ => true -% end. -% -% Also this works: -% -% Check let foo := 42 in -% match foo return match foo with -% | O => nat -% | _ => bool -% end -% with -% | O => 42 -% | _ => true -% end. -% -% But here: -% -% Definition foo := 42. -% Check match foo return match foo with -% | O => nat -% | _ => bool -% end -% with -% | O => 42 -% | _ => true -% end. -% -% Coq complains: -% -% Error: -% The term "42" has type "nat" while it is expected to have type -% "match foo with -% | 0 => nat -% | S _ => bool -% end". -% -% However, the Reference Manual says that: -% -% "Remark that when the term being matched is a variable, the as clause can -% be omitted and the term being matched can serve itself as binding name in the return type." -% -% so I do not understand why, in this case, Coq produces a given error message. - \paragraph{Type of branches.} Let $c$ be a term of type $C$, we assume $C$ is a type of constructor for an inductive type $I$. Let $P$ be a term that represents the @@ -1741,14 +1608,10 @@ definition. For doing this, the syntax of fixpoints is extended and becomes \[\Fix{f_i}{f_1/k_1:A_1:=t_1 \ldots f_n/k_n:A_n:=t_n}\] where $k_i$ are positive integers. +Each $k_i$ represents the index of pararameter of $f_i$, on which $f_i$ is decreasing. Each $A_i$ should be a type (reducible to a term) starting with at least $k_i$ products $\forall y_1:B_1,\ldots \forall y_{k_i}:B_{k_i}, A'_i$ -and $B_{k_i}$ -being an instance of an inductive definition. -% TODO: We should probably define somewhere explicitely, what we mean by -% "x is an instance of an inductive type I". -% -% QUESTION: So, $k_i$ is the index of the argument on which $f_i$ is decreasing? +and $B_{k_i}$ an is unductive type. Now in the definition $t_i$, if $f_j$ occurs then it should be applied to at least $k_j$ arguments and the $k_j$-th argument should be @@ -1764,9 +1627,6 @@ $\forall p_1:P_1,\ldots \forall p_r:P_r, \forall x_1:T_1, \ldots \forall x_r:T_r, (I_j~p_1\ldots p_r~t_1\ldots t_s)$ the recursive arguments will correspond to $T_i$ in which one of the $I_l$ occurs. -% QUESTION: The last sentence above really fully make sense. -% Isn't some word missing? -% Maybe "if"? The main rules for being structurally smaller are the following:\\ Given a variable $y$ of type an inductive @@ -1782,7 +1642,6 @@ The terms structurally smaller than $y$ are: If $c$ is $y$ or is structurally smaller than $y$, its type is an inductive definition $I_p$ part of the inductive declaration corresponding to $y$. - % QUESTION: What does the above sentence mean? Each $f_i$ corresponds to a type of constructor $C_q \equiv \forall p_1:P_1,\ldots,\forall p_r:P_r, \forall y_1:B_1, \ldots \forall y_k:B_k, (I~a_1\ldots a_k)$ and can consequently be @@ -1792,9 +1651,6 @@ The terms structurally smaller than $y$ are: in $g_i$ corresponding to recursive arguments $B_i$ (the ones in which one of the $I_l$ occurs) are structurally smaller than $y$. \end{itemize} -% QUESTION: How could one show, that some of the functions defined below are "guarded" -% in a sense of the definition given above. -% E.g., how could I show that "p" in "plus" below is structurally smaller than "n"? The following definitions are correct, we enter them using the {\tt Fixpoint} command as described in Section~\ref{Fixpoint} and show the internal representation. @@ -1828,7 +1684,6 @@ The reduction for fixpoints is: \[ (\Fix{f_i}{F}~a_1\ldots a_{k_i}) \triangleright_{\iota} \substs{t_i}{f_k}{\Fix{f_k}{F}}{k=1\ldots n} ~a_1\ldots a_{k_i}\] -% QUESTION: Is it wise to use \iota for twice with two different meanings? when $a_{k_i}$ starts with a constructor. This last restriction is needed in order to keep strong normalization and corresponds to the reduction for primitive recursive operators. @@ -2030,45 +1885,6 @@ impredicative system for sort \Set{} become: \{\Type(i)\}} {\compat{I:\Set}{I\ra s}}} \end{description} - -% QUESTION: Why, when I add this definition: -% -% Inductive foo : Type := . -% -% Coq claims that the type of 'foo' is 'Prop'? - -% QUESTION: If I add this definition: -% -% Inductive bar (A:Type) : Type := . -% -% then Coq claims that 'bar' has type 'Type → Prop' where I would expect 'Type → Type' with appropriate constraint. - -% QUESTION: If I add this definition: -% -% Inductive foo (A:Type) : Type := -% | foo1 : foo A -% -% then Coq claims that 'foo' has type 'Type → Prop'. -% Why? - -% QUESTION: If I add this definition: -% -% Inductive foo (A:Type) : Type := -% | foo1 : foo A -% | foo2 : foo A. -% -% then Coq claims that 'foo' has type 'Type → Set'. -% Why? - -% NOTE: If I add this definition: -% -% Inductive foo (A:Type) : Type := -% | foo1 : foo A -% | foo2 : A → foo A. -% -% then Coq claims, as expected, that: -% -% foo : Type → Type. %%% Local Variables: %%% mode: latex -- cgit v1.2.3 From 15311e51c20e6edc3b97f12d483dd15bfbc1164c Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 9 Nov 2015 16:43:47 +0100 Subject: PROPOSITION: Example was simplified --- doc/refman/RefMan-cic.tex | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 2f4016d71e..ac860b8276 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1688,33 +1688,14 @@ when $a_{k_i}$ starts with a constructor. This last restriction is needed in order to keep strong normalization and corresponds to the reduction for primitive recursive operators. -We can illustrate this behavior on examples. -\begin{coq_example} -Goal forall n m:nat, plus (S n) m = S (plus n m). -reflexivity. -Abort. -Goal forall f:forest, sizet (node f) = S (sizef f). -reflexivity. -Abort. -\end{coq_example} -But assuming the definition of a son function from \tree\ to \forest: -\begin{coq_example} -Definition sont (t:tree) : forest - := let (f) := t in f. -\end{coq_example} -The following is not a conversion but can be proved after a case analysis. -% (******************************************************************) -% (** Error: Impossible to unify .... **) -\begin{coq_example} -Goal forall t:tree, sizet t = S (sizef (sont t)). -Fail reflexivity. -destruct t. -reflexivity. -\end{coq_example} -\begin{coq_eval} -Abort. -\end{coq_eval} -% QUESTION: What are we trying to say with the above examples? +The following reductions are now possible: +\def\plus{\mathsf{plus}} +\def\tri{\triangleright_\iota} +\begin{eqnarray*} + \plus~(\nS~(\nS~\nO))~(\nS~\nO) & \tri & \nS~(\plus~(\nS~\nO)~(\nS~\nO))\\ + & \tri & \nS~(\nS~(\plus~\nO~(\nS~\nO)))\\ + & \tri & \nS~(\nS~(\nS~\nO))\\ +\end{eqnarray*} % La disparition de Program devrait rendre la construction Match obsolete % \subsubsection{The {\tt Match \ldots with \ldots end} expression} -- cgit v1.2.3 From 5e48f1aafb45d1c883e32e13a8458979663b04fb Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 9 Nov 2015 16:52:23 +0100 Subject: PROPOSITION: Added "if" and "then" words missing in the original sentence. --- doc/refman/RefMan-cic.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index ac860b8276..6c1417a7f2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1622,10 +1622,10 @@ The definition of being structurally smaller is a bit technical. One needs first to define the notion of {\em recursive arguments of a constructor}\index{Recursive arguments}. For an inductive definition \Ind{}{r}{\Gamma_I}{\Gamma_C}, -the type of a constructor $c$ has the form +if the type of a constructor $c$ has the form $\forall p_1:P_1,\ldots \forall p_r:P_r, \forall x_1:T_1, \ldots \forall x_r:T_r, (I_j~p_1\ldots -p_r~t_1\ldots t_s)$ the recursive arguments will correspond to $T_i$ in +p_r~t_1\ldots t_s)$, then the recursive arguments will correspond to $T_i$ in which one of the $I_l$ occurs. The main rules for being structurally smaller are the following:\\ -- cgit v1.2.3 From 32bd14114d5137b917601092730469db569d6385 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 10 Nov 2015 09:11:50 +0100 Subject: PROPOSITION: Added an explicit definition of the notation for enriching the global environment (we use throughout the document) --- doc/refman/RefMan-cic.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 6c1417a7f2..2781b4cbe5 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -257,6 +257,10 @@ A {\em global definition} will be represented in the global environment as $c:=t:T$ which defines the name $c$ to have value $t$ and type $T$. We shall call such names {\em constants}. +For the rest of the chapter, the $E;c:T$ denotes the global environment +$E$ enriched with the global assumption $c:T$. +Similarly, $E;c:=t:T$ denotes the global environment +$E$ enriched with the global definition $(c:=t:T)$. The rules for inductive definitions (see Section \ref{Cic-inductive-definitions}) have to be considered as assumption -- cgit v1.2.3 From e90a1be62b9d26b1982e48d7bbd2a73b5bc54b0a Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 10 Nov 2015 13:08:20 +0100 Subject: PROPOSITION: rephrasing of the explanation of the meaning of '[I:A|B]' --- doc/refman/RefMan-cic.tex | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 2781b4cbe5..dd194d4eb9 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1299,16 +1299,12 @@ compact notation: \label{allowedeleminationofsorts} An important question for building the typing rule for \kw{match} is -what can be the type of $\lb a x \mto P$ with respect to the type of the inductive -definitions. - -We define now a relation \compat{I:A}{B} between an inductive -definition $I$ of type $A$ and an arity $B$. This relation states that -an object in the inductive definition $I$ can be eliminated for -proving a property $\lb a x \mto P$ of arity $B$. -% TODO: The meaning of [I:A|B] relation is not trivial, -% but I do not think that we must explain it in as complicated way as we do above. -We use this concept to formulate the hypothesis of the typing rule for the match-construct. +what can be the type of $\lb a x \mto P$ with respect to the type of $m$. If +$m:I$ and +$I:A$ and +$\lb a x \mto P : B$ +then by \compat{I:A}{B} we mean that one can use $\lb a x \mto P$ with $m$ in the above +match-construct. \paragraph{Notations.} The \compat{I:A}{B} is defined as the smallest relation satisfying the -- cgit v1.2.3 From 48431e5f7583f9fec3b776b07fac0f84f021a69e Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 10 Nov 2015 14:55:39 +0100 Subject: PROPOSITION: the side-condition was made more specific. --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index dd194d4eb9..dd9284e606 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -1055,7 +1055,7 @@ $P_l$ arity implies $P'_l$ arity since $\WTELECONV{}{P'_l}{ \subst{P_l}{p_u}{q_u $\Gamma_{I'} = [I_1:\forall \Gamma_{P'},(A_1)_{/s_1};\ldots;I_k:\forall \Gamma_{P'},(A_k)_{/s_k}]$ we have $(\WTE{\Gamma_{I'};\Gamma_{P'}}{C_i}{s_{q_i}})_{i=1\ldots n}$; -\item the sorts are such that all eliminations, to {\Prop}, {\Set} and +\item the sorts $s_i$ are such that all eliminations, to {\Prop}, {\Set} and $\Type(j)$, are allowed (see Section~\ref{allowedeleminationofsorts}). \end{itemize} \end{description} -- cgit v1.2.3 From 9959dd34dedf40c3be9a1fb1e08f04b79e0869c5 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Thu, 12 Nov 2015 11:36:00 +0100 Subject: TYPOGRAPHY: adjustments --- doc/refman/RefMan-cic.tex | 123 ++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 65 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index dd9284e606..dd3a059d7f 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -69,7 +69,6 @@ system itself generates for each instance of \Type\ a new index for the universe and checks that the constraints between these indexes can be solved. From the user point of view we consequently have {\Type}:{\Type}. - We shall make precise in the typing rules the constraints between the indexes. @@ -125,13 +124,11 @@ Terms are built from sorts, variables, constants, abstractions, applications, local definitions, %case analysis, fixpoints, cofixpoints and products. - From a syntactic point of view, types cannot be distinguished from terms, except that they cannot start by an abstraction or a constructor. - More precisely the language of the {\em Calculus of Inductive Constructions} is built from the following rules. - +% \begin{enumerate} \item the sorts {\Set}, {\Prop}, ${\Type(i)}$ are terms. \item variables, hereafter ranged over by letters $x$, $y$, etc., are terms @@ -414,31 +411,31 @@ $\eta$-expansion $\lb x:T\mto (t\ x)$ for $x$ an arbitrary variable name fresh in $t$. \Rem We deliberately do not define $\eta$-reduction: -\begin{latexonly} +\begin{latexonly}% $$\lb x:T\mto (t\ x)\not\triangleright_\eta\hskip.3em t$$ -\end{latexonly} +\end{latexonly}% \begin{htmlonly} $$\lb x:T\mto (t\ x)~\not\triangleright_\eta~t$$ \end{htmlonly} This is because, in general, the type of $t$ need not to be convertible to the type of $\lb x:T\mto (t\ x)$. E.g., if we take $f$ such that: -\begin{latexonly} +\begin{latexonly}% $$f\hskip.5em:\hskip.5em\forall x:Type(2),Type(1)$$ -\end{latexonly} +\end{latexonly}% \begin{htmlonly} $$f~:~\forall x:Type(2),Type(1)$$ \end{htmlonly} then -\begin{latexonly} +\begin{latexonly}% $$\lb x:Type(1),(f\, x)\hskip.5em:\hskip.5em\forall x:Type(1),Type(1)$$ -\end{latexonly} +\end{latexonly}% \begin{htmlonly} $$\lb x:Type(1),(f\, x)~:~\forall x:Type(1),Type(1)$$ \end{htmlonly} We could not allow -\begin{latexonly} +\begin{latexonly}% $$\lb x:Type(1),(f\,x)\hskip.4em\not\triangleright_\eta\hskip.6em f$$ -\end{latexonly} +\end{latexonly}% \begin{htmlonly} $$\lb x:Type(1),(f\,x)~\not\triangleright_\eta~f$$ \end{htmlonly} @@ -514,7 +511,7 @@ term is no more an abstraction leads to the {\em $\beta$-head normal where $v$ is not an abstraction (nor an application). Note that the head normal form must not be confused with the normal form since some $u_i$ can be reducible. - +% Similar notions of head-normal forms involving $\delta$, $\iota$ and $\zeta$ reductions or any combination of those can also be defined. @@ -529,14 +526,12 @@ Formally, we can represent any {\em inductive definition\index{definition!induct \item $p$ determines the number of parameters of these inductive types. \end{itemize} These inductive definitions, together with global assumptions and global definitions, then form the global environment. - -\noindent Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$ +% +Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$ such that each $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as: -$\forall\Gamma_P, T^\prime$. +$\forall\Gamma_P, T^\prime$ where $\Gamma_P$ is called the {\em context of parameters\index{context of parameters}}. -\noindent $\Gamma_P$ is called {\em context of parameters\index{context of parameters}}. - -\begin{latexonly} +\begin{latexonly}% \subsection*{Examples} If we take the following inductive definition (denoted in concrete syntax): @@ -750,7 +745,7 @@ and thus it enriches the global environment with the following entry: \ind{0}{\GammaI}{\GammaC} \vskip.5em \noindent In this case, $\Gamma_P=[\,]$. -\end{latexonly} +\end{latexonly}% \subsection{Types of inductive objects} We have to give the type of constants in a global environment $E$ which @@ -763,7 +758,7 @@ contains an inductive declaration. \inference{\frac{\WFE{\Gamma}\hskip2em\Ind{}{p}{\Gamma_I}{\Gamma_C} \in E\hskip2em(c:C)\in\Gamma_C}{\WTEG{c}{C}}} \end{description} -\begin{latexonly} +\begin{latexonly}% \paragraph{Example.} Provided that our environment $E$ contains inductive definitions we showed before, these two inference rules above enable us to conclude that: @@ -776,7 +771,7 @@ $\begin{array}{@{} l} \prefix\evenS : \forall~n:\nat, \odd~n \ra \even~(\nS~n)\\ \prefix\oddS : \forall~n:\nat, \even~n \ra \odd~(\nS~n) \end{array}$ -\end{latexonly} +\end{latexonly}% %\paragraph{Parameters.} %%The parameters introduce a distortion between the inside specification @@ -837,10 +832,10 @@ any $t_i$ \item $T=\forall~x:U,V$ and $X$ occurs only strictly positively in $U$ and the type $V$ satisfies the positivity condition for $X$ \end{itemize} - +% The constant $X$ {\em occurs strictly positively} in $T$ in the following cases: - +% \begin{itemize} \item $X$ does not occur in $T$ \item $T$ converts to $(X~t_1 \ldots ~t_n)$ and $X$ does not occur in @@ -861,7 +856,7 @@ following cases: %positively in $T[x:U]u$ if $X$ does not occur in $U$ but occurs %strictly positively in $u$ \end{itemize} - +% The type of constructor $T$ of $I$ {\em satisfies the nested positivity condition} for a constant $X$ in the following cases: @@ -874,7 +869,7 @@ any $u_i$ the type $V$ satisfies the nested positivity condition for $X$ \end{itemize} -\begin{latexonly} +\begin{latexonly}% \newcommand\vv{\textSFxi} % │ \newcommand\hh{\textSFx} % ─ \newcommand\vh{\textSFviii} % ├ @@ -937,7 +932,7 @@ the type $V$ satisfies the nested positivity condition for $X$ \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\ListA$\ruleref3\\ \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 -\end{latexonly} +\end{latexonly}% \paragraph{Correctness rules.} We shall now describe the rules allowing the introduction of a new @@ -1008,7 +1003,6 @@ Inductive exType (P:Type->Prop) : Type Inductive types declared in {\Type} are polymorphic over their arguments in {\Type}. - If $A$ is an arity of some sort and $s$ is a sort, we write $A_{/s}$ for the arity obtained from $A$ by replacing its sort with $s$. Especially, if $A$ is well-typed in some global environment and local context, then $A_{/s}$ is typable @@ -1059,7 +1053,7 @@ we have $(\WTE{\Gamma_{I'};\Gamma_{P'}}{C_i}{s_{q_i}})_{i=1\ldots n}$; $\Type(j)$, are allowed (see Section~\ref{allowedeleminationofsorts}). \end{itemize} \end{description} - +% Notice that if $I_j\,q_1\,\ldots\,q_r$ is typable using the rules {\bf Ind-Const} and {\bf App}, then it is typable using the rule {\bf Ind-Family}. Conversely, the extended theory is not stronger than the @@ -1106,15 +1100,14 @@ and otherwise in the {\Type} hierarchy. Note that the side-condition about allowed elimination sorts in the rule~{\bf Ind-Family} is just to avoid to recompute the allowed elimination sorts at each instance of a pattern-matching (see -section~\ref{elimdep}). - +section~\ref{elimdep}). As an example, let us consider the following definition: \begin{coq_example*} Inductive option (A:Type) : Type := | None : option A | Some : A -> option A. \end{coq_example*} - +% As the definition is set in the {\Type} hierarchy, it is used polymorphically over its parameters whose types are arities of a sort in the {\Type} hierarchy. Here, the parameter $A$ has this property, @@ -1129,13 +1122,13 @@ section~\ref{singleton}) and it would lose the elimination to {\Set} and Check (fun A:Set => option A). Check (fun A:Prop => option A). \end{coq_example} - +% Here is another example. - +% \begin{coq_example*} Inductive prod (A B:Type) : Type := pair : A -> B -> prod A B. \end{coq_example*} - +% As \texttt{prod} is a singleton type, it will be in {\Prop} if applied twice to propositions, in {\Set} if applied twice to at least one type in {\Set} and none in {\Type}, and in {\Type} otherwise. In all cases, @@ -1186,24 +1179,25 @@ In case the inductive definition is effectively a recursive one, we want to capture the extra property that we have built the smallest fixed point of this recursive equation. This says that we are only manipulating finite objects. This analysis provides induction -principles. - +principles. For instance, in order to prove $\forall l:\ListA,(\haslengthA~l~(\length~l))$ it is enough to prove: - -\noindent $(\haslengthA~(\Nil~A)~(\length~(\Nil~A)))$ and - -\smallskip -$\forall a:A, \forall l:\ListA, (\haslengthA~l~(\length~l)) \ra -(\haslengthA~(\cons~A~a~l)~(\length~(\cons~A~a~l)))$. -\smallskip - -\noindent which given the conversion equalities satisfied by \length\ is the +% +\begin{itemize} + \item $(\haslengthA~(\Nil~A)~(\length~(\Nil~A)))$ + \item $\forall a:A, \forall l:\ListA, (\haslengthA~l~(\length~l)) \ra\\ + \ra (\haslengthA~(\cons~A~a~l)~(\length~(\cons~A~a~l)))$ +\end{itemize} +% +which given the conversion equalities satisfied by \length\ is the same as proving: -$(\haslengthA~(\Nil~A)~\nO)$ and $\forall a:A, \forall l:\ListA, -(\haslengthA~l~(\length~l)) \ra -(\haslengthA~(\cons~A~a~l)~(\nS~(\length~l)))$. - +% +\begin{itemize} + \item $(\haslengthA~(\Nil~A)~\nO)$ + \item $\forall a:A, \forall l:\ListA, (\haslengthA~l~(\length~l)) \ra\\ + \ra (\haslengthA~(\cons~A~a~l)~(\nS~(\length~l)))$ +\end{itemize} +% One conceptually simple way to do that, following the basic scheme proposed by Martin-L\"of in his Intuitionistic Type Theory, is to introduce for each inductive definition an elimination operator. At @@ -1223,7 +1217,6 @@ The basic idea of this operator is that we have an object $m$ in an inductive type $I$ and we want to prove a property which possibly depends on $m$. For this, it is enough to prove the property for $m = (c_i~u_1\ldots u_{p_i})$ for each constructor of $I$. - The \Coq{} term for this proof will be written: \[\kw{match}~m~\kw{with}~ (c_1~x_{11}~...~x_{1p_1}) \Ra f_1 ~|~\ldots~|~ (c_n~x_{n1}~...~x_{np_n}) \Ra f_n~ \kw{end}\] @@ -1262,7 +1255,7 @@ have to be variables The expression after \kw{in} must be seen as an \emph{inductive type pattern}. Notice that expansion of implicit arguments and notations apply to this pattern. - +% For the purpose of presenting the inference rules, we use a more compact notation: \[ \Case{(\lb a x \mto P)}{m}{ \lb x_{11}~...~x_{1p_1} \mto f_1 ~|~\ldots~|~ @@ -1315,14 +1308,14 @@ $I$. The case of inductive definitions in sorts \Set\ or \Type{} is simple. There is no restriction on the sort of the predicate to be eliminated. - +% \begin{description} \item[Prod] \inference{\frac{\compat{(I~x):A'}{B'}} {\compat{I:\forall x:A, A'}{\forall x:A, B'}}} \item[{\Set} \& \Type] \inference{\frac{ s_1 \in \{\Set,\Type(j)\}~~~~~~~~s_2 \in \Sort}{\compat{I:s_1}{I\ra s_2}}} \end{description} - +% The case of Inductive definitions of sort \Prop{} is a bit more complicated, because of our interpretation of this sort. The only harmless allowed elimination, is the one when predicate $P$ is also of @@ -1413,10 +1406,10 @@ eliminations are allowed. definition}~~~s \in \Sort}{\compat{I:\Prop}{I\ra s}} } \end{description} - +% % A {\em singleton definition} has always an informative content, % even if it is a proposition. - +% A {\em singleton definition} has only one constructor and all the arguments of this constructor have type \Prop. In that case, there is a canonical @@ -1573,17 +1566,17 @@ The typing rule is the expected one for a fixpoint. (\WTE{\Gamma,f_1:A_1,\ldots,f_n:A_n}{t_i}{A_i})_{i=1\ldots n}} {\WTEG{\Fix{f_i}{f_1:A_1:=t_1 \ldots f_n:A_n:=t_n}}{A_i}}} \end{description} - +% Any fixpoint definition cannot be accepted because non-normalizing terms allow proofs of absurdity. - +% The basic scheme of recursion that should be allowed is the one needed for defining primitive recursive functionals. In that case the fixpoint enjoys a special syntactic restriction, namely one of the arguments belongs to an inductive type, the function starts with a case analysis and recursive calls are done on variables coming from patterns and representing subterms. - +% For instance in the case of natural numbers, a proof of the induction principle of type \[\forall P:\nat\ra\Prop, (P~\nO)\ra(\forall n:\nat, (P~n)\ra(P~(\nS~n)))\ra @@ -1596,15 +1589,15 @@ can be represented by the term: p:\nat\mto (g~p~(h~p))}} \end{array} \] - +% Before accepting a fixpoint definition as being correctly typed, we check that the definition is ``guarded''. A precise analysis of this notion can be found in~\cite{Gim94}. - +% The first stage is to precise on which argument the fixpoint will be decreasing. The type of this argument should be an inductive definition. - +% For doing this, the syntax of fixpoints is extended and becomes \[\Fix{f_i}{f_1/k_1:A_1:=t_1 \ldots f_n/k_n:A_n:=t_n}\] where $k_i$ are positive integers. @@ -1687,7 +1680,7 @@ a_{k_i}) \triangleright_{\iota} \substs{t_i}{f_k}{\Fix{f_k}{F}}{k=1\ldots n} when $a_{k_i}$ starts with a constructor. This last restriction is needed in order to keep strong normalization and corresponds to the reduction for primitive recursive operators. - +% The following reductions are now possible: \def\plus{\mathsf{plus}} \def\tri{\triangleright_\iota} @@ -1785,7 +1778,7 @@ $\subst{\subst{E}{y_1}{(y_1~c)}\ldots}{y_n}{(y_n~c)}$. \inference{\frac{\WF{E;c:U;E';\Ind{}{p}{\Gamma_I}{\Gamma_C};E''}{\Gamma}} {\WFTWOLINES{E;c:U;E';\Ind{}{p+1}{\forall x:U,\subst{\Gamma_I}{c}{x}}{\forall x:U,\subst{\Gamma_C}{c}{x}};\subst{E''}{|\Gamma_I,\Gamma_C|}{|\Gamma_I,\Gamma_C|~c}}{\subst{\Gamma}{|\Gamma_I,\Gamma_C|}{|\Gamma_I,\Gamma_C|~c}}}} - +% One can similarly modify a global declaration by generalizing it over a previously defined constant~$c'$. Below, if $\Gamma$ is a context of the form $[y_1:A_1;\ldots;y_n:A_n]$, we write $ @@ -1830,7 +1823,7 @@ in~\cite{Gimenez95b,Gim98,GimCas05}. \Coq{} can be used as a type-checker for the Calculus of Inductive Constructions with an impredicative sort \Set{} by using the compiler option \texttt{-impredicative-set}. - +% For example, using the ordinary \texttt{coqtop} command, the following is rejected. % (** This example should fail ******************************* -- cgit v1.2.3 From 89d033112607733ad0007638762bde326fc0eb8b Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Wed, 18 Nov 2015 16:11:27 +0100 Subject: ENH: The definition of the "_ ; _" operation on local context was added. --- doc/refman/RefMan-cic.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index dd3a059d7f..4066a108cd 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -226,6 +226,8 @@ $\Gamma$ enriched with the local assumption $y:T$. Similarly, $\Gamma::(y:=t:T)$ denotes the local context $\Gamma$ enriched with the local definition $(y:=t:T)$. The notation $[]$ denotes the empty local context. +By $\Gamma_1; \Gamma_2$ we mean concatenation of the local context $\Gamma_1$ +and the local context $\Gamma_2$. % Does not seem to be used further... % Si dans l'explication WF(E)[Gamma] concernant les constantes -- cgit v1.2.3 From 6fa4d20b5208852ac468c28405e93bcb5288d774 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Mon, 23 Nov 2015 13:02:03 +0100 Subject: CLEANUP: putting examples inside "figure" environment --- doc/refman/RefMan-cic.tex | 507 ++++++++++++++++++++-------------------- doc/refman/Reference-Manual.tex | 4 + 2 files changed, 262 insertions(+), 249 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 4066a108cd..ad711549b2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -532,221 +532,221 @@ These inductive definitions, together with global assumptions and global definit Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$ such that each $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as: $\forall\Gamma_P, T^\prime$ where $\Gamma_P$ is called the {\em context of parameters\index{context of parameters}}. +Figures~\ref{fig:bool}--\ref{fig:even:odd} show formal representation of several inductive definitions. \begin{latexonly}% -\subsection*{Examples} - -If we take the following inductive definition (denoted in concrete syntax): -\begin{coq_example*} + \newpage + \def\captionstrut{\vbox to 1.5em{}} + \newcommand\ind[3]{$\mathsf{Ind}~[#1]\left(\hskip-.4em + \begin{array}{r @{\mathrm{~:=~}} l} + #2 & #3 \\ + \end{array} + \hskip-.4em + \right)$} + + \def\colon{@{\hskip.5em:\hskip.5em}} + + \begin{figure}[H] + \strut If we take the following inductive definition (denoted in concrete syntax): +\begin{verbatim} Inductive bool : Set := | true : bool | false : bool. -\end{coq_example*} -then: -\def\colon{@{\hskip.5em:\hskip.5em}} -\newcommand\ind[3]{$\mathsf{Ind}~[#1]\left(\hskip-.4em - \begin{array}{r @{\mathrm{~:=~}} l} - #2 & #3 \\ - \end{array} - \hskip-.4em - \right)$} - \def\GammaI{\left[\begin{array}{r \colon l} - \bool & \Set - \end{array} - \right]} - \def\GammaC{\left[\begin{array}{r \colon l} - \true & \bool\\ - \false & \bool - \end{array} - \right]} - \begin{itemize} +\end{verbatim} + then: + \def\GammaI{\left[\begin{array}{r \colon l} + \bool & \Set + \end{array} + \right]} + \def\GammaC{\left[\begin{array}{r \colon l} + \true & \bool\\ + \false & \bool + \end{array} + \right]} + \begin{itemize} \item $p = 0$ \item $\Gamma_I = \GammaI$ \item $\Gamma_C = \GammaC$ - \end{itemize} - and thus it enriches the global environment with the following entry: - \vskip.5em - \ind{p}{\Gamma_I}{\Gamma_C} - \vskip.5em - \noindent that is: - \vskip.5em - \ind{0}{\GammaI}{\GammaC} - \vskip.5em - \noindent In this case, $\Gamma_P=[\,]$. - -\vskip1em\hrule\vskip1em - -\noindent If we take the followig inductive definition: -\begin{coq_example*} + \item $\Gamma_P=[\,]$. + \end{itemize} + and thus it enriches the global environment with the following entry: + \vskip.5em + \ind{p}{\Gamma_I}{\Gamma_C} + \vskip.5em + \noindent that is: + \vskip.5em + \ind{0}{\GammaI}{\GammaC} + \caption{\captionstrut Formal representation of the {\bool} inductive type.} + \label{fig:bool} + \end{figure} + + \begin{figure}[H] + \strut If we take the followig inductive definition: +\begin{verbatim} Inductive nat : Set := | O : nat | S : nat -> nat. -\end{coq_example*} -then: -\def\GammaI{\left[\begin{array}{r \colon l} - \nat & \Set - \end{array} - \right]} -\def\GammaC{\left[\begin{array}{r \colon l} - \nO & \nat\\ - \nS & \nat\ra\nat - \end{array} - \right]} -\begin{itemize} - \item $p = 0$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ -\end{itemize} -and thus it enriches the global environment with the following entry: -\vskip.5em -\ind{p}{\Gamma_I}{\Gamma_C} -\vskip.5em -\noindent that is: -\vskip.5em -\ind{0}{\GammaI}{\GammaC} -\vskip.5em -\noindent In this case, $\Gamma_P=[~]$. - -\vskip1em\hrule\vskip1em - -\noindent If we take the following inductive definition: -\begin{coq_example*} +\end{verbatim} + then: + \def\GammaI{\left[\begin{array}{r \colon l} + \nat & \Set + \end{array} + \right]} + \def\GammaC{\left[\begin{array}{r \colon l} + \nO & \nat\\ + \nS & \nat\ra\nat + \end{array} + \right]} + \begin{itemize} + \item $p = 0$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ + \item $\Gamma_P=[\,]$. + \end{itemize} + and thus it enriches the global environment with the following entry: + \vskip.5em + \ind{p}{\Gamma_I}{\Gamma_C} + \vskip.5em + \noindent that is: + \vskip.5em + \ind{0}{\GammaI}{\GammaC} + \caption{\captionstrut Formal representation of the {\nat} inductive type.} + \label{fig:nat} + \end{figure} + + \begin{figure}[H] + \strut If we take the following inductive definition: +\begin{verbatim} Inductive list (A : Type) : Type := | nil : list A | cons : A -> list A -> list A. -\end{coq_example*} -then: -\def\GammaI{\left[\begin{array}{r \colon l} - \List & \Type\ra\Type - \end{array} - \right]} -\def\GammaC{\left[\begin{array}{r \colon l} - \Nil & \forall~A\!:\!\Type,~\List~A\\ - \cons & \forall~A\!:\!\Type,~A\ra\List~A\ra\List~A - \end{array} - \right]} -\begin{itemize} - \item $p = 1$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ -\end{itemize} -and thus it enriches the global environment with the following entry: -\vskip.5em -\ind{p}{\Gamma_I}{\Gamma_C} -\vskip.5em -\noindent that is: -\vskip.5em -\ind{1}{\GammaI}{\GammaC} -\vskip.5em -\noindent In this case, $\Gamma_P=[A:\Type]$. - -\vskip1em\hrule\vskip1em - -\noindent If we take the following inductive definition: -\begin{coq_example*} +\end{verbatim} + then: + \def\GammaI{\left[\begin{array}{r \colon l} + \List & \Type\ra\Type + \end{array} + \right]} + \def\GammaC{\left[\begin{array}{r \colon l} + \Nil & \forall~A\!:\!\Type,~\List~A\\ + \cons & \forall~A\!:\!\Type,~A\ra\List~A\ra\List~A + \end{array} + \right]} + \begin{itemize} + \item $p = 1$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ + \item $\Gamma_P=[A:\Type]$ + \end{itemize} + and thus it enriches the global environment with the following entry: + \vskip.5em + \ind{1}{\GammaI}{\GammaC} + \caption{\captionstrut Formal representation of the {\List} inductive type.} + \label{fig:list} + \end{figure} + + \begin{figure}[H] + \strut If we take the following inductive definition: +\begin{verbatim} Inductive even : nat -> Prop := | even_O : even 0 | even_S : forall n, odd n -> even (S n) with odd : nat -> Prop := | odd_S : forall n, even n -> odd (S n). -\end{coq_example*} -then: -\def\GammaI{\left[\begin{array}{r \colon l} - \even & \nat\ra\Prop \\ - \odd & \nat\ra\Prop - \end{array} - \right]} -\def\GammaC{\left[\begin{array}{r \colon l} - \evenO & \even~\nO \\ - \evenS & \forall n : \nat, \odd~n \ra \even~(\nS~n) - \end{array} - \right]} -\begin{itemize} - \item $p = 1$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ -\end{itemize} -and thus it enriches the global environment with the following entry: -\vskip.5em -\ind{p}{\Gamma_I}{\Gamma_C} -\vskip.5em -\noindent that is: -\vskip.5em -\ind{1}{\GammaI}{\GammaC} -\vskip.5em -\noindent In this case, $\Gamma_P=[A:\Type]$. - -\vskip1em\hrule\vskip1em - -\noindent If we take the following inductive definition: -\begin{coq_example*} +\end{verbatim} + then: + \def\GammaI{\left[\begin{array}{r \colon l} + \even & \nat\ra\Prop \\ + \odd & \nat\ra\Prop + \end{array} + \right]} + \def\GammaC{\left[\begin{array}{r \colon l} + \evenO & \even~\nO \\ + \evenS & \forall n : \nat, \odd~n \ra \even~(\nS~n)\\ + \oddS & \forall n : \nat, \even~n \ra \odd~(\nS~n) + \end{array} + \right]} + \begin{itemize} + \item $p = 1$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ + \item $\Gamma_P=[A:\Type]$. + \end{itemize} + and thus it enriches the global environment with the following entry: + \vskip.5em + \ind{1}{\GammaI}{\GammaC} + \caption{\captionstrut Formal representation of the {\even} and {\odd} inductive types.} + \label{fig:even:odd} + \end{figure} + + \begin{figure}[H] + \strut If we take the following inductive definition: +\begin{verbatim} Inductive has_length (A : Type) : list A -> nat -> Prop := | nil_hl : has_length A (nil A) O | cons_hl : forall (a:A) (l:list A) (n:nat), has_length A l n -> has_length A (cons A a l) (S n). -\end{coq_example*} -then: -\def\GammaI{\left[\begin{array}{r \colon l} - \haslength & \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop - \end{array} - \right]} -\def\GammaC{\left[\begin{array}{r c l} - \nilhl & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\haslength~A~(\Nil~A)~\nO\\ - \conshl & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ - & & \haslength~A~l~n\ra \haslength~A~(\cons~A~a~l)~(\nS~n) - \end{array} - \right]} -\begin{itemize} - \item $p = 1$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ -\end{itemize} -and thus it enriches the global environment with the following entry: -\vskip.5em -\ind{p}{\Gamma_I}{\Gamma_C} -%\vskip.5em -%\noindent that is: -%\vskip.5em -%\ind{1}{\GammaI}{\GammaC} -\vskip.5em -\noindent In this case, $\Gamma_P=[A:\Type]$. - -\vskip1em\hrule\vskip1em - -\noindent If we take the following inductive definition: -\begin{coq_example*} +\end{verbatim} + then: + \def\GammaI{\left[\begin{array}{r \colon l} + \haslength & \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop + \end{array} + \right]} + \def\GammaC{\left[\begin{array}{r c l} + \nilhl & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\haslength~A~(\Nil~A)~\nO\\ + \conshl & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ + & & \haslength~A~l~n\ra \haslength~A~(\cons~A~a~l)~(\nS~n) + \end{array} + \right]} + \begin{itemize} + \item $p = 1$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ + \item $\Gamma_P=[A:\Type]$. + \end{itemize} + and thus it enriches the global environment with the following entry: + \vskip.5em + \ind{p}{\Gamma_I}{\Gamma_C} + %\vskip.5em + %\noindent that is: + %\vskip.5em + %\ind{1}{\GammaI}{\GammaC} + \caption{\captionstrut Formal representation of the {\haslength} inductive type.} + \label{fig:haslength} + \end{figure} + + \begin{figure}[H] + \strut If we take the following inductive definition: +\begin{verbatim} Inductive tree : Set := | node : forest -> tree with forest : Set := | emptyf : forest | consf : tree -> forest -> forest. -\end{coq_example*} -then: -\def\GammaI{\left[\begin{array}{r \colon l} - \tree & \Set\\ - \forest & \Set - \end{array} - \right]} -\def\GammaC{\left[\begin{array}{r \colon l} - \node & \forest\ra\tree\\ - \emptyf & \forest\\ - \consf & \tree\ra\forest\ra\forest - \end{array} - \right]} -\begin{itemize} - \item $p = 0$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ -\end{itemize} -and thus it enriches the global environment with the following entry: -\vskip.5em -\ind{p}{\Gamma_I}{\Gamma_C} -\vskip.5em -\noindent that is: -\vskip.5em -\ind{0}{\GammaI}{\GammaC} -\vskip.5em -\noindent In this case, $\Gamma_P=[\,]$. +\end{verbatim} + then: + \def\GammaI{\left[\begin{array}{r \colon l} + \tree & \Set\\ + \forest & \Set + \end{array} + \right]} + \def\GammaC{\left[\begin{array}{r \colon l} + \node & \forest\ra\tree\\ + \emptyf & \forest\\ + \consf & \tree\ra\forest\ra\forest + \end{array} + \right]} + \begin{itemize} + \item $p = 0$ + \item $\Gamma_I = \GammaI$ + \item $\Gamma_C = \GammaC$ + \end{itemize} + and thus it enriches the global environment with the following entry: + \vskip.5em + \ind{0}{\GammaI}{\GammaC} + \caption{\captionstrut Formal representation of the {\tree} and {\forest} inductive types.} + \label{fig:tree:forest} + \end{figure}% + \newpage \end{latexonly}% \subsection{Types of inductive objects} @@ -872,68 +872,77 @@ the type $V$ satisfies the nested positivity condition for $X$ \end{itemize} \begin{latexonly}% -\newcommand\vv{\textSFxi} % │ -\newcommand\hh{\textSFx} % ─ -\newcommand\vh{\textSFviii} % ├ -\newcommand\hv{\textSFii} % └ -\newlength\framecharacterwidth -\settowidth\framecharacterwidth{\hh} -\newcommand\ws{\hbox{}\hskip\the\framecharacterwidth} -\newcommand\ruleref[1]{\hskip.25em\dots\hskip.2em{\em (bullet #1)}} -\paragraph{Example}~\\ -\vskip-.5em -\noindent$X$ occurs strictly positively in $A\ra X$\ruleref5\\ -\vv\\ -\vh\hh\ws $X$does not occur in $A$\ruleref3\\ -\vv\\ -\hv\hh\ws $X$ occurs strictly positively in $X$\ruleref4 -\paragraph{Example}~\\ -\vskip-.5em -\noindent $X$ occurs strictly positively in $X*A$\\ -\vv\\ -\hv\hh $X$ occurs strictly positively in $(\Prod~X~A)$\ruleref6\\ -\ws\ws\vv\\ -\ws\ws\vv\ws\verb|Inductive prod (A B : Type) : Type :=|\\ -\ws\ws\vv\ws\verb| pair : A -> B -> prod A B.|\\ -\ws\ws\vv\\ -\ws\ws\vh\hh $X$ does not occur in any (real) arguments of $\Prod$ in the original term $(\Prod~X~A)$\\ -\ws\ws\vv\\ -\ws\ws\hv\ws the (instantiated) type $\Prod~X~A$ of constructor $\Pair$,\\ -\ws\ws\ws\ws satisfies the nested positivity condition for $X$\ruleref7\\ -\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\hv\ws $X$ does not occur in any (real) arguments of $(\Prod~X~A)$ -\paragraph{Example}~\\ -\vskip-.5em -\noindent $X$ occurs strictly positively in $\ListA$\ruleref6\\ -\vv\\ -\vv\ws\verb|Inductive list (A:Type) : Type :=|\\ -\vv\ws\verb$ | nil : list A$\\ -\vv\ws\verb$ | cons : A -> list A -> list A$\\ -\vv\\ -\vh\hh $X$ does not occur in any arguments of $\List$\\ -\vv\\ -\hv\hh\ws Every instantiated constructor of $\ListA$ satisfies the nested positivity condition for $X$\\ -\ws\ws\ws\vv\\ -\ws\ws\ws\vh\hh\ws concerning type $\ListA$ of constructor $\Nil$:\\ -\ws\ws\ws\vv\ws\ws Type $\ListA$ of constructor $\Nil$ satisfies the nested positivity condition for $X$\\ -\ws\ws\ws\vv\ws\ws because $X$ does not appear in any (real) arguments of the type of that constructor\\ -\ws\ws\ws\vv\ws\ws (primarily because $\List$ does not have any (real) arguments)\ruleref7\\ -\ws\ws\ws\vv\\ -\ws\ws\ws\hv\hh\ws concerning type $\forall~A\ra\ListA\ra\ListA$ of constructor $\cons$:\\ -\ws\ws\ws\ws\ws\ws Type $\forall~A:\Type,A\ra\ListA\ra\ListA$ of constructor $\cons$\\ -\ws\ws\ws\ws\ws\ws satisfies the nested positivity condition for $X$\ruleref8\\ -\ws\ws\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\Type$\ruleref3\\ -\ws\ws\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $A\ra\ListA\ra\ListA$\ruleref8\\ -\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $A$\ruleref3\\ -\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA\ra\ListA$\ruleref8\\ -\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\ListA$\ruleref3\\ -\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ -\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 + \newpage + \newcommand\vv{\textSFxi} % │ + \newcommand\hh{\textSFx} % ─ + \newcommand\vh{\textSFviii} % ├ + \newcommand\hv{\textSFii} % └ + \newlength\framecharacterwidth + \settowidth\framecharacterwidth{\hh} + \newcommand\ws{\hbox{}\hskip\the\framecharacterwidth} + \newcommand\ruleref[1]{\hskip.25em\dots\hskip.2em{\em (bullet #1)}} + \def\captionstrut{\vbox to 1.5em{}} + + \begin{figure}[H] + \ws\strut $X$ occurs strictly positively in $A\ra X$\ruleref5\\ + \ws\vv\\ + \ws\vh\hh\ws $X$does not occur in $A$\\ + \ws\vv\\ + \ws\hv\hh\ws $X$ occurs strictly positively in $X$\ruleref4 + \caption{\captionstrut A proof that $X$ occurs strictly positively in $A\ra X$.} + \end{figure} + +% \begin{figure}[H] +% \strut $X$ occurs strictly positively in $X*A$\\ +% \vv\\ +% \hv\hh $X$ occurs strictly positively in $(\Prod~X~A)$\ruleref6\\ +% \ws\ws\vv\\ +% \ws\ws\vv\ws\verb|Inductive prod (A B : Type) : Type :=|\\ +% \ws\ws\vv\ws\verb| pair : A -> B -> prod A B.|\\ +% \ws\ws\vv\\ +% \ws\ws\vh\hh $X$ does not occur in any (real) arguments of $\Prod$ in the original term $(\Prod~X~A)$\\ +% \ws\ws\vv\\ +% \ws\ws\hv\hh\ws the (instantiated) type $\Prod~X~A$ of constructor $\Pair$,\\ +% \ws\ws\ws\ws\ws satisfies the nested positivity condition for $X$\ruleref7\\ +% \ws\ws\ws\ws\ws\vv\\ +% \ws\ws\ws\ws\ws\hv\hh\ws $X$ does not occur in any (real) arguments of $(\Prod~X~A)$ +% \caption{\captionstrut A proof that $X$ occurs strictly positively in $X*A$} +% \end{figure} + + \begin{figure}[H] + \ws\strut $X$ occurs strictly positively in $\ListA$\ruleref6\\ + \ws\vv\\ + \ws\vv\ws\verb|Inductive list (A:Type) : Type :=|\\ + \ws\vv\ws\verb$ | nil : list A$\\ + \ws\vv\ws\verb$ | cons : A -> list A -> list A$\\ + \ws\vv\\ + \ws\vh\hh $X$ does not occur in any (real) arguments of $\List$\\ + \ws\vv\\ + \ws\hv\hh\ws Every instantiated constructor of $\ListA$ satisfies the nested positivity condition for $X$\\ + \ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\vh\hh\ws concerning type $\ListA$ of constructor $\Nil$:\\ + \ws\ws\ws\ws\vv\ws\ws\ws\ws Type $\ListA$ of constructor $\Nil$ satisfies the nested positivity condition for $X$\\ + \ws\ws\ws\ws\vv\ws\ws\ws\ws because $X$ does not appear in any (real) arguments of the type of that constructor\\ + \ws\ws\ws\ws\vv\ws\ws\ws\ws (primarily because $\List$ does not have any (real) arguments)\ruleref7\\ + \ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\hv\hh\ws concerning type $\forall~A\ra\ListA\ra\ListA$ of constructor $\cons$:\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws Type $\forall~A:\Type,A\ra\ListA\ra\ListA$ of constructor $\cons$\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws satisfies the nested positivity condition for $X$\ruleref8\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\Type$\ruleref3\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $A\ra\ListA\ra\ListA$\ruleref8\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $A$\ruleref3\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA\ra\ListA$\ruleref8\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\ListA$\ruleref4\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 + \caption{\captionstrut A proof that $X$ occurs strictly positively in $\ListA$} + \end{figure} + \newpage \end{latexonly}% \paragraph{Correctness rules.} diff --git a/doc/refman/Reference-Manual.tex b/doc/refman/Reference-Manual.tex index cb5d2ecb54..dcb98d96b3 100644 --- a/doc/refman/Reference-Manual.tex +++ b/doc/refman/Reference-Manual.tex @@ -21,6 +21,10 @@ \usepackage{multicol} \usepackage{xspace} \usepackage{pmboxdraw} +\usepackage{float} + +\floatstyle{boxed} +\restylefloat{figure} % for coqide \ifpdf % si on est pas en pdflatex -- cgit v1.2.3 From f43f474fe3ba0b01115ef02b0032f706879ee521 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 24 Nov 2015 13:50:08 +0100 Subject: FIX: wrong reference to a figure --- doc/refman/RefMan-cic.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index ad711549b2..1b461afcb2 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -532,7 +532,7 @@ These inductive definitions, together with global assumptions and global definit Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$ such that each $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as: $\forall\Gamma_P, T^\prime$ where $\Gamma_P$ is called the {\em context of parameters\index{context of parameters}}. -Figures~\ref{fig:bool}--\ref{fig:even:odd} show formal representation of several inductive definitions. +Figures~\ref{fig:bool}--\ref{fig:tree:forest} show formal representation of several inductive definitions. \begin{latexonly}% \newpage -- cgit v1.2.3 From 9e12f35ddf03dd47af99284fa9bfbb14759834b8 Mon Sep 17 00:00:00 2001 From: Matej Kosik Date: Tue, 24 Nov 2015 18:12:32 +0100 Subject: ENH: redundant examples were removed --- doc/refman/RefMan-cic.tex | 198 ---------------------------------------------- 1 file changed, 198 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 1b461afcb2..3e50ac0de0 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -532,10 +532,8 @@ These inductive definitions, together with global assumptions and global definit Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$ such that each $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as: $\forall\Gamma_P, T^\prime$ where $\Gamma_P$ is called the {\em context of parameters\index{context of parameters}}. -Figures~\ref{fig:bool}--\ref{fig:tree:forest} show formal representation of several inductive definitions. \begin{latexonly}% - \newpage \def\captionstrut{\vbox to 1.5em{}} \newcommand\ind[3]{$\mathsf{Ind}~[#1]\left(\hskip-.4em \begin{array}{r @{\mathrm{~:=~}} l} @@ -546,104 +544,6 @@ Figures~\ref{fig:bool}--\ref{fig:tree:forest} show formal representation of seve \def\colon{@{\hskip.5em:\hskip.5em}} - \begin{figure}[H] - \strut If we take the following inductive definition (denoted in concrete syntax): -\begin{verbatim} -Inductive bool : Set := - | true : bool - | false : bool. -\end{verbatim} - then: - \def\GammaI{\left[\begin{array}{r \colon l} - \bool & \Set - \end{array} - \right]} - \def\GammaC{\left[\begin{array}{r \colon l} - \true & \bool\\ - \false & \bool - \end{array} - \right]} - \begin{itemize} - \item $p = 0$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ - \item $\Gamma_P=[\,]$. - \end{itemize} - and thus it enriches the global environment with the following entry: - \vskip.5em - \ind{p}{\Gamma_I}{\Gamma_C} - \vskip.5em - \noindent that is: - \vskip.5em - \ind{0}{\GammaI}{\GammaC} - \caption{\captionstrut Formal representation of the {\bool} inductive type.} - \label{fig:bool} - \end{figure} - - \begin{figure}[H] - \strut If we take the followig inductive definition: -\begin{verbatim} -Inductive nat : Set := - | O : nat - | S : nat -> nat. -\end{verbatim} - then: - \def\GammaI{\left[\begin{array}{r \colon l} - \nat & \Set - \end{array} - \right]} - \def\GammaC{\left[\begin{array}{r \colon l} - \nO & \nat\\ - \nS & \nat\ra\nat - \end{array} - \right]} - \begin{itemize} - \item $p = 0$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ - \item $\Gamma_P=[\,]$. - \end{itemize} - and thus it enriches the global environment with the following entry: - \vskip.5em - \ind{p}{\Gamma_I}{\Gamma_C} - \vskip.5em - \noindent that is: - \vskip.5em - \ind{0}{\GammaI}{\GammaC} - \caption{\captionstrut Formal representation of the {\nat} inductive type.} - \label{fig:nat} - \end{figure} - - \begin{figure}[H] - \strut If we take the following inductive definition: -\begin{verbatim} -Inductive list (A : Type) : Type := - | nil : list A - | cons : A -> list A -> list A. -\end{verbatim} - then: - \def\GammaI{\left[\begin{array}{r \colon l} - \List & \Type\ra\Type - \end{array} - \right]} - \def\GammaC{\left[\begin{array}{r \colon l} - \Nil & \forall~A\!:\!\Type,~\List~A\\ - \cons & \forall~A\!:\!\Type,~A\ra\List~A\ra\List~A - \end{array} - \right]} - \begin{itemize} - \item $p = 1$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ - \item $\Gamma_P=[A:\Type]$ - \end{itemize} - and thus it enriches the global environment with the following entry: - \vskip.5em - \ind{1}{\GammaI}{\GammaC} - \caption{\captionstrut Formal representation of the {\List} inductive type.} - \label{fig:list} - \end{figure} - \begin{figure}[H] \strut If we take the following inductive definition: \begin{verbatim} @@ -677,76 +577,6 @@ with odd : nat -> Prop := \caption{\captionstrut Formal representation of the {\even} and {\odd} inductive types.} \label{fig:even:odd} \end{figure} - - \begin{figure}[H] - \strut If we take the following inductive definition: -\begin{verbatim} -Inductive has_length (A : Type) : list A -> nat -> Prop := - | nil_hl : has_length A (nil A) O - | cons_hl : forall (a:A) (l:list A) (n:nat), - has_length A l n -> has_length A (cons A a l) (S n). -\end{verbatim} - then: - \def\GammaI{\left[\begin{array}{r \colon l} - \haslength & \forall~A\!:\!\Type,~\List~A\ra\nat\ra\Prop - \end{array} - \right]} - \def\GammaC{\left[\begin{array}{r c l} - \nilhl & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\haslength~A~(\Nil~A)~\nO\\ - \conshl & \hskip.1em:\hskip.1em & \forall~A\!:\!\Type,~\forall~a\!:\!A,~\forall~l\!:\!\List~A,~\forall~n\!:\!\nat,\\ - & & \haslength~A~l~n\ra \haslength~A~(\cons~A~a~l)~(\nS~n) - \end{array} - \right]} - \begin{itemize} - \item $p = 1$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ - \item $\Gamma_P=[A:\Type]$. - \end{itemize} - and thus it enriches the global environment with the following entry: - \vskip.5em - \ind{p}{\Gamma_I}{\Gamma_C} - %\vskip.5em - %\noindent that is: - %\vskip.5em - %\ind{1}{\GammaI}{\GammaC} - \caption{\captionstrut Formal representation of the {\haslength} inductive type.} - \label{fig:haslength} - \end{figure} - - \begin{figure}[H] - \strut If we take the following inductive definition: -\begin{verbatim} -Inductive tree : Set := - | node : forest -> tree -with forest : Set := - | emptyf : forest - | consf : tree -> forest -> forest. -\end{verbatim} - then: - \def\GammaI{\left[\begin{array}{r \colon l} - \tree & \Set\\ - \forest & \Set - \end{array} - \right]} - \def\GammaC{\left[\begin{array}{r \colon l} - \node & \forest\ra\tree\\ - \emptyf & \forest\\ - \consf & \tree\ra\forest\ra\forest - \end{array} - \right]} - \begin{itemize} - \item $p = 0$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ - \end{itemize} - and thus it enriches the global environment with the following entry: - \vskip.5em - \ind{0}{\GammaI}{\GammaC} - \caption{\captionstrut Formal representation of the {\tree} and {\forest} inductive types.} - \label{fig:tree:forest} - \end{figure}% - \newpage \end{latexonly}% \subsection{Types of inductive objects} @@ -872,7 +702,6 @@ the type $V$ satisfies the nested positivity condition for $X$ \end{itemize} \begin{latexonly}% - \newpage \newcommand\vv{\textSFxi} % │ \newcommand\hh{\textSFx} % ─ \newcommand\vh{\textSFviii} % ├ @@ -883,32 +712,6 @@ the type $V$ satisfies the nested positivity condition for $X$ \newcommand\ruleref[1]{\hskip.25em\dots\hskip.2em{\em (bullet #1)}} \def\captionstrut{\vbox to 1.5em{}} - \begin{figure}[H] - \ws\strut $X$ occurs strictly positively in $A\ra X$\ruleref5\\ - \ws\vv\\ - \ws\vh\hh\ws $X$does not occur in $A$\\ - \ws\vv\\ - \ws\hv\hh\ws $X$ occurs strictly positively in $X$\ruleref4 - \caption{\captionstrut A proof that $X$ occurs strictly positively in $A\ra X$.} - \end{figure} - -% \begin{figure}[H] -% \strut $X$ occurs strictly positively in $X*A$\\ -% \vv\\ -% \hv\hh $X$ occurs strictly positively in $(\Prod~X~A)$\ruleref6\\ -% \ws\ws\vv\\ -% \ws\ws\vv\ws\verb|Inductive prod (A B : Type) : Type :=|\\ -% \ws\ws\vv\ws\verb| pair : A -> B -> prod A B.|\\ -% \ws\ws\vv\\ -% \ws\ws\vh\hh $X$ does not occur in any (real) arguments of $\Prod$ in the original term $(\Prod~X~A)$\\ -% \ws\ws\vv\\ -% \ws\ws\hv\hh\ws the (instantiated) type $\Prod~X~A$ of constructor $\Pair$,\\ -% \ws\ws\ws\ws\ws satisfies the nested positivity condition for $X$\ruleref7\\ -% \ws\ws\ws\ws\ws\vv\\ -% \ws\ws\ws\ws\ws\hv\hh\ws $X$ does not occur in any (real) arguments of $(\Prod~X~A)$ -% \caption{\captionstrut A proof that $X$ occurs strictly positively in $X*A$} -% \end{figure} - \begin{figure}[H] \ws\strut $X$ occurs strictly positively in $\ListA$\ruleref6\\ \ws\vv\\ @@ -942,7 +745,6 @@ the type $V$ satisfies the nested positivity condition for $X$ \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 \caption{\captionstrut A proof that $X$ occurs strictly positively in $\ListA$} \end{figure} - \newpage \end{latexonly}% \paragraph{Correctness rules.} -- cgit v1.2.3 From 006e1a5bf9e90fba3ba9fa1541e7ed8978c99441 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Thu, 10 Dec 2015 09:25:03 +0100 Subject: Refman, ch. 4: A few fixes. --- doc/refman/RefMan-cic.tex | 155 ++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 66 deletions(-) diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex index 3e50ac0de0..e3e49e115d 100644 --- a/doc/refman/RefMan-cic.tex +++ b/doc/refman/RefMan-cic.tex @@ -533,51 +533,76 @@ Additionally, for any $p$ there always exists $\Gamma_P=[a_1:A_1;\dots;a_p:A_p]$ such that each $(t:T)\in\Gamma_I\cup\Gamma_C$ can be written as: $\forall\Gamma_P, T^\prime$ where $\Gamma_P$ is called the {\em context of parameters\index{context of parameters}}. -\begin{latexonly}% - \def\captionstrut{\vbox to 1.5em{}} - \newcommand\ind[3]{$\mathsf{Ind}~[#1]\left(\hskip-.4em +\paragraph{Examples} + + \newcommand\ind[3]{$\mathsf{Ind}~[#1]\left(\hskip-.4em \begin{array}{r @{\mathrm{~:=~}} l} #2 & #3 \\ \end{array} \hskip-.4em \right)$} + \def\colon{@{\hskip.5em:\hskip.5em}} - \def\colon{@{\hskip.5em:\hskip.5em}} +The declaration for parameterized lists is: + \vskip.5em - \begin{figure}[H] - \strut If we take the following inductive definition: -\begin{verbatim} -Inductive even : nat -> Prop := - | even_O : even 0 - | even_S : forall n, odd n -> even (S n) -with odd : nat -> Prop := - | odd_S : forall n, even n -> odd (S n). -\end{verbatim} - then: - \def\GammaI{\left[\begin{array}{r \colon l} +\ind{1}{\List:\Set\ra\Set}{\left[\begin{array}{r \colon l} + \Nil & \forall A:\Set,\List~A \\ + \cons & \forall A:\Set, A \ra \List~A \ra \List~A + \end{array}\right]} + \vskip.5em + +which corresponds to the result of the \Coq\ declaration: +\begin{coq_example*} +Inductive list (A:Set) : Set := + | nil : list A + | cons : A -> list A -> list A. +\end{coq_example*} + +The declaration for a mutual inductive definition of forests and trees is: + \vskip.5em +\ind{}{\left[\begin{array}{r \colon l}\tree&\Set\\\forest&\Set\end{array}\right]} + {\left[\begin{array}{r \colon l} + \node & \forest \ra \tree\\ + \emptyf & \forest\\ + \consf & \tree \ra \forest \ra \forest\\ + \end{array}\right]} + \vskip.5em + +which corresponds to the result of the \Coq\ +declaration: +\begin{coq_example*} +Inductive tree : Set := + node : forest -> tree +with forest : Set := + | emptyf : forest + | consf : tree -> forest -> forest. +\end{coq_example*} + +The declaration for a mutual inductive definition of even and odd is: + \newcommand\GammaI{\left[\begin{array}{r \colon l} \even & \nat\ra\Prop \\ \odd & \nat\ra\Prop \end{array} \right]} - \def\GammaC{\left[\begin{array}{r \colon l} + \newcommand\GammaC{\left[\begin{array}{r \colon l} \evenO & \even~\nO \\ \evenS & \forall n : \nat, \odd~n \ra \even~(\nS~n)\\ \oddS & \forall n : \nat, \even~n \ra \odd~(\nS~n) \end{array} \right]} - \begin{itemize} - \item $p = 1$ - \item $\Gamma_I = \GammaI$ - \item $\Gamma_C = \GammaC$ - \item $\Gamma_P=[A:\Type]$. - \end{itemize} - and thus it enriches the global environment with the following entry: \vskip.5em \ind{1}{\GammaI}{\GammaC} - \caption{\captionstrut Formal representation of the {\even} and {\odd} inductive types.} - \label{fig:even:odd} - \end{figure} -\end{latexonly}% + \vskip.5em +which corresponds to the result of the \Coq\ +declaration: +\begin{coq_example*} +Inductive even : nat -> Prop := + | even_O : even 0 + | even_S : forall n, odd n -> even (S n) +with odd : nat -> Prop := + | odd_S : forall n, even n -> odd (S n). +\end{coq_example*} \subsection{Types of inductive objects} We have to give the type of constants in a global environment $E$ which @@ -595,7 +620,7 @@ contains an inductive declaration. Provided that our environment $E$ contains inductive definitions we showed before, these two inference rules above enable us to conclude that: \vskip.5em -\def\prefix{E[\Gamma]\vdash\hskip.25em} +\newcommand\prefix{E[\Gamma]\vdash\hskip.25em} $\begin{array}{@{} l} \prefix\even : \nat\ra\Prop\\ \prefix\odd : \nat\ra\Prop\\ @@ -701,51 +726,49 @@ any $u_i$ the type $V$ satisfies the nested positivity condition for $X$ \end{itemize} -\begin{latexonly}% - \newcommand\vv{\textSFxi} % │ - \newcommand\hh{\textSFx} % ─ - \newcommand\vh{\textSFviii} % ├ - \newcommand\hv{\textSFii} % └ - \newlength\framecharacterwidth - \settowidth\framecharacterwidth{\hh} - \newcommand\ws{\hbox{}\hskip\the\framecharacterwidth} - \newcommand\ruleref[1]{\hskip.25em\dots\hskip.2em{\em (bullet #1)}} - \def\captionstrut{\vbox to 1.5em{}} - - \begin{figure}[H] - \ws\strut $X$ occurs strictly positively in $\ListA$\ruleref6\\ - \ws\vv\\ - \ws\vv\ws\verb|Inductive list (A:Type) : Type :=|\\ - \ws\vv\ws\verb$ | nil : list A$\\ - \ws\vv\ws\verb$ | cons : A -> list A -> list A$\\ - \ws\vv\\ - \ws\vh\hh $X$ does not occur in any (real) arguments of $\List$\\ - \ws\vv\\ - \ws\hv\hh\ws Every instantiated constructor of $\ListA$ satisfies the nested positivity condition for $X$\\ +%% \begin{latexonly}% + \newcommand\vv{\textSFxi} % │ + \newcommand\hh{\textSFx} % ─ + \newcommand\vh{\textSFviii} % ├ + \newcommand\hv{\textSFii} % └ + \newlength\framecharacterwidth + \settowidth\framecharacterwidth{\hh} + \newcommand\ws{\hbox{}\hskip\the\framecharacterwidth} + \newcommand\ruleref[1]{\hskip.25em\dots\hskip.2em{\em (bullet #1)}} +%% \def\captionstrut{\vbox to 1.5em{}} + +%% \begin{figure}[H] +For instance, if one considers the type + +\begin{verbatim} +Inductive tree (A:Type) : Type := + | leaf : list A + | node : A -> (nat -> tree A) -> tree A +\end{verbatim} + +Then every instantiated constructor of $\ListA$ satisfies the nested positivity condition for $\List$ + +\noindent \ws\ws\ws\ws\vv\\ \ws\ws\ws\ws\vh\hh\ws concerning type $\ListA$ of constructor $\Nil$:\\ - \ws\ws\ws\ws\vv\ws\ws\ws\ws Type $\ListA$ of constructor $\Nil$ satisfies the nested positivity condition for $X$\\ - \ws\ws\ws\ws\vv\ws\ws\ws\ws because $X$ does not appear in any (real) arguments of the type of that constructor\\ - \ws\ws\ws\ws\vv\ws\ws\ws\ws (primarily because $\List$ does not have any (real) arguments)\ruleref7\\ + \ws\ws\ws\ws\vv\ws\ws\ws\ws Type $\ListA$ of constructor $\Nil$ satisfies the positivity condition for $\List$\\ + \ws\ws\ws\ws\vv\ws\ws\ws\ws because $\List$ does not appear in any (real) arguments of the type of that constructor\\ + \ws\ws\ws\ws\vv\ws\ws\ws\ws (primarily because $\List$ does not have any (real) arguments)\ruleref1\\ \ws\ws\ws\ws\vv\\ \ws\ws\ws\ws\hv\hh\ws concerning type $\forall~A\ra\ListA\ra\ListA$ of constructor $\cons$:\\ \ws\ws\ws\ws\ws\ws\ws\ws\ws Type $\forall~A:\Type,A\ra\ListA\ra\ListA$ of constructor $\cons$\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws satisfies the nested positivity condition for $X$\ruleref8\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws satisfies the positivity condition for $\List$ because:\\ \ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\Type$\ruleref3\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $\List$ occurs only strictly positively in $\Type$\ruleref3\\ \ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $A\ra\ListA\ra\ListA$\ruleref8\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $A$\ruleref3\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA\ra\ListA$\ruleref8\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $X$ occurs only strictly positively in $\ListA$\ruleref4\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ - \ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $X$ satisfies the nested positivity condition for $\ListA$\ruleref7 - \caption{\captionstrut A proof that $X$ occurs strictly positively in $\ListA$} - \end{figure} -\end{latexonly}% + \ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $\List$ occurs only strictly positively in $A$\ruleref3\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\vh\hh\ws $\List$ occurs only strictly positively in $\ListA$\ruleref4\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\vv\\ + \ws\ws\ws\ws\ws\ws\ws\ws\ws\hv\hh\ws $\List$ satisfies the positivity condition for $\ListA$\ruleref1 +%% \caption{\captionstrut A proof that $X$ occurs strictly positively in $\ListA$} +%% \end{figure} +%% \end{latexonly}% \paragraph{Correctness rules.} We shall now describe the rules allowing the introduction of a new -- cgit v1.2.3 From a6f1944809e4caa6c99deb8c508dab9ad0e0071e Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Thu, 10 Dec 2015 16:02:15 +0100 Subject: Silently ignore requests to _not_ clear something when that something cannot be cleared. This should fix the contrib failures on tactics like "destruct (0)". --- tactics/tactics.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tactics/tactics.ml b/tactics/tactics.ml index ce8b9b3dbd..536a10eaa7 100644 --- a/tactics/tactics.ml +++ b/tactics/tactics.ml @@ -277,7 +277,8 @@ let apply_clear_request clear_flag dft c = error "keep/clear modifiers apply only to hypothesis names." in let clear = match clear_flag with | None -> dft && isVar c - | Some clear -> check_isvar c; clear in + | Some true -> check_isvar c; true + | Some false -> false in if clear then Proofview.V82.tactic (thin [destVar c]) else Tacticals.New.tclIDTAC -- cgit v1.2.3 From 20e1829ad3de42dd322af972c6f9a585f40738ef Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Thu, 10 Dec 2015 16:40:38 +0100 Subject: Fixing compilation with OCaml 3.12 after commit 9d45d45f3a87 on removing "open Unix" from lib/system.ml. --- lib/system.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/system.ml b/lib/system.ml index f860bd2f7e..a902229609 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -262,7 +262,7 @@ type time = float * float * float let get_time () = let t = Unix.times () in - (Unix.gettimeofday(), t.tms_utime, t.tms_stime) + (Unix.gettimeofday(), t.Unix.tms_utime, t.Unix.tms_stime) (* Keep only 3 significant digits *) let round f = (floor (f *. 1e3)) *. 1e-3 -- cgit v1.2.3 From fb77937a6ba0fe45e978911db08de57f931683e1 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Wed, 9 Dec 2015 23:38:00 +0100 Subject: Changing syntax of pat/constr1.../constrn into pat%constr1...%constrn. Marking it as experimental. --- CHANGES | 3 +++ doc/refman/RefMan-tac.tex | 14 +++++++------- parsing/g_tactic.ml4 | 3 ++- test-suite/success/intros.v | 20 ++++++++++---------- theories/Logic/WKL.v | 6 +++--- theories/Logic/WeakFan.v | 2 +- theories/Wellfounded/Lexicographic_Exponentiation.v | 2 +- 7 files changed, 27 insertions(+), 23 deletions(-) diff --git a/CHANGES b/CHANGES index 70ed1bef01..389572014e 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,9 @@ Tactics - Syntax "destruct !hyp" changed to "destruct (hyp)", and similarly for induction. +- Syntax "p/c" for on-the-fly application of a lemma c before + introducing along pattern p changed to p%c1..%cn. The feature and + syntax are in experimental stage. Changes from V8.5beta2 to V8.5beta3 =================================== diff --git a/doc/refman/RefMan-tac.tex b/doc/refman/RefMan-tac.tex index f367f04c43..3a3877105b 100644 --- a/doc/refman/RefMan-tac.tex +++ b/doc/refman/RefMan-tac.tex @@ -813,7 +813,7 @@ either: \item the pattern \texttt{?\ident} \item an identifier \end{itemize} -\item a {\em destructing introduction pattern} which itself classifies into: +\item an {\em action introduction pattern} which itself classifies into: \begin{itemize} \item a {\em disjunctive/conjunctive introduction pattern}, i.e. either one of: \begin{itemize} @@ -828,9 +828,9 @@ either: \item a pattern for decomposing an equality: {\tt [= $p_1$ \dots\ $p_n$]} \item the rewriting orientations: {\tt ->} or {\tt <-} \end{itemize} - \item the on-the-fly application of lemmas: $p${\tt /{\term$_1$}} - \ldots {\tt /{\term$_n$}} where $p$ itself is not an on-the-fly - application of lemmas pattern + \item the on-the-fly application of lemmas: $p${\tt \%{\term$_1$}} + \ldots {\tt \%{\term$_n$}} where $p$ itself is not a pattern for + on-the-fly application of lemmas (note: syntax is in experimental stage) \end{itemize} \item the wildcard: {\tt \_} \end{itemize} @@ -898,10 +898,10 @@ introduction pattern~$p$: itself is erased; if the term to substitute is a variable, it is substituted also in the context of goal and the variable is removed too; -\item introduction over a pattern $p${\tt /{\term$_1$}} \ldots {\tt - /{\term$_n$}} first applies {\term$_1$},\ldots, {\term$_n$} on the +\item introduction over a pattern $p${\tt \%{\term$_1$}} \ldots {\tt + \%{\term$_n$}} first applies {\term$_1$},\ldots, {\term$_n$} on the hypothesis to be introduced (as in {\tt apply }{\term}$_1$, \ldots, - {\term}$_n$ {\tt in}), prior to the application of the introduction + {\term}$_n$ {\tt in}) prior to the application of the introduction pattern $p$; \item introduction on the wildcard depends on whether the product is dependent or not: in the non-dependent case, it erases the diff --git a/parsing/g_tactic.ml4 b/parsing/g_tactic.ml4 index 4d42dfe85a..3d59b9b8db 100644 --- a/parsing/g_tactic.ml4 +++ b/parsing/g_tactic.ml4 @@ -311,7 +311,8 @@ GEXTEND Gram | "**" -> !@loc, IntroForthcoming false ]] ; simple_intropattern: - [ [ pat = simple_intropattern_closed; l = LIST0 ["/"; c = constr -> c] -> + [ [ pat = simple_intropattern_closed; + l = LIST0 ["%"; c = operconstr LEVEL "0" -> c] -> let loc0,pat = pat in let f c pat = let loc = Loc.merge loc0 (Constrexpr_ops.constr_loc c) in diff --git a/test-suite/success/intros.v b/test-suite/success/intros.v index 741f372ff2..17f160f98e 100644 --- a/test-suite/success/intros.v +++ b/test-suite/success/intros.v @@ -34,47 +34,47 @@ intros _ ?. exact H. Qed. -(* A short test about introduction pattern pat/c *) +(* A short test about introduction pattern pat%c *) Goal (True -> 0=0) -> True /\ False -> 0=0. -intros H (H1/H,_). +intros H (H1%H,_). exact H1. Qed. (* A test about bugs in 8.5beta2 *) Goal (True -> 0=0) -> True /\ False -> False -> 0=0. intros H H0 H1. -destruct H0 as (a/H,_). +destruct H0 as (a%H,_). (* Check that H0 is removed (was bugged in 8.5beta2) *) Fail clear H0. -(* Check position of newly created hypotheses when using pat/c (was +(* Check position of newly created hypotheses when using pat%c (was left at top in 8.5beta2) *) match goal with H:_ |- _ => clear H end. (* clear H1:False *) match goal with H:_ |- _ => exact H end. (* check that next hyp shows 0=0 *) Qed. Goal (True -> 0=0) -> True -> 0=0. -intros H H1/H. +intros H H1%H. exact H1. Qed. Goal forall n, n = S n -> 0=0. -intros n H/n_Sn. +intros n H%n_Sn. destruct H. Qed. (* Another check about generated names and cleared hypotheses with - pat/c patterns *) + pat%c patterns *) Goal (True -> 0=0 /\ 1=1) -> True -> 0=0. -intros H (H1,?)/H. +intros H (H1,?)%H. change (1=1) in H0. exact H1. Qed. -(* Checking iterated pat/c1.../cn introduction patterns and side conditions *) +(* Checking iterated pat%c1...%cn introduction patterns and side conditions *) Goal forall A B C D:Prop, (A -> B -> C) -> (C -> D) -> B -> A -> D. intros * H H0 H1. -intros H2/H/H0. +intros H2%H%H0. - exact H2. - exact H1. Qed. diff --git a/theories/Logic/WKL.v b/theories/Logic/WKL.v index 408eca4a33..abe6a8d995 100644 --- a/theories/Logic/WKL.v +++ b/theories/Logic/WKL.v @@ -40,7 +40,7 @@ Proposition is_path_from_characterization P n l : Proof. intros. split. - induction 1 as [|* HP _ (l'&Hl'&HPl')|* HP _ (l'&Hl'&HPl')]. - + exists []. split. reflexivity. intros n <-/le_n_0_eq. assumption. + + exists []. split. reflexivity. intros n <-%le_n_0_eq. assumption. + exists (true :: l'). split. apply eq_S, Hl'. intros [|] H. * assumption. * simpl. rewrite <- app_assoc. apply HPl', le_S_n, H. @@ -51,10 +51,10 @@ intros. split. + constructor. apply (HPl' 0). apply le_0_n. + eapply next_left. * apply (HPl' 0), le_0_n. - * fold (length l'). apply IHl'. intros n' H/le_n_S. apply HPl' in H. simpl in H. rewrite <- app_assoc in H. assumption. + * fold (length l'). apply IHl'. intros n' H%le_n_S. apply HPl' in H. simpl in H. rewrite <- app_assoc in H. assumption. + apply next_right. * apply (HPl' 0), le_0_n. - * fold (length l'). apply IHl'. intros n' H/le_n_S. apply HPl' in H. simpl in H. rewrite <- app_assoc in H. assumption. + * fold (length l'). apply IHl'. intros n' H%le_n_S. apply HPl' in H. simpl in H. rewrite <- app_assoc in H. assumption. Qed. (** [infinite_from P l] means that we can find arbitrary long paths diff --git a/theories/Logic/WeakFan.v b/theories/Logic/WeakFan.v index 2f84ebe5f3..365661be05 100644 --- a/theories/Logic/WeakFan.v +++ b/theories/Logic/WeakFan.v @@ -89,7 +89,7 @@ Qed. Theorem WeakFanTheorem : forall P, barred P -> inductively_barred P []. Proof. intros P Hbar. -destruct Hbar with (X P) as (l,(Hd/Y_approx,HP)). +destruct Hbar with (X P) as (l,(Hd%Y_approx,HP)). assert (inductively_barred P l) by (apply (now P l), HP). clear Hbar HP. induction l as [|a l]. diff --git a/theories/Wellfounded/Lexicographic_Exponentiation.v b/theories/Wellfounded/Lexicographic_Exponentiation.v index dd9e4c986e..b8b9e929c2 100644 --- a/theories/Wellfounded/Lexicographic_Exponentiation.v +++ b/theories/Wellfounded/Lexicographic_Exponentiation.v @@ -95,7 +95,7 @@ Section Wf_Lexicographic_Exponentiation. intros. - inversion H. assert ([b; a] = ([] ++ [b]) ++ [a]) by auto with sets. - destruct (app_inj_tail (l ++ [y]) ([] ++ [b]) _ _ H0) as ((?, <-)/app_inj_tail, <-). + destruct (app_inj_tail (l ++ [y]) ([] ++ [b]) _ _ H0) as ((?, <-)%app_inj_tail, <-). inversion H1; subst; [ apply rt_step; assumption | apply rt_refl ]. - inversion H0. + apply app_cons_not_nil in H3 as (). -- cgit v1.2.3 From cdaf8e2ed109bd117da2366a279fa575d7b6185a Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Thu, 10 Dec 2015 19:14:19 +0100 Subject: Fixing a pat%constr bug. Thanks to Enrico for reporting. --- tactics/tacinterp.ml | 2 +- test-suite/success/intros.v | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tactics/tacinterp.ml b/tactics/tacinterp.ml index 693b382cac..59420e4e01 100644 --- a/tactics/tacinterp.ml +++ b/tactics/tacinterp.ml @@ -866,7 +866,7 @@ and interp_intro_pattern_action ist env sigma = function let sigma,l = interp_intro_pattern_list_as_list ist env sigma l in sigma, IntroInjection l | IntroApplyOn (c,ipat) -> - let c = fun env sigma -> interp_constr ist env sigma c in + let c = fun env sigma -> interp_open_constr ist env sigma c in let sigma,ipat = interp_intro_pattern ist env sigma ipat in sigma, IntroApplyOn (c,ipat) | IntroWildcard | IntroRewrite _ as x -> sigma, x diff --git a/test-suite/success/intros.v b/test-suite/success/intros.v index 17f160f98e..11156aa0ee 100644 --- a/test-suite/success/intros.v +++ b/test-suite/success/intros.v @@ -78,3 +78,9 @@ intros H2%H%H0. - exact H2. - exact H1. Qed. + +(* Bug found by Enrico *) + +Goal forall x : nat, True. +intros y%(fun x => x). +Abort. -- cgit v1.2.3 From 5ad28372f001acbc562e1d095728cdb8a131938c Mon Sep 17 00:00:00 2001 From: Maxime Dénès Date: Thu, 10 Dec 2015 18:26:08 +0100 Subject: Add tactic native_cast_no_check, analog to vm_cast_no_check. --- tactics/coretactics.ml4 | 4 ++++ tactics/tactics.ml | 4 ++++ tactics/tactics.mli | 1 + 3 files changed, 9 insertions(+) diff --git a/tactics/coretactics.ml4 b/tactics/coretactics.ml4 index e909a14c9e..92d4960a7c 100644 --- a/tactics/coretactics.ml4 +++ b/tactics/coretactics.ml4 @@ -42,6 +42,10 @@ TACTIC EXTEND vm_cast_no_check [ "vm_cast_no_check" constr(c) ] -> [ Proofview.V82.tactic (Tactics.vm_cast_no_check c) ] END +TACTIC EXTEND native_cast_no_check + [ "native_cast_no_check" constr(c) ] -> [ Proofview.V82.tactic (Tactics.native_cast_no_check c) ] +END + TACTIC EXTEND casetype [ "casetype" constr(c) ] -> [ Tactics.case_type c ] END diff --git a/tactics/tactics.ml b/tactics/tactics.ml index 536a10eaa7..131730ebc0 100644 --- a/tactics/tactics.ml +++ b/tactics/tactics.ml @@ -1731,6 +1731,10 @@ let vm_cast_no_check c gl = let concl = pf_concl gl in refine_no_check (Term.mkCast(c,Term.VMcast,concl)) gl +let native_cast_no_check c gl = + let concl = pf_concl gl in + refine_no_check (Term.mkCast(c,Term.NATIVEcast,concl)) gl + let exact_proof c gl = let c,ctx = Constrintern.interp_casted_constr (pf_env gl) (project gl) c (pf_concl gl) diff --git a/tactics/tactics.mli b/tactics/tactics.mli index b9a0184180..896b33727c 100644 --- a/tactics/tactics.mli +++ b/tactics/tactics.mli @@ -118,6 +118,7 @@ val intros_patterns : intro_patterns -> unit Proofview.tactic val assumption : unit Proofview.tactic val exact_no_check : constr -> tactic val vm_cast_no_check : constr -> tactic +val native_cast_no_check : constr -> tactic val exact_check : constr -> unit Proofview.tactic val exact_proof : Constrexpr.constr_expr -> tactic -- cgit v1.2.3 From ab3a1aed8fcaed3b0988b686b7f4cf7124b07ab2 Mon Sep 17 00:00:00 2001 From: Maxime Dénès Date: Fri, 11 Dec 2015 12:15:17 +0100 Subject: Remove Set Virtual Machine from doc, since the command itself has been removed. --- doc/refman/RefMan-com.tex | 6 ------ doc/refman/RefMan-oth.tex | 20 -------------------- 2 files changed, 26 deletions(-) diff --git a/doc/refman/RefMan-com.tex b/doc/refman/RefMan-com.tex index 9862abb533..8bb1cc331b 100644 --- a/doc/refman/RefMan-com.tex +++ b/doc/refman/RefMan-com.tex @@ -87,7 +87,6 @@ code. The list of highlight tags can be retrieved with the {\tt -list-tags} command-line option of {\tt coqtop}. \subsection{By command line options\index{Options of the command line} -\label{vmoption} \label{coqoptions}} The following command-line options are recognized by the commands {\tt @@ -224,11 +223,6 @@ Add physical path {\em directory} to the {\ocaml} loadpath. \item[{\tt -no-hash-consing}] \mbox{} -\item[{\tt -vm}]\ - - This activates the use of the bytecode-based conversion algorithm - for the current session (see Section~\ref{SetVirtualMachine}). - \item[{\tt -image} {\em file}]\ This option sets the binary image to be used by {\tt coqc} to be {\em file} diff --git a/doc/refman/RefMan-oth.tex b/doc/refman/RefMan-oth.tex index 4b2b8660c2..0a243308d5 100644 --- a/doc/refman/RefMan-oth.tex +++ b/doc/refman/RefMan-oth.tex @@ -1075,26 +1075,6 @@ perform a {\tt Ltac \ident\ := {\rm\sl convtactic}}. \SeeAlso sections \ref{Conversion-tactics} -\subsection{\tt Set Virtual Machine -\label{SetVirtualMachine} -\optindex{Virtual Machine}} - -This activates the bytecode-based conversion algorithm. - -\subsection{\tt Unset Virtual Machine -\optindex{Virtual Machine}} - -This deactivates the bytecode-based conversion algorithm. - -\subsection{\tt Test Virtual Machine -\optindex{Virtual Machine}} - -This tells if the bytecode-based conversion algorithm is -activated. The default behavior is to have the bytecode-based -conversion algorithm deactivated. - -\SeeAlso sections~\ref{vmcompute} and~\ref{vmoption}. - \section{Controlling the locality of commands} \subsection{{\tt Local}, {\tt Global} -- cgit v1.2.3 From 119d61453c6761f20b8862f47334bfb8fae0049e Mon Sep 17 00:00:00 2001 From: Maxime Dénès Date: Fri, 11 Dec 2015 12:17:14 +0100 Subject: Document removal of Set Virtual Machine and -vm in CHANGES. --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 389572014e..f31f4efa88 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,7 @@ Vernacular commands declaration of all polymorphic universes appearing in a definition when introducing it. - New command "Show id" to show goal named id. +- Option "Virtual Machine" removed. Tactics @@ -82,6 +83,7 @@ Tools - The -require and -load-vernac-object command-line options now take a logical path of a given library rather than a physical path, thus they behave like Require [Import] path. +- The -vm command-line option has been removed. Standard Library -- cgit v1.2.3