-
Notifications
You must be signed in to change notification settings - Fork 0
/
Formula.thy
78 lines (61 loc) · 2.99 KB
/
Formula.thy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
(* Title: Separation-Logic-Formalization/Interpretation.thy
Author: Nicolas Amat, Mnacho Echenim, Nicolas Peltier
*)
section \<open>Formulas\<close>
text \<open>This section contains the formulas syntax and semantic.\<close>
theory Formula
imports
Interpretation
begin
subsection \<open>Formulas Syntax\<close>
datatype ('var, 'k::finite) sl_formula =
(* Boolean *)
sl_true
| sl_false
(* Classical Logic *)
| sl_not "('var, 'k) sl_formula"
| sl_and "('var, 'k) sl_formula" "('var, 'k) sl_formula"
(* Quantifier *)
| sl_exists 'var "('var, 'k) sl_formula"
(* Separation Logic *)
| sl_emp
| sl_eq 'var 'var
| sl_mapsto 'var "('var, 'k) vec"
| sl_conj "('var, 'k) sl_formula" "('var, 'k) sl_formula"
| sl_magic_wand "('var, 'k) sl_formula" "('var, 'k) sl_formula"
subsection \<open>Formulas Semantics\<close>
fun evaluation :: "('var, 'addr, 'k) interp \<Rightarrow> ('var, 'k::finite) sl_formula \<Rightarrow> bool"
where
"evaluation I sl_true = True"
| "evaluation I sl_false = False"
| "evaluation I (sl_not P) = (\<not>(evaluation I P))"
| "evaluation I (sl_and P Q) = ((evaluation I P) \<and> (evaluation I Q))"
| "evaluation I (sl_exists x P) = (\<exists>u. (evaluation (to_interp ((store I)(x:=u)) (heap I)) P))"
| "evaluation I (sl_eq x y) = ((store I) x = (store I) y)"
| "evaluation I (sl_emp) = empty_heap (heap I)"
| "evaluation I (sl_mapsto x y) = ((h_dom (heap I) = {(store I) x})
\<and> ((store_and_heap I x) = Some (store_vector (store I) y)))"
| "evaluation I (sl_conj P Q) = (\<exists>h1 h2. (union_heaps h1 h2 = heap I)
\<and> (disjoint_heaps h1 h2)
\<and> (evaluation (to_interp (store I) h1) P)
\<and> (evaluation (to_interp (store I) h2) Q))"
| "evaluation I (sl_magic_wand P Q) = (\<forall>h. ((disjoint_heaps h (heap I)) \<and> (evaluation (to_interp (store I) h) P))
\<longrightarrow> (evaluation (to_interp (store I) (union_heaps (heap I) h))) Q)"
subsection \<open>Formula Complement\<close>
fun sl_formula_complement :: "('var, 'k::finite) sl_formula \<Rightarrow> ('var ,'k) sl_formula"
where "sl_formula_complement (sl_not l) = l"
| "sl_formula_complement l = (sl_not l)"
subsection \<open>Formula Var Set\<close>
fun var_set :: "('var, 'k::finite) sl_formula \<Rightarrow> 'var set"
where
"var_set sl_true = {}"
| "var_set sl_false = {}"
| "var_set (sl_not P) = var_set P"
| "var_set (sl_and P Q) = var_set P \<union> var_set Q"
| "var_set (sl_exists x P) = var_set P"
| "var_set (sl_emp) = {}"
| "var_set (sl_eq x y) = {x, y}"
| "var_set (sl_mapsto x y) = {x} \<union> {y $ i | i. True}"
| "var_set (sl_conj P Q) = var_set P \<union> var_set Q"
| "var_set (sl_magic_wand P Q) = var_set P \<union> var_set Q"
end