Skip to content

Commit d152729

Browse files
committed
Separated out definitional equations produced by the alphabet command to the theorem attribute "alpha_defs" instead of "lens_defs" to allow greater control in proof methods.
1 parent 4bd9e92 commit d152729

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Lens_Instances.thy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ ML_file \<open>Lens_Record.ML\<close>
301301
text \<open>The following theorem attribute stores splitting theorems for alphabet types which which is useful
302302
for proof automation.\<close>
303303

304-
named_theorems alpha_splits
304+
named_theorems alpha_splits and alpha_defs
305305

306306
text \<open> We supply a helpful tactic to remove the subscripted v characters from subgoals. These
307307
exist because the internal names of record fields have them. \<close>

Lens_Record.ML

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ val lens_defsN = "lens_defs"
3838
val lens_defs = (Binding.empty, [Token.make_src (lens_defsN, Position.none) []])
3939
val alpha_splitsN = "alpha_splits"
4040
val alpha_splits = [Token.make_src (alpha_splitsN, Position.none) []]
41+
val alpha_defsN = "alpha_defs"
42+
val alpha_defs = (Binding.empty, [Token.make_src (alpha_defsN, Position.none) []])
4143
val equivN = "equivs"
4244
val splits_suffix = ".splits"
4345
val defs_suffix = ".defs"
@@ -102,7 +104,7 @@ fun lens_sym_proof tname thy =
102104

103105
fun prove_lens_goal tname thy ctx =
104106
let open Simplifier; open Global_Theory in
105-
auto_tac (fold add_simp (get_thms thy lens_defsN @
107+
auto_tac (fold add_simp (get_thms thy lens_defsN @ get_thms thy alpha_defsN @
106108
get_thms thy (tname ^ splits_suffix) @
107109
[@{thm prod.case_eq_if}]) ctx)
108110
end
@@ -148,7 +150,7 @@ fun lens_bij_proof tname thy =
148150
$ const (Context.theory_name {long = false} thy ^ "." ^ tname ^ "." ^ child_lensN)))]))
149151
(fn {context = context, prems = _}
150152
=> EVERY [ Locale.intro_locales_tac {strict = true, eager = true} context []
151-
, auto_tac (fold add_simp (get_thms thy lens_defsN @ [@{thm prod.case_eq_if}])
153+
, auto_tac (fold add_simp (get_thms thy lens_defsN @ get_thms thy alpha_defsN @ [@{thm prod.case_eq_if}])
152154
context)])
153155
end
154156

@@ -227,7 +229,7 @@ fun lenses_bij_proof tname parent thy fs =
227229
]))
228230
(fn {context = context, prems = _}
229231
=> EVERY [ Locale.intro_locales_tac {strict = true, eager = true} context []
230-
, auto_tac (fold add_simp (get_thms thy lens_defsN @ [@{thm prod.case_eq_if}])
232+
, auto_tac (fold add_simp (get_thms thy lens_defsN @ get_thms thy alpha_defsN @ [@{thm prod.case_eq_if}])
231233
context)])
232234
end
233235

@@ -323,8 +325,8 @@ fun add_alphabet (params, binding) raw_parent ty_fields thy =
323325
val attrs = map (Attrib.attribute (Named_Target.theory_init thy)) @{attributes [simp, code_unfold, lens]}
324326
in thy (* Add a new record for the new alphabet lenses *)
325327
|> add_record_cmd {overloaded = false} (params, binding) raw_parent fields
326-
(* Add the record definition theorems to lens_defs *)
327-
|> Named_Target.theory_map (snd o Specification.theorems_cmd "" [((Binding.empty, []), [(Facts.named (tname ^ defs_suffix), snd lens_defs)])] [] false)
328+
(* Add the record definition theorems to alpha_defs *)
329+
|> Named_Target.theory_map (snd o Specification.theorems_cmd "" [((Binding.empty, []), [(Facts.named (tname ^ defs_suffix), snd alpha_defs)])] [] false)
328330
(* Add the record splitting theorems to the alpha_splits set for proof automation *)
329331
|> Named_Target.theory_map (snd o Specification.theorems_cmd "" [((Binding.empty, []), [(Facts.named (tname ^ splits_suffix), alpha_splits)])] [] false)
330332
(* Reorder parent splitting theorems, so the child ones have higher priority *)
@@ -340,7 +342,7 @@ fun add_alphabet (params, binding) raw_parent ty_fields thy =
340342
(* Add definitions for each of the lenses corresponding to each record field in-situ *)
341343
|> Sign.qualified_path false binding
342344
|> Named_Target.theory_map
343-
(fold (fn (n, d) => snd o Specification.definition_cmd (SOME (Binding.make (n, Position.none), NONE, NoSyn)) [] [] (lens_defs, d) true) (map ldef lnames @ [bldef, mldef]))
345+
(fold (fn (n, d) => snd o Specification.definition_cmd (SOME (Binding.make (n, Position.none), NONE, NoSyn)) [] [] (alpha_defs, d) true) (map ldef lnames @ [bldef, mldef]))
344346
(* Add definition of the underlying symmetric lens *)
345347
|> Named_Target.theory_map
346348
(fold (fn (n, d) => Specification.abbreviation_cmd Syntax.mode_default (SOME (Binding.make (n, Position.none), NONE, NoSyn)) [] d true) [sldef])

0 commit comments

Comments
 (0)