Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =======================================================================================================================================
  2. =======================================================================================================================================
  3. =======================================================================================================================================
  4.             The Actual File is below this line
  5. =======================================================================================================================================
  6. =======================================================================================================================================
  7. =======================================================================================================================================
  8.  
  9. Package sequent
  10.  
  11. =============================================
  12.                   export
  13. =============================================
  14.  
  15. =============================================
  16. %%              Expectations
  17. =============================================
  18. Expect
  19.     validSequent?: Sequent -> Boolean
  20.     %: validSequent?(x) is true if sequent x is
  21.     %: valid.
  22.     ;
  23.     isBasic?: Sequent -> Boolean
  24.     %: Returns true if the given Sequent is
  25.     %: basic. Used by validSequent?.
  26.     ;
  27.     moveToFront: ([Formula],FormulaTester) -> [Formula]
  28.     %: Finds the first item in the [Formula]
  29.     %: which satisfies the FormulaTester, then
  30.     %: moves it to the front of the list.
  31.     %: In the event that no objects satisfy it,
  32.     %: the list is returned unaltered.
  33. %Expect
  34.  
  35. =============================================
  36. %%             Binary operators
  37. =============================================
  38.  
  39. Operator
  40.   |-  (++);
  41.   \/  (+);
  42.   /\  (*);
  43.   ==> (opL5)
  44. %Operator
  45.  
  46. =============================================
  47. %%             Formula
  48. =============================================
  49.  
  50. Type Formula =
  51.     vbl String
  52.   | neg Formula
  53.   | Formula /\ Formula
  54.   | Formula \/ Formula
  55.   | Formula ==> Formula
  56. with
  57.   $, show, ==
  58. %Type
  59.  
  60. =============================================
  61. %%             Sequent
  62. =============================================
  63.  
  64. Type Sequent =
  65.   [Formula] |- [Formula]
  66. with
  67.   $, show, ==
  68. %Type
  69.  
  70. Expect
  71.   valid?: Formula -> Boolean
  72.  
  73.     %: valid?(f) is true if formula f is valid.
  74. %Expect
  75.  
  76. =============================================
  77.                 implementation
  78. =============================================
  79.  
  80. Import "collect/search".
  81.  
  82. Abbrev
  83.   MaybeSequents = Maybe of [Sequent];
  84.   FormulaTester = Formula -> Boolean;
  85.   Rule          = Sequent -> MaybeSequents
  86. %Abbrev
  87.  
  88. =============================================
  89. %%             Valid Sequent Tester
  90. =============================================
  91.  
  92. Define
  93.     validSequent? (x) = true
  94. %Define
  95.  
  96. =============================================
  97. %%             Is Basic
  98. =============================================
  99.  
  100. Define
  101.     case isBasic? ([] |- ?) = false;
  102.     case isBasic? (h::? |- back) = true when h `in` back
  103.     else isBasic? (?::t |- back) = isBasic?(t |- back);            
  104. %Define
  105.  
  106. =============================================
  107. %%             Move to Front
  108. =============================================
  109.  
  110. Define
  111.     case moveToFront ( list, tester ) = list when someSatisfy tester list
  112.     else moveToFront ( list, tester ) = (select tester list)::(list -/ (select tester list));
  113. %Define
  114.  
  115. %Package
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement