0

I am not able to prove the the following lemma in Isabelle:

lemma "Id^* = Id"

Any ideas on how to prove this?

chris
  • 4,988
  • 20
  • 36
Nuno Amálio
  • 101
  • 7

3 Answers3

1

If you just invoke sledgehammer (via the panel, or via try), then you immediately get the proof:

by (metis rtrancl_empty rtrancl_idemp)
René Thiemann
  • 1,251
  • 6
  • 2
1

To get an idea how this works you should first think about how you would prove this on paper. As you see by

term "Id"

Id is a set of pairs (type ('a * 'a) set). Thus you have to show the equality of two sets. The canonical way to do so is by showing that each set is a subset of the other one.

Lets start with Id^* ⊆ Id. How to show that a set is a subset of another one? Exactly, show that every element of the 'smaller' set is also an element of the 'bigger' one, i.e.,

fix x y
assume "(x, y) ∈ Id^*"
then show "(x, y) ∈ Id"

Since the transitive closure is defined inductively we can do this by induction as follows

by (induct) simp_all

That is to say, use the default induction rule for a premise of the form (_, _) ∈ _^* (which happens to be rtrancl_induct) and then solve the base-case as well as the inductive-case by simplification.

Once again, the full proof

lemma
  "Id^* ⊆ Id"
proof (rule subrelI)
  fix x y
  assume "(x, y) ∈ Id^*"
  then show "(x, y) ∈ Id"
    by (induct rule: rtrancl_induct) simp_all
qed

The other direction is left as an exercise.

chris
  • 4,988
  • 20
  • 36
0

I am still new to this. I guess that the whole Isar proof is something like:

lemma "Id^* = Id"
proof (rule equalityI)
  show "Id^* ⊆ Id"
  proof (rule subrelI)
    fix x y
    assume "(x, y) ∈ Id^*"
    then show "(x, y) ∈ Id"
    by (induct) simp_all
  qed
next 
  show "Id ⊆ Id^*"
  proof (rule subrelI)
    fix x y
    assume "(x, y) ∈ Id"
    then show "(x, y) ∈ Id^*"
    by (auto) 
  qed
qed
chris
  • 4,988
  • 20
  • 36
Nuno Amálio
  • 101
  • 7