Skip to content

Commit

Permalink
Made temporary tmEqn
Browse files Browse the repository at this point in the history
  • Loading branch information
samm82 committed Jun 21, 2019
1 parent 17a7620 commit bf2509d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
16 changes: 5 additions & 11 deletions code/drasil-example/Drasil/GlassBR/TMods.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Drasil.GlassBR.TMods (tMods, pbIsSafe, lrIsSafe) where

import Language.Drasil
import Theory.Drasil (TheoryModel, mkQuantDef, tm)
import Theory.Drasil (TheoryModel, mkQuantDef, tmEqn)
import Utils.Drasil

import Control.Lens ((^.))
Expand All @@ -24,13 +24,10 @@ tMods = [pbIsSafe, lrIsSafe]


lrIsSafe :: TheoryModel
lrIsSafe = tm (cw lrIsSafeQD)
[qw isSafeLoad, qw tmLRe, qw tmDemand] ([] :: [ConceptChunk])
[lrIsSafeQD] [sy isSafeLoad $= sy tmLRe $> sy tmDemand] [] [makeCite astm2009]
"isSafeLoad" [lrIsSafeDesc]
lrIsSafe = tmEqn lrIsSafeQD [] [makeCite astm2009] "isSafeLoad" [lrIsSafeDesc]

lrIsSafeQD :: QDefinition
lrIsSafeQD = mkQuantDef isSafeLoad (sy tmLRe $> sy tmDemand)
lrIsSafeQD = mkQuantDef isSafeLoad (sy isSafeLoad $= sy tmLRe $> sy tmDemand)

This comment has been minimized.

Copy link
@samm82

samm82 Jun 21, 2019

Author Collaborator

For IMs, the equation doesn't include the output (ie. a force IM would have m * a), while the equation for a TM does (ie. a force TM: F = m * a). Is this OK to manually enforce this, or should there be a separate mkQuantDef that implicitly adds the output to the equation? @JacquesCarette

This comment has been minimized.

Copy link
@JacquesCarette

JacquesCarette Jun 21, 2019

Owner

If things are 'done right', then when a model is definitional, the quantity to be defined is (like in the above) isSafeLoad, and its definition is the rhs of the equation.
This was done in the old QDef branch. i.e. the 'equation' part of a mkQuantDef should instead be a value.

This comment has been minimized.

Copy link
@samm82

samm82 Jun 21, 2019

Author Collaborator

So it's just a matter of rendering the TMs differently then. ie. When displaying the TM equation, if the QDefinition is mkQuant quan eq it should essentially display E (sy quan $= eq) for the Equation. (Let me know if I'm understanding this wrong.) @JacquesCarette

This comment has been minimized.

Copy link
@JacquesCarette

JacquesCarette Jun 21, 2019

Owner

That's exactly right - and what I had implemented before.

This comment has been minimized.

Copy link
@samm82

samm82 Jun 21, 2019

Author Collaborator

Great! Now to track down that code

This comment has been minimized.

Copy link
@JacquesCarette

JacquesCarette Jun 21, 2019

Owner

Should be trackeable from #1373

This comment has been minimized.

Copy link
@samm82

samm82 Jun 21, 2019

Author Collaborator

I can't find the change in #1373 or in the branch itself, but I think this will be easier (and will make more sense) after #1601

This comment has been minimized.

Copy link
@JacquesCarette

JacquesCarette Jun 24, 2019

Owner

Agreed. But let's try to really hurry on #1601 (sorry, I was slow on looking at that)!


lrIsSafeDesc :: Sentence
lrIsSafeDesc = tModDesc isSafeLoad s ending
Expand All @@ -41,13 +38,10 @@ lrIsSafeDesc = tModDesc isSafeLoad s ending
titleize demandq) `isThe` (demandq ^. defn)

pbIsSafe :: TheoryModel
pbIsSafe = tm (cw pbIsSafeQD)
[qw isSafeProb, qw probFail, qw pbTolfail] ([] :: [ConceptChunk])
[pbIsSafeQD] [sy isSafeProb $= sy probFail $< sy pbTolfail] [] [makeCite astm2009]
"isSafeProb" [pbIsSafeDesc]
pbIsSafe = tmEqn pbIsSafeQD [] [makeCite astm2009] "isSafeProb" [pbIsSafeDesc]

pbIsSafeQD :: QDefinition
pbIsSafeQD = mkQuantDef isSafeProb (sy probFail $< sy pbTolfail)
pbIsSafeQD = mkQuantDef isSafeProb (sy isSafeProb $= sy probFail $< sy pbTolfail)

pbIsSafeDesc :: Sentence
pbIsSafeDesc = tModDesc isSafeProb s ending
Expand Down
2 changes: 1 addition & 1 deletion code/drasil-theory/Theory/Drasil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Theory.Drasil (
, inCons, outCons, imOutput, imInputs
, getEqMod
-- Theory
, Theory(..), TheoryModel, tm, tmNoRefs
, Theory(..), TheoryModel, tm, tmEqn, tmNoRefs
) where

import Theory.Drasil.DataDefinition (DataDefinition, mkQuantDef,
Expand Down
15 changes: 5 additions & 10 deletions code/drasil-theory/Theory/Drasil/Theory.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# Language TemplateHaskell #-}
module Theory.Drasil.Theory (Theory(..), TheoryModel, tm, tmNoRefs) where
module Theory.Drasil.Theory (Theory(..), TheoryModel, tm, tmEqn, tmNoRefs) where

import Language.Drasil
import Data.Drasil.IdeaDicts (thModel)
Expand Down Expand Up @@ -75,16 +75,11 @@ tm c _ _ _ _ _ [] _ = error $ "Source field of " ++ c ^. uid ++ " is emp
tm c0 q c1 dq inv dfn r lbe =
TM (cw c0) [] [] (map qw q) (map cw c1) dq inv dfn r (shortname' lbe)
(prependAbrv thModel lbe)
{-}
tmEqn :: QDefinition ->
[q] -> [c1] -> [QDefinition] ->
[Relation] -> [QDefinition] -> [Reference] ->
String -> [Sentence] -> TheoryModel
tm c _ _ _ _ _ [] _ = error $ "Source field of " ++ c ^. uid ++ " is empty"
tm c0 q c1 dq inv dfn r lbe =
TM (cw c0) [] [] (map qw q) (map cw c1) dq inv dfn r (shortname' lbe)

tmEqn :: QDefinition -> [QDefinition] -> [Reference] -> String -> [Sentence] -> TheoryModel
tmEqn c _ [] _ = error $ "Source field of " ++ c ^. uid ++ " is empty"
tmEqn q dfn r lbe = TM (cw q) [] [] [qw q] [] [q] [q ^. defnExpr] dfn r (shortname' lbe)

This comment has been minimized.

Copy link
@samm82

samm82 Jun 21, 2019

Author Collaborator

As (partially) noted by the FIXME on lines 67-69, I think the current TM definition is quite broken. My new work-in-progress tmEqn passes in the same quantity multiple times, which demonstrates a design flaw. I think the definition of a Theory should be:

data TheoryModel = TM 
  { _mk   :: ModelKind
  , _vctx :: [TheoryModel]
  , _spc  :: [SpaceDefn]
  , _dfun :: [QDefinition]
  , _ref  :: [Reference]
  ,  lb   :: ShortName
  ,  ra   :: String
  , _notes :: [Sentence]
  }

where ModelKind would hold the QDefinition (or RelationConcept). While the _vctx :: [TheoryModel] and _spc :: [SpaceDefn] fields are currently always initialized to be empty (by the constructors), I'm pretty sure that they're to be implemented in the future, so I'll leave them be. My only other uncertainty is _dfun :: [QDefinition] - it is always an empty list when the constructors are called in the examples, and I'm not sure what its purpose is, so we might be able to remove it. Does this whole proposal sound good @JacquesCarette?

This comment has been minimized.

Copy link
@JacquesCarette

JacquesCarette Jun 21, 2019

Owner

Can you flesh this out into an issue? I need to think about it some more.

(prependAbrv thModel lbe)
-}

tmNoRefs :: (Concept c0, Quantity q, MayHaveUnit q, Concept c1) => c0 ->
[q] -> [c1] -> [QDefinition] -> [Relation] -> [QDefinition] ->
Expand Down

0 comments on commit bf2509d

Please sign in to comment.