Skip to content

Commit 198ef98

Browse files
committed
Code cleanup
1 parent 4f9a3c8 commit 198ef98

File tree

1 file changed

+14
-42
lines changed

1 file changed

+14
-42
lines changed

src/Act/Coq.hs

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ stepBehv (Behaviour name _ i _ conds cases _ _ _) =
9898
<> [ stepType <> " " <> stateVar <> " " <> parens (name' <> " " <> envVar <> " " <> stateVar <> " " <> arguments i)]
9999

100100

101-
-- | inductive definition of reachable states
101+
-- | definition of reachable states
102102
reachable :: T.Text
103103
reachable = definition
104104
reachableType args value
@@ -109,6 +109,7 @@ reachable = definition
109109
stateVar' <> " " <> stateVar
110110
stateVar' = stateVar <> "'"
111111

112+
-- | specialization of generic multistep
112113
multistep :: T.Text
113114
multistep = definition
114115
multistepType args value
@@ -117,9 +118,7 @@ multistep = definition
117118
value = multistepType <> " " <> stepType <> " " <> stateVar <> " " <> stateVar'
118119
stateVar' = stateVar <> "'"
119120

120-
multistepType :: T.Text
121-
multistepType = "multistep"
122-
121+
-- | definition of reachable states from initial state
123122
reachableFromInit :: T.Text
124123
reachableFromInit = definition
125124
reachableFromInitType args value
@@ -130,17 +129,12 @@ reachableFromInit = definition
130129
stateVar <> " " <> stateVar'
131130
stateVar' = stateVar <> "'"
132131

133-
reachableFromInitType :: T.Text
134-
reachableFromInitType = "reachableFromInit"
135-
136-
stepMultistepType :: T.Text
137-
stepMultistepType = "step_multi_step"
138-
132+
-- | specialization of generic multistep lemma
139133
stepMultistep :: T.Text
140134
stepMultistep = definition
141135
stepMultistepType "" $ stepMultistepType <> " " <> stepType
142136

143-
137+
-- | definition of preconditions for initial state
144138
initPred :: Constructor -> T.Text
145139
initPred (Constructor name i@(Interface _ decls) _ conds _ _ _ ) = inductive
146140
initType "" (stateType <> " -> " <> " Prop") [body]
@@ -157,37 +151,6 @@ initPred (Constructor name i@(Interface _ decls) _ conds _ _ _ ) = inductive
157151
then ""
158152
else interface i) <> ","
159153

160-
161-
-- | non-recursive constructor for the reachable relation
162-
baseCase :: Constructor -> T.Text
163-
baseCase (Constructor name i@(Interface _ decls) _ conds _ _ _ ) =
164-
T.pack name <> baseSuffix <> " : " <> universal <> "\n" <> constructorBody
165-
where
166-
baseval = parens $ T.pack name <> " " <> envVar <> " " <> arguments i
167-
constructorBody = (indent 2) . implication . concat $
168-
[ coqprop <$> conds
169-
, [reachableType <> " " <> baseval <> " " <> baseval]
170-
]
171-
universal =
172-
"forall " <> envDecl <> " " <>
173-
(if null decls
174-
then ""
175-
else interface i) <> ","
176-
177-
-- | recursive constructor for the reachable relation
178-
reachableStep :: T.Text
179-
reachableStep =
180-
reachStep <> " : forall "
181-
<> envDecl <> " "
182-
<> parens (baseVar <> " " <> stateVar <> " " <> nextVar <> " : " <> stateType) <> ",\n"
183-
<> constructorBody where
184-
185-
constructorBody = (indent 2) . implication $
186-
[ reachableType <> " " <> baseVar <> " " <> stateVar ]
187-
<> [stepType <> " " <> stateVar <> " " <> nextVar ]
188-
<> [reachableType <> " " <> baseVar <> " " <> nextVar ]
189-
190-
191154
-- | definition of a base state
192155
base :: Store -> Constructor -> T.Text
193156
base store (Constructor name i _ _ _ _ updates) =
@@ -519,9 +482,18 @@ stepType = "step"
519482
initType :: T.Text
520483
initType = "init"
521484

485+
multistepType :: T.Text
486+
multistepType = "multistep"
487+
522488
reachableType :: T.Text
523489
reachableType = "reachable"
524490

491+
reachableFromInitType :: T.Text
492+
reachableFromInitType = "reachableFromInit"
493+
494+
stepMultistepType :: T.Text
495+
stepMultistepType = "step_multi_step"
496+
525497
reachStep:: T.Text
526498
reachStep= "reach_step"
527499

0 commit comments

Comments
 (0)