Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  OO.thy

  Sprache: Isabelle
 

theory OO imports Main begin

subsection "Towards an OO Language: A Language of Records"

(* FIXME: move to HOL/Fun *)
abbreviation fun_upd2 :: "('a 'b 'c) 'a 'b 'c 'a 'b 'c"
  (_/'((2_,_ :=/ _)') [1000,0,0,0900)
where "f(x,y := z) == f(x := (f x)(y := z))"

type_synonym addr = nat
datatype ref = null | Ref addr

type_synonym obj = "string ref"
type_synonym venv = "string ref"
type_synonym store = "addr obj"

datatype exp =
  Null |
  New |
  V string |
  Faccess exp string       (_/_ [63,100063) |
  Vassign string exp       ((_ ::=/ _) [1000,6162) |
  Fassign exp string exp   ((__ ::=/ _) [63,0,6262) |
  Mcall exp string exp     ((_/_🚫) [63,0,063) |
  Seq exp exp              (_;/ _ [61,6060) |
  If bexp exp exp          (IF _/ THEN (2_)/ ELSE (2_) [0,0,6161)
and bexp = B bool | Not bexp | And bexp bexp | Eq exp exp

type_synonym menv = "string exp"
type_synonym config = "venv × store × addr"

inductive
  big_step :: "menv exp × config ref × config bool"
    ((_ / (_/ _)) [60,0,6055and
  bval ::  "menv bexp × config bool × config bool"
    (_ _ _ [60,0,6055)
where
Null:
"me (Null,c) (null,c)" |
New:
"me (New,ve,s,n) (Ref n,ve,s(n := (λf. null)),n+1)" |
Vaccess:
"me (V x,ve,sn) (ve x,ve,sn)" |
Faccess:
"me (e,c) (Ref a,ve',s',n') ==>
 me (ef,c) (s' a f,ve',s',n')" |
Vassign:
"me (e,c) (r,ve',sn') ==>
 me (x ::= e,c) (r,ve'(x:=r),sn')" |
Fassign:
"[ me (oe,c1) (Ref a,c2); me (e,c2) (r,ve3,s3,n3) ] ==>
 me (oef ::= e,c1) (r,ve3,s3(a,f := r),n3)" |
Mcall:
"[ me (oe,c1) (or,c2); me (pe,c2) (pr,ve3,sn3);
   ve = (λx. null)(''this'' := or, ''param'' := pr);
   me (me m,ve,sn3) (r,ve',sn4) ]
  ==>
 me (oem<pe>,c1) (r,ve3,sn4)" for or |
Seq:
"[ me (e1,c1) (r,c2); me (e2,c2) c3 ] ==>
 me (e1; e2,c1) c3" |
IfTrue:
"[ me (b,c1) (True,c2); me (e1,c2) c3 ] ==>
 me (IF b THEN e1 ELSE e2,c1) c3" |
IfFalse:
"[ me (b,c1) (False,c2); me (e2,c2) c3 ] ==>
 me (IF b THEN e1 ELSE e2,c1) c3" |

"me (B bv,c) (bv,c)" |

"me (b,c1) (bv,c2) ==> me (Not b,c1) (¬bv,c2)" |

"[ me (b1,c1) (bv1,c2); me (b2,c2) (bv2,c3) ] ==>
 me (And b1 b2,c1) (bv1bv2,c3)" |

"[ me (e1,c1) (r1,c2); me (e2,c2) (r2,c3) ] ==>
 me (Eq e1 e2,c1) (r1=r2,c3)"


code_pred (modes: i => i => o => bool) big_step .

textExample: natural numbers encoded as objects with a predecessor
 . Null is zero. Method succ adds an object in front, method add
  as many objects in front as the parameter specifies.

 , the method bodies:


definition
"m_succ = (''s'' ::= New)''pred'' ::= V ''this''; V ''s''"

definition "m_add =
  IF Eq (V ''param'') Null
  THEN V ''this''
  ELSE V ''this''''succ''<Null>''add''<V ''param''''pred''>"

textThe method environment:
definition
"menv = (λm. Null)(''succ'' := m_succ, ''add'' := m_add)"

textThe main code, adding 1 and 2:
definition "main =
  ''1'' ::= Null''succ''<Null>;
  ''2'' ::= V ''1''''succ''<Null>;
  V ''2'' ''add'' <V ''1''>"

textExecution of semantics. The final variable environment and store are
  into lists of references based on given lists of variable and field
  to extract.


values
 "{(r, map ve' [''1'',''2''], map (λn. map (s' n)[''pred'']) [0..<n])|
    r ve' s' n. menv (main, λx. null, nth[], 0) (r,ve',s',n)}"

end

Messung V0.5 in Prozent
C=84 H=87 G=85

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-06-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

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik