Re: [isabelle] [isabelle-dev] Partial functions



How about unfolding the definition of "f"?

Then it should work, e.g., as follows

  definition f :: "nat ⇒ nat option"
  where
    "f x = (if x ∈ {1, 2, 3} then Some 0 else None)"

  lemma "dom f = {1, 2, 3}"
    by (force simp: f_def dom_def)

cheers

chris

On 10/25/2013 03:34 PM, Gottfried Barrow wrote:
On 5/22/2013 6:44 AM, Andreas Lochbihler wrote:
For example,

definition f :: "nat => nat option" where
"f x = (if x : {1,2,3} then Some .... else None)"

Then, "dom f" returns the domain of f as {1,2,3} and "ran f" the range
of f. There are a few more operations defined in theory Map, in
particular map_of. Option.bind in theory Option is used for function
composition.

On 5/22/2013 6:50 AM, Manuel Eberl wrote:
You can find out the domain/range of such a partial function using dom
and ran. For instance, "dom f" is defined as {a. f a ≠ None}.

I was looking at how to do a partial function with option, so I was
looking at this old email thread.

The two statements above make it sound like it should be easy to get
"dom f = {1,2,3}".

I do this:
theorem "(dom f) = {1,2,3}"
apply(unfold dom_def)

And I get a goal: "{a. f a ≠ None} = {1, 2, 3}", with no easy automatic
proof.

Is there something simple I'm supposed to do get "(dom f) = {1,2,3}"?

Thanks,
GB










This archive was generated by a fusion of Pipermail (Mailman edition) and MHonArc.