Skip to content

Commit

Permalink
Add AllCasePreds()
Browse files Browse the repository at this point in the history
This is meant to be like AllCaseEqs(), but for the situation where
the case statement occurs at the top level.

Yong Kiam threatened he might use every_case_tac if there is no
convenient way to do this.
  • Loading branch information
IlmariReissumies committed Nov 10, 2023
1 parent be29184 commit 5492f86
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/1/TypeBase.sig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ sig
val CaseEqs : string list -> thm
val AllCaseEqs : unit -> thm

val CasePred : string -> thm
val CasePreds : string list -> thm
val AllCasePreds : unit -> thm

(* f (case x of ...) <=> (case x of ..) *)
val case_rand_of : hol_type -> thm
(* f (case x of ...) <=> disjunction of possibilities *)
Expand Down
25 changes: 25 additions & 0 deletions src/1/TypeBase.sml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,31 @@ fun case_rand_of ty = let
val case_pred_disj_of = Prim_rec.prove_case_ho_elim_thm o type_info_of
val case_pred_imp_of = Prim_rec.prove_case_ho_imp_thm o type_info_of

fun CasePred' tyinfo =
let
val id = mk_abs(mk_var ("x", bool), mk_var ("x", bool))
in
{case_def = TypeBasePure.case_def_of tyinfo,
nchotomy = TypeBasePure.nchotomy_of tyinfo}
|> Prim_rec.prove_case_ho_elim_thm
|> Drule.ISPEC id
|> Conv.CONV_RULE (Conv.LHS_CONV Thm.BETA_CONV)
end

val CasePred = CasePred' o tyi_from_name

val CasePreds = Drule.LIST_CONJ o map CasePred
fun AllCasePreds() =
let
fun foldthis(ty, tyi, acc) =
case Lib.total CasePred' tyi of
NONE => acc
| SOME th => if aconv (concl acc) boolSyntax.T then th
else CONJ th acc
in
TypeBasePure.fold foldthis boolTheory.TRUTH (theTypeBase())
end

(* ---------------------------------------------------------------------- *
* Install case transformation function for parser *
* ---------------------------------------------------------------------- *)
Expand Down

0 comments on commit 5492f86

Please sign in to comment.