| Name of string
| Anonymous
+type object_flavour =
+ [ `Definition
+ | `Fact
+ | `Lemma
+ | `Remark
+ | `Theorem
+ | `Variant
+ ]
+
type object_class =
[ `Coercion
| `Elim of sort (** elimination principle; if sort is Type, the universe is
type attribute =
[ `Class of object_class
+ | `Flavour of object_flavour
| `Generated
]
(string * Cic.annterm) list (* id, name, inductive, arity, constructors *)
| Meta_subst of Cic.annterm option
| Obj_class of Cic.object_class
+ | Obj_flavour of Cic.object_flavour
| Obj_field of string (* field name *)
| Obj_generated
| Tag of string * (string * string) list (* tag name, attributes *)
sprintf "Inductive_type %s (id=%s)" name id
| Meta_subst _ -> "Meta_subst"
| Obj_class _ -> "Obj_class"
+ | Obj_flavour _ -> "Obj_flavour"
| Obj_field name -> "Obj_field " ^ name
| Obj_generated -> "Obj_generated"
| Tag (tag, _) -> "Tag " ^ tag)
| "attributes" ->
let rec aux acc = function (* retrieve object attributes *)
| Obj_class c :: tl -> aux (`Class c :: acc) tl
+ | Obj_flavour f :: tl -> aux (`Flavour f :: acc) tl
| Obj_generated :: tl -> aux (`Generated :: acc) tl
| tl -> acc, tl
in
(match pop_tag_attrs ctxt with
| ["name", name] -> Obj_field name
| _ -> attribute_error ())
+ | "flavour" ->
+ push ctxt
+ (match pop_tag_attrs ctxt with
+ | [ "value", "definition"] -> Obj_flavour `Definition
+ | [ "value", "fact"] -> Obj_flavour `Fact
+ | [ "value", "lemma"] -> Obj_flavour `Lemma
+ | [ "value", "remark"] -> Obj_flavour `Remark
+ | [ "value", "theorem"] -> Obj_flavour `Theorem
+ | [ "value", "variant"] -> Obj_flavour `Variant
+ | _ -> attribute_error ())
| "class" ->
let class_modifiers = pop_class_modifiers ctxt in
push ctxt
TacticAst.Set (loc, n, v)
| [ IDENT "drop" ] -> TacticAst.Drop loc
| [ IDENT "qed" ] -> TacticAst.Qed loc
+ | IDENT "variant" ; name = IDENT; SYMBOL ":";
+ typ = term; SYMBOL <:unicode<def>> ; newname = IDENT ->
+ TacticAst.Obj (loc,
+ TacticAst.Theorem
+ (`Variant,name,typ,Some (CicAst.Ident (newname, None))))
| flavour = theorem_flavour; name = IDENT; SYMBOL ":"; typ = term;
body = OPT [ SYMBOL <:unicode<def>> (* ≝ *); body = term -> body ] ->
TacticAst.Obj (loc,TacticAst.Theorem (flavour, name, typ, body))
let field_names = List.map fst fields in
Cic.InductiveDefinition
(tyl,[],List.length params,[`Class (`Record field_names)])
- | TacticAst.Theorem (_,name,ty,bo) ->
+ | TacticAst.Theorem (flavour, name, ty, bo) ->
+ let attrs = [`Flavour flavour] in
let ty' = interpretate_term [] env None false ty in
- match bo with
+ (match bo with
None ->
- Cic.CurrentProof (name,[],Cic.Implicit None,ty',[],[])
+ Cic.CurrentProof (name,[],Cic.Implicit None,ty',[],attrs)
| Some bo ->
let bo' = Some (interpretate_term [] env None false bo) in
- Cic.Constant (name,bo',ty',[],[])
+ Cic.Constant (name,bo',ty',[],attrs))
+
(* e.g. [5;1;1;1;2;3;4;1;2] -> [2;1;4;3;5] *)
let rev_uniq =
) field_names [<>])
| `Projection -> Xml.xml_empty "class" [None,"value","projection"]
in
+ let flavour_of = function
+ | `Definition -> Xml.xml_empty "flavour" [None, "value", "definition"]
+ | `Fact -> Xml.xml_empty "flavour" [None, "value", "fact"]
+ | `Lemma -> Xml.xml_empty "flavour" [None, "value", "lemma"]
+ | `Remark -> Xml.xml_empty "flavour" [None, "value", "remark"]
+ | `Theorem -> Xml.xml_empty "flavour" [None, "value", "theorem"]
+ | `Variant -> Xml.xml_empty "flavour" [None, "value", "variant"]
+ in
let xml_attr_of = function
| `Generated -> Xml.xml_empty "generated" []
| `Class c -> class_of c
+ | `Flavour f -> flavour_of f
in
let xml_attrs =
List.fold_right
| Symmetry of loc
| Transitivity of loc * 'term
-type thm_flavour =
- [ `Definition
- | `Fact
- | `Lemma
- | `Remark
- | `Theorem
- ]
+type thm_flavour = Cic.object_flavour
(** <name, inductive/coinductive, type, constructor list>
* true means inductive, false coinductive *)
| `Lemma -> "Lemma"
| `Remark -> "Remark"
| `Theorem -> "Theorem"
+ | `Variant -> "Variant"
let pp_search_kind = function
| `Locate -> "locate"
| `Hint -> "hint"
| `Match -> "match"
| `Elim -> "elim"
+ | `Instance -> "instance"
let pp_macro pp_term = function
(* Whelp *)
"record " ^ name ^ " " ^ pp_params params ^ " \\def {" ^
pp_fields fields ^ "}"
-
let pp_command = function
| Include (_,path) -> "include " ^ path
| Qed _ -> "qed"