theory TypedArithInClass imports Main begin section "Syntax" datatype trm = TTrue | TFalse | TIf trm trm trm | TZero | TSucc trm | TPred trm | TIsZero trm inductive_set numeric_values :: "trm set" where zero_nv: "TZero \ numeric_values" | succ_nv: "nv \ numeric_values \ TSucc nv \ numeric_values" thm numeric_values.cases thm numeric_values.induct definition vals :: "trm set" where "vals \ {TTrue, TFalse} \ numeric_values" declare vals_def[simp] section "Operational Semantics" inductive reduction :: "trm \ trm \ bool" (infix "\" 80) where EIfTrue: "TIf TTrue t2 t3 \ t2" | EIfFalse: "TIf TFalse t2 t3 \ t3" | EIf: "t1 \ t1' \ TIf t1 t2 t3 \ TIf t1' t2 t3" | ESucc: "t1 \ t1' \ TSucc t1 \ TSucc t1'" | EPredZero: "TPred TZero \ TZero" | EPredSucc: "nv \ numeric_values \ TPred (TSucc nv) \ nv" | EPred: "t1 \ t1' \ TPred t1 \ TPred t1'" | EIsZero: "t1 \ t1' \ TIsZero t1 \ TIsZero t1'" | EIsZeroZero: "TIsZero TZero \ TTrue" | EIsZeroSucc: "nv \ numeric_values \ TIsZero (TSucc nv) \ TFalse" section "Type System" section "Meta Theory" inductive_cases zero_case: "TZero \ x" and iftru_case: "TIf TTrue t2 t3 \ t" and succ_case: "TSucc nv \ x" theorem numeric_value_not_reducible: fixes nv::trm assumes nv: "nv \ numeric_values" and r: "nv \ x" shows "False" using nv r apply (induct arbitrary: x rule: numeric_values.induct) apply (erule zero_case) apply (erule succ_case) apply blast done lemma reduction_smaller: fixes t::trm assumes r: "t \ t'" shows "size t' < size t" using r by (induct rule: reduction.induct) auto end