From 69bf0744a5ce3ba144f59564ebf74d7d2f56b748 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Mon, 15 Jun 2020 11:52:19 +0200 Subject: rename folders --- spartan/core/ml/cases.ML | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 spartan/core/ml/cases.ML (limited to 'spartan/core/ml/cases.ML') diff --git a/spartan/core/ml/cases.ML b/spartan/core/ml/cases.ML new file mode 100644 index 0000000..560a9f1 --- /dev/null +++ b/spartan/core/ml/cases.ML @@ -0,0 +1,42 @@ +(* Title: cases.ML + Author: Joshua Chen + +Case reasoning. +*) + +structure Case: sig + +val rules: Proof.context -> thm list +val lookup_rule: Proof.context -> Termtab.key -> thm option +val register_rule: thm -> Context.generic -> Context.generic + +end = struct + +(* Context data *) + +(*Stores elimination rules together with a list of the indexnames of the + variables each rule eliminates. Keyed by head of the type being eliminated.*) +structure Rules = Generic_Data ( + type T = thm Termtab.table + val empty = Termtab.empty + val extend = I + val merge = Termtab.merge Thm.eq_thm_prop +) + +val rules = map #2 o Termtab.dest o Rules.get o Context.Proof +fun lookup_rule ctxt = Termtab.lookup (Rules.get (Context.Proof ctxt)) +fun register_rule rl = + let val hd = Term.head_of (Lib.type_of_typing (Thm.major_prem_of rl)) + in Rules.map (Termtab.update (hd, rl)) end + + +(* [cases] attribute *) +val _ = Theory.setup ( + Attrib.setup \<^binding>\cases\ + (Scan.succeed (Thm.declaration_attribute register_rule)) + "" + #> Global_Theory.add_thms_dynamic (\<^binding>\cases\, rules o Context.proof_of) +) + + +end -- cgit v1.2.3