E***@data61.csiro.au
2018-11-14 07:18:08 UTC
Hi all,
I'm currently working on extracting theorem dependencies from proof terms. I've noticed that the prop one gets from `Thm.full_prop_of` sometimes doesn't match the prop in the topmost proof body of a `thm`. As an example, the following two props are different:
```
theory Scratch
imports Main
begin
declare [[show_sorts]]
ML \<open>
val prop1 = Thm.full_prop_of @{thm refl};
val prop2 = @{thm refl}
|> Thm.proof_body_of
|> (fn (PBody {thms, ...}) => thms)
|> List.hd
|> snd
|> Proofterm.thm_node_prop;
\<close>
```
In particular, `prop2` has the `type_class` sort constraint pulled out as a premise, whereas `prop1` leaves it as a constraint on types in the term. As far as I can tell, the transformation only occurs in proof bodies as part of a post-processing step introduced by `Proofterm.thm_proof`.
I ran into the above while attempting to disambiguate the names that occur in proof bodies. That is, if a proof body refers to a prop `p` with name `"foo_1"`, I need to distinguish between `p` being proven by the first theorem in a thm list (`foo(1)`) or by a thm with the actual name `foo_1`. Since `Thm.full_prop_of` and proof bodies sometimes disagree, the easiest solution at the time was to use the proof body terms as a 'normal form', which seems unsatisfying. So, for my own education:
- What is the canonical way to get the dependencies of a thm?
- What is the canonical way to disambiguate between the first theorem of `foo` vs. a theorem named `foo_1`?
Regards,
--Ed
I'm currently working on extracting theorem dependencies from proof terms. I've noticed that the prop one gets from `Thm.full_prop_of` sometimes doesn't match the prop in the topmost proof body of a `thm`. As an example, the following two props are different:
```
theory Scratch
imports Main
begin
declare [[show_sorts]]
ML \<open>
val prop1 = Thm.full_prop_of @{thm refl};
val prop2 = @{thm refl}
|> Thm.proof_body_of
|> (fn (PBody {thms, ...}) => thms)
|> List.hd
|> snd
|> Proofterm.thm_node_prop;
\<close>
```
In particular, `prop2` has the `type_class` sort constraint pulled out as a premise, whereas `prop1` leaves it as a constraint on types in the term. As far as I can tell, the transformation only occurs in proof bodies as part of a post-processing step introduced by `Proofterm.thm_proof`.
I ran into the above while attempting to disambiguate the names that occur in proof bodies. That is, if a proof body refers to a prop `p` with name `"foo_1"`, I need to distinguish between `p` being proven by the first theorem in a thm list (`foo(1)`) or by a thm with the actual name `foo_1`. Since `Thm.full_prop_of` and proof bodies sometimes disagree, the easiest solution at the time was to use the proof body terms as a 'normal form', which seems unsatisfying. So, for my own education:
- What is the canonical way to get the dependencies of a thm?
- What is the canonical way to disambiguate between the first theorem of `foo` vs. a theorem named `foo_1`?
Regards,
--Ed