(* Use this for prototyping: Axiom todo : forall A : Type, A. *) Let Unit : Type := unit. Let Bool : Type := bool. Let Nat : Type := nat. Let List : Type -> Type := list. (* Inductive Unit : Type := tt : Unit. Inductive Bool : Type := true : Bool | false : Bool. Inductive Nat : Type := O : Nat | S : Nat -> Nat. Inductive List (T : Type) : Type := nil : List T | cons : T -> List T -> List T. Implicit Arguments nil [T]. (* Means you don't have to specify which type of list when using nil *) Implicit Arguments cons [T]. (* or when using cons. *) *) Inductive Typ : Type := bool : Typ | nat : Typ. Fixpoint sem_Typ (t : Typ) : Type := match t with | bool => Bool | nat => Nat end. Inductive sub : Typ -> Typ -> Type := sub_bool : sub bool bool | sub_nat : sub nat nat | sub_bn : sub bool nat. Fixpoint sub_refl (t : Typ) : sub t t := match t as t return sub t t with | bool => sub_bool | nat => sub_nat end. Definition if_nat (t : Typ) (T : Type) : Type := match t with | nat => T | _ => Unit end. Fixpoint sub_trans (t t' t'' : Typ) (s : sub t t') (s' : sub t' t'') : sub t t'' := match s in sub t t' return sub t' t'' -> sub t t'' with | sub_bool => fun s' => s' | sub_nat => fun s' => s' | sub_bn => fun s' => match s' in sub t' t'' return if_nat t' (sub bool t'') with | sub_nat => sub_bn | _ => tt end end s'. Fixpoint sem_sub (t t' : Typ) (s : sub t t') : sem_Typ t -> sem_Typ t' := match s in sub t t' return sem_Typ t -> sem_Typ t' with | sub_bool => fun b => b | sub_nat => fun n => n | sub_bn => fun b => if b then S O else O end.