*To*: <isabelle-users at cl.cam.ac.uk>*Subject*: [isabelle] difficulties with polymorphic record extension*From*: "Elsa L. Gunter" <egunter at illinois.edu>*Date*: Wed, 27 Jul 2016 08:38:34 -0500*Cc*: "Bergvelt, David Paul" <bergvel1 at illinois.edu>*User-agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Dear Isabelle community, I am having difficulty building records they way I want. I may well have forgotten something, but the behavior I am see with extending polymorphic records is surprising to me. First I define: record ('instr,'dir) generalized_control_flow_graph_context = Instructions :: "'instr set" Directions :: "'dir set" edgeTyping :: "'instr â ('dir â nat)set" If I then enter declare [[show_types = true]] term "âInstructions =a, Directions = b, edgeTyping =câ" I get "âInstructions = a::'a set, Directions = b::'b set, edgeTyping = c::'a â ('b â nat) setâ" :: "('a, 'b) generalized_control_flow_graph_context" as output, which is what I would expect. Now I wish to extend this record to a new record with additional fields, introducing some new type variables, but also sharing the type variables already used in generalized_control_flow_graph_context. So I enter the following: record ('instr,'dir,'node) generalized_control_flow_graph = "('instr,'dir) generalized_control_flow_graph_context" + Nodes :: "'node set" Edges :: "'node â ('dir Ã 'node)set" labeling :: "'node â 'instr" The intent is that the types of 'dir and 'instr are shared between Instructions, Directions, edgeTyping, Edges and labeling. When I create at element of this extended record type as follows I get the given results: term "âInstructions =a, Directions = b, edgeTyping =c, Nodes = d, Edges = e, labeling = fâ" "âInstructions = a::'a set, Directions = b::'b set, edgeTyping = c::'a â ('b â nat) set, Nodes = d::'e set, Edges = e::'e â ('d Ã 'e) set, labeling = f::'e â 'câ" :: "âInstructions :: 'a set, Directions :: 'b set, edgeTyping :: 'a â ('b â nat) set, Nodes :: 'e set, Edges :: 'e â ('d Ã 'e) set, labeling :: 'e â 'câ" Note that the types of Nodes, Edges, labeling are completely independent of those for Instructions, Directions and edgeTyping, despite the same types being used in both parts of the generalized_control_flow_graph record definition. I know each type gets separately parsed separately, but it seems plausible that the whole record extension package could infer that the types used in one part of the definition where to be the same as those of the same name in other parts. These extra degrees of freedom present problems where type variables can end up buried on the right-hand side of a definition without being captured by the left hand side, where they would if the desired type constraints had been enforced. I have found a number of crufty ways around the difficulty, but I would appreciate help with learning how to do this record extension definition correctly. I've not been able to find it in the documentation. ---Elsa

**Follow-Ups**:**Re: [isabelle] difficulties with polymorphic record extension***From:*Andreas Lochbihler

- Previous by Date: Re: [isabelle] Proposal: An update to Multiset theory
- Next by Date: Re: [isabelle] difficulties with polymorphic record extension
- Previous by Thread: Re: [isabelle] Proposal: An update to Multiset theory
- Next by Thread: Re: [isabelle] difficulties with polymorphic record extension
- Cl-isabelle-users July 2016 archives indexes sorted by: [ thread ] [ subject ] [ author ] [ date ]
- Cl-isabelle-users list archive Table of Contents
- More information about the Cl-isabelle-users mailing list