(*<*)

(* Author: Kyndylan Nienhuis *)

theory ExceptionFlag

imports
  "CHERI-core.CheriLemmas"
begin

(*>*)
section \<open>Invariance of @{const getExceptionSignalled}\<close>

named_theorems ExceptionSignalledI

lemma ExceptionSignalled_to_HoareTriple:
  fixes m :: "state \<Rightarrow> 'a \<times> state"
  assumes "\<And>s. getExceptionSignalled (StatePart m s) = True"
  shows "HoareTriple (return True) m (\<lambda>_. read_state getExceptionSignalled)"
using assms
by - HoareTriple

lemmas nonExceptionCase_exceptions =
  ExceptionSignalled_to_HoareTriple[OF setSignalException_getExceptionSignalled]
  ExceptionSignalled_to_HoareTriple[OF setSignalCP2UnusableException_getExceptionSignalled]
  ExceptionSignalled_to_HoareTriple[OF setSignalCapException_internal_getExceptionSignalled]
  ExceptionSignalled_to_HoareTriple[OF setSignalCapException_getExceptionSignalled]
  ExceptionSignalled_to_HoareTriple[OF setSignalCapException_noReg_getExceptionSignalled]
  ExceptionSignalled_to_HoareTriple[OF setSignalTLBException_getExceptionSignalled]
  ExceptionSignalled_to_HoareTriple[OF setSignalTLBCapException_getExceptionSignalled]

(* Code generation - start - ExceptionSignalled invariant *)

lemma ExceptionSignalled_raise'exception [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (raise'exception v)"
unfolding raise'exception_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_PIC_update [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (PIC_update v)"
unfolding PIC_update_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_PIC_initialise [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (PIC_initialise v)"
unfolding PIC_initialise_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_PIC_load [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (PIC_load v)"
unfolding PIC_load_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_PIC_store [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (PIC_store v)"
unfolding PIC_store_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_JTAG_UART_update_interrupt_bit [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (JTAG_UART_update_interrupt_bit v)"
unfolding JTAG_UART_update_interrupt_bit_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_JTAG_UART_load [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) JTAG_UART_load"
unfolding JTAG_UART_load_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_JTAG_UART_input [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (JTAG_UART_input v)"
unfolding JTAG_UART_input_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_JTAG_UART_store [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (JTAG_UART_store v)"
unfolding JTAG_UART_store_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_JTAG_UART_output [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) JTAG_UART_output"
unfolding JTAG_UART_output_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_JTAG_UART_initialise [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (JTAG_UART_initialise v)"
unfolding JTAG_UART_initialise_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_gpr [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (gpr v)"
unfolding gpr_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'gpr [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'gpr v)"
unfolding write'gpr_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_GPR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (GPR v)"
unfolding GPR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'GPR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'GPR v)"
unfolding write'GPR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_UserMode [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) UserMode"
unfolding UserMode_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_SupervisorMode [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) SupervisorMode"
unfolding SupervisorMode_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_KernelMode [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) KernelMode"
unfolding KernelMode_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_BigEndianMem [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) BigEndianMem"
unfolding BigEndianMem_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_ReverseEndian [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) ReverseEndian"
unfolding ReverseEndian_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_BigEndianCPU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) BigEndianCPU"
unfolding BigEndianCPU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_CheckBranch [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) CheckBranch"
unfolding CheckBranch_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_BranchNotTaken [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) BranchNotTaken"
unfolding BranchNotTaken_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_BranchLikelyNotTaken [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) BranchLikelyNotTaken"
unfolding BranchLikelyNotTaken_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_initCoreStats [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) initCoreStats"
unfolding initCoreStats_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_printCoreStats [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) printCoreStats"
unfolding printCoreStats_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_next_unknown [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (next_unknown v)"
unfolding next_unknown_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_PCC [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) PCC"
unfolding PCC_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'PCC [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'PCC v)"
unfolding write'PCC_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_CAPR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (CAPR v)"
unfolding CAPR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'CAPR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'CAPR v)"
unfolding write'CAPR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_SCAPR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (SCAPR v)"
unfolding SCAPR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'SCAPR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'SCAPR v)"
unfolding write'SCAPR_alt_def
by (Invariant intro: ExceptionSignalledI)

(* Code generation - override - SignalException *)

lemma ExceptionSignalled_SignalException [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (SignalException v)"
unfolding SignalException_alt_def
by (HoareTriple intro: ExceptionSignalledI)

(* Code generation - end override *)

lemma ExceptionSignalled_SignalCP2UnusableException [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) SignalCP2UnusableException"
unfolding SignalCP2UnusableException_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_SignalCapException_internal [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (SignalCapException_internal v)"
unfolding SignalCapException_internal_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_SignalCapException [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (SignalCapException v)"
unfolding SignalCapException_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_SignalCapException_noReg [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (SignalCapException_noReg v)"
unfolding SignalCapException_noReg_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ERET [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'ERET"
unfolding dfn'ERET_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_TLB_direct [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (TLB_direct v)"
unfolding TLB_direct_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'TLB_direct [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'TLB_direct v)"
unfolding write'TLB_direct_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_TLB_assoc [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (TLB_assoc v)"
unfolding TLB_assoc_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'TLB_assoc [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'TLB_assoc v)"
unfolding write'TLB_assoc_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_LookupTLB [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (LookupTLB v)"
unfolding LookupTLB_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_SignalTLBException_internal [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (SignalTLBException_internal v)"
unfolding SignalTLBException_internal_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_SignalTLBException [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (SignalTLBException v)"
unfolding SignalTLBException_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_CheckSegment [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (CheckSegment v)"
unfolding CheckSegment_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_check_cca [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (check_cca v)"
unfolding check_cca_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_TLB_next_random [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (TLB_next_random v)"
unfolding TLB_next_random_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_AddressTranslation [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (AddressTranslation v)"
unfolding AddressTranslation_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_CP0TLBEntry [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (CP0TLBEntry v)"
unfolding CP0TLBEntry_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_SignalTLBCapException [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (SignalTLBCapException v)"
unfolding SignalTLBCapException_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_printMemStats [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) printMemStats"
unfolding printMemStats_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_initMemStats [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) initMemStats"
unfolding initMemStats_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_stats_data_reads_updt [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (stats_data_reads_updt v)"
unfolding stats_data_reads_updt_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_stats_data_writes_updt [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (stats_data_writes_updt v)"
unfolding stats_data_writes_updt_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_stats_inst_reads_updt [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (stats_inst_reads_updt v)"
unfolding stats_inst_reads_updt_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_stats_valid_cap_reads_updt [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (stats_valid_cap_reads_updt v)"
unfolding stats_valid_cap_reads_updt_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_stats_valid_cap_writes_updt [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (stats_valid_cap_writes_updt v)"
unfolding stats_valid_cap_writes_updt_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_stats_invalid_cap_reads_updt [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (stats_invalid_cap_reads_updt v)"
unfolding stats_invalid_cap_reads_updt_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_stats_invalid_cap_writes_updt [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (stats_invalid_cap_writes_updt v)"
unfolding stats_invalid_cap_writes_updt_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_MEM [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (MEM v)"
unfolding MEM_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'MEM [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'MEM v)"
unfolding write'MEM_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_InitMEM [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) InitMEM"
unfolding InitMEM_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_ReadData [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (ReadData v)"
unfolding ReadData_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_WriteData [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (WriteData v)"
unfolding WriteData_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_ReadInst [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (ReadInst v)"
unfolding ReadInst_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_ReadCap [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (ReadCap v)"
unfolding ReadCap_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_WriteCap [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (WriteCap v)"
unfolding WriteCap_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_AdjustEndian [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (AdjustEndian v)"
unfolding AdjustEndian_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_initMemAccessStats [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) initMemAccessStats"
unfolding initMemAccessStats_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_printMemAccessStats [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) printMemAccessStats"
unfolding printMemAccessStats_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_getVirtualAddress [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (getVirtualAddress v)"
unfolding getVirtualAddress_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_LoadMemoryCap [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (LoadMemoryCap v)"
unfolding LoadMemoryCap_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_LoadMemory [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (LoadMemory v)"
unfolding LoadMemory_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_LoadCap [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (LoadCap v)"
unfolding LoadCap_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_StoreMemoryCap [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (StoreMemoryCap v)"
unfolding StoreMemoryCap_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_StoreMemory [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (StoreMemory v)"
unfolding StoreMemory_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_StoreCap [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (StoreCap v)"
unfolding StoreCap_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_Fetch [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) Fetch"
unfolding Fetch_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_CP0R [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (CP0R v)"
unfolding CP0R_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'CP0R [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'CP0R v)"
unfolding write'CP0R_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_resetStats [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) resetStats"
unfolding resetStats_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_HI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) HI"
unfolding HI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'HI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'HI v)"
unfolding write'HI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_LO [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) LO"
unfolding LO_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_write'LO [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (write'LO v)"
unfolding write'LO_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_mtc [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (mtc v)"
unfolding mtc_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dmtc [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dmtc v)"
unfolding dmtc_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_mfc [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (mfc v)"
unfolding mfc_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dmfc [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dmfc v)"
unfolding dmfc_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ADDI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'ADDI v)"
unfolding dfn'ADDI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ADDIU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'ADDIU v)"
unfolding dfn'ADDIU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DADDI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DADDI v)"
unfolding dfn'DADDI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DADDIU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DADDIU v)"
unfolding dfn'DADDIU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SLTI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SLTI v)"
unfolding dfn'SLTI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SLTIU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SLTIU v)"
unfolding dfn'SLTIU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ANDI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'ANDI v)"
unfolding dfn'ANDI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ORI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'ORI v)"
unfolding dfn'ORI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'XORI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'XORI v)"
unfolding dfn'XORI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LUI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LUI v)"
unfolding dfn'LUI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ADD [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'ADD v)"
unfolding dfn'ADD_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ADDU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'ADDU v)"
unfolding dfn'ADDU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SUB [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SUB v)"
unfolding dfn'SUB_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SUBU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SUBU v)"
unfolding dfn'SUBU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DADD [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DADD v)"
unfolding dfn'DADD_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DADDU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DADDU v)"
unfolding dfn'DADDU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSUB [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSUB v)"
unfolding dfn'DSUB_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSUBU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSUBU v)"
unfolding dfn'DSUBU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SLT [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SLT v)"
unfolding dfn'SLT_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SLTU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SLTU v)"
unfolding dfn'SLTU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'AND [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'AND v)"
unfolding dfn'AND_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'OR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'OR v)"
unfolding dfn'OR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'XOR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'XOR v)"
unfolding dfn'XOR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'NOR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'NOR v)"
unfolding dfn'NOR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MOVN [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MOVN v)"
unfolding dfn'MOVN_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MOVZ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MOVZ v)"
unfolding dfn'MOVZ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MADD [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MADD v)"
unfolding dfn'MADD_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MADDU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MADDU v)"
unfolding dfn'MADDU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MSUB [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MSUB v)"
unfolding dfn'MSUB_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MSUBU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MSUBU v)"
unfolding dfn'MSUBU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MUL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MUL v)"
unfolding dfn'MUL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MULT [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MULT v)"
unfolding dfn'MULT_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MULTU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MULTU v)"
unfolding dfn'MULTU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DMULT [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DMULT v)"
unfolding dfn'DMULT_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DMULTU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DMULTU v)"
unfolding dfn'DMULTU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DIV [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DIV v)"
unfolding dfn'DIV_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DIVU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DIVU v)"
unfolding dfn'DIVU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DDIV [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DDIV v)"
unfolding dfn'DDIV_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DDIVU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DDIVU v)"
unfolding dfn'DDIVU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MFHI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MFHI v)"
unfolding dfn'MFHI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MFLO [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MFLO v)"
unfolding dfn'MFLO_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MTHI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MTHI v)"
unfolding dfn'MTHI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MTLO [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MTLO v)"
unfolding dfn'MTLO_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SLL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SLL v)"
unfolding dfn'SLL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SRL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SRL v)"
unfolding dfn'SRL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SRA [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SRA v)"
unfolding dfn'SRA_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SLLV [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SLLV v)"
unfolding dfn'SLLV_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SRLV [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SRLV v)"
unfolding dfn'SRLV_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SRAV [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SRAV v)"
unfolding dfn'SRAV_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSLL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSLL v)"
unfolding dfn'DSLL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSRL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSRL v)"
unfolding dfn'DSRL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSRA [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSRA v)"
unfolding dfn'DSRA_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSLLV [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSLLV v)"
unfolding dfn'DSLLV_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSRLV [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSRLV v)"
unfolding dfn'DSRLV_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSRAV [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSRAV v)"
unfolding dfn'DSRAV_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSLL32 [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSLL32 v)"
unfolding dfn'DSLL32_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSRL32 [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSRL32 v)"
unfolding dfn'DSRL32_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DSRA32 [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DSRA32 v)"
unfolding dfn'DSRA32_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TGE [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TGE v)"
unfolding dfn'TGE_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TGEU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TGEU v)"
unfolding dfn'TGEU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TLT [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TLT v)"
unfolding dfn'TLT_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TLTU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TLTU v)"
unfolding dfn'TLTU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TEQ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TEQ v)"
unfolding dfn'TEQ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TNE [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TNE v)"
unfolding dfn'TNE_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TGEI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TGEI v)"
unfolding dfn'TGEI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TGEIU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TGEIU v)"
unfolding dfn'TGEIU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TLTI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TLTI v)"
unfolding dfn'TLTI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TLTIU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TLTIU v)"
unfolding dfn'TLTIU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TEQI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TEQI v)"
unfolding dfn'TEQI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TNEI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'TNEI v)"
unfolding dfn'TNEI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_loadByte [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (loadByte v)"
unfolding loadByte_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_loadHalf [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (loadHalf v)"
unfolding loadHalf_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_loadWord [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (loadWord v)"
unfolding loadWord_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_loadDoubleword [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (loadDoubleword v)"
unfolding loadDoubleword_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LB [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LB v)"
unfolding dfn'LB_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LBU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LBU v)"
unfolding dfn'LBU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LH [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LH v)"
unfolding dfn'LH_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LHU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LHU v)"
unfolding dfn'LHU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LW [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LW v)"
unfolding dfn'LW_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LWU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LWU v)"
unfolding dfn'LWU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LL v)"
unfolding dfn'LL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LD [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LD v)"
unfolding dfn'LD_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LLD [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LLD v)"
unfolding dfn'LLD_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LWL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LWL v)"
unfolding dfn'LWL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LWR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LWR v)"
unfolding dfn'LWR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LDL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LDL v)"
unfolding dfn'LDL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'LDR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'LDR v)"
unfolding dfn'LDR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SB [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SB v)"
unfolding dfn'SB_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SH [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SH v)"
unfolding dfn'SH_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_storeWord [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (storeWord v)"
unfolding storeWord_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_storeDoubleword [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (storeDoubleword v)"
unfolding storeDoubleword_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SW [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SW v)"
unfolding dfn'SW_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SD [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SD v)"
unfolding dfn'SD_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SC [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SC v)"
unfolding dfn'SC_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SCD [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SCD v)"
unfolding dfn'SCD_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SWL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SWL v)"
unfolding dfn'SWL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SWR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SWR v)"
unfolding dfn'SWR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SDL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SDL v)"
unfolding dfn'SDL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SDR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'SDR v)"
unfolding dfn'SDR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BREAK [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'BREAK"
unfolding dfn'BREAK_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'SYSCALL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'SYSCALL"
unfolding dfn'SYSCALL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MTC0 [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MTC0 v)"
unfolding dfn'MTC0_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DMTC0 [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DMTC0 v)"
unfolding dfn'DMTC0_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'MFC0 [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'MFC0 v)"
unfolding dfn'MFC0_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'DMFC0 [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'DMFC0 v)"
unfolding dfn'DMFC0_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'J [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'J v)"
unfolding dfn'J_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'JAL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'JAL v)"
unfolding dfn'JAL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'JALR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'JALR v)"
unfolding dfn'JALR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'JR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'JR v)"
unfolding dfn'JR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BEQ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BEQ v)"
unfolding dfn'BEQ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BNE [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BNE v)"
unfolding dfn'BNE_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BLEZ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BLEZ v)"
unfolding dfn'BLEZ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BGTZ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BGTZ v)"
unfolding dfn'BGTZ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BLTZ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BLTZ v)"
unfolding dfn'BLTZ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BGEZ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BGEZ v)"
unfolding dfn'BGEZ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BLTZAL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BLTZAL v)"
unfolding dfn'BLTZAL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BGEZAL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BGEZAL v)"
unfolding dfn'BGEZAL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BEQL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BEQL v)"
unfolding dfn'BEQL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BNEL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BNEL v)"
unfolding dfn'BNEL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BLEZL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BLEZL v)"
unfolding dfn'BLEZL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BGTZL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BGTZL v)"
unfolding dfn'BGTZL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BLTZL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BLTZL v)"
unfolding dfn'BLTZL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BGEZL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BGEZL v)"
unfolding dfn'BGEZL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BLTZALL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BLTZALL v)"
unfolding dfn'BLTZALL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'BGEZALL [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'BGEZALL v)"
unfolding dfn'BGEZALL_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'RDHWR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'RDHWR v)"
unfolding dfn'RDHWR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CACHE [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CACHE v)"
unfolding dfn'CACHE_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ReservedInstruction [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'ReservedInstruction"
unfolding dfn'ReservedInstruction_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'Unpredictable [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'Unpredictable"
unfolding dfn'Unpredictable_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TLBP [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'TLBP"
unfolding dfn'TLBP_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TLBR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'TLBR"
unfolding dfn'TLBR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TLBWI [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'TLBWI"
unfolding dfn'TLBWI_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'TLBWR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'TLBWR"
unfolding dfn'TLBWR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'COP1 [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'COP1 v)"
unfolding dfn'COP1_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetBase [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetBase v)"
unfolding dfn'CGetBase_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetOffset [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetOffset v)"
unfolding dfn'CGetOffset_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetLen [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetLen v)"
unfolding dfn'CGetLen_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetTag [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetTag v)"
unfolding dfn'CGetTag_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetSealed [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetSealed v)"
unfolding dfn'CGetSealed_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetPerm [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetPerm v)"
unfolding dfn'CGetPerm_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetType [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetType v)"
unfolding dfn'CGetType_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetAddr [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetAddr v)"
unfolding dfn'CGetAddr_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetPCC [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetPCC v)"
unfolding dfn'CGetPCC_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetPCCSetOffset [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetPCCSetOffset v)"
unfolding dfn'CGetPCCSetOffset_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CGetCause [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CGetCause v)"
unfolding dfn'CGetCause_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSetCause [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSetCause v)"
unfolding dfn'CSetCause_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CIncOffset [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CIncOffset v)"
unfolding dfn'CIncOffset_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CIncOffsetImmediate [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CIncOffsetImmediate v)"
unfolding dfn'CIncOffsetImmediate_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSetBounds [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSetBounds v)"
unfolding dfn'CSetBounds_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSetBoundsExact [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSetBoundsExact v)"
unfolding dfn'CSetBoundsExact_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSetBoundsImmediate [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSetBoundsImmediate v)"
unfolding dfn'CSetBoundsImmediate_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_ClearRegs [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (ClearRegs v)"
unfolding ClearRegs_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ClearLo [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'ClearLo v)"
unfolding dfn'ClearLo_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'ClearHi [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'ClearHi v)"
unfolding dfn'ClearHi_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CClearLo [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CClearLo v)"
unfolding dfn'CClearLo_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CClearHi [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CClearHi v)"
unfolding dfn'CClearHi_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CClearTag [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CClearTag v)"
unfolding dfn'CClearTag_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CAndPerm [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CAndPerm v)"
unfolding dfn'CAndPerm_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSetOffset [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSetOffset v)"
unfolding dfn'CSetOffset_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSub [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSub v)"
unfolding dfn'CSub_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CCheckPerm [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CCheckPerm v)"
unfolding dfn'CCheckPerm_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CCheckType [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CCheckType v)"
unfolding dfn'CCheckType_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CFromPtr [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CFromPtr v)"
unfolding dfn'CFromPtr_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CToPtr [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CToPtr v)"
unfolding dfn'CToPtr_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_CPtrCmp [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (CPtrCmp v)"
unfolding CPtrCmp_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CEQ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CEQ v)"
unfolding dfn'CEQ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CNE [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CNE v)"
unfolding dfn'CNE_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CLT [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CLT v)"
unfolding dfn'CLT_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CLE [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CLE v)"
unfolding dfn'CLE_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CLTU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CLTU v)"
unfolding dfn'CLTU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CLEU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CLEU v)"
unfolding dfn'CLEU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CEXEQ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CEXEQ v)"
unfolding dfn'CEXEQ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CNEXEQ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CNEXEQ v)"
unfolding dfn'CNEXEQ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CBTU [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CBTU v)"
unfolding dfn'CBTU_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CBTS [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CBTS v)"
unfolding dfn'CBTS_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CBEZ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CBEZ v)"
unfolding dfn'CBEZ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CBNZ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CBNZ v)"
unfolding dfn'CBNZ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSC [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSC v)"
unfolding dfn'CSC_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CLC [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CLC v)"
unfolding dfn'CLC_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CLoad [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CLoad v)"
unfolding dfn'CLoad_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_store [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (store v)"
unfolding store_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CStore [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CStore v)"
unfolding dfn'CStore_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CLLC [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CLLC v)"
unfolding dfn'CLLC_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CLLx [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CLLx v)"
unfolding dfn'CLLx_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSCC [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSCC v)"
unfolding dfn'CSCC_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSCx [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSCx v)"
unfolding dfn'CSCx_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CMOVN [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CMOVN v)"
unfolding dfn'CMOVN_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CMOVZ [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CMOVZ v)"
unfolding dfn'CMOVZ_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CMove [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CMove v)"
unfolding dfn'CMove_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CTestSubset [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CTestSubset v)"
unfolding dfn'CTestSubset_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CBuildCap [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CBuildCap v)"
unfolding dfn'CBuildCap_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CCopyType [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CCopyType v)"
unfolding dfn'CCopyType_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CJR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CJR v)"
unfolding dfn'CJR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CJALR [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CJALR v)"
unfolding dfn'CJALR_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CSeal [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CSeal v)"
unfolding dfn'CSeal_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CUnseal [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CUnseal v)"
unfolding dfn'CUnseal_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CCall [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CCall v)"
unfolding dfn'CCall_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CCallFast [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CCallFast v)"
unfolding dfn'CCallFast_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_special_register_accessible [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (special_register_accessible v)"
unfolding special_register_accessible_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CReadHwr [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CReadHwr v)"
unfolding dfn'CReadHwr_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CWriteHwr [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (dfn'CWriteHwr v)"
unfolding dfn'CWriteHwr_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'CReturn [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'CReturn"
unfolding dfn'CReturn_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_dfn'UnknownCapInstruction [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) dfn'UnknownCapInstruction"
unfolding dfn'UnknownCapInstruction_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_log_instruction [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (log_instruction v)"
unfolding log_instruction_alt_def
by (Invariant intro: ExceptionSignalledI)

lemma ExceptionSignalled_Run [ExceptionSignalledI]:
  shows "IsInvariant (read_state getExceptionSignalled) (Run v)"
unfolding Run_alt_def
by (Invariant intro: ExceptionSignalledI)

(* Code generation - skip - Next *)

(* Code generation - end *)

(*<*)
end
(*>*)


theory No_Spoof_Embeddings
imports Semantics_Embeddings
        "Primitive_Matchers/No_Spoof"
begin

section\<open>Spoofing protection in Ternary Semantics implies Spoofing protection Boolean Semantics\<close>
text\<open>If @{const no_spoofing} is shown in the ternary semantics, it implies that no spoofing
        is possible in the Boolean semantics with magic oracle.
        We only assume that the oracle agrees with the @{const common_matcher} on the not-unknown parts.\<close>
  lemma approximating_imp_booloan_semantics_nospoofing:
      assumes "matcher_agree_on_exact_matches \<gamma> common_matcher"
      and "simple_ruleset rs"
      and no_spoofing: "no_spoofing TYPE('pkt_ext) ipassmt rs"
      shows "\<forall> iface \<in> dom ipassmt. \<forall>p::('i::len,'pkt_ext) tagged_packet_scheme.
                (\<Gamma>,\<gamma>,p\<lparr>p_iiface:=iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow) \<longrightarrow>
                    p_src p \<in> (ipcidr_union_set (set (the (ipassmt iface))))"
      unfolding no_spoofing_def
      proof(intro ballI allI impI)
        fix iface p
        assume i: "iface \<in> dom ipassmt"
           and a: "\<Gamma>,\<gamma>,p\<lparr>p_iiface := iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow"

        from no_spoofing[unfolded no_spoofing_def] i have no_spoofing':
          "(common_matcher, in_doubt_allow),p\<lparr>p_iiface := iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow \<longrightarrow>
           p_src p \<in> ipcidr_union_set (set (the (ipassmt iface)))" by blast

        from assms simple_imp_good_ruleset FinalAllows_subseteq_in_doubt_allow[where rs=rs] have
          "{p. \<Gamma>,\<gamma>,p\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow} \<subseteq> {p. (common_matcher, in_doubt_allow),p\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow}"
          by blast
        with a have "(common_matcher, in_doubt_allow),p\<lparr>p_iiface := iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow" by blast
        with no_spoofing' show "p_src p \<in> ipcidr_union_set (set (the (ipassmt iface)))"by blast
      qed

 (*expressed as set*)
  corollary
      assumes "matcher_agree_on_exact_matches \<gamma> common_matcher" and "simple_ruleset rs"
          and no_spoofing: "no_spoofing TYPE('pkt_ext) ipassmt rs" and "iface \<in> dom ipassmt"
      shows "{p_src p | p :: ('i::len,'pkt_ext) tagged_packet_scheme. (\<Gamma>,\<gamma>,p\<lparr>p_iiface:=iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow)} \<subseteq>
                 ipcidr_union_set (set (the (ipassmt iface)))"
      using approximating_imp_booloan_semantics_nospoofing[OF assms(1) assms(2) assms(3), where \<Gamma>=\<Gamma>]
      using assms(4) by blast

 (*expressed as set*)
  corollary no_spoofing_executable_set:
      assumes "matcher_agree_on_exact_matches \<gamma> common_matcher"
          and "simple_ruleset rs"
          and "\<forall>r\<in>set rs. normalized_nnf_match (get_match r)"
          and no_spoofing_executable: "\<forall>iface \<in> dom ipassmt. no_spoofing_iface iface ipassmt rs"
          and "iface \<in> dom ipassmt"
      shows "{p_src p | p :: ('i::len,'pkt_ext) tagged_packet_scheme. (\<Gamma>,\<gamma>,p\<lparr>p_iiface:=iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow)} \<subseteq>
                 ipcidr_union_set (set (the (ipassmt iface)))"
  proof -
    { assume no_spoofing: "no_spoofing TYPE('pkt_ext) ipassmt rs"
      have "{p_src p | p :: ('i,'pkt_ext) tagged_packet_scheme. (\<Gamma>,\<gamma>,p\<lparr>p_iiface:=iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow)} \<subseteq>
                 ipcidr_union_set (set (the (ipassmt iface)))"
      using approximating_imp_booloan_semantics_nospoofing[OF assms(1) assms(2) no_spoofing, where \<Gamma>=\<Gamma>]
      using assms(5) by blast
    }
    with no_spoofing_iface[OF assms(2) assms(3) no_spoofing_executable] show ?thesis by blast
  qed

  corollary no_spoofing_executable_set_preprocessed:
      fixes ipassmt :: "'i::len ipassignment"
      defines "preprocess rs \<equiv> upper_closure (packet_assume_new rs)"
          and "newpkt p \<equiv> match_tcp_flags ipt_tcp_syn (p_tcp_flags p) \<and> p_tag_ctstate p = CT_New"
      assumes "matcher_agree_on_exact_matches \<gamma> common_matcher"
          and simplers: "simple_ruleset rs"
          and no_spoofing_executable: "\<forall>iface \<in> dom ipassmt. no_spoofing_iface iface ipassmt (preprocess rs)"
          and "iface \<in> dom ipassmt"
      shows "{p_src p | p :: ('i::len,'pkt_ext) tagged_packet_scheme. newpkt p \<and> \<Gamma>,\<gamma>,p\<lparr>p_iiface:=iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow} \<subseteq>
                 ipcidr_union_set (set (the (ipassmt iface)))"
  proof -
   have newpktD: "newpkt p \<Longrightarrow> newpkt (p\<lparr>p_iiface := iface_sel iface\<rparr>)" for p
     by(simp add: newpkt_def)
   from packet_assume_new_simple_ruleset[OF simplers] have s1: "simple_ruleset (packet_assume_new rs)" .
   from transform_upper_closure(2)[OF s1] have s2: "simple_ruleset (upper_closure (packet_assume_new rs))" .
   hence s2': "simple_ruleset (preprocess rs)" unfolding preprocess_def by simp
   have "\<forall>r\<in>set (preprocess rs). normalized_nnf_match (get_match r)"
     unfolding preprocess_def
     using transform_upper_closure(3)[OF s1] by simp

   from no_spoofing_iface[OF s2' this no_spoofing_executable] have nospoof: "no_spoofing TYPE('a) ipassmt (preprocess rs)" .

   from assms(3) have 1: "{p. \<Gamma>,\<gamma>,p\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow \<and> newpkt p} \<subseteq>
                       {p. (common_matcher, in_doubt_allow),p\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow \<and> newpkt p}"
    apply(drule_tac rs=rs and \<Gamma>=\<Gamma> in FinalAllows_subseteq_in_doubt_allow)
     using simple_imp_good_ruleset assms(4) apply blast
    by blast
   have 2: "{p. (common_matcher, in_doubt_allow),p\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow \<and> newpkt p} \<subseteq>
         {p. (common_matcher, in_doubt_allow),p\<turnstile> \<langle>preprocess rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow \<and> newpkt p}"
     unfolding newpkt_def preprocess_def
     apply(subst transform_upper_closure(1)[OF s1])
     apply(subst approximating_semantics_iff_fun_good_ruleset[OF simple_imp_good_ruleset[OF s1]])
     apply(subst approximating_semantics_iff_fun_good_ruleset[OF simple_imp_good_ruleset[OF simplers]])
     using packet_assume_new newpkt_def by force
   from 1 2 have "{p. \<Gamma>,\<gamma>,p\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow \<and> newpkt p} \<subseteq>
         {p. (common_matcher, in_doubt_allow),p\<turnstile> \<langle>preprocess rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow \<and> newpkt p}" by simp
   hence p: "\<Gamma>,\<gamma>,p\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow \<and> newpkt p \<Longrightarrow>
           (common_matcher, in_doubt_allow),p\<turnstile> \<langle>preprocess rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow \<and> newpkt p" for p by blast
   have x: "{p_src p | p . newpkt p \<and> (\<Gamma>,\<gamma>,p\<lparr>p_iiface:=iface_sel iface\<rparr>\<turnstile> \<langle>rs, Undecided\<rangle> \<Rightarrow> Decision FinalAllow)} \<subseteq>
            {p_src p | p . newpkt p \<and> (common_matcher, in_doubt_allow),p\<lparr>p_iiface:=iface_sel iface\<rparr>\<turnstile> \<langle>preprocess rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow}"
     apply(safe, rename_tac p)
     apply(drule newpktD)
     apply(rule_tac x="p\<lparr>p_iiface := iface_sel iface\<rparr>" in exI)
     using p by simp
   note[[show_types]]
   with nospoof have y:
    "{p_src p | p :: ('i::len,'pkt_ext) tagged_packet_scheme. newpkt p \<and> (common_matcher, in_doubt_allow),p\<lparr>p_iiface:=iface_sel iface\<rparr>\<turnstile> \<langle>preprocess rs, Undecided\<rangle> \<Rightarrow>\<^sub>\<alpha> Decision FinalAllow}
    \<subseteq> ipcidr_union_set (set (the (ipassmt iface)))"
    apply(simp add: no_spoofing_def)
    by(blast dest: bspec[OF _ assms(6)])
   from x y show ?thesis by simp
  qed

end


(*  Title:      JinjaThreads/MM/JMM_Type2.thy
    Author:     Andreas Lochbihler
*)

header {* \isaheader{JMM heap implementation 2} *}

theory JMM_Type2
imports
  "../Common/ExternalCallWF"
  "../Common/ConformThreaded"
  JMM_Heap
begin

section {* Definitions *}

datatype addr = Address htype nat   -- "heap type and sequence number"

lemma rec_addr_conv_case_addr [simp]: "rec_addr = case_addr"
by(auto intro!: ext split: addr.split)

instantiation addr :: addr begin
definition "hash_addr (a :: addr) = (case a of Address ht n \<Rightarrow> int n)"
definition "monitor_finfun_to_list (ls :: addr \<Rightarrow>f nat) = (SOME xs. set xs = {x. finfun_dom ls $ x })"
instance
proof
  fix ls :: "addr \<Rightarrow>f nat"
  show "set (monitor_finfun_to_list ls) = Collect (op $ (finfun_dom ls))"
    unfolding monitor_finfun_to_list_addr_def
    using finite_list[OF finite_finfun_dom, where ?f.1 = "ls"]
    by(rule someI_ex)
qed
end

primrec the_Address :: "addr \<Rightarrow> htype \<times> nat"
where "the_Address (Address hT n) = (hT, n)"

text {*
  The JMM heap only stores which sequence numbers of a given @{typ "htype"} have already been allocated.
*}

type_synonym JMM_heap = "htype \<Rightarrow> nat set"

translations (type) "JMM_heap" <= (type) "htype \<Rightarrow> nat set"

definition jmm_allocate :: "JMM_heap \<Rightarrow> htype \<Rightarrow> (JMM_heap \<times> addr) set"
where "jmm_allocate h hT = (let hhT = h hT in (\<lambda>n. (h(hT := insert n hhT), Address hT n)) ` (- hhT))"

abbreviation jmm_empty :: "JMM_heap" where "jmm_empty == (\<lambda>_. {})"

definition jmm_typeof_addr :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr \<rightharpoonup> htype"
where "jmm_typeof_addr P h = (\<lambda>hT. if is_htype P hT then Some hT else None) \<circ> fst \<circ> the_Address"

definition jmm_typeof_addr' :: "'m prog \<Rightarrow> addr \<rightharpoonup> htype"
where "jmm_typeof_addr' P = (\<lambda>hT. if is_htype P hT then Some hT else None) \<circ> fst \<circ> the_Address"

lemma jmm_typeof_addr'_conv_jmm_type_addr: "jmm_typeof_addr' P = jmm_typeof_addr P h"
by(simp add: jmm_typeof_addr_def jmm_typeof_addr'_def)

lemma jmm_typeof_addr'_conv_jmm_typeof_addr: "(\<lambda>_. jmm_typeof_addr' P) = jmm_typeof_addr P"
by(simp add: jmm_typeof_addr_def jmm_typeof_addr'_def fun_eq_iff)

lemma jmm_typeof_addr_conv_jmm_typeof_addr': "jmm_typeof_addr = (\<lambda>P _. jmm_typeof_addr' P)"
by(simp add: jmm_typeof_addr'_conv_jmm_typeof_addr)

definition jmm_heap_read :: "JMM_heap \<Rightarrow> addr \<Rightarrow> addr_loc \<Rightarrow> addr val \<Rightarrow> bool"
where "jmm_heap_read h a ad v = True"

inductive jmm_heap_write :: "JMM_heap \<Rightarrow> addr \<Rightarrow> addr_loc \<Rightarrow> addr val \<Rightarrow> JMM_heap \<Rightarrow> bool"
where "jmm_heap_write h a ad v h"

definition jmm_hconf :: "JMM_heap \<Rightarrow> bool"
where "jmm_hconf h \<longleftrightarrow> True"

definition jmm_allocated :: "JMM_heap \<Rightarrow> addr set"
where "jmm_allocated h = {Address CTn n|CTn n. n \<in> h CTn}"

definition jmm_spurious_wakeups :: "bool"
where "jmm_spurious_wakeups = True"

lemmas jmm_heap_ops_defs =
  jmm_allocate_def jmm_typeof_addr_def
  jmm_heap_read_def jmm_heap_write_def
  jmm_allocated_def jmm_spurious_wakeups_def

type_synonym thread_id = "addr"

abbreviation (input) addr2thread_id :: "addr \<Rightarrow> thread_id"
where "addr2thread_id \<equiv> \<lambda>x. x"

abbreviation (input) thread_id2addr :: "thread_id \<Rightarrow> addr"
where "thread_id2addr \<equiv> \<lambda>x. x"

interpretation jmm!: heap_base
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" jmm_heap_read jmm_heap_write
  for P
.

abbreviation jmm_hext :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> JMM_heap \<Rightarrow> bool" ("_ \<turnstile> _ \<unlhd>jmm _" [51,51,51] 50)
where "jmm_hext \<equiv> jmm.hext TYPE('m)"

abbreviation jmm_conf :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr val \<Rightarrow> ty \<Rightarrow> bool"
  ("_,_ \<turnstile>jmm _ :\<le> _"  [51,51,51,51] 50)
where "jmm_conf P \<equiv> jmm.conf TYPE('m) P P"

abbreviation jmm_addr_loc_type :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr \<Rightarrow> addr_loc \<Rightarrow> ty \<Rightarrow> bool"
  ("_,_ \<turnstile>jmm _@_ : _" [50, 50, 50, 50, 50] 51)
where "jmm_addr_loc_type P \<equiv> jmm.addr_loc_type TYPE('m) P P"

abbreviation jmm_confs :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr val list \<Rightarrow> ty list \<Rightarrow> bool"
  ("_,_ \<turnstile>jmm _ [:\<le>] _"  [51,51,51,51] 50)
where "jmm_confs P \<equiv> jmm.confs TYPE('m) P P"

abbreviation jmm_tconf :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr \<Rightarrow> bool" ("_,_ \<turnstile>jmm _ \<surd>t" [51,51,51] 50)
where "jmm_tconf P \<equiv> jmm.tconf TYPE('m) P P"

interpretation jmm!: allocated_heap_base
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" jmm_heap_read jmm_heap_write
  jmm_allocated
  for P
.

text {* Now a variation of the JMM with a different read operation that permits to read only type-conformant values *}

abbreviation jmm_heap_read_typed :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr \<Rightarrow> addr_loc \<Rightarrow> addr val \<Rightarrow> bool"
where "jmm_heap_read_typed P \<equiv> jmm.heap_read_typed TYPE('m) P P"

interpretation jmm'!: heap_base
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" "jmm_heap_read_typed P" jmm_heap_write
  for P .

abbreviation jmm'_hext :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> JMM_heap \<Rightarrow> bool" ("_ \<turnstile> _ \<unlhd>jmm' _" [51,51,51] 50)
where "jmm'_hext \<equiv> jmm'.hext TYPE('m)"

abbreviation jmm'_conf :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr val \<Rightarrow> ty \<Rightarrow> bool"
  ("_,_ \<turnstile>jmm' _ :\<le> _"  [51,51,51,51] 50)
where "jmm'_conf P \<equiv> jmm'.conf TYPE('m) P P"

abbreviation jmm'_addr_loc_type :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr \<Rightarrow> addr_loc \<Rightarrow> ty \<Rightarrow> bool"
  ("_,_ \<turnstile>jmm' _@_ : _" [50, 50, 50, 50, 50] 51)
where "jmm'_addr_loc_type P \<equiv> jmm'.addr_loc_type TYPE('m) P P"

abbreviation jmm'_confs :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr val list \<Rightarrow> ty list \<Rightarrow> bool"
  ("_,_ \<turnstile>jmm' _ [:\<le>] _"  [51,51,51,51] 50)
where "jmm'_confs P \<equiv> jmm'.confs TYPE('m) P P"

abbreviation jmm'_tconf :: "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr \<Rightarrow> bool" ("_,_ \<turnstile>jmm' _ \<surd>t" [51,51,51] 50)
where "jmm'_tconf P \<equiv> jmm'.tconf TYPE('m) P P"

section {* Heap locale interpretations *}

subsection {* Locale @{text heap} *}

lemma jmm_heap: "heap addr2thread_id thread_id2addr jmm_allocate (jmm_typeof_addr P) jmm_heap_write P"
proof
  fix h' a h hT
  assume "(h', a) \<in> jmm_allocate h hT" "is_htype P hT"
  thus "jmm_typeof_addr P h' a = \<lfloor>hT\<rfloor>"
    by(auto simp add: jmm_heap_ops_defs)
next
  fix h hT h' a
  assume "(h', a) \<in> jmm_allocate h hT"
  thus "P \<turnstile> h \<unlhd>jmm h'" by(auto simp add: jmm_heap_ops_defs intro: jmm.hextI)
next
  fix h a al v h'
  assume "jmm_heap_write h a al v h'"
  thus "P \<turnstile> h \<unlhd>jmm h'" by cases auto
qed simp

interpretation jmm!: heap
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" jmm_heap_read jmm_heap_write
  P
  for P
by(rule jmm_heap)

declare jmm.typeof_addr_thread_id2_addr_addr2thread_id [simp del]

lemmas jmm'_heap = jmm_heap

interpretation jmm'!: heap
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" "jmm_heap_read_typed P" jmm_heap_write
  P
  for P
by(rule jmm'_heap)

declare jmm'.typeof_addr_thread_id2_addr_addr2thread_id [simp del]

lemma jmm_heap_read_typed_default_val:
  "heap_base.heap_read_typed typeof_addr jmm_heap_read P h a al
   (default_val (THE T. heap_base.addr_loc_type typeof_addr P h a al T))"
by(rule heap_base.heap_read_typedI)(simp_all add: heap_base.THE_addr_loc_type jmm_heap_read_def heap_base.defval_conf)

lemma jmm_allocate_Eps:
  "(SOME ha. ha \<in> jmm_allocate h hT) = (h', a')
  \<Longrightarrow> jmm_allocate h hT \<noteq> {} \<longrightarrow> (h', a') \<in> jmm_allocate h hT"
by(auto dest: jmm.allocate_Eps)

lemma jmm_allocate_eq_empty: "jmm_allocate h hT = {} \<longleftrightarrow> h hT = UNIV"
by(auto simp add: jmm_allocate_def)

lemma jmm_allocate_otherD:
  "(h', a) \<in> jmm_allocate h hT \<Longrightarrow> \<forall>hT'. hT' \<noteq> hT \<longrightarrow> h' hT' = h hT'"
by(auto simp add: jmm_allocate_def)

lemma jmm_start_heap_ok: "jmm.start_heap_ok"
apply(simp add: jmm.start_heap_ok_def jmm.start_heap_data_def initialization_list_def sys_xcpts_list_def jmm.create_initial_object_simps)
apply(split prod.split, clarify, clarsimp simp add: jmm.create_initial_object_simps jmm_allocate_eq_empty Thread_neq_sys_xcpts sys_xcpts_neqs dest!: jmm_allocate_Eps jmm_allocate_otherD)+
done

subsection {* Locale @{text "heap_conf"} *}

interpretation jmm!: heap_conf_base
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" jmm_heap_read jmm_heap_write jmm_hconf
  P
  for P .

abbreviation (input) jmm'_hconf :: "JMM_heap \<Rightarrow> bool"
where "jmm'_hconf == jmm_hconf"

interpretation jmm'!: heap_conf_base
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" "jmm_heap_read_typed P" jmm_heap_write jmm'_hconf
  P
  for P .

abbreviation jmm_heap_read_typeable :: "'m prog \<Rightarrow> bool"
where "jmm_heap_read_typeable P \<equiv> jmm.heap_read_typeable TYPE('m) P jmm_hconf P"

abbreviation jmm'_heap_read_typeable :: "'m prog \<Rightarrow> bool"
where "jmm'_heap_read_typeable P \<equiv> jmm'.heap_read_typeable TYPE('m) P jmm_hconf P"

lemma jmm_heap_read_typeable: "jmm_heap_read_typeable P"
by(rule jmm.heap_read_typeableI)(simp add: jmm_heap_read_def)

lemma jmm'_heap_read_typeable: "jmm'_heap_read_typeable P"
by(rule jmm'.heap_read_typeableI)(auto simp add: jmm_heap_read_def jmm.heap_read_typed_def dest: jmm'.addr_loc_type_fun)

lemma jmm_heap_conf:
  "heap_conf addr2thread_id thread_id2addr jmm_empty jmm_allocate (jmm_typeof_addr P) jmm_heap_write jmm_hconf P"
by(unfold_locales)(simp_all add: jmm_hconf_def jmm_heap_ops_defs split: split_if_asm)

interpretation jmm!: heap_conf
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" jmm_heap_read jmm_heap_write jmm_hconf
  P
  for P
by(rule jmm_heap_conf)

lemmas jmm'_heap_conf = jmm_heap_conf

interpretation jmm'!: heap_conf
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" "jmm_heap_read_typed P" jmm_heap_write jmm'_hconf
  P
  for P
by(rule jmm'_heap_conf)

subsection {* Locale @{text heap_progress} *}

lemma jmm_heap_progress:
  "heap_progress addr2thread_id thread_id2addr jmm_empty jmm_allocate (jmm_typeof_addr P) jmm_heap_read jmm_heap_write jmm_hconf P"
proof
  fix h a al T
  assume "jmm_hconf h"
    and al: "P,h \<turnstile>jmm a@al : T"
  show "\<exists>v. jmm_heap_read h a al v \<and> P,h \<turnstile>jmm v :\<le> T"
    using jmm.defval_conf[of P P h T] unfolding jmm_heap_ops_defs by blast
next
  fix h a al T v
  assume "P,h \<turnstile>jmm a@al : T"
  show "\<exists>h'. jmm_heap_write h a al v h'"
    by(auto intro: jmm_heap_write.intros)
qed

interpretation jmm!: heap_progress
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" jmm_heap_read jmm_heap_write jmm_hconf
  P
  for P
by(rule jmm_heap_progress)

lemma jmm'_heap_progress:
  "heap_progress addr2thread_id thread_id2addr jmm_empty jmm_allocate (jmm_typeof_addr P) (jmm_heap_read_typed P) jmm_heap_write jmm'_hconf P"
proof
  fix h a al T
  assume "jmm'_hconf h"
    and al: "P,h \<turnstile>jmm' a@al : T"
  thus "\<exists>v. jmm_heap_read_typed P h a al v \<and> P,h \<turnstile>jmm' v :\<le> T"
    unfolding jmm_heap_read_def jmm.heap_read_typed_def
    by(blast dest: jmm'.addr_loc_type_fun intro: jmm'.defval_conf)+
next
  fix h a al T v
  assume "P,h \<turnstile>jmm' a@al : T"
    and "P,h \<turnstile>jmm' v :\<le> T"
  thus "\<exists>h'. jmm_heap_write h a al v h'"
    by(auto intro: jmm_heap_write.intros)
qed

interpretation jmm'!: heap_progress
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" "jmm_heap_read_typed P" jmm_heap_write jmm'_hconf
  P
  for P
by(rule jmm'_heap_progress)

subsection {* Locale @{text heap_conf_read} *}

lemma jmm'_heap_conf_read:
  "heap_conf_read addr2thread_id thread_id2addr jmm_empty jmm_allocate (jmm_typeof_addr P) (jmm_heap_read_typed P) jmm_heap_write jmm'_hconf P"
by(rule jmm.heap_conf_read_heap_read_typed)

interpretation jmm'!: heap_conf_read
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" "jmm_heap_read_typed P" jmm_heap_write jmm'_hconf
  P
  for P
by(rule jmm'_heap_conf_read)

interpretation jmm'!: heap_typesafe
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" "jmm_heap_read_typed P" jmm_heap_write jmm'_hconf
  P
  for P
..

subsection {* Locale @{text "allocated_heap"} *}

lemma jmm_allocated_heap:
  "allocated_heap addr2thread_id thread_id2addr jmm_empty jmm_allocate (jmm_typeof_addr P) jmm_heap_write jmm_allocated P"
proof
  show "jmm_allocated jmm_empty = {}" by(simp add: jmm_allocated_def)
next
  fix h' a h hT
  assume "(h', a) \<in> jmm_allocate h hT"
  thus "jmm_allocated h' = insert a (jmm_allocated h) \<and> a \<notin> jmm_allocated h"
    by(auto simp add: jmm_heap_ops_defs split: split_if_asm)
next
  fix h a al v h'
  assume "jmm_heap_write h a al v h'"
  thus "jmm_allocated h' = jmm_allocated h" by cases simp
qed

interpretation jmm!: allocated_heap
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" jmm_heap_read jmm_heap_write
  jmm_allocated
  P
  for P
by(rule jmm_allocated_heap)

lemmas jmm'_allocated_heap = jmm_allocated_heap

interpretation jmm'!: allocated_heap
  addr2thread_id thread_id2addr
  jmm_spurious_wakeups
  jmm_empty jmm_allocate "jmm_typeof_addr P" "jmm_heap_read_typed P" jmm_heap_write
  jmm_allocated
  P
  for P
by(rule jmm'_allocated_heap)

subsection {* Syntax translations *}

notation jmm'.external_WT' ("_,_ \<turnstile>jmm' (_\<bullet>_'(_')) : _" [50,0,0,0,50] 60)

abbreviation jmm'_red_external ::
  "'m prog \<Rightarrow> thread_id \<Rightarrow> JMM_heap \<Rightarrow> addr \<Rightarrow> mname \<Rightarrow> addr val list
  \<Rightarrow> (addr, thread_id, JMM_heap) external_thread_action
  \<Rightarrow> addr extCallRet \<Rightarrow> JMM_heap \<Rightarrow> bool"
where "jmm'_red_external P \<equiv> jmm'.red_external (TYPE('m)) P P"

abbreviation jmm'_red_external_syntax ::
  "'m prog \<Rightarrow> thread_id \<Rightarrow> addr \<Rightarrow> mname \<Rightarrow> addr val list \<Rightarrow> JMM_heap
  \<Rightarrow> (addr, thread_id, JMM_heap) external_thread_action
  \<Rightarrow> addr extCallRet \<Rightarrow> JMM_heap \<Rightarrow> bool"
  ("_,_ \<turnstile>jmm' (\<langle>(_\<bullet>_'(_')),/_\<rangle>) -_\<rightarrow>ext (\<langle>(_),/(_)\<rangle>)" [50, 0, 0, 0, 0, 0, 0, 0, 0] 51)
where
  "P,t \<turnstile>jmm' \<langle>a\<bullet>M(vs), h\<rangle> -ta\<rightarrow>ext \<langle>va, h'\<rangle> \<equiv> jmm'_red_external P t h a M vs ta va h'"

abbreviation jmm'_red_external_aggr ::
  "'m prog \<Rightarrow> thread_id \<Rightarrow> addr \<Rightarrow> mname \<Rightarrow> addr val list \<Rightarrow> JMM_heap
    \<Rightarrow> ((addr, thread_id, JMM_heap) external_thread_action \<times> addr extCallRet \<times> JMM_heap) set"
where "jmm'_red_external_aggr P \<equiv> jmm'.red_external_aggr TYPE('m) P P"

abbreviation jmm'_heap_copy_loc ::
  "'m prog \<Rightarrow> addr \<Rightarrow> addr \<Rightarrow> addr_loc \<Rightarrow> JMM_heap
  \<Rightarrow> (addr, thread_id) obs_event list \<Rightarrow> JMM_heap \<Rightarrow> bool"
where "jmm'_heap_copy_loc \<equiv> jmm'.heap_copy_loc TYPE('m)"

abbreviation jmm'_heap_copies ::
  "'m prog \<Rightarrow> addr \<Rightarrow> addr \<Rightarrow> addr_loc list \<Rightarrow> JMM_heap
  \<Rightarrow> (addr, thread_id) obs_event list \<Rightarrow> JMM_heap \<Rightarrow> bool"
where "jmm'_heap_copies \<equiv> jmm'.heap_copies TYPE('m)"

abbreviation jmm'_heap_clone ::
  "'m prog \<Rightarrow> JMM_heap \<Rightarrow> addr \<Rightarrow> JMM_heap
  \<Rightarrow> ((addr, thread_id) obs_event list \<times> addr) option \<Rightarrow> bool"
where "jmm'_heap_clone P \<equiv> jmm'.heap_clone TYPE('m) P P"

end


theory inFlashData

imports Data_inc
begin

typedef inFlash="{cin}"
  by auto

instance inFlash::finite
  apply (intro_classes)
  using type_definition.Abs_image type_definition_inFlash typedef_finite_UNIV by fastforce

instantiation inFlash::somechan
begin
definition Rep_inFlash_def:"Rep = Rep_inFlash"

lemma repflash_range[simp]:"range (Rep::inFlash\<Rightarrow>channel) = {cin}"
  apply(subst Rep_inFlash_def)
  using type_definition.Rep_range type_definition_inFlash by fastforce

instance
  apply(intro_classes)
  apply clarsimp
  unfolding Rep_inFlash_def by (meson Rep_inFlash_inject injI)
end

lemma inFlash_chdom[simp]: "chDom TYPE (inFlash) = {cin}"
  by (simp add: somechandom)

section \<open>Constructors\<close>

definition "Flashinin1 \<equiv> Abs_inFlash cin"

free_constructors inFlash for Flashinin1
  apply auto?  (* TODO: kann man das "auto" entfernen? *)
  unfolding Flashinin1_def
  apply (metis Rep_inFlash Rep_inFlash_inverse empty_iff insert_iff)
  apply (simp add: Abs_inFlash_inject)?
  done

lemma flashinin1_rep [simp]: "Rep Flashinin1 = cin"
  unfolding Rep_inFlash_def Flashinin1_def
  by (simp add: Abs_inFlash_inverse)

section \<open>Preperation for locale instantiation\<close>

(* Tuple:
      1. Value should go to port cin. It is of type "bool"
*)

(* The first parameter is the converter from user-type (here bool) to "M"

  for every type in the tuple such a function must be in the parameter. So if the tuple
  would consist of (nat\<times>bool) there are 2 converters required *)

fun inFlashChan::"('bool \<Rightarrow> 'a) \<Rightarrow> ('bool) \<Rightarrow> inFlash \<Rightarrow> 'a" where
"inFlashChan boolConv  (port_cin) Flashinin1 = boolConv port_cin"

(* Helper Function for lemmata (mostly surj). Should be hidden from the user! *)
definition inFlashChan_inv::"('bool \<Rightarrow> 'a) \<Rightarrow> (inFlash \<Rightarrow> 'a) \<Rightarrow> ('bool)" where
"inFlashChan_inv boolConv f = ((inv boolConv) (f Flashinin1))"

lemma inFlashChan_surj_helper:
    assumes "f Flashinin1 \<in> range boolConv"
  shows "inFlashChan boolConv (inFlashChan_inv boolConv f) = f"
  unfolding inFlashChan_inv_def
  apply(rule ext, rename_tac "c")
  apply(case_tac c; simp)
  by (auto simp add: assms f_inv_into_f)

lemma inFlashChan_surj:
    assumes "f Flashinin1 \<in> range boolConv"
      shows "f \<in> range (inFlashChan boolConv)"
  by (metis UNIV_I image_iff assms inFlashChan_surj_helper)

lemma inFlashChan_inj: assumes "inj boolConv"
  shows "inj (inFlashChan boolConv)"
  apply (auto simp add: inj_def)
   by (metis assms inFlashChan.simps injD)+

subsection \<open>SBE\<close>
(* Dieses Beispiel ist zeitsychron, daher das "Tsyn" *)
abbreviation "buildFlashInSBE \<equiv> inFlashChan (Tsyn o map_option \<B>)"
(* Die Signatur lautet: "bool option \<times> bool option \<Rightarrow> inFlash \<Rightarrow> M"
    Das "option" kommt aus der Zeit. "None" = keine Nachricht *)

lemma buildandin_ctype: "buildFlashInSBE a c \<in> ctype (Rep c)"
  apply(cases c; cases a)
  by(auto simp add: ctype_def)

lemma buildandin_inj: "inj buildFlashInSBE"
  apply(rule inFlashChan_inj)
  by simp

lemma buildandin_range: "range (\<lambda>a. buildFlashInSBE a c) = ctype (Rep c)"
  apply(cases c)
  apply(auto simp add: image_iff ctype_def)
  by (metis option.simps(9))+

lemma buildandin_surj: assumes "\<And>c. sbe c \<in> ctype (Rep c)"
  shows "sbe \<in> range buildFlashInSBE"
  apply(rule inFlashChan_surj)
   apply (metis flashinin1_rep assms rangecin) (* Die metis-Sachen kann man bestimmt in einen 1-Zeiler umwandeln *)
  done

interpretation inFlashSBE: sbeGen "buildFlashInSBE"
  apply(unfold_locales)
  apply(simp add: buildandin_ctype)
  apply (simp add: buildandin_inj)
  apply (simp add: buildandin_surj)
  by simp

subsection \<open>SB\<close>

abbreviation "buildFlashInSB \<equiv> inFlashChan (Rep_cfun (smap (Tsyn o map_option \<B>)))"

lemma buildFlashInSB_ctype: "sValues\<cdot>(buildFlashInSB a c) \<subseteq> ctype (Rep c)"
  apply(cases c; cases a)
  by (auto simp add: ctype_def smap_sValues)

lemma buildFlashInSB_inj: "inj buildFlashInSB"
  apply(rule inFlashChan_inj, rule smap_inj)
  by (simp)

lemma smap_rang2values: assumes "sValues\<cdot>s \<subseteq> range f"
    shows "s \<in> range (Rep_cfun (smap f))"
  using assms smap_well by force

lemma buildFlashInSB_surj: assumes "sb_well sb"
  shows "sb \<in> range buildFlashInSB"
  apply(rule inFlashChan_surj; rule smap_rang2values; rule sbwellD)
  apply (simp_all add: assms)
  using rangecin apply simp
  done

interpretation inFlashSB: sbGen "buildFlashInSB"
  apply(unfold_locales)
  apply (simp add: buildFlashInSB_ctype)
  apply (simp add: buildFlashInSB_inj)
  by (simp add: buildFlashInSB_surj)

end