Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  Heap.thy   Sprache: Isabelle

 

(*  Title:      HOL/Imperative_HOL/Heap.thy
    Author:     John Matthews, Galois Connections; Alexander Krauss, TU Muenchen
*)


section ‹A polymorphic heap based on cantor encodings›

theory Heap
imports Main "HOL-Library.Countable"
begin

subsection ‹Representable types›

text ‹The type class of representable types›

class heap = typerep + countable

instance unit :: heap ..

instance bool :: heap ..

instance nat :: heap ..

instance prod :: (heap, heap) heap ..

instance sum :: (heap, heap) heap ..

instance list :: (heap) heap ..

instance option :: (heap) heap ..

instance int :: heap ..

instance String.literal :: heap ..

instance char :: heap ..

instance typerep :: heap ..


subsection ‹A polymorphic heap with dynamic arrays and references›

text ‹
 References and arrays are developed in parallel,
 but keeping them separate makes some later proofs simpler.
 
›

type_synonym addr = nat ― ‹untyped heap references›
type_synonym heap_rep = nat ― ‹representable values›

record heap =
  arrays :: "typerep → addr → heap_rep list"
  refs :: "typerep → addr → heap_rep"
  lim  :: addr

definition empty :: heap where
  "empty = (arrays = (λ_ _. []), refs = (λ_ _. 0), lim = 0)"

datatype 'a array = Array addr ― ‹note the phantom type 'a›
datatype 'a ref = Ref addr ― ‹note the phantom type 'a›

primrec addr_of_array :: "'a array → addr" where
  "addr_of_array (Array x) = x"

primrec addr_of_ref :: "'a ref → addr" where
  "addr_of_ref (Ref x) = x"

lemma addr_of_array_inj [simp]:
  "addr_of_array a = addr_of_array a' ⟷ a = a'"
  by (cases a, cases a') simp_all

lemma addr_of_ref_inj [simp]:
  "addr_of_ref r = addr_of_ref r' ⟷ r = r'"
  by (cases r, cases r') simp_all

instance array :: (type) countable
  by (rule countable_classI [of addr_of_array]) simp

instance ref :: (type) countable
  by (rule countable_classI [of addr_of_ref]) simp

instance array :: (type) heap ..

instance ref :: (type) heap ..


text ‹Syntactic convenience›

setup ‹
 Sign.add_const_constraint (const_name‹Array›, SOME typ‹nat → 'a::heap array›)
 #> Sign.add_const_constraint (const_name‹Ref›, SOME typ‹nat → 'a::heap ref›)
 #> Sign.add_const_constraint (const_name‹addr_of_array›, SOME typ‹'a::heap array → nat›)
 #> Sign.add_const_constraint (const_name‹addr_of_ref›, SOME typ‹'a::heap ref → nat›)
 
›

hide_const (open) empty

end

Messung V0.5 in Prozent
C=72 H=100 G=86

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-09-29) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1126864
#Domains=1897691