I would like to translate the following type declaration into Isabelle/HOL.
The definitions above serves for evaluating a modal formula in the basic modal language. I defined formula, frame and model in Isabelle as follows. (Is everything good up to now?)
datatype form = VAR "num"
| FALSE
| DISJ "form" "form"
| NOT "form"
| DIAM "form"
record 'a frame =
world :: "'a ⇒ bool"
rel :: "'a ⇒ 'a ⇒ bool"
record 'a model = "'a frame" +
valt :: "num ⇒ 'a ⇒ bool"
But then I think I get confused on the translation of the "satis" predicate. It seems to be a bunch of options. There are primrec, fun and inductive. Is there any consideration that I should take before picking one?
I am attempting to do "fun". I wrote:
fun satis :: "'a model ⇒ 'a ⇒ form ⇒ bool"
where
"satis M w (VAR p) = M.valt p v ∧ M.frame.world w
| satis M w FALSE = false"
And it already started complaining:
image.png
May I please ask if there is any quick fix? Thanks in advance!
I'm not so familiar with record syntax in Isabelle, but that should be valt M
Yong Kiam said:
I'm not so familiar with record syntax in Isabelle, but that should be
valt M
Thanks so much! The underscore before disappears.
Now I type (world (frame M))
and it does not look correct:
image.png
The "frame" is green, and may I please ask a "human language" translation of the error message?
= is binding to strongly. Use statis M w ... <--> ...
or statis M w ... = (...)
And it is False
instead of false
Thanks! I changed it into False and <-->.
image.png
Any clue why it thinks "frame" is green? M.frame also does not work.
Not obvious from https://isabelle.in.tum.de/doc/isar-ref.pdf how can we extract fields of a record term.
frame is a type, you cannot use it as a function in a term
I do not even know what you are trying to achieve
I would like the effect to be "a model consists of a frame and a valuation". So I should be able to type M.frame to extract the field "frame" from "M" and then type (M.frame).world to extract the field "world" from the frame "M.frame". But your comment does give a hint! I have just figured out the type "model" will not take "frame" as its field. So what I need is just "world M". Thank you!
For the type declaration, I wrote:
record 'a frame =
world :: "'a ⇒ bool"
rel :: "'a ⇒ 'a ⇒ bool"
record 'a model = "'a frame" +
valt :: "num ⇒ 'a ⇒ bool"
The same recipe of writing rel M to be the field "rel" of M does not seem to work.
Sorry if it turns out to be stupid, but I am confused again.
It seems that Isabelle does not complain about rel M w v, it is complaining about te quantification.
What's wrong here?
add parentheses. And binds too strongly
Thank you for the swift answer, it solves my problem.
image.png
Now Isabelle is happy.
(But I feel its strength to this extent is a bit weird.)
Regarding what to choose to use among fun/definition/primrec. I find an answer here:
https://courses.grainger.illinois.edu/cs576/sp2015/lectures/3-4/04-Isabelle-syntax-2x3.pdf slides 5.
usually definition for stuff that does not recurse, fun for everything else
there is rarely a reason to use primrec
Got it. I will just not use it for the foreseeable future then.
Last updated: Dec 21 2024 at 16:20 UTC