theory compare
  imports Main
"/Volumes/Setup/Isabelle/Isabelle-Code/August/libs_functions" "/Volumes/Setup/Isabelle/Isabelle-Code/August/bip" "/Volumes/Setup/Isabelle/Isabelle-Code/August/javabip"
begin
value "(\<forall>j \<in> set test_synchron. \<forall>u \<in> set j. \<forall>t \<in> set u. \<exists>l \<in> set (snd t).\<forall>l1 \<in> set (snd t) - {l}. \<not> P (fst t) l1)"
value "(\<forall>j \<in> set test_synchron. \<forall>u \<in> set j. \<forall>t \<in> set u. \<forall>l \<in> set (snd t). P (fst t) l \<longrightarrow> (\<forall>l1 \<in> set (snd t) - {l}. \<not>P (fst t) l1))"

lemma test_apart: "((\<forall>j \<in> set test_synchron. \<forall>u \<in> set j. \<forall>t \<in> set u. \<exists>l \<in> set (snd t).\<forall>l1 \<in> set (snd t) - {l}. \<not> P (fst t) l1)) \<Longrightarrow>
(\<forall>j \<in> set test_synchron. \<forall>u \<in> set j. \<forall>t \<in> set u. \<forall>l \<in> set (snd t). P (fst t) l \<longrightarrow> (\<forall>l1 \<in> set (snd t) - {l}. \<not>P (fst t) l1))"
  by blast

<<<<<<< Updated upstream
lemma compare_tool: "((broadcast_x \<longrightarrow> (isReg_y_x \<longrightarrow> (speak_y \<and> \<not>listen_y) \<or> (listen_y \<and> \<not>speak_y))) \<and> (broadcast_x \<longrightarrow> (isReg_Px_x \<and> speak_Px \<and> (differ_y1_Px \<and> isReg_y1_x \<longrightarrow> listen_y1)) \<or> (isReg_y_x \<longrightarrow> listen_y)) \<and> (speak_y \<longrightarrow> broadcast_x \<and> isReg_y_x) \<and> (listen_y \<longrightarrow> broadcast_x \<and> isReg_y_x))
\<Longrightarrow>
((\<not>broadcast_x \<or> \<not>isReg_y_x \<or> speak_y \<or> listen_y)
\<and> (\<not>broadcast_x \<or> \<not>isReg_y_x \<or> \<not>listen_y \<or> listen_y)
\<and> (\<not>broadcast_x \<or> \<not>isReg_y_x \<or> \<not>listen_y \<or> \<not>speak_y)
\<and> (\<not>broadcast_x \<or> isReg_Px_x \<or> \<not>isReg_y_x \<or> listen_y)
\<and> (\<not>broadcast_x \<or> speak_Px \<or> \<not>isReg_y_x \<or> listen_y)
\<and> (\<not>broadcast_x \<or> \<not>differ_y1_Px \<or> \<not>isReg_y1_x \<or> listen_y1 \<or> \<not>isReg_y_x \<or> listen_y)
\<and> (\<not>speak_y \<or> broadcast_x)
\<and> (\<not>speak_y \<or> isReg_y_x)
\<and> (\<not>listen_y \<or> broadcast_x)
\<and> (\<not>listen_y \<or> isReg_y_x))
"
  by blast

lemma compare_tool_1: "(broadcast_x \<longrightarrow> speak_y)
\<Longrightarrow>
(\<not> broadcast_x \<or> speak_y)
"
  by blast
=======
(*
lemma test_instance: "
(((P_5c_1 \<longrightarrow> (Q_1a_1 \<or> Q_1b_1) \<and> P_5d_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1a_3 \<and> \<not> Q_1b_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_1 \<or> Q_1b_1) \<and> P_5c_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1a_3 \<and> \<not> Q_1b_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_1a_1 \<or> Q_1b_2) \<and> P_5d_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1a_3 \<and> \<not> Q_1b_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_1 \<or> Q_1b_2) \<and> P_5c_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1a_3 \<and> \<not> Q_1b_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_1a_2 \<or> Q_1b_1) \<and> P_5d_1 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_3 \<and> \<not> Q_1b_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_2 \<or> Q_1b_1) \<and> P_5c_1 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_3 \<and> \<not> Q_1b_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_1a_2 \<or> Q_1b_2) \<and> P_5d_1 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_3 \<and> \<not> Q_1b_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_2 \<or> Q_1b_2) \<and> P_5c_1 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_3 \<and> \<not> Q_1b_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_1a_3 \<or> Q_1b_1) \<and> P_5d_1 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1b_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_3 \<or> Q_1b_1) \<and> P_5c_1 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1b_2)) \<or>
 (P_5c_1 \<longrightarrow> (Q_1a_3 \<or> Q_1b_2) \<and> P_5d_1 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1b_1) \<or>
 (P_5d_1 \<longrightarrow> (Q_1a_3 \<or> Q_1b_2) \<and> P_5c_1 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1b_1)) \<Longrightarrow>
(((P_5c_1 \<longrightarrow>
((Q_1a_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1a_3 \<or> Q_1a_2 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_3 \<or> Q_1a_3 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_2) \<or>
Q_1b_1 \<and> \<not> Q_1b_2 \<or> Q_1b_2 \<and> \<not> Q_1b_1) \<and>
P_5d_1) \<and>
(P_5d_1 \<longrightarrow>
((Q_1a_1 \<and> \<not> Q_1a_2 \<and> \<not> Q_1a_3 \<or> Q_1a_2 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_3 \<or> Q_1a_3 \<and> \<not> Q_1a_1 \<and> \<not> Q_1a_2) \<or>
Q_1b_1 \<and> \<not> Q_1b_2 \<or> Q_1b_2 \<and> \<not> Q_1b_1) \<and>
P_5c_1)) \<and>
(\<not> Q_1a_2 \<and> \<not> Q_1a_3 \<or> \<not> Q_1a_1 \<and> \<not> Q_1a_3 \<or> \<not> Q_1a_1 \<and> \<not> Q_1a_2) \<and> (\<not> Q_1b_2 \<or> \<not> Q_1b_1))"
*)
lemma test_inc_2:"(((P_5c_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_1 \<and> (\<not> P_5c_2 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_3 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_1 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_2) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_1 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_2 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_1) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_2)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_1 \<and> Q_3b2_2) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_2 \<and> \<not> Q_3b2_1)) \<or>
 ((P_5c_3 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2) \<or>
  (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_1) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_2)) \<or>
 (P_5c_3 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5d_2 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1) \<or>
 (P_5d_2 \<longrightarrow> (Q_3a_2 \<or> Q_3b1_2 \<and> Q_3b2_2) \<and> P_5c_3 \<and> (\<not> P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5d_1) \<and> \<not> Q_3a_1 \<and> \<not> Q_3b1_1 \<and> \<not> Q_3b2_1)) \<Longrightarrow>
((((P_5c_1 \<longrightarrow>
    ((Q_3a_1 \<and> \<not> Q_3a_2 \<or> Q_3a_2 \<and> \<not> Q_3a_1) \<or>
     (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or>
     (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1 \<or>
     (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or> (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1) \<and>
    (P_5d_1 \<and> \<not> P_5d_2 \<or> P_5d_2 \<and> \<not> P_5d_1)) \<and>
   (P_5c_2 \<longrightarrow>
    ((Q_3a_1 \<and> \<not> Q_3a_2 \<or> Q_3a_2 \<and> \<not> Q_3a_1) \<or>
     (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or>
     (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1 \<or>
     (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or> (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1) \<and>
    (P_5d_1 \<and> \<not> P_5d_2 \<or> P_5d_2 \<and> \<not> P_5d_1)) \<and>
   (P_5c_3 \<longrightarrow>
    ((Q_3a_1 \<and> \<not> Q_3a_2 \<or> Q_3a_2 \<and> \<not> Q_3a_1) \<or>
     (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or>
     (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1 \<or>
     (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or> (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1) \<and>
    (P_5d_1 \<and> \<not> P_5d_2 \<or> P_5d_2 \<and> \<not> P_5d_1))) \<and>
  (P_5d_1 \<longrightarrow>
   ((Q_3a_1 \<and> \<not> Q_3a_2 \<or> Q_3a_2 \<and> \<not> Q_3a_1) \<or>
    (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or>
    (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1 \<or>
    (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or> (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1) \<and>
   (P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5c_3 \<or> P_5c_2 \<and> \<not> P_5c_1 \<and> \<not> P_5c_3 \<or> P_5c_3 \<and> \<not> P_5c_1 \<and> \<not> P_5c_2)) \<and>
  (P_5d_2 \<longrightarrow>
   ((Q_3a_1 \<and> \<not> Q_3a_2 \<or> Q_3a_2 \<and> \<not> Q_3a_1) \<or>
    (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or>
    (Q_3b1_1 \<and> \<not> Q_3b1_2) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1 \<or>
    (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_1 \<and> \<not> Q_3b2_2 \<or> (Q_3b1_2 \<and> \<not> Q_3b1_1) \<and> Q_3b2_2 \<and> \<not> Q_3b2_1) \<and>
   (P_5c_1 \<and> \<not> P_5c_2 \<and> \<not> P_5c_3 \<or> P_5c_2 \<and> \<not> P_5c_1 \<and> \<not> P_5c_3 \<or> P_5c_3 \<and> \<not> P_5c_1 \<and> \<not> P_5c_2))) \<and>
 ((\<not> P_5c_2 \<and> \<not> P_5c_3 \<or> \<not> P_5c_1 \<and> \<not> P_5c_3 \<or> \<not> P_5c_1 \<and> \<not> P_5c_2) \<and> (\<not> P_5d_2 \<or> \<not> P_5d_1)) \<and>
 (\<not> Q_3a_2 \<or> \<not> Q_3a_1) \<and> (\<not> Q_3b1_2 \<or> \<not> Q_3b1_1) \<and> (\<not> Q_3b2_2 \<or> \<not> Q_3b2_1))
"
>>>>>>> Stashed changes

notepad
begin
  have"
(\<exists>connector \<in> set BIP_Connector_2.\<exists>sync\<in>set (fst connector).(P (fst sync) (snd sync) \<longrightarrow>
((\<exists>trig\<in>set (snd connector).\<forall>elm\<in>set trig. Q (fst elm) (snd elm))
  \<and> (\<forall>sync1\<in>set (fst connector) - {sync}. P (fst sync1) (snd sync1))
  \<and> (\<forall>rs \<in> remaining_pairs (all_pairs test_synchron) (fst connector). \<not>P (fst rs) (snd rs))
  \<and> (\<forall>rt \<in> remaining_pairs (all_pairs test_triggers) (concat (snd connector)). \<not>Q (fst rt) (snd rt)))
)) \<Longrightarrow>
((\<forall>connector\<in>set JavaBIP_Connector_2.\<forall>sync_list\<in>set (fst connector).\<forall>sync\<in>set sync_list. (P (fst sync) (snd sync) \<longrightarrow>
      ((\<exists>trig_list\<in>set(snd connector).\<exists>trig\<in>set trig_list. \<forall>t_elm\<in>set trig. (Q (fst t_elm) (snd t_elm)
      \<and> (\<forall>h \<in> set (lookup_3 (fst t_elm) test_triggers) - {snd t_elm}. \<not>Q (fst t_elm) h)))
      \<and> (\<forall>sync_1\<in>set(fst connector)-{sync_list}.\<exists>s_elm_1\<in>set(sync_1). P (fst s_elm_1) (snd s_elm_1)
      \<and> (\<forall>l \<in> set (lookup_3 (fst s_elm_1) test_synchron) - {snd s_elm_1}. \<not>P (fst s_elm_1) l))
    )
))
\<and> (\<forall>j \<in> set test_synchron. \<forall>u \<in> set j. \<forall>t \<in> set u. \<forall>l \<in> set (snd t).(P (fst t) l \<longrightarrow> (\<forall>l1 \<in> set (snd t) - {l}. \<not>P (fst t) l1)))
\<and> (\<forall>i \<in> set test_triggers. \<forall>v \<in> set i. \<forall>k \<in> set v. \<forall>h \<in> set (snd k).(Q (fst k) h \<longrightarrow> (\<forall>h1 \<in> set (snd k) - {h}. \<not>Q (fst k) h1))))
"
    unfolding test_synchron_def test_triggers_def JavaBIP_Connector_2_def BIP_Connector_2_def
    sledgehammer
(*
  proof (rule classical)
    assume "\<not> ?thesis"
    then show ?thesis by force
  qed
*)
end

<<<<<<< Updated upstream
lemma "((speak_y \<longrightarrow> broadcast_x \<and> isReg_y_x \<and> \<not>listen_y \<and> (listen_y1 \<longrightarrow> broadcast_x \<and> differ_y1_y \<and> isReg_y1_x)) \<and> (listen_y \<longrightarrow> broadcast_x \<and> isReg_y_x \<and> \<not>speak_y \<and> (listen_y1 \<longrightarrow> broadcast_x \<and> differ_y1_y \<and> isReg_y1_x)))
\<Longrightarrow>
((\<not>speak_y \<or> broadcast_x)
\<and> (\<not>speak_y \<or> isReg_y_x)
\<and> (\<not>speak_y \<or> \<not>listen_y)
\<and> (\<not>speak_y \<or> \<not>listen_y1 \<or> broadcast_x)
\<and> (\<not>speak_y \<or> \<not>listen_y1 \<or> differ_y1_y)
\<and> (\<not>speak_y \<or> \<not>listen_y1 \<or> isReg_y1_x)
\<and> (\<not>listen_y \<or> broadcast_x)
\<and> (\<not>listen_y \<or> isReg_y_x)
\<and> (\<not>listen_y \<or> \<not>speak_y)
\<and> (\<not>listen_y \<or> \<not>listen_y1 \<or> broadcast_x)
\<and> (\<not>listen_y \<or> \<not>listen_y1 \<or> differ_y1_y)
\<and> (\<not>listen_y \<or> \<not>listen_y1 \<or> isReg_y1_x))"
  by blast

lemma "((P_4_1 \<longrightarrow> (Q_1_1 \<or> Q_2_1) \<and> (\<not>P_4_2 \<and> \<not>P_4_3) \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<and> \<not>Q_2_2) \<or>
 (P_4_1 \<longrightarrow> (Q_1_1 \<or> Q_2_2) \<and> (\<not>P_4_2 \<and> \<not>P_4_3) \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<and> \<not>Q_2_1) \<or>
 (P_4_1 \<longrightarrow> (Q_1_2 \<or> Q_2_1) \<and> (\<not>P_4_2 \<and> \<not>P_4_3) \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<and> \<not>Q_2_2) \<or>
 (P_4_1 \<longrightarrow> (Q_1_2 \<or> Q_2_2) \<and> (\<not>P_4_2 \<and> \<not>P_4_3) \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<and> \<not>Q_2_1) \<or>
 (P_4_1 \<longrightarrow> (Q_1_3 \<or> Q_2_1) \<and> (\<not>P_4_2 \<and> \<not>P_4_3) \<and> \<not>Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_2_2) \<or>
 (P_4_1 \<longrightarrow> (Q_1_3 \<or> Q_2_2) \<and> (\<not>P_4_2 \<and> \<not>P_4_3) \<and> \<not>Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_2_1)) \<and>
 ((P_4_2 \<longrightarrow> (Q_1_1 \<or> Q_2_1) \<and> (\<not>P_4_1 \<and> \<not>P_4_3) \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<and> \<not>Q_2_2) \<or>
 (P_4_2 \<longrightarrow> (Q_1_1 \<or> Q_2_2) \<and> (\<not>P_4_1 \<and> \<not>P_4_3) \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<and> \<not>Q_2_1) \<or>
 (P_4_2 \<longrightarrow> (Q_1_2 \<or> Q_2_1) \<and> (\<not>P_4_1 \<and> \<not>P_4_3) \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<and> \<not>Q_2_2) \<or>
 (P_4_2 \<longrightarrow> (Q_1_2 \<or> Q_2_2) \<and> (\<not>P_4_1 \<and> \<not>P_4_3) \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<and> \<not>Q_2_1) \<or>
 (P_4_2 \<longrightarrow> (Q_1_3 \<or> Q_2_1) \<and> (\<not>P_4_1 \<and> \<not>P_4_3) \<and> \<not>Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_2_2) \<or>
 (P_4_2 \<longrightarrow> (Q_1_3 \<or> Q_2_2) \<and> (\<not>P_4_1 \<and> \<not>P_4_3) \<and> \<not>Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_2_1)) \<and>
 ((P_4_3 \<longrightarrow> (Q_1_1 \<or> Q_2_1) \<and> (\<not>P_4_1 \<and> \<not>P_4_2) \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<and> \<not>Q_2_2) \<or>
 (P_4_3 \<longrightarrow> (Q_1_1 \<or> Q_2_2) \<and> (\<not>P_4_1 \<and> \<not>P_4_2) \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<and> \<not>Q_2_1) \<or>
 (P_4_3 \<longrightarrow> (Q_1_2 \<or> Q_2_1) \<and> (\<not>P_4_1 \<and> \<not>P_4_2) \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<and> \<not>Q_2_2) \<or>
 (P_4_3 \<longrightarrow> (Q_1_2 \<or> Q_2_2) \<and> (\<not>P_4_1 \<and> \<not>P_4_2) \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<and> \<not>Q_2_1) \<or>
 (P_4_3 \<longrightarrow> (Q_1_3 \<or> Q_2_1) \<and> (\<not>P_4_1 \<and> \<not>P_4_2) \<and> \<not>Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_2_2) \<or>
 (P_4_3 \<longrightarrow> (Q_1_3 \<or> Q_2_2) \<and> (\<not>P_4_1 \<and> \<not>P_4_2) \<and> \<not>Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_2_1))
\<Longrightarrow>
(
  (P_4_1 \<longrightarrow>  (Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<or> Q_1_2 \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<or> Q_1_3 \<and> \<not>Q_1_1 \<and> \<not>Q_1_2)
	\<or> Q_2_1 \<and> \<not>Q_2_2 \<or> Q_2_2 \<and> \<not>Q_2_1) \<and>
  (P_4_2 \<longrightarrow>  (Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<or> Q_1_2 \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<or> Q_1_3 \<and> \<not>Q_1_1 \<and> \<not>Q_1_2)
  	\<or> Q_2_1 \<and> \<not>Q_2_2 \<or> Q_2_2 \<and> \<not>Q_2_1) \<and>
  (P_4_3 \<longrightarrow>  (Q_1_1 \<and> \<not>Q_1_2 \<and> \<not>Q_1_3 \<or> Q_1_2 \<and> \<not>Q_1_1 \<and> \<not>Q_1_3 \<or> Q_1_3 \<and> \<not>Q_1_1 \<and> \<not>Q_1_2)
  	\<or> Q_2_1 \<and> \<not>Q_2_2 \<or> Q_2_2 \<and> \<not>Q_2_1) \<and>
 (P_4_1 \<longrightarrow> \<not>P_4_2 \<and> \<not>P_4_3) \<and> (P_4_2 \<longrightarrow> \<not>P_4_1 \<and> \<not>P_4_3) \<and> (P_4_3 \<longrightarrow> \<not>P_4_1 \<and> \<not>P_4_2) \<and>
 (Q_1_1 \<longrightarrow> \<not>Q_1_2 \<and> \<not>Q_1_3) \<and> (Q_1_2 \<longrightarrow> \<not>Q_1_1 \<and> \<not>Q_1_3) \<and> (Q_1_3 \<longrightarrow> \<not>Q_1_1 \<and> \<not>Q_1_2) \<and>
 (Q_2_1 \<longrightarrow> \<not>Q_2_2) \<and> (Q_2_2 \<longrightarrow> \<not>Q_2_1)
)"
  by blast

value "((True \<longrightarrow> (False \<or> False) \<and> (\<not>False \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (True \<longrightarrow> (False \<or> False) \<and> (\<not>False \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (True \<longrightarrow> (False \<or> False) \<and> (\<not>False \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (True \<longrightarrow> (False \<or> False) \<and> (\<not>False \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (True \<longrightarrow> (False \<or> False) \<and> (\<not>False \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (True \<longrightarrow> (False \<or> False) \<and> (\<not>False \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False) \<or>
 (False \<longrightarrow> (False \<or> False) \<and> (\<not>True \<and> \<not>False) \<and> \<not>False \<and> \<not>False \<and> \<not>False))"

value "(
  (True \<longrightarrow>  (False \<and> \<not>False \<and> \<not>False \<or> False \<and> \<not>False \<and> \<not>False \<or> False \<and> \<not>False \<and> \<not>False)
	\<or> False \<and> \<not>False \<or> False \<and> \<not>False) \<and>
  (False \<longrightarrow>  (False \<and> \<not>False \<and> \<not>False \<or> False \<and> \<not>False \<and> \<not>False \<or> False \<and> \<not>False \<and> \<not>False)
  	\<or> False \<and> \<not>False \<or> False \<and> \<not>False) \<and>
  (False \<longrightarrow>  (False \<and> \<not>False \<and> \<not>False \<or> False \<and> \<not>False \<and> \<not>False \<or> False \<and> \<not>False \<and> \<not>False)
  	\<or> False \<and> \<not>False \<or> False \<and> \<not>False) \<and>
 (True \<longrightarrow> \<not>False \<and> \<not>False) \<and> (False \<longrightarrow> \<not>True \<and> \<not>False) \<and> (False \<longrightarrow> \<not>True \<and> \<not>False) \<and>
 (False \<longrightarrow> \<not>False \<and> \<not>False) \<and> (False \<longrightarrow> \<not>False \<and> \<not>False) \<and> (False \<longrightarrow> \<not>False \<and> \<not>False) \<and>
 (False \<longrightarrow> \<not>False) \<and> (False \<longrightarrow> \<not>False)
)"

lemma "((speak_y \<longrightarrow> broadcast_x \<and> isReg_y_x \<and> \<not>listen_y)
\<and> (listen_y \<longrightarrow> broadcast_x \<and> isReg_y_x \<and> \<not>speak_y)
\<and> (
	listen_y1 \<longrightarrow> broadcast_x \<and> differ_y1_Px \<and> isReg_y1_x \<and> isReg_Px_x \<and> (speak_Px \<or> listen_Px)
))
\<Longrightarrow>
((\<not>speak_y \<or> broadcast_x)
\<and> (\<not>speak_y \<or> isReg_y_x)
\<and> (\<not>speak_y \<or> \<not>listen_y)
\<and> (\<not>listen_y \<or> broadcast_x)
\<and> (\<not>listen_y \<or> isReg_y_x)
\<and> (\<not>listen_y \<or> \<not>speak_y)
\<and> (\<not>listen_y1 \<or> broadcast_x)
\<and> (\<not>listen_y1 \<or> differ_y1_Px)
\<and> (\<not>listen_y1 \<or> isReg_y1_x)
\<and> (\<not>listen_y1 \<or> isReg_Px_x)
\<and> (\<not>listen_y1 \<or> speak_Px \<or> listen_Px))"
  by blast

=======
locale geometry =
  fixes parallel :: "'line \<Rightarrow> 'line \<Rightarrow> bool"
  and intersect :: "'line \<Rightarrow> 'line \<Rightarrow> bool"
  and angle :: "'line \<Rightarrow> 'line \<Rightarrow> nat"
  assumes axiom1: "parallel l1 l2 \<Longrightarrow> angle l1 l2 = 0"
  and axiom2: "intersect l1 l2 \<Longrightarrow> \<not> (angle l1 l2 = 0)"
begin
lemma parallel_not_intersect: "parallel l1 l2 \<Longrightarrow> \<not> intersect l1 l2"
  using axiom1 axiom2 by blast
end

lemma test_2: "(((P_5c_1 \<longrightarrow> (Q_1a_1 \<or> Q_1b_1) \<and> P_5d_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1a_3 \<and> \<not>Q_1b_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_1 \<or> Q_1b_1) \<and> P_5c_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1a_3 \<and> \<not>Q_1b_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_1a_1 \<or> Q_1b_2) \<and> P_5d_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1a_3 \<and> \<not>Q_1b_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_1 \<or> Q_1b_2) \<and> P_5c_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1a_3 \<and> \<not>Q_1b_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_1a_2 \<or> Q_1b_1) \<and> P_5d_1 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_3 \<and> \<not>Q_1b_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_2 \<or> Q_1b_1) \<and> P_5c_1 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_3 \<and> \<not>Q_1b_2)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_1a_2 \<or> Q_1b_2) \<and> P_5d_1 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_3 \<and> \<not>Q_1b_1) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_2 \<or> Q_1b_2) \<and> P_5c_1 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_3 \<and> \<not>Q_1b_1)) \<or>
 ((P_5c_1 \<longrightarrow> (Q_1a_3 \<or> Q_1b_1) \<and> P_5d_1 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1b_2) \<or>
  (P_5d_1 \<longrightarrow> (Q_1a_3 \<or> Q_1b_1) \<and> P_5c_1 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1b_2)) \<or>
 (P_5c_1 \<longrightarrow> (Q_1a_3 \<or> Q_1b_2) \<and> P_5d_1 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1b_1) \<or>
 (P_5d_1 \<longrightarrow> (Q_1a_3 \<or> Q_1b_2) \<and> P_5c_1 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1b_1))
\<Longrightarrow>
(((P_5c_1 \<longrightarrow>
	(Q_1a_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1a_3
	\<or> Q_1a_2 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_3
	\<or> Q_1a_3 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_2
	\<or> Q_1b_1 \<and> \<not>Q_1b_2
	\<or> Q_1b_2 \<and> \<not>Q_1b_1) \<and>
	P_5d_1) \<and>
(P_5d_1 \<longrightarrow>
	(Q_1a_1 \<and> \<not>Q_1a_2 \<and> \<not>Q_1a_3
	\<or> Q_1a_2 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_3
	\<or> Q_1a_3 \<and> \<not>Q_1a_1 \<and> \<not>Q_1a_2
	\<or> Q_1b_1 \<and> \<not>Q_1b_2
	\<or> Q_1b_2 \<and> \<not>Q_1b_1) \<and>
	P_5c_1) \<and>
(\<not>Q_1a_2 \<and> \<not>Q_1a_3 \<or> \<not>Q_1a_1 \<and> \<not>Q_1a_3 \<or> \<not>Q_1a_1 \<and> \<not>Q_1a_2) \<and> (\<not>Q_1b_2 \<or> \<not>Q_1b_1)))"

(*
locale comparision_1 =
  fixes test_synchron :: "(string * string list) list list list"
  and test_triggers :: "(string * string list) list list list"
  and BIP_Connector_2 :: "((string \<times> string) list \<times> (string \<times> string) list list) list"
  and JavaBIP_Connector_2 :: "((string \<times> string) list list \<times> (string \<times> string) list list list) list"
  assumes axiom1: "BIP_Connector_2 = List.product (concat (mk_pair_4 test_synchron)) (product_lists (mk_Trigger_list (mk_pair_4_no_product test_triggers)))"
  and axiom2: "JavaBIP_Connector_2 = mk_jvb (mk_pair_4_no_product test_synchron) (mk_Trigger_list (mk_pair_4_no_product test_triggers))"
begin
lemma test_1: "(\<exists>connector \<in> set BIP_Connector_2.\<exists>sync\<in>set (fst connector).(P (fst sync) (snd sync) \<longrightarrow>
((\<exists>trig\<in>set (snd connector).\<forall>elm\<in>set trig. Q (fst elm) (snd elm))
  \<and> (\<forall>sync1\<in>set (fst connector) - {sync}. P (fst sync1) (snd sync1))
  \<and> (\<forall>rs \<in> remaining_pairs (all_pairs test_synchron) (fst connector). \<not>P (fst rs) (snd rs))
  \<and> (\<forall>rt \<in> remaining_pairs (all_pairs test_triggers) (concat (snd connector)). \<not>Q (fst rt) (snd rt)))
)) \<Longrightarrow>
((\<forall>connector\<in>set JavaBIP_Connector_2.\<forall>sync_list\<in>set (fst connector).\<forall>sync\<in>set sync_list. (P (fst sync) (snd sync) \<longrightarrow>
      ((\<exists>trig_list\<in>set(snd connector).\<exists>trig\<in>set trig_list. \<forall>t_elm\<in>set trig. (Q (fst t_elm) (snd t_elm)
      \<and> (\<forall>h \<in> set (lookup_3 (fst t_elm) test_triggers) - {snd t_elm}. \<not>Q (fst t_elm) h)))
      \<and> (\<forall>sync_1\<in>set(fst connector)-{sync_list}.\<exists>s_elm_1\<in>set(sync_1). P (fst s_elm_1) (snd s_elm_1)
      \<and> (\<forall>l \<in> set (lookup_3 (fst s_elm_1) test_synchron) - {snd s_elm_1}. \<not>P (fst s_elm_1) l))
    )
))
\<and> (\<forall>j \<in> set test_synchron. \<forall>u \<in> set j. \<forall>t \<in> set u. \<exists>l \<in> set (snd t).\<forall>l1 \<in> set (snd t) - {l}. \<not> P (fst t) l1)
\<and> (\<forall>i \<in> set test_triggers. \<forall>v \<in> set i. \<forall>k \<in> set v. \<exists>h \<in> set (snd k).\<forall>h1 \<in> set (snd k) - {h}. \<not> Q (fst k) h1))"

end*)
>>>>>>> Stashed changes
(*
by presburger
value "
\<forall>x \<in> Tracker.\<forall>y \<in> Peer. (
  broadcast(x) \<and> isReg(y,x) \<longrightarrow> (speak(y) \<Longleftrightarrow> \<not>listen(y))
)
\<equiv>
\<forall>x \<in> Tracker.\<forall>y \<in> Peer. (
  broadcast(x) \<and> isReg(y,x) \<longrightarrow> (speak(y) \<and> \<not>listen(y) \<or> (listen(y) \<and> \<not>speak(y)))
)
\<And>

k \<noteq> j
k \<in> [1,m]
"
value "\<forall>x \<in> Tracker. (
  broadcast(x) \<longrightarrow> (
    \<exists>y \<in> Peer.(isReg(y,x) \<and> speak(y) \<and> (
      \<forall>y'\<in>Peer.(differ(y', y) \<and> isReg(y',x) \<longrightarrow> listen(y'))
    ))
    \<or> (\<forall>y \<in> Peer. isReg(y,x) \<longrightarrow> listen(y))
  )
)"

value "
\<forall>x \<in> Tracker.\<forall>y \<in> Peer. (
  \<not>(broadcast(x) \<and> isReg(y,x)) \<or> (\<not>speak(y)\<and>listen(y) \<or> \<not>listen(y)\<and>speak(y))
)"

value "
\<not>broadcast(x) \<or> \<not>isReg(y,x) \<or> \<not>speak(y)\<and>listen(y) \<or> \<not>listen(y)\<and>speak(y)
"

(*---------*)
value "
\<forall>x \<in> Tracker. (
  broadcast(x) \<longrightarrow> (
    \<exists>y \<in> Peer.(isReg(y,x) \<and> speak(y) \<and> (
      \<forall>y'\<in>Peer.(differ(y', y) \<and> isReg(y',x) \<longrightarrow> listen(y'))
    ))
    \<or> (\<forall>y \<in> Peer. isReg(y,x) \<longrightarrow> listen(y))
  )
)"

value "
\<forall>x \<in> Tracker. (
  \<not>broadcast(x) \<or> (
    \<exists>y \<in> Peer.(broadcast(x) \<and> isReg(y,x) \<and> speak(y) \<and> (
      \<forall>y'\<in>Peer.(\<not>(differ(y', y) \<and> isReg(y',x)) \<or> listen(y') \<and> differ(y', y) \<and> isReg(y',x))
    ))
  )
  \<or> (\<forall>y \<in> Peer. broadcast(x) \<and> (\<not>isReg(y,x) \<or> isReg(y,x) \<and> listen(y)))
)"

value "
  \<not>broadcast(x) \<or> (
    broadcast(x) \<and> isReg(Px,x) \<and> speak(Px) \<and> (
      \<not>(differ(y', y) \<and> isReg(y',x)) \<or> listen(y') \<and> differ(y', y) \<and> isReg(y',x)
    )
  )
  \<or> broadcast(x) \<and> (\<not>isReg(y,x) \<or> isReg(y,x) \<and> listen(y))
"

value "
\<not>broadcast(x)
\<or> (
    broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)
    \<and> (\<not>differ(y', y) \<or> listen(y') \<and> differ(y', y) \<and> isReg(y',x))
    \<and> (\<not>isReg(y',x) \<or> listen(y') \<and> differ(y', y) \<and> isReg(y',x))
  )
\<or> broadcast(x) \<and> (\<not>isReg(y,x) \<or> isReg(y,x) \<and> listen(y))
"

value "
(broadcast(x) \<Rightarrow> False)
\<or>
(
    (True \<Rightarrow> broadcast(x))
    \<and> (True \<Rightarrow> isReg(Px,x))
    \<and> (True \<Rightarrow> speak(Px))
    \<and> (\<not>differ(y', y) \<or> listen(y') \<and> differ(y', y) \<and> isReg(y',x))
    \<and> (\<not>isReg(y',x) \<or> listen(y') \<and> differ(y', y) \<and> isReg(y',x))
)
\<or>
(
  (True \<Rightarrow> broadcast(x))
  \<and> (\<not>isReg(y,x) \<or> isReg(y,x) \<and> listen(y))
)
"

value "
(
  True \<Longrightarrow> broadcast(x)
  \<and> True \<Longrightarrow> isReg(Px,x)
  \<and> True \<Longrightarrow> speak(Px)
  \<and> differ(y', y) \<Longrightarrow> listen(y')  \<and> isReg(y',x)
  \<and> isReg(y',x) \<Longrightarrow> listen(y') \<and> differ(y', y)
  \<and> listen(y') \<Longrightarrow> True

  \<and> isReg(y,x) \<Longrightarrow> True
  \<and> listen(y) \<Longrightarrow> True
)
\<or>
(
  True \<Longrightarrow> broadcast(x)
  \<and> isReg(y,x) \<Longrightarrow> listen(y)
  \<and> listen(y) \<Longrightarrow> True

  \<and> listen(y') \<Longrightarrow> True
  \<and> differ(y', y) \<Longrightarrow> True
  \<and> isReg(y',x) \<Longrightarrow> True
  \<and> isReg(Px,x) \<Longrightarrow> True
  \<and> speak(Px) \<Longrightarrow> True
)
"

value "
(
  True \<Rightarrow> broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)
  \<and> differ(y', y) \<Rightarrow> listen(y') \<and> isReg(y',x)
  \<and> isReg(y',x) \<Rightarrow> listen(y') \<and> differ(y', y)
  \<and> listen(y') \<Rightarrow> broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)

  \<and> isReg(y,x) \<Rightarrow> broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)
  \<and> listen(y) \<Rightarrow>  broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)
)
\<or>
(
  True \<Rightarrow> broadcast(x)
  \<and> isReg(y,x) \<Rightarrow> listen(y)
  \<and> listen(y) \<Rightarrow> broadcast(x)

  \<and> listen(y') \<Rightarrow> broadcast(x)
  \<and> differ(y', y) \<Rightarrow> broadcast(x)
  \<and> isReg(y',x) \<Rightarrow> broadcast(x)
  \<and> isReg(Px,x) \<Rightarrow> broadcast(x)
  \<and> speak(Px) \<Rightarrow> broadcast(x)
)
"

value "
(
  True \<Rightarrow> broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)
  \<and> differ(y', y) \<Rightarrow> broadcast(x) \<and> isReg(Px,x) \<and> speak(Px) \<and> isReg(y',x)
  \<and> isReg(y',x) \<Rightarrow> broadcast(x) \<and> isReg(Px,x) \<and> speak(Px) \<and> differ(y', y)
  \<and> listen(y') \<Rightarrow> broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)

  \<and> isReg(y,x) \<Rightarrow> broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)
  \<and> listen(y) \<Rightarrow>  broadcast(x) \<and> isReg(Px,x) \<and> speak(Px)
)
\<or>
(
  True \<Rightarrow> broadcast(x)
  \<and> isReg(y,x) \<Rightarrow> listen(y) \<and> broadcast(x)
  \<and> listen(y) \<Rightarrow> broadcast(x)

  \<and> listen(y') \<Rightarrow> broadcast(x)
  \<and> differ(y', y) \<Rightarrow> broadcast(x)
  \<and> isReg(y',x) \<Rightarrow> broadcast(x)
  \<and> isReg(Px,x) \<Rightarrow> broadcast(x)
  \<and> speak(Px) \<Rightarrow> broadcast(x)
)
"

value "
{
broadcast(x),
broadcast(x) \<and> isReg(Px,x) \<and> speak(Px),
broadcast(x) \<and> isReg(Px,x) \<and> speak(Px) \<and> listen(y'),
broadcast(x) \<and> isReg(Px,x) \<and> speak(Px) \<and> listen(y),
broadcast(x) \<and> isReg(Px,x) \<and> speak(Px) \<and> isReg(y,x),
broadcast(x) \<and> isReg(Px,x) \<and> speak(Px) \<and> isReg(y',x) \<and> differ(y', y),
} \<or>
{
broadcast(x),
listen(y) \<and> broadcast(x),
listen(y) \<and> broadcast(x) \<and> isReg(y,x),
listen(y') \<and> broadcast(x),
differ(y', y) \<and> broadcast(x),
isReg(y',x) \<and> broadcast(x),
isReg(Px,x) \<and> broadcast(x),
speak(Px) \<and> broadcast(x),
}"
*)
end


(*
   Title: The pi-calculus
   Author/Maintainer: Jesper Bengtson (jebe.dk), 2012
*)
theory Weak_Late_Cong_SC
  imports Weak_Late_Cong Strong_Late_Bisim_SC
begin

(******** Structural Congruence **********)

(******** The \<nu>-operator *****************)

lemma resComm:
  fixes P :: pi

  shows "<\<nu>a><\<nu>b>P \<simeq> <\<nu>b><\<nu>a>P"
proof -
  have "<\<nu>a><\<nu>b>P \<sim> <\<nu>b><\<nu>a>P" by(rule Strong_Late_Bisim_SC.resComm)
  thus ?thesis by(rule strongBisimWeakEq)
qed

(******** Match *****************)

lemma matchId:
  fixes a :: name
  and   P :: pi

  shows "[a\<frown>a]P \<simeq> P"
proof -
  have "[a\<frown>a]P \<sim> P" by(rule Strong_Late_Bisim_SC.matchId)
  thus ?thesis by(rule strongBisimWeakEq)
qed

(******** Mismatch *****************)

lemma mismatchId:
  fixes a :: name
  and   b :: name
  and   P :: pi

  assumes "a \<noteq> b"

  shows "[a\<noteq>b]P \<simeq> P"
proof -
  from \<open>a \<noteq> b\<close> have "[a\<noteq>b]P \<sim> P" by(rule Strong_Late_Bisim_SC.mismatchId)
  thus ?thesis by(rule strongBisimWeakEq)
qed

(******** The +-operator *********)

lemma sumSym:
  fixes P :: pi
  and   Q :: pi

  shows "P \<oplus> Q \<simeq> Q \<oplus> P"
proof -
  have "P \<oplus> Q \<sim> Q \<oplus> P" by(rule Strong_Late_Bisim_SC.sumSym)
  thus ?thesis by(rule strongBisimWeakEq)
qed

(******** The |-operator *********)

lemma parZero:
  fixes P :: pi

  shows "P \<parallel> \<zero> \<simeq> P"
proof -
  have "P \<parallel> \<zero> \<sim> P" by(rule Strong_Late_Bisim_SC.parZero)
  thus ?thesis by(rule strongBisimWeakEq)
qed

lemma parSym:
  fixes P :: pi
  and   Q :: pi

  shows "P \<parallel> Q \<simeq> Q \<parallel> P"
proof -
  have "P \<parallel> Q \<sim> Q \<parallel> P" by(rule Strong_Late_Bisim_SC.parSym)
  thus ?thesis by(rule strongBisimWeakEq)
qed

  assumes "x \<sharp> P"

  shows "<\<nu>x>(P \<parallel> Q) \<simeq> P \<parallel> <\<nu>x>Q"
proof -
  from \<open>x \<sharp> P\<close> have "<\<nu>x>(P \<parallel> Q) \<sim> P \<parallel> <\<nu>x>Q" by(rule Strong_Late_Bisim_SC.scopeExtPar)
  thus ?thesis by(rule strongBisimWeakEq)
qed

lemma scopeExtPar':
  fixes P :: pi
  and   Q :: pi
  and   x :: name

  assumes "x \<sharp> Q"

  shows "<\<nu>x>(P \<parallel> Q) \<simeq> (<\<nu>x>P) \<parallel> Q"
proof -
  from \<open>x \<sharp> Q\<close> have "<\<nu>x>(P \<parallel> Q) \<sim> (<\<nu>x>P) \<parallel> Q" by(rule Strong_Late_Bisim_SC.scopeExtPar')
  thus ?thesis by(rule strongBisimWeakEq)
qed

  shows "(P \<parallel> Q) \<parallel> R \<simeq> P \<parallel> (Q \<parallel> R)"
proof -
  have "(P \<parallel> Q) \<parallel> R \<sim> P \<parallel> (Q \<parallel> R)" by(rule Strong_Late_Bisim_SC.parAssoc)
  thus ?thesis by(rule strongBisimWeakEq)
qed

  assumes "a \<sharp> P"

  shows "<\<nu>a>P \<simeq> P"
proof -
  from \<open>a \<sharp> P\<close> have "<\<nu>a>P \<sim> P" by(rule Strong_Late_Bisim_SC.scopeFresh)
  thus ?thesis by(rule strongBisimWeakEq)
qed

lemma scopeExtSum:
  fixes P :: pi
  and   Q :: pi
  and   x :: name

  assumes "x \<sharp> P"

  shows "<\<nu>x>(P \<oplus> Q) \<simeq> P \<oplus> <\<nu>x>Q"
proof -
  from \<open>x \<sharp> P\<close> have "<\<nu>x>(P \<oplus> Q) \<sim> P \<oplus> <\<nu>x>Q" by(rule Strong_Late_Bisim_SC.scopeExtSum)
  thus ?thesis by(rule strongBisimWeakEq)
qed

lemma bangSC:
  fixes P

  shows "!P \<simeq> P \<parallel> !P"
proof -
  have "!P \<sim> P \<parallel> !P" by(rule Strong_Late_Bisim_SC.bangSC)
  thus ?thesis by(rule strongBisimWeakEq)
qed

end


(*
Auction Theory Toolbox (http://formare.github.io/auctions/)

Authors:
* Marco B. Caminati http://caminati.co.nr
* Manfred Kerber <mnfrd.krbr@gmail.com>
* Christoph Lange <math.semantic.web@gmail.com>
* Colin Rowat <c.rowat@bham.ac.uk>

Dually licenced under
* Creative Commons Attribution (CC-BY) 3.0
* ISC License (1-clause BSD License)
See LICENSE file for details
(Rationale for this dual licence: http://arxiv.org/abs/1107.3212)
*)

section \<open>VCG auction: three simple examples evaluating the VCG allocation algorithm
          vcgaAlg and the price determination algorithm vcgpAlg in Isabelle\<close>

theory CombinatorialAuctionExamples

imports
CombinatorialAuction

begin

(* The following counterexample is built by deleting the additional assumption that n1 \<noteq> n2. *)
(* Since this a "false" theorem, the following needs to be commented out, since otherwise
   the subsequent lines will fail. *)
(* theorem counterexample_allocationDisjoint:
  assumes "a \<in> allocationsUniverse" "n1\<in> Domain a" "n2 \<in> Domain a"
  shows "a,,,n1 \<inter> a,,,n2 = {}" nitpick
*)

(* Test example 1 for evaluation of vcga and vcgp in Isabelle *)
definition "r1 = 0" (* r1 in {0, 1, 2, ... 23 *)
definition "N1 = {1,2,3::integer}"
definition "\<Omega>1 = [11, 12]"
definition "b1 = {((1::integer, {11::integer, 12}), 2::nat),
                  ((2,          {11}),          2),
                  ((2,          {12}),          2),
                  ((3,          {11}),          2),
                  ((3,          {12}),          2)}"
definition "vcga1 = vcgaAlg N1 \<Omega>1 (b1 Elsee 0) r1"

value "vcga1"
value [nbe] "vcgpAlg N1 \<Omega>1 (b1 Elsee 0) r1 1 vcga1"
value [nbe] "vcgpAlg N1 \<Omega>1 (b1 Elsee 0) r1 2 vcga1"
value [nbe] "vcgpAlg N1 \<Omega>1 (b1 Elsee 0) r1 3 vcga1"

(* Test example 2 for evaluation of vcga and vcgp in Isabelle *)
definition "r2 = 1" (* r1 in {0, 1, 2, ... 23 *)
definition "N2 = {1,2,3::integer}"
definition "\<Omega>2 = [11, 12]"
definition "b2 = {((1::integer, {11::integer, 12}), 5::nat),
                  ((2,          {11}),              3),
                  ((2,          {12}),              3),
                  ((3,          {11}),              2),
                  ((3,          {12}),              4)}"
definition "vcga2 = vcgaAlg N2 \<Omega>2 (b2 Elsee 0) r2"

value "vcga2"
value [nbe] "vcgpAlg N2 \<Omega>2 (b2 Elsee 0) r2 1 vcga2"
value [nbe] "vcgpAlg N2 \<Omega>2 (b2 Elsee 0) r2 2 vcga2"
value [nbe] "vcgpAlg N2 \<Omega>2 (b2 Elsee 0) r2 3 vcga2"

(* Test example 3 for evaluation of vcga and vcgp in Isabelle *)
definition "r3 = 0" (* r1 in {0, 1, 2, ... 47 *)
definition "N3 = {1,2,3::integer}"
definition "\<Omega>3 = [11, 12, 13]"
definition "b3 = {((1::integer, {11::integer, 12, 13}), 20::nat),
                  ((1,          {11,12}),               18),
                  ((2,          {11}),                  10),
                  ((2,          {12}),                  15),
                  ((2,          {13}),                  15),
                  ((2,          {12,13}),               18),
                  ((3,          {11}),                   2),
                  ((3,          {11,12}),               12),
                  ((3,          {11,13}),               17),
                  ((3,          {12,13}),               18),
                  ((3,          {11,12,13}),            19)}"
definition "vcga3 = vcgaAlg N3 \<Omega>3 (b3 Elsee 0) r3"

value "vcga3"
value [nbe] "vcgpAlg N3 \<Omega>3 (b3 Elsee 0) r3 1 vcga3"
value [nbe] "vcgpAlg N3 \<Omega>3 (b3 Elsee 0) r3 2 vcga3"
value [nbe] "vcgpAlg N3 \<Omega>3 (b3 Elsee 0) r3 3 vcga3"

end


theory ValueOntology imports PreferenceLogicBasics (** Benzm., Fuenmayor & Lomfeld, 2021 **)
begin (*** Lomfeld's value ontology is encoded ***)
 (*new datatype for parties/contenders (there could be more in principle)*)
datatype c = p | d (*plaintiff & defendant*)
fun other::"c\<Rightarrow>c" ("_\<inverse>") where "p\<inverse> = d" | "d\<inverse> = p"
 (*new constant symbol: finding/ruling for party*)
consts For::"c\<Rightarrow>\<sigma>"
axiomatization where ForAx: "\<lfloor>For x \<^bold>\<leftrightarrow> (\<^bold>\<not>For x\<inverse>)\<rfloor>"
 (*new parameterized datatype for abstract values (wrt. a given party)*)
datatype 't VAL = FREEDOM 't | UTILITY 't | SECURITY 't | EQUALITY 't
type_synonym v = "(c)VAL\<Rightarrow>bool" (*principles: sets of (abstract) values*)
type_synonym cv = "c\<Rightarrow>v" (*principles are specified wrt. a given party*)
 (*notation for sets*)
abbreviation vset1 ("\<lbrace>_\<rbrace>") where "\<lbrace>\<phi>\<rbrace> \<equiv> \<lambda>x::(c)VAL. x=\<phi>"
abbreviation vset2 ("\<lbrace>_,_\<rbrace>")   where "\<lbrace>\<alpha>,\<beta>\<rbrace> \<equiv> \<lambda>x::(c)VAL. x=\<alpha> \<or> x=\<beta>"
 (*abstract values and value principles*)
abbreviation utility::cv  ("UTILITY\<^sup>_")  where "UTILITY\<^sup>x  \<equiv> \<lbrace>UTILITY  x\<rbrace>"
abbreviation security::cv ("SECURITY\<^sup>_") where "SECURITY\<^sup>x \<equiv> \<lbrace>SECURITY x\<rbrace>"
abbreviation equality::cv ("EQUALITY\<^sup>_") where "EQUALITY\<^sup>x \<equiv> \<lbrace>EQUALITY x\<rbrace>"
abbreviation freedom::cv  ("FREEDOM\<^sup>_")  where "FREEDOM\<^sup>x  \<equiv> \<lbrace>FREEDOM  x\<rbrace>"
abbreviation stab::cv ("STAB\<^sup>_") where "STAB\<^sup>x \<equiv> \<lbrace>SECURITY x, UTILITY  x\<rbrace>"
abbreviation effi::cv ("EFFI\<^sup>_") where "EFFI\<^sup>x \<equiv> \<lbrace>UTILITY  x, SECURITY x\<rbrace>"
abbreviation gain::cv ("GAIN\<^sup>_") where "GAIN\<^sup>x \<equiv> \<lbrace>UTILITY  x, FREEDOM  x\<rbrace>"
abbreviation will::cv ("WILL\<^sup>_") where "WILL\<^sup>x \<equiv> \<lbrace>FREEDOM  x, UTILITY  x\<rbrace>"
abbreviation resp::cv ("RESP\<^sup>_") where "RESP\<^sup>x \<equiv> \<lbrace>FREEDOM  x, EQUALITY x\<rbrace>"
abbreviation fair::cv ("FAIR\<^sup>_") where "FAIR\<^sup>x \<equiv> \<lbrace>EQUALITY x, FREEDOM  x\<rbrace>"
abbreviation equi::cv ("EQUI\<^sup>_") where "EQUI\<^sup>x \<equiv> \<lbrace>EQUALITY x, SECURITY x\<rbrace>"
abbreviation reli::cv ("RELI\<^sup>_") where "RELI\<^sup>x \<equiv> \<lbrace>SECURITY x, EQUALITY x\<rbrace>"
(**Value Theory*)
consts Irel::"\<iota>\<Rightarrow>v" ("\<I>") (*incidence relation worlds-values*)
 (*derivation operators (cf. theory of "formal concept analysis") *)
abbreviation intent::"\<sigma>\<Rightarrow>v" ("_\<up>") where "W\<up> \<equiv> \<lambda>v. \<forall>x. W x \<longrightarrow> \<I> x v"
abbreviation extent::"v\<Rightarrow>\<sigma>" ("_\<down>") where "V\<down> \<equiv> \<lambda>w. \<forall>x. V x \<longrightarrow> \<I> w x"
abbreviation extent_brkt ("[_]") where "[V] \<equiv> V\<down>" (*alternative notation*)
 (*connective for aggregating value principles*)
abbreviation aggr ("[_\<^bold>\<oplus>_]") where "[V\<^sub>1\<^bold>\<oplus>V\<^sub>2] \<equiv> (V\<^sub>1\<down>) \<^bold>\<or> (V\<^sub>2\<down>)"
 (*chosen variant for preference relation (cf. Halpern (1997)*)
abbreviation pref::"\<sigma>\<Rightarrow>\<sigma>\<Rightarrow>\<sigma>"  ("_\<^bold>\<prec>_") where "\<phi> \<^bold>\<prec> \<psi> \<equiv> \<phi> \<^bold>\<prec>\<^sub>A\<^sub>E \<psi>"
 (*schema for value principle promotion*)
abbreviation "Promotes F D V \<equiv> \<lfloor>F \<^bold>\<rightarrow> \<^bold>\<box>\<^sup>\<prec>(D \<^bold>\<leftrightarrow> \<^bold>\<diamond>\<^sup>\<prec>(V\<down>))\<rfloor>"
 (*proposition for testing for value conflict*)
abbreviation conflict ("Conflict\<^sup>_") where (*conflict for value support*)
 "Conflict\<^sup>x \<equiv> [SECURITY\<^sup>x] \<^bold>\<and> [EQUALITY\<^sup>x] \<^bold>\<and> [FREEDOM\<^sup>x] \<^bold>\<and> [UTILITY\<^sup>x]"
 (*verify consistency of this theory*)
lemma "True" nitpick[satisfy] oops
end


theory Sec_TypingT imports Sec_Type_Expr
begin

subsection "A Termination-Sensitive Syntax Directed System"

inductive sec_type :: "nat \<Rightarrow> com \<Rightarrow> bool" ("(_/ \<turnstile> _)" [0,0] 50) where
Skip:
  "l \<turnstile> SKIP"  |
Assign:
  "\<lbrakk> sec x \<ge> sec a;  sec x \<ge> l \<rbrakk> \<Longrightarrow> l \<turnstile> x ::= a"  |
Seq:
  "l \<turnstile> c\<^sub>1 \<Longrightarrow> l \<turnstile> c\<^sub>2 \<Longrightarrow> l \<turnstile> c\<^sub>1;;c\<^sub>2"  |
If:
  "\<lbrakk> max (sec b) l \<turnstile> c\<^sub>1;  max (sec b) l \<turnstile> c\<^sub>2 \<rbrakk>
   \<Longrightarrow> l \<turnstile> IF b THEN c\<^sub>1 ELSE c\<^sub>2"  |
While:
  "sec b = 0 \<Longrightarrow> 0 \<turnstile> c \<Longrightarrow> 0 \<turnstile> WHILE b DO c"

code_pred (expected_modes: i => i => bool) sec_type .

inductive_cases [elim!]:
  "l \<turnstile> x ::= a"  "l \<turnstile> c\<^sub>1;;c\<^sub>2"  "l \<turnstile> IF b THEN c\<^sub>1 ELSE c\<^sub>2"  "l \<turnstile> WHILE b DO c"

lemma anti_mono: "l \<turnstile> c \<Longrightarrow> l' \<le> l \<Longrightarrow> l' \<turnstile> c"
apply(induction arbitrary: l' rule: sec_type.induct)
apply (metis sec_type.intros(1))
apply (metis le_trans sec_type.intros(2))
apply (metis sec_type.intros(3))
apply (metis If le_refl sup_mono sup_nat_def)
by (metis While le_0_eq)

lemma confinement: "(c,s) \<Rightarrow> t \<Longrightarrow> l \<turnstile> c \<Longrightarrow> s = t (< l)"
proof(induction rule: big_step_induct)
  case Skip thus ?case by simp
next
  case Assign thus ?case by auto
next
  case Seq thus ?case by auto
next
  case (IfTrue b s c1)
  hence "max (sec b) l \<turnstile> c1" by auto
  hence "l \<turnstile> c1" by (metis max.cobounded2 anti_mono)
  thus ?case using IfTrue.IH by metis
next
  case (IfFalse b s c2)
  hence "max (sec b) l \<turnstile> c2" by auto
  hence "l \<turnstile> c2" by (metis max.cobounded2 anti_mono)
  thus ?case using IfFalse.IH by metis
next
  case WhileFalse thus ?case by auto
next
  case (WhileTrue b s1 c)
  hence "l \<turnstile> c" by auto
  thus ?case using WhileTrue by metis
qed

lemma termi_if_non0: "l \<turnstile> c \<Longrightarrow> l \<noteq> 0 \<Longrightarrow> \<exists> t. (c,s) \<Rightarrow> t"
apply(induction arbitrary: s rule: sec_type.induct)
apply (metis big_step.Skip)
apply (metis big_step.Assign)
apply (metis big_step.Seq)
apply (metis IfFalse IfTrue le0 le_antisym max.cobounded2)
apply simp
done

theorem noninterference: "(c,s) \<Rightarrow> s' \<Longrightarrow> 0 \<turnstile> c \<Longrightarrow>  s = t (\<le> l)
  \<Longrightarrow> \<exists> t'. (c,t) \<Rightarrow> t' \<and> s' = t' (\<le> l)"
proof(induction arbitrary: t rule: big_step_induct)
  case Skip thus ?case by auto
next
  case (Assign x a s)
  have "sec x >= sec a" using `0 \<turnstile> x ::= a` by auto
  have "(x ::= a,t) \<Rightarrow> t(x := aval a t)" by auto
  moreover
  have "s(x := aval a s) = t(x := aval a t) (\<le> l)"
  proof auto
    assume "sec x \<le> l"
    with `sec x \<ge> sec a` have "sec a \<le> l" by arith
    thus "aval a s = aval a t"
      by (rule aval_eq_if_eq_le[OF `s = t (\<le> l)`])
  next
    fix y assume "y \<noteq> x" "sec y \<le> l"
    thus "s y = t y" using `s = t (\<le> l)` by simp
  qed
  ultimately show ?case by blast
next
  case Seq thus ?case by blast
next
  case (IfTrue b s c1 s' c2)
  have "sec b \<turnstile> c1" "sec b \<turnstile> c2" using `0 \<turnstile> IF b THEN c1 ELSE c2` by auto
  obtain t' where t': "(c1, t) \<Rightarrow> t'" "s' = t' (\<le> l)"
    using IfTrue.IH[OF anti_mono[OF `sec b \<turnstile> c1`] `s = t (\<le> l)`] by blast
  show ?case
  proof cases
    assume "sec b \<le> l"
    hence "s = t (\<le> sec b)" using `s = t (\<le> l)` by auto
    hence "bval b t" using `bval b s` by(simp add: bval_eq_if_eq_le)
    thus ?thesis by (metis t' big_step.IfTrue)
  next
    assume "\<not> sec b \<le> l"
    hence 0: "sec b \<noteq> 0" by arith
    have 1: "sec b \<turnstile> IF b THEN c1 ELSE c2"
      by(rule sec_type.intros)(simp_all add: `sec b \<turnstile> c1` `sec b \<turnstile> c2`)
    from confinement[OF big_step.IfTrue[OF IfTrue(1,2)] 1] `\<not> sec b \<le> l`
    have "s = s' (\<le> l)" by auto
    moreover
    from termi_if_non0[OF 1 0, of t] obtain t' where
      t': "(IF b THEN c1 ELSE c2,t) \<Rightarrow> t'" ..
    moreover
    from confinement[OF t' 1] `\<not> sec b \<le> l`
    have "t = t' (\<le> l)" by auto
    ultimately
    show ?case using `s = t (\<le> l)` by auto
  qed
next
  case (IfFalse b s c2 s' c1)
  have "sec b \<turnstile> c1" "sec b \<turnstile> c2" using `0 \<turnstile> IF b THEN c1 ELSE c2` by auto
  obtain t' where t': "(c2, t) \<Rightarrow> t'" "s' = t' (\<le> l)"
    using IfFalse.IH[OF anti_mono[OF `sec b \<turnstile> c2`] `s = t (\<le> l)`] by blast
  show ?case
  proof cases
    assume "sec b \<le> l"
    hence "s = t (\<le> sec b)" using `s = t (\<le> l)` by auto
    hence "\<not> bval b t" using `\<not> bval b s` by(simp add: bval_eq_if_eq_le)
    thus ?thesis by (metis t' big_step.IfFalse)
  next
    assume "\<not> sec b \<le> l"
    hence 0: "sec b \<noteq> 0" by arith
    have 1: "sec b \<turnstile> IF b THEN c1 ELSE c2"
      by(rule sec_type.intros)(simp_all add: `sec b \<turnstile> c1` `sec b \<turnstile> c2`)
    from confinement[OF big_step.IfFalse[OF IfFalse(1,2)] 1] `\<not> sec b \<le> l`
    have "s = s' (\<le> l)" by auto
    moreover
    from termi_if_non0[OF 1 0, of t] obtain t' where
      t': "(IF b THEN c1 ELSE c2,t) \<Rightarrow> t'" ..
    moreover
    from confinement[OF t' 1] `\<not> sec b \<le> l`
    have "t = t' (\<le> l)" by auto
    ultimately
    show ?case using `s = t (\<le> l)` by auto
  qed
next
  case (WhileFalse b s c)
  hence [simp]: "sec b = 0" by auto
  have "s = t (\<le> sec b)" using `s = t (\<le> l)` by auto
  hence "\<not> bval b t" using `\<not> bval b s` by (metis bval_eq_if_eq_le le_refl)
  with WhileFalse.prems(2) show ?case by auto
next
  case (WhileTrue b s c s'' s')
  let ?w = "WHILE b DO c"
  from `0 \<turnstile> ?w` have [simp]: "sec b = 0" by auto
  have "0 \<turnstile> c" using `0 \<turnstile> WHILE b DO c` by auto
  from WhileTrue.IH(1)[OF this `s = t (\<le> l)`]
  obtain t'' where "(c,t) \<Rightarrow> t''" and "s'' = t'' (\<le>l)" by blast
  from WhileTrue.IH(2)[OF `0 \<turnstile> ?w` this(2)]
  obtain t' where "(?w,t'') \<Rightarrow> t'" and "s' = t' (\<le>l)" by blast
  from `bval b s` have "bval b t"
    using bval_eq_if_eq_le[OF `s = t (\<le>l)`] by auto
  show ?case
    using big_step.WhileTrue[OF `bval b t` `(c,t) \<Rightarrow> t''` `(?w,t'') \<Rightarrow> t'`]
    by (metis `s' = t' (\<le> l)`)
qed

subsection "The Standard Termination-Sensitive System"

text{* The predicate @{prop"l \<turnstile> c"} is nicely intuitive and executable. The
standard formulation, however, is slightly different, replacing the maximum
computation by an antimonotonicity rule. We introduce the standard system now
and show the equivalence with our formulation. *}

inductive sec_type' :: "nat \<Rightarrow> com \<Rightarrow> bool" ("(_/ \<turnstile>'' _)" [0,0] 50) where
Skip':
  "l \<turnstile>' SKIP"  |
Assign':
  "\<lbrakk> sec x \<ge> sec a;  sec x \<ge> l \<rbrakk> \<Longrightarrow> l \<turnstile>' x ::= a"  |
Seq':
  "l \<turnstile>' c\<^sub>1 \<Longrightarrow> l \<turnstile>' c\<^sub>2 \<Longrightarrow> l \<turnstile>' c\<^sub>1;;c\<^sub>2"  |
If':
  "\<lbrakk> sec b \<le> l;  l \<turnstile>' c\<^sub>1;  l \<turnstile>' c\<^sub>2 \<rbrakk> \<Longrightarrow> l \<turnstile>' IF b THEN c\<^sub>1 ELSE c\<^sub>2"  |
While':
  "\<lbrakk> sec b = 0;  0 \<turnstile>' c \<rbrakk> \<Longrightarrow> 0 \<turnstile>' WHILE b DO c"  |
anti_mono':
  "\<lbrakk> l \<turnstile>' c;  l' \<le> l \<rbrakk> \<Longrightarrow> l' \<turnstile>' c"

lemma sec_type_sec_type':
  "l \<turnstile> c \<Longrightarrow> l \<turnstile>' c"
apply(induction rule: sec_type.induct)
apply (metis Skip')
apply (metis Assign')
apply (metis Seq')
apply (metis max.commute max.absorb_iff2 nat_le_linear If' anti_mono')
by (metis While')

lemma sec_type'_sec_type:
  "l \<turnstile>' c \<Longrightarrow> l \<turnstile> c"
apply(induction rule: sec_type'.induct)
apply (metis Skip)
apply (metis Assign)
apply (metis Seq)
apply (metis max.absorb2 If)
apply (metis While)
by (metis anti_mono)

corollary sec_type_eq: "l \<turnstile> c \<longleftrightarrow> l \<turnstile>' c"
by (metis sec_type'_sec_type sec_type_sec_type')

end


theory Let
imports "../Nominal2"
begin

atom_decl name

nominal_datatype trm =
  Var "name"
| App "trm" "trm"
| Lam x::"name" t::"trm"  binds  x in t
| Let as::"assn" t::"trm"   binds "bn as" in t
and assn =
  ANil
| ACons "name" "trm" "assn"
binder
  bn
where
  "bn ANil = []"
| "bn (ACons x t as) = (atom x) # (bn as)"

print_theorems

thm alpha_trm_raw_alpha_assn_raw_alpha_bn_raw.intros
thm bn_raw.simps
thm permute_bn_raw.simps
thm trm_assn.perm_bn_alpha
thm trm_assn.permute_bn

thm trm_assn.fv_defs
thm trm_assn.eq_iff
thm trm_assn.bn_defs
thm trm_assn.bn_inducts
thm trm_assn.perm_simps
thm trm_assn.permute_bn
thm trm_assn.induct
thm trm_assn.inducts
thm trm_assn.distinct
thm trm_assn.supp
thm trm_assn.fresh
thm trm_assn.exhaust
thm trm_assn.strong_exhaust
thm trm_assn.perm_bn_simps

lemma alpha_bn_inducts_raw[consumes 1]:
  "\<lbrakk>alpha_bn_raw a b; P3 ANil_raw ANil_raw;
 \<And>trm_raw trm_rawa assn_raw assn_rawa name namea.
    \<lbrakk>alpha_trm_raw trm_raw trm_rawa; alpha_bn_raw assn_raw assn_rawa;
     P3 assn_raw assn_rawa\<rbrakk>
    \<Longrightarrow> P3 (ACons_raw name trm_raw assn_raw)
        (ACons_raw namea trm_rawa assn_rawa)\<rbrakk> \<Longrightarrow> P3 a b"
  by (erule alpha_trm_raw_alpha_assn_raw_alpha_bn_raw.inducts(3)[of _ _ "\<lambda>x y. True" _ "\<lambda>x y. True", simplified]) auto

lemmas alpha_bn_inducts[consumes 1] = alpha_bn_inducts_raw[quot_lifted]

lemma alpha_bn_refl: "alpha_bn x x"
  by (induct x rule: trm_assn.inducts(2))
     (rule TrueI, auto simp add: trm_assn.eq_iff)
lemma alpha_bn_sym: "alpha_bn x y \<Longrightarrow> alpha_bn y x"
  sorry
lemma alpha_bn_trans: "alpha_bn x y \<Longrightarrow> alpha_bn y z \<Longrightarrow> alpha_bn x z"
  sorry

lemma bn_inj[rule_format]:
  assumes a: "alpha_bn x y"
  shows "bn x = bn y \<longrightarrow> x = y"
  by (rule alpha_bn_inducts[OF a]) (simp_all add: trm_assn.bn_defs)

lemma bn_inj2:
  assumes a: "alpha_bn x y"
  shows "\<And>q r. (q \<bullet> bn x) = (r \<bullet> bn y) \<Longrightarrow> permute_bn q x = permute_bn r y"
using a
apply(induct rule: alpha_bn_inducts)
apply(simp add: trm_assn.perm_bn_simps)
apply(simp add: trm_assn.perm_bn_simps)
apply(simp add: trm_assn.bn_defs)
done

function
  apply_assn :: "(trm \<Rightarrow> nat) \<Rightarrow> assn \<Rightarrow> nat"
where
  "apply_assn f ANil = (0 :: nat)"
| "apply_assn f (ACons x t as) = max (f t) (apply_assn f as)"
apply(case_tac x)
apply(case_tac b rule: trm_assn.exhaust(2))
apply(simp_all)
done

termination by lexicographic_order

lemma [eqvt]:
  "p \<bullet> (apply_assn f a) = apply_assn (p \<bullet> f) (p \<bullet> a)"
  apply(induct f a rule: apply_assn.induct)
  apply simp
  apply(simp only: apply_assn.simps trm_assn.perm_simps)
  apply(perm_simp)
  apply(simp)
  done

lemma alpha_bn_apply_assn:
  assumes "alpha_bn as bs"
  shows "apply_assn f as = apply_assn f bs"
  using assms
  apply (induct rule: alpha_bn_inducts)
  apply simp_all
  done

nominal_function
    height_trm :: "trm \<Rightarrow> nat"
where
  "height_trm (Var x) = 1"
| "height_trm (App l r) = max (height_trm l) (height_trm r)"
| "height_trm (Lam v b) = 1 + (height_trm b)"
| "height_trm (Let as b) = max (apply_assn height_trm as) (height_trm b)"
  apply (simp only: eqvt_def height_trm_graph_aux_def)
  apply (rule, perm_simp, rule, rule TrueI)
  apply (case_tac x rule: trm_assn.exhaust(1))
  apply (auto)[4]
  apply (drule_tac x="assn" in meta_spec)
  apply (drule_tac x="trm" in meta_spec)
  apply (simp add: alpha_bn_refl)
  using [[simproc del: alpha_lst]]
  apply(simp_all)
  apply (erule_tac c="()" in Abs_lst1_fcb2)
  apply (simp_all add: pure_fresh fresh_star_def eqvt_at_def)[4]
  apply (erule conjE)
  apply (subst alpha_bn_apply_assn)
  apply assumption
  apply (rule arg_cong) back
  apply (erule_tac c="()" in Abs_lst_fcb2)
  apply (simp_all add: pure_fresh fresh_star_def)[3]
  apply (simp_all add: eqvt_at_def)[2]
  done

definition "height_assn = apply_assn height_trm"

function
  apply_assn2 :: "(trm \<Rightarrow> trm) \<Rightarrow> assn \<Rightarrow> assn"
where
  "apply_assn2 f ANil = ANil"
| "apply_assn2 f (ACons x t as) = ACons x (f t) (apply_assn2 f as)"
  apply(case_tac x)
  apply(case_tac b rule: trm_assn.exhaust(2))
  apply(simp_all)
  done

termination by lexicographic_order

lemma [eqvt]:
  "p \<bullet> (apply_assn2 f a) = apply_assn2 (p \<bullet> f) (p \<bullet> a)"
  apply(induct f a rule: apply_assn2.induct)
  apply simp_all
  done

lemma bn_apply_assn2: "bn (apply_assn2 f as) = bn as"
  apply (induct as rule: trm_assn.inducts(2))
  apply (rule TrueI)
  apply (simp_all add: trm_assn.bn_defs)
  done

nominal_function
    subst  :: "name \<Rightarrow> trm \<Rightarrow> trm \<Rightarrow> trm"
where
  "subst s t (Var x) = (if (s = x) then t else (Var x))"
| "subst s t (App l r) = App (subst s t l) (subst s t r)"
| "atom v \<sharp> (s, t) \<Longrightarrow> subst s t (Lam v b) = Lam v (subst s t b)"
| "set (bn as) \<sharp>* (s, t) \<Longrightarrow> subst s t (Let as b) = Let (apply_assn2 (subst s t) as) (subst s t b)"
  apply (simp only: eqvt_def subst_graph_aux_def)
  apply (rule, perm_simp, rule)
  apply (rule TrueI)
  apply (case_tac x)
  apply (rule_tac y="c" and c="(a,b)" in trm_assn.strong_exhaust(1))
  apply (auto simp add: fresh_star_def)[3]
  apply (drule_tac x="assn" in meta_spec)
  apply (simp add: Abs1_eq_iff alpha_bn_refl)
  apply simp_all[7]
  prefer 2
  apply(simp)
  using [[simproc del: alpha_lst]]
  apply(simp)
  apply(erule conjE)+
  apply (erule_tac c="(sa, ta)" in Abs_lst1_fcb2)
  apply (simp add: Abs_fresh_iff)
  apply (simp add: fresh_star_def)
  apply (simp_all add: fresh_star_Pair_elim perm_supp_eq eqvt_at_def)[2]
  apply (simp add: bn_apply_assn2)
  apply(erule conjE)+
  apply(rule conjI)
  apply (erule_tac c="(sa, ta)" in Abs_lst_fcb2)
  apply (simp add: fresh_star_def Abs_fresh_iff)
  apply assumption+
  apply (simp_all add: fresh_star_Pair_elim perm_supp_eq eqvt_at_def trm_assn.fv_bn_eqvt)[2]
  apply (erule alpha_bn_inducts)
  apply simp_all
  done

lemma lets_bla:
  "x \<noteq> z \<Longrightarrow> y \<noteq> z \<Longrightarrow> x \<noteq> y \<Longrightarrow>(Let (ACons x (Var y) ANil) (Var x)) \<noteq> (Let (ACons x (Var z) ANil) (Var x))"
  by (simp add: trm_assn.eq_iff)

lemma lets_ok:
  "(Let (ACons x (Var y) ANil) (Var x)) = (Let (ACons y (Var y) ANil) (Var y))"
  apply (simp add: trm_assn.eq_iff Abs_eq_iff )
  apply (rule_tac x="(x \<leftrightarrow> y)" in exI)
  apply (simp_all add: alphas atom_eqvt supp_at_base fresh_star_def trm_assn.bn_defs trm_assn.supp)
  done

lemma lets_ok3:
  "x \<noteq> y \<Longrightarrow>
   (Let (ACons x (App (Var y) (Var x)) (ACons y (Var y) ANil)) (App (Var x) (Var y))) \<noteq>
   (Let (ACons y (App (Var x) (Var y)) (ACons x (Var x) ANil)) (App (Var x) (Var y)))"
  apply (simp add: trm_assn.eq_iff)
  done

lemma lets_not_ok1:
  "x \<noteq> y \<Longrightarrow>
   (Let (ACons x (Var x) (ACons y (Var y) ANil)) (App (Var x) (Var y))) \<noteq>
   (Let (ACons y (Var x) (ACons x (Var y) ANil)) (App (Var x) (Var y)))"
  apply (simp add: alphas trm_assn.eq_iff trm_assn.supp fresh_star_def atom_eqvt Abs_eq_iff trm_assn.bn_defs)
  done

lemma lets_nok:
  "x \<noteq> y \<Longrightarrow> x \<noteq> z \<Longrightarrow> z \<noteq> y \<Longrightarrow>
   (Let (ACons x (App (Var z) (Var z)) (ACons y (Var z) ANil)) (App (Var x) (Var y))) \<noteq>
   (Let (ACons y (Var z) (ACons x (App (Var z) (Var z)) ANil)) (App (Var x) (Var y)))"
  apply (simp add: alphas trm_assn.eq_iff fresh_star_def trm_assn.bn_defs Abs_eq_iff trm_assn.supp trm_assn.distinct)
  done

lemma
  fixes a b c :: name
  assumes x: "a \<noteq> c" and y: "b \<noteq> c"
  shows "\<exists>p.([atom a], Var c) \<approx>lst (op =) supp p ([atom b], Var c)"
  apply (rule_tac x="(a \<leftrightarrow> b)" in exI)
  apply (simp add: alphas trm_assn.supp supp_at_base x y fresh_star_def atom_eqvt)
  by (metis Rep_name_inverse atom_name_def flip_fresh_fresh fresh_atom fresh_perm x y)

end


(*
 * Copyright 2014, NICTA
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(NICTA_BSD)
 *)

(* Author: Thomas Sewell

  Instance of words in the enumeration class.
*)

chapter "Enumeration instances for Words"

theory WordEnum
imports Enumeration WordLib
begin

instantiation word :: (len) enum
begin

definition
  "(enum_class.enum :: ('a :: len) word list) \<equiv> map of_nat [0 ..< 2 ^ len_of TYPE('a)]"

definition
  "enum_class.enum_all (P :: ('a :: len) word \<Rightarrow> bool) \<longleftrightarrow> Ball UNIV P"

definition
  "enum_class.enum_ex (P :: ('a :: len) word \<Rightarrow> bool) \<longleftrightarrow> Bex UNIV P"

instance
  apply (intro_classes)
     apply (simp add: enum_word_def)
     apply force
    apply (simp add: distinct_map enum_word_def)
    apply (rule subset_inj_on, rule word_unat.Abs_inj_on)
    apply (clarsimp simp add: unats_def)
   apply (simp add: enum_all_word_def)
  apply (simp add: enum_ex_word_def)
  done

end

lemma fromEnum_unat[simp]: "fromEnum (x :: ('a :: len) word) = unat x"
  apply (subgoal_tac "x \<in> set enum")
   defer
   apply simp
  apply (unfold fromEnum_def enum_word_def)
  apply (subgoal_tac "ALL n. n < 2 ^ len_of TYPE('a) --> (map of_nat [0..< 2 ^ len_of TYPE('a)] ! n) = x --> n = unat x")
   apply (subgoal_tac "(map of_nat [0..< 2 ^ len_of TYPE('a)]) ! (the_index (map of_nat [0..< 2 ^ len_of TYPE('a)]) x) = x")
    apply (subgoal_tac "the_index (map of_nat [0..< 2 ^ len_of TYPE('a)]) x < 2 ^ len_of TYPE('a)")
     apply simp
    apply (subgoal_tac "the_index (map of_nat [0..< 2 ^ len_of TYPE('a)]) x < length (map of_nat [0..< 2 ^ len_of TYPE('a)])")
     apply simp
    apply (rule the_index_bounded)
    apply (simp add: enum_word_def)
   apply (rule nth_the_index)
   apply (simp add: enum_word_def)
  apply safe
  apply (simp add: unat_of_nat)
  done

lemma length_word_enum: "length (enum :: ('a :: len) word list) = 2 ^ len_of TYPE('a)"
  apply (simp add: enum_word_def)
  done

lemma toEnum_of_nat[simp]: "n < 2 ^ len_of TYPE('a) \<Longrightarrow> ((toEnum n) :: ('a :: len) word) = of_nat n"
  apply (subst toEnum_def)
  apply (simp add: length_word_enum)
  apply (subst enum_word_def)
  apply simp
  done

declare of_nat_diff [simp]
declare word_pow_0 [simp]

lemma "(maxBound :: ('a :: len) word) = -1"
  apply (unfold maxBound_def enum_word_def)
  apply (subst last_map)
   apply simp
  apply simp
  done

lemma "(minBound :: ('a :: len) word) = 0"
  apply (unfold minBound_def enum_word_def)
  apply (simp add: hd_conv_nth)
  done

instantiation word :: (len) enumeration_both
begin

definition
  enum_alt_word_def: "enum_alt \<equiv> alt_from_ord (enum :: ('a :: len) word list)"

instance
  by (intro_classes, simp add: enum_alt_word_def)

end

definition
  upto_enum_step :: "word32 \<Rightarrow> word32 \<Rightarrow> word32 \<Rightarrow> word32 list" ("[_ , _ .e. _]")
where
  "upto_enum_step a b c \<equiv>
      if c < a then [] else map (\<lambda>x. a + x * (b - a)) [0 .e. (c - a) div (b - a)]"
  (* in the wraparound case, bad things happen. *)

end