Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. Converted form of expression/paragraph:
  4.  
  5. - 102.   Pattern
  6. - 102.     ~compareX     =>
  7. - 102.       Ensure compareX?(target) else testX %Ensure
  8.  
  9. -----Types:
  10.  
  11. - 102.     compareX        : ExceptionType
  12. - 102.     compareX?       : (ExceptionType -> Boolean)
  13. - 102.     target          : ExceptionType
  14.  
  15. - 102.   %Pattern
  16.  
  17. -----Types:
  18.  
  19. - 102.   compareX        : ExceptionType
  20. - 102.   compareX?       : (ExceptionType -> Boolean)
  21. - 102.   target          : ExceptionType
  22. - 102.   compareX?       : (ExceptionType -> Boolean)
  23.  
  24.  
  25.  
  26. ---------------------------------------------------
  27. --- Summary of inference steps leading to error ---
  28.  
  29. ---------------------------------------------------
  30.  
  31.   Line 102. If function f has type S -> T then its argument must have type S.
  32.   Function:
  33.   - 102.  compareX?
  34.  
  35.          : (ExceptionType -> Boolean)
  36.  
  37.     Argument:
  38.   - 102.  target
  39.  
  40.          : ExceptionType
  41.  
  42. ---------------------------------------------------
  43.  
  44.  
  45. =======================================================================================================================================
  46. =======================================================================================================================================
  47. =======================================================================================================================================
  48.             The Actual File is below this line
  49. =======================================================================================================================================
  50. =======================================================================================================================================
  51. =======================================================================================================================================
  52.  
  53. Package sequent
  54.  
  55. =============================================
  56.                   export
  57. =============================================
  58.  
  59. =============================================
  60. %%              Expectations
  61. =============================================
  62. Expect
  63.     validSequent?: Sequent -> Boolean
  64.     %: validSequent?(x) is true if sequent x is
  65.     %: valid.
  66.     ;
  67.     isBasic?: Sequent -> Boolean
  68.     %: Returns true if the given Sequent is
  69.     %: basic. Used by validSequent?.
  70.     ;
  71.     moveToFront: ([Formula],FormulaTester) -> [Formula]
  72.     %: Finds the first item in the [Formula]
  73.     %: which satisfies the FormulaTester, then
  74.     %: moves it to the front of the list.
  75.     %: In the event that no objects satisfy it,
  76.     %: the list is returned unaltered.
  77. %Expect
  78.  
  79. =============================================
  80. %%             Binary operators
  81. =============================================
  82.  
  83. Operator
  84.   |-  (++);
  85.   \/  (+);
  86.   /\  (*);
  87.   ==> (opL5)
  88. %Operator
  89.  
  90. =============================================
  91. %%             Formula
  92. =============================================
  93.  
  94. Type Formula =
  95.     vbl String
  96.   | neg Formula
  97.   | Formula /\ Formula
  98.   | Formula \/ Formula
  99.   | Formula ==> Formula
  100. with
  101.   $, show, ==
  102. %Type
  103.  
  104. =============================================
  105. %%             Sequent
  106. =============================================
  107.  
  108. Type Sequent =
  109.   [Formula] |- [Formula]
  110. with
  111.   $, show, ==
  112. %Type
  113.  
  114. Expect
  115.   valid?: Formula -> Boolean
  116.  
  117.     %: valid?(f) is true if formula f is valid.
  118. %Expect
  119.  
  120. =============================================
  121.                 implementation
  122. =============================================
  123.  
  124. Import "collect/search".
  125.  
  126. Abbrev
  127.   MaybeSequents = Maybe of [Sequent];
  128.   FormulaTester = Formula -> Boolean;
  129.   Rule          = Sequent -> MaybeSequents
  130. %Abbrev
  131.  
  132. =============================================
  133. %%             Valid Sequent Tester
  134. =============================================
  135.  
  136. Define
  137.     validSequent? (x) = true
  138. %Define
  139.  
  140. =============================================
  141. %%             Is Basic
  142. =============================================
  143.  
  144. Define
  145.     case isBasic? ([] |- ?) = false;
  146.     case isBasic? (h::? |- back) = true when h `in` back
  147.     else isBasic? (?::t |- back) = isBasic?(t |- back);            
  148. %Define
  149.  
  150. =============================================
  151. %%             Move to Front
  152. =============================================
  153.  
  154. Define
  155.     case moveToFront ( list, tester ) = list when someSatisfy tester list
  156.     else moveToFront ( list, tester ) = (select tester list)::(list -/ (select tester list));
  157. %Define
  158.  
  159. %Package
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement