Post an answer Follow-up question
Brian provided the answer, proposing a solution to use lift and gear. However, I cannot find enough tutorial information on how to lift and transmit to know how to set up his answer in order to finish what I will need to do.
Here I work in the dark and use the answer given as the plug'n'play template to ask this next question.
The command in my source code typedef trivAlg = "{x::sT. x = emS}" gives me a new type, which is a subset of the parent type sT .
I have a membership operator consts inP :: "sT => sT => bool" , and therefore in my naive view of raising and passing, since my monoid_add 0 was defined as the constant emS::sT , and I can make this statement , (emS::sT) inP emS , I would like to do something like this:
theorem "~((0::trivAlg) inP 0)"
So, I'm trying to use the lift to get my inP to work with the trivAlg type like this:
lift_definition inP_trivAlg :: "trivAlg => trivAlg => bool" is "% x y. (x inP y)" by simp theorem "~((0::trivAlg) inP 0)" theorem "(emS::trivAlg) = emS"
However, I get type collisions using theorem because my use of sT and trivAlg incompatible.
If the answer can be added to show me how to make my inP work with the trivAlg type, I would appreciate it. Or maybe I'm not familiar.
Preliminary Information on the (Original) Question
I have my sT type, which represents "everything is a collection." So far, all my constants and operators have been defined with a single type sT . For example, my empty set, membership operator, and union operator are defined like this:
consts emS :: "sT" consts inP :: "sT => sT => bool" consts geU :: "sT => sT"
Now I find out a little early if I can link my sT into generalized groups in Groups.thy .
From the HOL document, I try to get examples from sections 4.2, 4.3 and 4.4 of groups and 15.2 and 15.3 from Nat.
Well, I almost answer my own question, but I don’t know enough to find out if I am asking a reasonable question. I think that I know that a solution can only be with locales, sublayers, and interpretations, and not with type classes.
I was looking a bit for locales.pdf and classes.pdf , and therefore I know that locales and classes are intertwined. I also looked at IsarMathLib to see how locales, subwords, and interpretations are used there.
Question
My question is, with my trivial algebraic structure below trivAlg , which is a new type defined with typedef , how can I set things up with class classes so that I can use my constants like emS , inP and geU listed above, with elements like trivAlg ?
After I have listed the code below, I ask a few questions about specific lines of code in Groups.thy .
The code
typedef trivAlg = "{x::sT. x = emS}" by auto instantiation trivAlg :: zero begin definition trivAlg_zero: "0 = Abs_trivAlg emS" instance .. end instantiation trivAlg :: monoid_add begin definition plus_trivAlg: "m + n = (Abs_trivAlg emS)" instance proof fix nmq :: trivAlg show "(n + m) + q = n + (m + q)" by(metis plus_trivAlg) show "0 + n = n" apply(induct n) apply(auto) by(metis plus_trivAlg) show "n + 0 = n" apply(induct n) apply(auto) by(metis plus_trivAlg) qed end theorem "((n::trivAlg) + m) + q = n + (m + q)" by(metis plus_trivAlg) theorem "((0::trivAlg) + 0) = 0" by(metis monoid_add_class.add.left_neutral)
The next question is about Groups.thy
In lines 151 to 155 in groups. Thus, the following code exists:
class semigroup_add = plus + assumes add_assoc [algebra_simps, field_simps]: "(a + b) + c = a + (b + c)" sublocale semigroup_add < add!: semigroup plus proof qed (fact add_assoc)
There is not a single document to teach me how to use classes, locales, subwords and interpretations, so I don’t know exactly what that tells me.
If I want to use semigroup_add , which is in Groups.thy, do I have the choice to use it either as a type class or as a language?