Cookies disclaimer

I agree Our site saves small pieces of text information (cookies) on your device in order to deliver better content and for statistical purposes. You can disable the usage of cookies by changing the settings of your browser. By browsing our website without changing the browser settings you grant us permission to store that information on your device.

Homework 6.3

This is the task corresponding to homework 6.3.

Resources

Download Files

Definitions File

theory Defs imports "HOL-IMP.Types" begin



end

Template File

theory Submission imports Defs begin

type_synonym ety = "ty option"
type_synonym etyenv = "vname \<Rightarrow> ety"

inductive infer_aty :: "etyenv \<Rightarrow> aexp \<Rightarrow> ty \<Rightarrow> bool"

inductive infer_bty :: "etyenv \<Rightarrow> bexp \<Rightarrow> bool"

definition is_inst :: "tyenv \<Rightarrow> etyenv \<Rightarrow> bool"
  where "is_inst \<Gamma> e\<Gamma> \<equiv> \<forall>x \<tau>. e\<Gamma> x = Some \<tau> \<longrightarrow> \<Gamma> x = \<tau>"

theorem ainfer: assumes "infer_aty e\<Gamma> a \<tau>" and "is_inst \<Gamma> e\<Gamma>" shows "atyping \<Gamma> a \<tau>"
  sorry

theorem binfer: assumes "infer_bty e\<Gamma> b" and "is_inst \<Gamma> e\<Gamma>" shows "btyping \<Gamma> b"
  sorry

definition combine :: "etyenv \<Rightarrow> etyenv \<Rightarrow> etyenv \<Rightarrow> bool" where
  "combine e\<Gamma>\<^sub>1 e\<Gamma>\<^sub>2 e\<Gamma> \<equiv> e\<Gamma> = e\<Gamma>\<^sub>1 ++ e\<Gamma>\<^sub>2  \<and>
    (\<forall>x \<tau>\<^sub>1 \<tau>\<^sub>2. e\<Gamma>\<^sub>1 x = Some \<tau>\<^sub>1 \<and> e\<Gamma>\<^sub>2 x = Some \<tau>\<^sub>2 \<longrightarrow> \<tau>\<^sub>1 = \<tau>\<^sub>2)"

inductive infer_cty :: "etyenv \<Rightarrow> com \<Rightarrow> etyenv \<Rightarrow> bool"

abbreviation "test_c \<equiv> 
  ''x''::=Ic 0;; 
  (IF Less (V ''x'') (Ic 2) THEN SKIP ELSE ''y'' ::= Rc 1.0);; 
  ''y'' ::= Plus (V ''y'') (Rc 3.1)"

lemma "\<exists>e\<Gamma>'. infer_cty (\<lambda>_. None) test_c e\<Gamma>'"
  apply (rule exI)
    apply (rule infer_cty.intros)
   apply simp
   apply (rule infer_cty.intros)
    apply (rule infer_cty.intros)
  apply simp
    apply (rule infer_aty.intros)  \<comment>\<open>and so on ...\<close>
  sorry

theorem infer_typing: assumes "infer_cty e\<Gamma> c e\<Gamma>'" and "is_inst \<Gamma> e\<Gamma>'" shows "ctyping \<Gamma> c"
  sorry

end

Check File

theory Check imports Submission begin

theorem ainfer: assumes "infer_aty e\<Gamma> a \<tau>" and "is_inst \<Gamma> e\<Gamma>" shows "atyping \<Gamma> a \<tau>"
  using assms by (rule Submission.ainfer)

theorem binfer: assumes "infer_bty e\<Gamma> b" and "is_inst \<Gamma> e\<Gamma>" shows "btyping \<Gamma> b"
  using assms by (rule Submission.binfer)

theorem infer_typing: assumes "infer_cty e\<Gamma> c e\<Gamma>'" and "is_inst \<Gamma> e\<Gamma>'" shows "ctyping \<Gamma> c"
  using assms by (rule Submission.infer_typing)

end

Terms and Conditions