Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  C_like.thy

  Sprache: Isabelle
 

theory C_like imports Main begin

subsection "A C-like Language"

type_synonym state = "nat nat"

datatype aexp = N nat | Deref aexp (!) | Plus aexp aexp

fun aval :: "aexp state nat" where
"aval (N n) s = n" |
"aval (!a) s = s(aval a s)" |
"aval (Plus a1 a2) s = aval a1 s + aval a2 s"

datatype bexp = Bc bool | Not bexp | And bexp bexp | Less aexp aexp

primrec bval :: "bexp state bool" where
"bval (Bc v) _ = v" |
"bval (Not b) s = (¬ bval b s)" |
"bval (And b1 b2) s = (if bval b1 s then bval b2 s else False)" |
"bval (Less a1 a2) s = (aval a1 s < aval a2 s)"


datatype
  com = SKIP 
      | Assign aexp aexp         (_ ::= _ [616161)
      | New    aexp aexp
      | Seq    com  com          (_;/ _  [606160)
      | If     bexp com com     ((IF _/ THEN _/ ELSE _)  [006161)
      | While  bexp com         ((WHILE _/ DO _)  [06161)

inductive
  big_step :: "com × state × nat state × nat bool"  (infix  55)
where
Skip:    "(SKIP,sn) sn" |
Assign:  "(lhs ::= a,s,n) (s(aval lhs s := aval a s),n)" |
New:     "(New lhs a,s,n) (s(aval lhs s := n), n+aval a s)"  |
Seq:    "[ (c1,sn1) sn2; (c2,sn2) sn3 ] ==>
          (c1;c2, sn1) sn3" |

IfTrue:  "[ bval b s; (c1,s,n) tn ] ==>
         (IF b THEN c1 ELSE c2, s,n) tn" |
IfFalse: "[ ¬bval b s; (c2,s,n) tn ] ==>
         (IF b THEN c1 ELSE c2, s,n) tn" |

WhileFalse: "¬bval b s ==> (WHILE b DO c,s,n) (s,n)" |
WhileTrue:
  "[ bval b s1; (c,s1,n) sn2; (WHILE b DO c, sn2) sn3 ] ==>
   (WHILE b DO c, s1,n) sn3"

code_pred big_step .

declare [[values_timeout = 3600]]

textExamples:

definition
"array_sum =
 WHILE Less (!(N 0)) (Plus (!(N 1)) (N 1))
 DO ( N 2 ::= Plus (!(N 2)) (!(!(N 0)));
      N 0 ::= Plus (!(N 0)) (N 1) )"

text To show the first n variables in a typnat nat state:
definition 
  "list t n = map t [0 ..< n]"

values "{list t n |t n. (array_sum, nth[3,4,0,3,7],5) (t,n)}"

definition
"linked_list_sum =
 WHILE Less (N 0) (!(N 0))
 DO ( N 1 ::= Plus(!(N 1)) (!(!(N 0)));
      N 0 ::= !(Plus(!(N 0))(N 1)) )"

values "{list t n |t n. (linked_list_sum, nth[4,0,3,0,7,2],6) (t,n)}"

definition
"array_init =
 New (N 0) (!(N 1)); N 2 ::= !(N 0);
 WHILE Less (!(N 2)) (Plus (!(N 0)) (!(N 1)))
 DO ( !(N 2) ::= !(N 2);
      N 2 ::= Plus (!(N 2)) (N 1) )"

values "{list t n |t n. (array_init, nth[5,2,7],3) (t,n)}"

definition
"linked_list_init =
 WHILE Less (!(N 1)) (!(N 0))
 DO ( New (N 3) (N 2);
      N 1 ::= Plus (!(N 1)) (N 1);
      !(N 3) ::= !(N 1);
      Plus (!(N 3)) (N 1) ::= !(N 2);
      N 2 ::= !(N 3) )"

values "{list t n |t n. (linked_list_init, nth[2,0,0,0],4) (t,n)}"

end

Messung V0.5 in Prozent
C=91 H=100 G=95

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-30) ¤

*© 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