Suppose that I have the following expression in Isabelle/HOL:
typedecl Person
typedecl Car
consts age :: "Person ⇒ int"
consts drives ::"(Person × Car) set"
consts owns ::"(Person × Car) set"
This is supposed to model Person and Car types with two relations between them, named drives and owns, and also the age property of Person.
I would like to state that everybody who owns a car, would definitely drive the car, and people who drive cars are greater than 17, So the constraints:
(∀a. a ∈ owns ⟶ a ∈ drives)
(∀d ∈ drives. age (fst d) > 17)
What is the best way to define these kind of constraints in Isabelle, in the sense that I can prove some properties over the model, assuming these constraints hold true?
Setting aside things you might need to fix, such as that a (Person * Car) pair doesn't own or drive, you have two types, Person and Car which have no properties defined for them.
To give them properties, you need axioms, but you don't want to use something like axiomatization to define global axioms.
What you do to get some axiom action going is use type classes or locales. Someone else will want to fill in more details, but here's one bare-bones template:
typedecl Person
typedecl Car
locale foo_model =
fixes age :: "Person => int"
fixes drives :: "(Person * Car) set"
fixes owns :: "(Person * Car) set"
assumes owns_axiom: "a ∈ owns --> a ∈ drives"
assumes age_axiom: "∀d ∈ drives. age (fst d) > 17"
begin
lemma some_lemma_you_want: "True"
by(simp)
end
lemma (in foo_model) some_other_lemma_you_want : "True"
by(simp)
Related
theory Scratch
imports
"HOL.Fields"
"HOL.Groups"
begin
locale Field_is_group=
fixes F :: "'a :: field"
begin
typedef 'a mul_group = "{x :: 'a set. x ≠ 0}"
end
end
I'm new to Isabelle, and I have learned something about proving in first-order logic but not about data structures. I tried to formalize the proof of the fact that a field has a multiplicative group, but I don't know how to define the multiplicative group. It is the set of the whole field except zero, and a field in Isabelle is defined as a type. By looking about the references, I know I need use typedef, but it fails:
Type unification failed: No type arity set :: zero
Failed to meet type constraint:
Term: λx. x ≠ 0 :: ??'b ⇒ bool
Type: 'a set ⇒ ??'a
The error(s) above occurred in typedef "mul_group"
I am trying to use the export_code tool for the following definition:
definition set_to_list :: "('a×'a) set ⇒ ('a×'a) list"
where "set_to_list A = (SOME L. set L = A)"
This is not working due to missing code equations for Eps. Now I discovered that there is also a definition:
definition sorted_list_of_set :: "'a set ⇒ 'a list" where
"sorted_list_of_set = folding.F insort []"
However, I am not capable of asserting that ('a ×'a) is a linear order (which would be fine for me, e.g. first comparing the first element and then the second). Can someone help me to either fix my own definition or using the existing one?
To use sorted_list_of_set you can implement the type class linorder for product types:
instantiation prod :: (linorder,linorder) linorder begin
definition "less_eq_prod ≡ λ(x1,x2) (y1,y2). x1<y1 ∨ x1=y1 ∧ x2≤y2"
definition "less_prod ≡ λ(x1,x2) (y1,y2). x1<y1 ∨ x1=y1 ∧ x2<y2"
instance by standard (auto simp add: less_eq_prod_def less_prod_def)
end
You can also import "HOL-Library.Product_Lexorder" from the standard library, which includes a similar definition.
Then you can define set_to_list if you restrict the type parameter to implement linorder:
definition set_to_list :: "('a::linorder×'a) set ⇒ ('a×'a) list"
where "set_to_list A = sorted_list_of_set A"
What is the meaning of CONST in Isabelle/Pure? In HOL.thy, we have the following code blocks:
translations "∃!x. P" ⇌ "CONST Ex1 (λx. P)"
translations "THE x. P" ⇌ "CONST The (λx. P)"
translations
"_Let (_binds b bs) e" ⇌ "_Let b (_Let bs e)"
"let x = a in e" ⇌ "CONST Let a (λx. e)"
I was trying to understand what "THE" meant, and found this in HOL.thy. "THE" is explained somewhat here, but I don't really get what's going fundamentally, since supposing P :: 'a ==> a' ==> bool
definition test :: "'a ==> 'a" where
"test y = (THE x. (P x y))"
How can "test y" be type "'a" if there doesn't exists x s.t. P x y? Somehow this has to be hiding in CONST and The (which I also don't really understand as it's just given axiomatically as something of type "('a ==> bool) ==> 'a" without any properties).
Perhaps most importantly, where is there a reference for all of this?? It's not in the Isabelle/Isar reference manual, the Isabelle HOL tutorial, the Isabelle/Isar Implementation pdf, in comments of the theory files, or anywhere I've been able to find.
I'm trying to do the following simple thing: given a topological space, extract its topology and view it as a poset. For that, I imported Topology.thy and Orders.thy and tried something along these lines
fun undtop :: "'a top ⇒'a partial_order" where
"undtop T = (leq ::"T ⇒ T ⇒ bool" where
"leq x y = (x ⊆ y)")"
where 'a top is the type 'a set set and partial_order is of type 'a=>'a => bool (the theory Orders.thy defines a class class partial_order) . The idea was that some T of type a' top should give the topology and then undtop would pick such a T and associate a partial order leq, viewed as a map T => T => bool. Clearly this is not how it works, so I'd like to ask
1) How would you define a function that picks each T of a certain type and defines a new function with domain T?
2) How to specify that this T of type 'a top is a topology, and not just a random collection of subsets, i.e how do I tell Isabelle that it should obey the axioms of the locale "topology" in Topology.thy?
Thank you for the support, as a beginner I'm still struggling with the syntax and the way Isabelle operates.
I am working with limits and I am unable to prove the following
definition func :: "real ⇒ real"
where "func = real"
lemma "(λh. (func (x+h))) -- 0 --> (func (x))"
unfolding func_def
apply (auto intro!: tendsto_eq_intros)
However if I replace the definition of func to
definition func :: "real ⇒ real"
where "func x = x"
the lemma is solved.
How can I solve this lemma when working with generic definitions?
I believe, here the problem is that the function real has just a generic (overloaded) syntax, i.e., real :: 'a => real, but it is not necessarily defined for all possible types 'a. This is easily seen when using find_theorems: when searching for lemmas on real :: nat => real, you get plenty of results whereas searching for real :: real => real doesn't give you a single result.
find_theorems "real :: real => real"
find_theorems "real :: nat => real"
Consequently, you can not even prove a simple lemma like func x = x, since it is not specified that real :: real => real really is the identity function.