Theory M2L_Examples
theory M2L_Examples
imports M2L_Equivalence_Checking "HOL-Library.Char_ord"
"HOL-Library.Product_Lexorder"
begin
abbreviation FALSE where "FALSE ≡ FExists (FLess 0 0)"
abbreviation TRUE where "TRUE ≡ FNot FALSE"
abbreviation All where "All φ ≡ FNot (FExists (FNot φ))"
abbreviation AL where "AL φ ≡ FNot (FEXISTS (FNot φ))"
abbreviation Imp where "Imp φ ψ ≡ FOr (FNot φ) ψ"
abbreviation Iff where "Iff φ ψ ≡ FAnd (Imp φ ψ) (Imp ψ φ)"
abbreviation Ball where "Ball X φ ≡ All (Imp (FIn 0 (X+1)) φ)"
abbreviation Bex where "Bex X φ ≡ FExists (FAnd (FIn 0 (X+1)) φ)"
abbreviation Eq where "Eq x y ≡ FAnd (FNot (FLess x y)) (FNot (FLess y x))"
abbreviation SUBSET where "SUBSET X Y ≡ Ball X (FIn 0 (Y+1))"
abbreviation EQ where "EQ X Y ≡ FAnd (SUBSET X Y) (SUBSET Y X)"
abbreviation First where "First x ≡ FNot (FExists (FLess 0 (x+1)))"
abbreviation Last where "Last x ≡ FNot (FExists (FLess (x+1) 0))"
abbreviation Suc where "Suc sucx x ≡ FAnd (FLess x sucx) (FNot (FExists (FAnd (FLess (x+1) 0) (FLess 0 (sucx+1)))))"
definition "Thm (type :: 'a :: {enum, linorder} itself) n φ = fast.check_eqv n (FNot φ :: 'a formula) FALSE"
definition "Thm_slow (type :: 'a :: {enum, linorder} itself) n φ = slow.check_eqv n (FNot φ :: 'a formula) FALSE"
definition "Thm_dual (type :: 'a :: {enum, linorder} itself) n φ = dual.check_eqv n (FNot φ :: 'a formula) FALSE"
definition "M2L = (FEXISTS (All (FIn 0 1)) :: Enum.finite_1 formula)"
lemma "Thm TYPE(Enum.finite_1) 0 M2L" by eval
lemma "Thm TYPE(Enum.finite_1) 0 (FNot (All (FExists (FLess 1 0))))" by eval
lemma "Thm (TYPE(bool)) 0 (FNot (FExists (FExists (FAnd (FLess 0 1) (FLess 1 0)))))" by eval
lemma Drinker: "Thm (TYPE(bool)) 1 (FExists (Imp (FIn 0 1) (All (FIn 0 2))))" by eval
lemma "Thm (TYPE(bool)) 1 (Imp (All (FIn 0 1)) (FExists (FIn 0 1)))" by eval
abbreviation Globally ("□_" [40] 40) where "Globally P == %n. All (Imp (FNot (FLess (n+1) 0)) (P 0))"
abbreviation Future ("◇_" [40] 40) where "Future P == %n. FExists (FAnd (FNot (FLess (n+1) 0)) (P 0))"
abbreviation IMP (infixr "→" 50) where "IMP P1 P2 == %n. Imp (P1 n) (P2 n)"
abbreviation "FOR xs n ≡ rexp_of_list FOr FALSE (map (λx. FQ x n) xs)"
abbreviation Φ0 :: "bool formula" where "Φ0 ≡
(All (((□(FOR [(True)])) → (□(FOR [(True)]))) 0))"
abbreviation Φ1 :: "(bool × bool) formula" where "Φ1 ≡
(All (((□(FOR [(True, True), (True, False)] →
FOR [(True, True), (False, True)])) →
(□(FOR [(True, True), (True, False)])) →
(□(FOR [(True, True), (False, True)]))) 0))"
abbreviation Φ2 :: "(bool × bool × bool) formula" where "Φ2 ≡
(All (((□(FOR [(True, True, True), (True, True, False), (True, False, True), (True, False, False)] →
FOR [(True, True, True), (True, True, False), (False, True, True), (False, True, False)] →
FOR [(True, True, True), (True, False, True), (False, True, True), (False, False, True)])) →
(□(FOR [(True, True, True), (True, True, False), (True, False, True), (True, False, False)])) →
(□(FOR [(True, True, True), (True, True, False), (False, True, True), (False, True, False)])) →
(□(FOR [(True, True, True), (True, True, False), (False, True, True), (False, True, False)]))) 0))"
definition Ψ :: "nat ⇒ Enum.finite_1 formula" where
"Ψ n = All (((□(foldr (λi φ. (λm. FIn m (2 + i)) → φ) [0..<n] (λm. FIn m (n + 2)))) →
foldr (λi φ. (□(λm. FIn m (2 + i))) → φ) [0..<n] (□(λm. FIn m (n + 2)))) 0)"
definition "Thm1 n = Thm (TYPE(Enum.finite_1)) (n + 1) (Ψ n)"
definition "Thm1_slow n = Thm_slow (TYPE(Enum.finite_1)) (n + 1) (Ψ n)"
definition "Thm1_dual n = Thm_dual (TYPE(Enum.finite_1)) (n + 1) (Ψ n)"
lemma "Thm1 0" by eval
lemma "Thm1 1" by eval
lemma "Thm1 2" by eval
lemma "Thm (TYPE(bool)) 0 Φ0" by eval
lemma "Thm (TYPE(bool * bool)) 0 Φ1" by eval
lemma "Thm (TYPE(bool * bool * bool)) 0 Φ2" by eval
end