X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Facic_procedural%2FproceduralTypes.ml;h=b194fbfa9fd9f5afce2bfa3f6384ec6d660ab85c;hb=04c05cf08605156ba8c6fa7225b4a90496c03698;hp=d505a8b152ebdc73cc5d362a2f2c80bee8747cec;hpb=876ac1889f8b11c97c8d94a0523504a0bcb70ddd;p=helm.git diff --git a/helm/software/components/acic_procedural/proceduralTypes.ml b/helm/software/components/acic_procedural/proceduralTypes.ml index d505a8b15..b194fbfa9 100644 --- a/helm/software/components/acic_procedural/proceduralTypes.ml +++ b/helm/software/components/acic_procedural/proceduralTypes.ml @@ -54,21 +54,24 @@ let list_init f i = (****************************************************************************) -type flavour = Cic.object_flavour +type flavour = C.object_flavour type name = string option type hyp = string -type what = Cic.annterm +type what = C.annterm type how = bool -type using = Cic.annterm +type using = C.annterm type count = int type note = string type where = (hyp * name) option -type inferred = Cic.annterm -type pattern = Cic.annterm -type body = Cic.annterm option +type inferred = C.annterm +type pattern = C.annterm +type body = C.annterm option +type types = C.anninductiveType list +type lpsno = int type step = Note of note - | Statement of flavour * name * what * body * note + | Inductive of types * lpsno * note + | Statement of flavour * name * what * body * note | Qed of note | Id of note | Intros of count option * name list * note @@ -84,7 +87,34 @@ type step = Note of note (* annterm constructors *****************************************************) -let mk_arel i b = Cic.ARel ("", "", i, b) +let mk_arel i b = C.ARel ("", "", i, b) + +(* FG: this is really awful !! *) +let arel_of_name = function + | C.Name s -> mk_arel 0 s + | C.Anonymous -> mk_arel 0 "_" + +(* helper functions on left params for use with inductive types *************) + +let strip_lps lpsno arity = + let rec aux no lps = function + | C.AProd (_, name, w, t) when no > 0 -> + let lp = name, Some w in + aux (pred no) (lp :: lps) t + | t -> lps, t + in + aux lpsno [] arity + +let merge_lps lps1 lps2 = + let map (n1, w1) (n2, _) = + let n = match n1, n2 with + | C.Name _, _ -> n1 + | _ -> n2 + in + n, w1 + in + if lps1 = [] then lps2 else + List.map2 map lps1 lps2 (* grafite ast constructors *************************************************) @@ -101,6 +131,22 @@ let mk_notenote str a = let mk_thnote str a = if str = "" then a else mk_note "" :: mk_note str :: a +let mk_inductive types lpsno = + let map1 (lps1, cons) (name, arity) = + let lps2, arity = strip_lps lpsno arity in + merge_lps lps1 lps2, (name, arity) :: cons + in + let map2 (lps1, types) (_, name, kind, arity, cons) = + let lps2, arity = strip_lps lpsno arity in + let lps1, rev_cons = List.fold_left map1 (lps1, []) cons in + merge_lps lps1 lps2, (name, kind, arity, List.rev rev_cons) :: types + in + let map3 (name, xw) = arel_of_name name, xw in + let rev_lps, rev_types = List.fold_left map2 ([], []) types in + let lpars, types = List.rev_map map3 rev_lps, List.rev rev_types in + let obj = N.Inductive (lpars, types) in + G.Executable (floc, G.Command (floc, G.Obj (floc, obj))) + let mk_statement flavour name t v = let name = match name with Some name -> name | None -> assert false in let obj = N.Theorem (flavour, name, t, v) in @@ -185,6 +231,7 @@ let mk_vb = G.Shift floc let rec render_step sep a = function | Note s -> mk_notenote s a | Statement (f, n, t, v, s) -> mk_statement f n t v :: mk_thnote s a + | Inductive (lps, ts, s) -> mk_inductive lps ts :: mk_thnote s a | Qed s -> mk_qed :: mk_tacnote s a | Id s -> mk_id sep :: mk_tacnote s a | Intros (c, ns, s) -> mk_intros c ns sep :: mk_tacnote s a @@ -228,6 +275,7 @@ and count_steps a = List.fold_left count_step a let rec count_node a = function | Note _ + | Inductive _ | Statement _ | Qed _ | Id _