drasil from generating code to generating software
play

Drasil: From generating code to generating software Jacques - PowerPoint PPT Presentation

Drasil: From generating code to generating software Jacques Carette, Spencer Smith, Dan Szymczak and Steven Palmer McMaster University WG 2.11, August 2016 Meeting Context software certification Context software (re)certification Context


  1. Drasil: From generating code to generating software Jacques Carette, Spencer Smith, Dan Szymczak and Steven Palmer McMaster University WG 2.11, August 2016 Meeting

  2. Context software certification

  3. Context software (re)certification

  4. Context software (re)certification ◮ All software artefacts as evidence: ◮ requirements, software specification, software design, code, tests, “theory manual”, user manual, . . .

  5. Context software (re)certification ◮ All software artefacts as evidence: ◮ requirements, software specification, software design, code, tests, “theory manual”, user manual, . . . ◮ Massive amounts of knowledge duplication ◮ Implies that either ◮ non-code artefacts do not get maintained well enough, OR ◮ are felt to be an expensive nuisance ◮ duplication harms traceability

  6. Example SRS/LP (see document)

  7. Literate Programming What can we learn from it?

  8. Literate Programming What can we learn from it? 1. Code in most languages is not well organized for human understanding.

  9. Literate Programming What can we learn from it? 1. Code in most languages is not well organized for human understanding. 2. Code in some languages can not efficiently be broken down into very small pieces.

  10. Literate Programming What can we learn from it? 1. Code in most languages is not well organized for human understanding. 2. Code in some languages can not efficiently be broken down into very small pieces. 3. Chunk labels add convenient traceability information.

  11. Drasil Ideas behind our prototype: 1. no information duplication

  12. Drasil Ideas behind our prototype: 1. no information duplication 2. Recipes used to weave together information into documents / software artefacts.

  13. Drasil Ideas behind our prototype: 1. no information duplication 2. Recipes used to weave together information into documents / software artefacts. Implies: ◮ Bug in one place, bugs everywhere!

  14. Drasil Ideas behind our prototype: 1. no information duplication 2. Recipes used to weave together information into documents / software artefacts. Implies: ◮ Bug in one place, bugs everywhere! ◮ Huge up-front investment.

  15. Drasil Ideas behind our prototype: 1. no information duplication 2. Recipes used to weave together information into documents / software artefacts. Implies: ◮ Bug in one place, bugs everywhere! ◮ Huge up-front investment. ◮ Doesn’t work if you have no theory.

  16. Example (high level) SRS ( verbose ) SRS ( LaTeX ) SRS ( html ) MG MIS Test cases C Code) Matlab ( no Makefile ( checks ) checks ) Recipes h c is the heat −∇ · q + q ′′′ W = J/s = transfer coeff kg m 2 s − 3 = ρ C ∂ T between clad ∂ t and coolant uncertainty, typical val- L > 0 ues etc.

  17. Sanity checks Var Constraints Typical Value Uncertainty L L > 0 1.5 m 10% D > 0 0.412 m 10% D 0.05 m 3 V P V P > 0 10% 1.2 m 2 A P A P > 0 10% 1007 kg/m 3 ρ P > 0 10% ρ P � t � t E W = h C A C ( T C − T W ( t )) dt − h P A P ( T W ( t ) − T P ( t )) dt 0 0 ◮ Sanity checks captured and reused ◮ Generate guards against invalid input ◮ Generate test cases

  18. Reusability Ref T1 Label Conservation of energy −∇ · q + q ′′′ = ρ C ∂ T Eq ∂ t Desc. Conservation of energy for time varying heat trans- fer in a material of specific heat capacity C and den- sity ρ , where q is the thermal flux vector, q ′′′ is the volumetric heat generation, T is the temperature, ∇ is the del operator and t is time.

  19. Basic Drasil Design Chunk ( name ) Concept ( description ) Quantity Unit ( unit ) ( symbol ) Unital RelationChunk DefEqChunk ( relation ) ( equation )

  20. Example Recipe vars : : [ EqChunk ] vars = [ h g , h c ] s1 , s2 , s3 , s4 : : LayoutObj s1= t a b l e o f u n i t s s i u n i t s s2=table of symbols vars s3=Section 0 (S ” Data D e f i n i t i o n s ” ) $ map ( D e f i n i t i o n . Data ) vars s4=Section 0 (S ”Code” ) $ map ( CodeBlock . toCode CLang Calc ) [ h c ] srs : : Quantity s = > [ s ] − > String − > [ LayoutObj ] − > Document srs l s author body = Document ( (S ”SRS f o r ” ) : + : ( foldr1 ( : + : ) ( intersperse (S ” and ” ) ( map ( \ x − > U $ x ˆ . symbol ) l s ) ) ) ) (S author ) body srsBody : : Document srsBody = srs vars ” Spencer Smith ” [ s1 , s2 , s3 , s4 ]

  21. Example Recipe table of symbols : : ( Unit s , Quantity s ) = > [ s ] − > LayoutObj table of symbols l s =Section 0 (S ” Table of Sym” ) [ i n t r o , table l s ] table : : ( Unit s , Quantity s ) = > [ s ] − > LayoutObj table l s =Table [S ” Symbol ” ,S ” Description ” ,S ” Units ” ] ( mkTable [ ( \ ch − > U ( ch ˆ . symbol ) ) , ( \ ch − > ch ˆ . descr ) , ( \ ch − > Sy $ ch ˆ . u n i t ) ] l s ) (S ” Table of Symbols ” ) False

  22. Example Recipe table of symbols : : ( Unit s , Quantity s ) = > [ s ] − > LayoutObj table of symbols l s =Section 0 (S ” Table of Sym” ) [ i n t r o , table l s ] table : : ( Unit s , Quantity s ) = > [ s ] − > LayoutObj table l s =Table [S ” Symbol ” ,S ” Description ” ,S ” Units ” ] ( mkTable [ ( \ ch − > U ( ch ˆ . symbol ) ) , ( \ ch − > ch ˆ . descr ) , ( \ ch − > Sy $ ch ˆ . u n i t ) ] l s ) (S ” Table of Symbols ” ) False Classy Optics class Chunk c where name : : Simple Lens c String class Chunk c = > Concept c where descr : : Simple Lens c Sentence

  23. Units Recipe fundamentals : : [ FundUnit ] fundamentals = [ metre , kilogram , second , kelvin , mole , ampere , candela ] derived : : [ DerUChunk ] derived = [ centigrade , joule , watt , calorie , k i l o w a t t ] s i u n i t s : : [ UnitDefn ] s i u n i t s = map UU fundamentals ++ map UU derived − − − − − − − − − − − − − Fundamental SI Units − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − fund : : String − > String − > String − > FundUnit fund nam desc sym = UD (CC nam (S desc ) ) (UName $ Atomic sym) metre , kilogram , second , kelvin , mole , ampere , candela : : FundUnit metre = fund ” Metre ” ” length ” ”m” kilogram = fund ” Kilogram ” ”mass” ” kg ” second = fund ” Second ” ” time ” ” s ” kelvin = fund ” Kelvin ” ” temperature ” ”K” mole = fund ” Mole ” ” amount of substance ” ” mol ” ampere = fund ”Ampere” ” e l e c t r i c current ” ”A” candela = fund ” Candela ” ” luminous i n t e n s i t y ” ” cd ”

  24. The h c Chunk 2 k c h b h c = 2 k c + τ c h b h e a t tr a n sf e r : : DerUChunk h e a t tr a n sf e r = DUC (UD ht con ht symb ) heat transfer eqn ht con : : ConceptChunk ht con = makeCC ” Heat t r a n s f e r ” ” Heat t r a n s f e r ” ht symb : : USymb ht symb = from udefn heat transfer eqn heat transfer eqn = USynonym ( UProd [ kilogram ˆ . unit , UPow ( second ˆ . u n i t ) ( − 3) , UPow ( centigrade ˆ . u n i t ) ( − 1)]) h c eq : : Expr h c eq = 2 ∗ (C k c ) ∗ (C h b ) / ( 2 ∗ (C k c )+(C tau c ) ∗ (C h b ) ) h c : : EqChunk h c = fromEqn ” h c ” (S ” convective heat t r a n s f e r . . . ” ) ( lH ‘ sub ‘ lC ) h e a t tr a n sf e r h c eq

  25. Design Documentation Control Module (M7) Temperature ODE Solver Energy Equations Plotting Module Input Format Output Format ODEs Module Module (M9) Module (M6) (M10) Module (M2) Module (M4) (M5) Input Parameters Hardware Hiding Module (M3) Module (M1) Sequence Data Structure Module (M8)

  26. Approach ◮ Case studies ◮ Solar water heating tank ◮ Slope stability analysis ◮ Glass safety analysis ◮ Game physics engine ◮ (medium-sized industrial code) ◮ Small chunks of knowledge ◮ Aggressively look for patterns and capture ◮ Currently working on capturing design decisions

  27. Approach ◮ Case studies ◮ Solar water heating tank ◮ Slope stability analysis ◮ Glass safety analysis ◮ Game physics engine ◮ (medium-sized industrial code) ◮ Small chunks of knowledge ◮ Aggressively look for patterns and capture ◮ Currently working on capturing design decisions

Recommend


More recommend