|  | 
|  | 1 | +(use-macros "../milkyway/prelude.sg") | 
|  | 2 | + | 
|  | 3 | +''' ======================================================== ''' | 
|  | 4 | +''' FIRST-ORDER MULTIPLICATIVE LINEAR LOGIC PROOF-STRUCTURES ''' | 
|  | 5 | +''' ======================================================== ''' | 
|  | 6 | +' FOMLL proof-structures are MLL proof-structures | 
|  | 7 | +' (cf. examples/proofnets/mll.sg) which contain only cut and axiom | 
|  | 8 | +' constructors. | 
|  | 9 | +' | 
|  | 10 | +' An axiom between vertices x and y becomes the binary postive star | 
|  | 11 | +[+x +y] | 
|  | 12 | +' | 
|  | 13 | +' A cut between vertices y and z becomes the binary negative star | 
|  | 14 | +' which will link two axioms | 
|  | 15 | +[-y -z] | 
|  | 16 | + | 
|  | 17 | +''' ======================================================== ''' | 
|  | 18 | +''' FOR EXAMPLE ''' | 
|  | 19 | +''' ======================================================== ''' | 
|  | 20 | +' MLL proof-structures with only cuts and axioms yield partitions | 
|  | 21 | +' corresponding to axiom links with links between natural numbers. | 
|  | 22 | +' | 
|  | 23 | +'   ax    ax    ax | 
|  | 24 | +'   __    __    __ | 
|  | 25 | +'  /  \  /  \  /  \ | 
|  | 26 | +'  1  2  3  4  5  6 | 
|  | 27 | +'  \   \____/__/ | 
|  | 28 | +'   \   cut/ | 
|  | 29 | +'    \____/ | 
|  | 30 | +'     cut | 
|  | 31 | +' | 
|  | 32 | +'     becomes | 
|  | 33 | +' | 
|  | 34 | +'   [1, 2]  [3, 4]  [5, 6] | 
|  | 35 | +'    \   \______/____/ | 
|  | 36 | +'     \________/ | 
|  | 37 | +' | 
|  | 38 | +'    corresponding to the constellation | 
|  | 39 | +(:= x { | 
|  | 40 | +  [+1 +2] [+3 +4] [+5 +6] | 
|  | 41 | +      [-1 -4]  [-2 -5] | 
|  | 42 | +}) | 
|  | 43 | +'     which evaluates into | 
|  | 44 | +' | 
|  | 45 | +'   [1, 6]  [3, 4] | 
|  | 46 | +'    \          / | 
|  | 47 | +'     \________/ | 
|  | 48 | +' | 
|  | 49 | +'    then | 
|  | 50 | + | 
|  | 51 | +'   [3, 6] | 
|  | 52 | +' | 
|  | 53 | +' This corresponds to the following execution in stellogen | 
|  | 54 | +' in which [-3 +3] is a way to initiate a starting point in computation | 
|  | 55 | +(:= comp (exec #x @[-3 +3])) | 
|  | 56 | +(:= res { [+3 +6] }) | 
|  | 57 | +(== #comp #res) | 
|  | 58 | + | 
|  | 59 | + | 
|  | 60 | +''' ======================================================== ''' | 
|  | 61 | +''' SUCCESSFUL TYPING ''' | 
|  | 62 | +''' ======================================================== ''' | 
|  | 63 | +' We want to check that we have a proof of identity | 
|  | 64 | +' (A ⊗ B) -o (A ⊗ B) | 
|  | 65 | +' with the following constellation (two axioms) | 
|  | 66 | +(:= proof? { [+1 +3] [+2 +4]}) | 
|  | 67 | + | 
|  | 68 | +' We do it in two steps. | 
|  | 69 | +' 1. checking the structure of the candidate | 
|  | 70 | +' 2. checking that the duality of variables is coherent | 
|  | 71 | + | 
|  | 72 | +' Specification with tests returning [ok] when interacting | 
|  | 73 | +' with a constellation having the shape of a proof of | 
|  | 74 | +' (_ ⊗ _) -o (_ ⊗ _) | 
|  | 75 | +(spec (-o (⊗ A B) (⊗ C D)) { | 
|  | 76 | +  [+testrl [ | 
|  | 77 | +    [-A -B +(⊗ A B)] | 
|  | 78 | +    [-C] [-D +(⅋ C D)] | 
|  | 79 | +    [-(⊗ A B) +concl] [-(⅋ C D)] | 
|  | 80 | +    @[-concl ok]]] | 
|  | 81 | +  [+testrr [ | 
|  | 82 | +    [-A -B +(⊗ A B)] | 
|  | 83 | +    [-C] [-D +(⅋ C D)] | 
|  | 84 | +    [-(⊗ A B)] [+concl -(⅋ C D)] | 
|  | 85 | +    @[-concl ok]]] | 
|  | 86 | +  [+testll [ | 
|  | 87 | +    [-A -B +(⊗ A B)] | 
|  | 88 | +    [-D] [-C +(⅋ C D)] | 
|  | 89 | +    [-(⊗ A B) +concl] [-(⅋ C D)] | 
|  | 90 | +    @[-concl ok]]] | 
|  | 91 | +  [+testlr [ | 
|  | 92 | +    [-A -B +(⊗ A B)] | 
|  | 93 | +    [-D] [-C +(⅋ C D)] | 
|  | 94 | +    [-(⊗ A B)] [+concl -(⅋ C D)] | 
|  | 95 | +    @[-concl ok]]]}) | 
|  | 96 | + | 
|  | 97 | +' Check if proof? satisfies the test-based specification | 
|  | 98 | +'(:: proof? (-o (⊗ 1 2) (⊗ 3 4)) | 
|  | 99 | + | 
|  | 100 | +' Check if duality is coherent | 
|  | 101 | +' TODO | 
|  | 102 | + | 
|  | 103 | +''' ======================================================== ''' | 
|  | 104 | +''' FAILING TYPING ''' | 
|  | 105 | +''' ======================================================== ''' | 
|  | 106 | + | 
|  | 107 | +(spec (⊗ A B) { | 
|  | 108 | +  [-A -B +(⊗ A B)] | 
|  | 109 | +  @[-(⊗ A B) ok] | 
|  | 110 | +}) | 
|  | 111 | + | 
|  | 112 | +' To avoid unecessary infinite loop, | 
|  | 113 | +' we use a linear type assertion | 
|  | 114 | +(macro (::lin Tested Test) (== @(fire #Tested #Test) ok)) | 
|  | 115 | + | 
|  | 116 | +(:= proof? [+1 +2]) | 
|  | 117 | +' (::lin proof? (⊗ 1 2)) ' does not typecheck | 
|  | 118 | + | 
|  | 119 | +''' ======================================================== ''' | 
|  | 120 | +''' COMPRESSED TESTS ''' | 
|  | 121 | +''' ======================================================== ''' | 
|  | 122 | +' Actually, have internal connections which could be compressed | 
|  | 123 | +' by pre-executing them, thus avoiding unecessary computation. | 
|  | 124 | +' The two specifications above become: | 
|  | 125 | + | 
|  | 126 | +(spec (comp-o (⊗ A B) (⊗ C D)) { | 
|  | 127 | +  [+testrl [ | 
|  | 128 | +    [-A -B +concl] [-C] [-D] | 
|  | 129 | +    @[-concl ok]]] | 
|  | 130 | +  [+testrr [ | 
|  | 131 | +    [-A -B] [-C] [-D +concl] | 
|  | 132 | +    @[-concl ok]]] | 
|  | 133 | +  [+testll [ | 
|  | 134 | +    [-A -B +concl] [-D] [-C] | 
|  | 135 | +    @[-concl ok]]] | 
|  | 136 | +  [+testlr [ | 
|  | 137 | +    [-A -B] [-D] [-C +concl] | 
|  | 138 | +    @[-concl ok]]]}) | 
|  | 139 | + | 
|  | 140 | +(spec (⊗ A B) @[-A -B ok]) | 
0 commit comments