├── .eslintrc.js ├── .gitignore ├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── api ├── controllers │ ├── calculus.js │ ├── rule.js │ ├── symbols.js │ └── user.js ├── models │ ├── calculus.js │ ├── rule.js │ ├── symbols.js │ └── user.js └── routes │ ├── calculus.js │ ├── rule.js │ ├── symbols.js │ └── user.js ├── app.sh ├── bower.json ├── config └── db.js ├── package-lock.json ├── package.json ├── passport-config.js ├── public └── javascripts │ ├── apply │ ├── applyRule.js │ ├── initSequent.js │ ├── preview.js │ ├── prooftree.js │ ├── rule_sidebar.js │ ├── setupItems.js │ └── updateParser.js │ ├── calculus │ ├── get_set_calcs.js │ ├── sample_calculi.js │ └── setupItems.js │ ├── escape_text.js │ ├── generateProof.js │ ├── login │ ├── addUser.js │ └── setupItems.js │ ├── parser_text.js │ ├── properties │ ├── checkCut.js │ ├── checkInit.js │ ├── checkPerms.js │ ├── checkWeak.js │ ├── displayRules.js │ └── setupItems.js │ ├── rule │ ├── editTitleDesc.js │ ├── fixRules.js │ ├── getRule.js │ ├── placeRule.js │ ├── preview.js │ ├── rules_cards.js │ └── setupItems.js │ ├── sample_images │ ├── favicon.ico │ ├── gif1.gif │ ├── gif2.gif │ └── gif3.gif │ └── symbols_table.js ├── server.js ├── sml ├── applyunifier │ ├── applyunifier.cm │ ├── applyunifier.sig │ └── applyunifier.sml ├── basics │ ├── basics.cm │ ├── datatypes │ │ ├── datatypes.cm │ │ ├── datatypes.sig │ │ └── datatypes.sml │ ├── helpers │ │ ├── helpers.cm │ │ ├── helpers.sig │ │ └── helpers.sml │ └── ord_keys │ │ ├── ctx_var_con_key.sml │ │ ├── ctx_var_key.sml │ │ ├── form_key.sml │ │ └── string_key.sml ├── calculi │ ├── README │ ├── calculi.cm │ ├── constructive_logic.sml │ ├── lin2_logic.sml │ ├── lin3_logic.sml │ └── lin_logic.sml ├── equiv │ ├── check.sml │ ├── equiv.cm │ ├── equiv.sig │ ├── equiv.sml │ ├── equiv_test.cm │ ├── equiv_test.sml │ └── milp │ │ ├── README │ │ ├── milp.py │ │ ├── test1.txt │ │ ├── test2.txt │ │ ├── test3.txt │ │ └── test4.txt ├── html_exporter │ ├── html_exporter.cm │ ├── html_exporter.sig │ └── html_exporter.sml ├── latex_exporter │ ├── latex_exporter.cm │ ├── latex_exporter.sig │ └── latex_exporter.sml ├── properties │ ├── cut_elim │ │ └── cut_elim.sml │ ├── id_expansion │ │ └── id_expansion.sml │ ├── permute │ │ └── permute.sml │ ├── properties.cm │ ├── properties.sig │ ├── properties.sml │ ├── utilities │ │ └── utilities.sml │ └── weakening │ │ └── weakening.sml ├── recompile-sml.sh ├── smlCommands.js ├── tree_func │ ├── tree_func.cm │ ├── tree_func.sig │ └── tree_func.sml ├── unification │ ├── ac_unification │ │ ├── ac_unification.cm │ │ ├── ac_unification.sig │ │ └── ac_unification.sml │ ├── constraints │ │ ├── constraints.cm │ │ ├── constraints.sig │ │ └── constraints.sml │ ├── fresh_var │ │ └── fresh_var.sml │ ├── unification.cm │ ├── unification.sig │ └── unification.sml ├── unify.cm └── unit_test │ ├── apply_sub_pred │ └── apply_sub_pred.sml │ ├── basics_tests │ ├── datatypes_test.sml │ ├── helpers_test.sml │ └── ord_keys_test.sml │ ├── generators │ ├── gen.sig │ ├── gen.sml │ └── rules.sml │ ├── properties_tests │ ├── properties_tests.sml │ ├── result_type.sml │ ├── test_cases.sml │ └── test_cases │ │ ├── cut_elim_test_cases.sml │ │ ├── id_expansion_test_cases.sml │ │ ├── permute_test_cases.sml │ │ └── weakening_test_cases.sml │ ├── tree_func_pred │ └── tree_func_pred.sml │ ├── unification_pred │ └── unification_pred.sml │ ├── unit_test.cm │ └── unit_test.sml ├── tempProofs └── silly.txt └── views ├── apply └── index.hbs ├── calculus └── index.hbs ├── layouts ├── apply.hbs ├── calculus.hbs ├── cutadmiss.hbs ├── initcoherence.hbs ├── landing_in.hbs ├── landing_out.hbs ├── layout.hbs ├── login.hbs ├── main.hbs ├── permutability.hbs ├── properties.hbs ├── rule.hbs ├── temporary.hbs └── weakadmiss.hbs ├── login ├── index.hbs ├── landing.hbs └── register.hbs ├── main └── index.hbs ├── partials ├── log_navbar.hbs ├── main_navbar.hbs └── navbar.hbs ├── properties ├── cutadmiss.hbs ├── index.hbs ├── initcoherence.hbs ├── invertibility.hbs ├── permutability.hbs └── weakadmiss.hbs ├── rule └── index.hbs └── temporary └── index.hbs /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true 6 | }, 7 | "extends": "eslint:recommended", 8 | "globals": { 9 | "Atomics": "readonly", 10 | "SharedArrayBuffer": "readonly" 11 | }, 12 | "parserOptions": { 13 | "ecmaVersion": 2018, 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "indent": [ 18 | "error", 19 | 4 20 | ], 21 | "linebreak-style": [ 22 | "error", 23 | "unix" 24 | ], 25 | "quotes": [ 26 | "error", 27 | "double" 28 | ], 29 | "semi": [ 30 | "error", 31 | "never" 32 | ] 33 | } 34 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | #sml generated files 61 | sml/generated-sml/*.sml 62 | 63 | # VisualStudio config 64 | .vscode/ 65 | 66 | # MacOS folder 67 | .DS_Store/ 68 | 69 | # SML Compilation Manager files 70 | **/.cm/ 71 | 72 | #log file for python Linear Program 73 | **/log.txt 74 | 75 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "sml/qcheck"] 2 | path = sml/qcheck 3 | url = https://github.com/league/qcheck.git 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | default: install 5 | install: 6 | npm install 7 | npm install nodemon 8 | bower install 9 | pip3 install mip 10 | echo $(EOF) | sml -m "sml/unify.cm" 11 | 12 | compile: 13 | echo $(EOF) | sml -m "sml/unify.cm" 14 | 15 | test: 16 | sml -m "sml/unit_test/unit_test.cm" 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sequoia 2 | Sequent calculus proof construction tool 3 | 4 | ## Getting Started 5 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. 6 | 7 | ### Prerequisites 8 | 9 | - [Node.js](http://nodejs.org/) 10 | - [MongoDB](https://www.mongodb.com/download-center?jmp=nav) 11 | - [Standard ML of New Jersey](https://www.smlnj.org/) 12 | - [Python3](https://www.python.org/download/releases/3.0/) 13 | - [mip](https://pypi.org/project/mip/) 14 | 15 | ### Installing 16 | 17 | The commands below should be run once. 18 | 19 | Clone the repo 20 | 21 | ``` 22 | git clone git@github.com:meta-logic/sequoia.git 23 | ``` 24 | 25 | Installing the dependencies 26 | 27 | ``` 28 | cd sequoia 29 | npm install 30 | npm install bower 31 | npx bower install 32 | ``` 33 | 34 | ### Running 35 | 36 | Run mongoDB 37 | 38 | ``` 39 | mongod --dbpath . 40 | ``` 41 | Then, run the server 42 | 43 | ``` 44 | npm start 45 | ``` 46 | The application should now be running on [localhost:8080/sequoia](http://localhost:8080/sequoia). 47 | -------------------------------------------------------------------------------- /api/controllers/calculus.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var Calculus = require("../models/calculus") 9 | var Rule = require("../models/rule") 10 | var Symbols = require("../models/symbols") 11 | 12 | 13 | function createCalculus (req, res) { 14 | var calculus = new Calculus() 15 | calculus.title = req.body.title 16 | calculus.description = req.body.description 17 | calculus.rules = [] 18 | calculus.symbols = [] 19 | calculus.user = req.body.user 20 | calculus.save(function(err) { 21 | if (err) { 22 | return res.status(400).json({ 23 | "status" : "failure", 24 | "message" : "something went wrong while creating the calculus" 25 | }) 26 | } 27 | return res.status(200).json({ 28 | "status" : "success", 29 | "message" : "calculus was created", 30 | "calculus" : calculus 31 | }) 32 | }) 33 | } 34 | 35 | 36 | function updateCalculus (req, res) { 37 | Calculus.findOneAndUpdate({ _id : req.body.id}, 38 | { title : req.body.title, 39 | description :req.body.description 40 | }, { new : true}, 41 | function(err, calculus) { 42 | if (err || calculus == null) { 43 | return res.status(400).json({ 44 | "status" : "failure", 45 | "message" : "calculus does not exist" 46 | }) 47 | } 48 | return res.status(200).json({ 49 | "status" : "success", 50 | "calculus" : calculus 51 | }) 52 | }) 53 | } 54 | 55 | 56 | function deleteCalculus (req, res) { 57 | Calculus.deleteOne({ _id : req.body.id}, function(err, calc) { 58 | Symbols.remove({calculus : req.body.id}, function(err, symbs) {}) 59 | Rule.remove({ calculus : req.body.id}, function(err, rls) {}) 60 | if (err || calc == null) { 61 | return res.status(400).json({ 62 | "status" : "failure", 63 | "message" : "calculus does not exist" 64 | }) 65 | } 66 | return res.status(200).json({ 67 | "status" : "success", 68 | "message" : "calculus successfully deleted" 69 | }) 70 | }) 71 | } 72 | 73 | 74 | function getCalculus (req, res) { 75 | Calculus.findById(req.params.calc_id, function(err, calculus) { 76 | if (err || calculus == null) { 77 | return res.status(400).json({ 78 | "status" : "failure", 79 | "message" : "calculus does not exist" 80 | }) 81 | } 82 | return res.status(200).json({ 83 | "status" : "success", 84 | "calculus" : calculus 85 | }) 86 | }) 87 | } 88 | 89 | 90 | function getCalculi (req, res) { 91 | Calculus.find({user : req.params.user_id}, function(err, calculi) { 92 | if (err || calculi == null) { 93 | return res.status(400).json({ 94 | "status" : "failure", 95 | "message" : err 96 | }) 97 | } 98 | return res.status(200).json({ 99 | "status" : "success", 100 | "calculi" : calculi 101 | }) 102 | }) 103 | } 104 | 105 | 106 | module.exports = {createCalculus, updateCalculus, deleteCalculus, getCalculus, getCalculi} -------------------------------------------------------------------------------- /api/controllers/rule.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var Rule = require("../models/rule") 9 | 10 | 11 | function createRule (req, res) { 12 | var rule = new Rule() 13 | rule.rule = req.body.rule 14 | rule.premises = JSON.parse(req.body.premises) 15 | rule.conclusion = req.body.conclusion 16 | rule.sml_prem = JSON.parse(req.body.parsed_prem) 17 | rule.sml_conc = req.body.parsed_conc 18 | rule.calculus = req.body.calculus 19 | rule.connective = req.body.connective 20 | rule.type = req.body.type 21 | rule.side = req.body.side 22 | rule.cutvar = req.body.cutvar 23 | rule.save(function(err) { 24 | if (err) { 25 | return res.status(400).json({ 26 | "status" : "failure", 27 | "message" : "something went wrong while creating the rule" 28 | }) 29 | } 30 | return res.status(200).json({ 31 | "status" : "success", 32 | "message" : "rule was created", 33 | "rule" : rule 34 | }) 35 | }) 36 | } 37 | 38 | 39 | function createRules (req, res) { 40 | var rules = JSON.parse(req.body.items) 41 | for (var i = 0; i < rules.length; i++) { 42 | var rule = new Rule() 43 | var rls = rules[i] 44 | rule.rule = rls.rule 45 | rule.premises = JSON.parse(rls.premises) 46 | rule.conclusion = rls.conclusion 47 | rule.sml_prem = JSON.parse(rls.parsed_prem) 48 | rule.sml_conc = rls.parsed_conc 49 | rule.calculus = rls.calculus 50 | rule.connective = rls.connective 51 | rule.type = rls.type 52 | rule.side = rls.side 53 | rule.cutvar = rls.cutvar 54 | rule.save(function(err) { 55 | if (err) { 56 | return res.status(400).json({ 57 | "status" : "failure", 58 | "message" : "something went wrong while creating the rule" 59 | }) 60 | } 61 | }) 62 | } 63 | return res.status(200).json({ 64 | "status" : "success", 65 | "message" : "rule was created", 66 | "rule" : rule 67 | }) 68 | } 69 | 70 | 71 | function updateRule (req, res) { 72 | Rule.findOneAndUpdate({ _id : req.body.id}, 73 | { rule : req.body.rule, 74 | premises : JSON.parse(req.body.premises), 75 | conclusion : req.body.conclusion, 76 | sml_prem : JSON.parse(req.body.parsed_prem), 77 | sml_conc : req.body.parsed_conc, 78 | calculus : req.body.calculus, 79 | connective : req.body.connective, 80 | side : req.body.side, 81 | type : req.body.type, 82 | cutvar : req.body.cutvar 83 | }, { new : true}, 84 | function(err, rule) { 85 | if (err || rule == null) { 86 | return res.status(400).json({ 87 | "status" : "failure", 88 | "message" : "rule does not exist" 89 | }) 90 | } 91 | return res.status(200).json({ 92 | "status" : "success", 93 | "rule" : rule 94 | }) 95 | }) 96 | } 97 | 98 | 99 | function deleteRule (req, res) { 100 | Rule.remove({ _id : req.body.id}, function(err, rule) { 101 | if (err || rule == null) { 102 | return res.status(400).json({ 103 | "status" : "failure", 104 | "message" : "rule does not exist" 105 | }) 106 | } 107 | return res.status(200).json({ 108 | "status" : "success", 109 | "message" : "rule successfully deleted", 110 | "rule" : rule 111 | }) 112 | }) 113 | } 114 | 115 | 116 | function getRule (req, res) { 117 | Rule.findById(req.params.rule_id, function(err, rule) { 118 | if (err || rule == null) { 119 | return res.status(400).json({ 120 | "status" : "failure", 121 | "message" : "rule does not exist" 122 | }) 123 | } 124 | return res.status(200).json({ 125 | "status" : "success", 126 | "rule" : rule 127 | }) 128 | }) 129 | } 130 | 131 | 132 | function getRules (req, res) { 133 | Rule.find({'calculus': req.params.calc_id}, function(err, rules) { 134 | if (err || rules == null) { 135 | return res.status(400).json({ 136 | "status" : "failure", 137 | "message" : "rules do not exist" 138 | }) 139 | } 140 | return res.status(200).json({ 141 | "status" : "success", 142 | "rules" : rules 143 | }) 144 | }) 145 | } 146 | 147 | 148 | module.exports = {createRule, createRules, updateRule, deleteRule, getRule, getRules} 149 | -------------------------------------------------------------------------------- /api/controllers/symbols.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var Symbols = require("../models/symbols") 9 | 10 | 11 | function addSymbol (req, res) { 12 | var symbol = new Symbols() 13 | symbol.symbol = req.body.symbol 14 | symbol.type = req.body.type 15 | symbol.group = req.body.group 16 | symbol.calculus = req.body.calculus 17 | symbol.save(function(err) { 18 | if (err) { 19 | return res.status(400).json({ 20 | "status" : "failure", 21 | "message" : "something went wrong while creating the symbol" 22 | }) 23 | } 24 | return res.status(200).json({ 25 | "status" : "success", 26 | "message" : "symbol was created", 27 | "symbol" : symbol 28 | }) 29 | }) 30 | } 31 | 32 | 33 | function addSymbols (req, res) { 34 | var symbols = JSON.parse(req.body.items) 35 | for (var i = 0; i < symbols.length; i++) { 36 | var symbol = new Symbols() 37 | var syms = symbols[i] 38 | symbol.symbol = syms.symbol 39 | symbol.type = syms.type 40 | symbol.group = syms.group 41 | symbol.calculus = syms.calculus 42 | symbol.save(function(err) { 43 | if (err) { 44 | return res.status(400).json({ 45 | "status" : "failure", 46 | "message" : "something went wrong while creating the symbol" 47 | }) 48 | } 49 | }) 50 | } 51 | return res.status(200).json({ 52 | "status" : "success", 53 | "message" : "symbol was created", 54 | "symbol" : symbol 55 | }) 56 | } 57 | 58 | 59 | function deleteSymbol (req, res) { 60 | Symbols.remove({ _id : req.body.id}, function(err, symbol) { 61 | if (err || symbol == null) { 62 | return res.status(400).json({ 63 | "status" : "failure", 64 | "message" : "symbol does not exist" 65 | }) 66 | } 67 | return res.status(200).json({ 68 | "status" : "success", 69 | "message" : "symbol successfully deleted", 70 | "rule" : symbol 71 | }) 72 | }) 73 | } 74 | 75 | 76 | function getRuleSymbols (req, res) { 77 | Symbols.find({ $and: [{'calculus': req.params.calc_id}, {group : "rule"}]}, 78 | function(err, symbols) { 79 | if (err || symbols == null) { 80 | return res.status(400).json({ 81 | "status" : "failure", 82 | "message" : "symbol does not exist" 83 | }) 84 | } 85 | return res.status(200).json({ 86 | "status" : "success", 87 | "symbols" : symbols 88 | }) 89 | }) 90 | } 91 | 92 | 93 | function getSeqSymbols (req, res) { 94 | Symbols.find({ $and: [{'calculus': req.params.calc_id}, {group : "seq"}]}, 95 | function(err, symbols) { 96 | if (err || symbols == null) { 97 | return res.status(400).json({ 98 | "status" : "failure", 99 | "message" : "symbol does not exist" 100 | }) 101 | } 102 | return res.status(200).json({ 103 | "status" : "success", 104 | "symbols" : symbols 105 | }) 106 | }) 107 | } 108 | 109 | 110 | function getParsingSymbols (req, res) { 111 | Symbols.find({ $and: [{'calculus': req.params.calc_id}, 112 | {$or:[{group: "seq"},{type : {$in: ["connective", "sequent sign", "context separator", "empty"]}}]}]}, 113 | function(err, symbols) { 114 | if (err || symbols == null) { 115 | return res.status(400).json({ 116 | "status" : "failure", 117 | "message" : "symbol does not exist" 118 | }) 119 | } 120 | return res.status(200).json({ 121 | "status" : "success", 122 | "symbols" : symbols 123 | }) 124 | }) 125 | } 126 | 127 | 128 | function getCertainSymbols (req, res) { 129 | Symbols.find({ $and: [{'calculus': req.params.calc_id}, 130 | {type : {$in: ["connective", "sequent sign", "context separator", "empty"]}}]}, 131 | function(err, symbols) { 132 | if (err || symbols == null) { 133 | return res.status(400).json({ 134 | "status" : "failure", 135 | "message" : "symbol does not exist" 136 | }) 137 | } 138 | return res.status(200).json({ 139 | "status" : "success", 140 | "symbols" : symbols 141 | }) 142 | }) 143 | } 144 | 145 | 146 | module.exports = {addSymbol, addSymbols, deleteSymbol, getRuleSymbols, getSeqSymbols, getParsingSymbols, getCertainSymbols} -------------------------------------------------------------------------------- /api/controllers/user.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var bcrypt = require('bcrypt') 9 | var User = require("../models/user") 10 | var Calculus = require("../models/calculus") 11 | var Rule = require("../models/rule") 12 | var Symbols = require("../models/symbols") 13 | 14 | 15 | async function createUser (req, res) { 16 | var user = new User() 17 | user.username = req.body.username 18 | user.password = await bcrypt.hash(req.body.password, 10) 19 | user.email = req.body.email 20 | user.occupation = req.body.occupation 21 | user.save(function(err) { 22 | if (err) { 23 | return res.status(400).json({ 24 | "status" : "failure", 25 | "message" : "something went wrong while creating the user" 26 | }) 27 | } 28 | return res.status(200).json({ 29 | "status" : "success", 30 | "message" : "user was created", 31 | "user" : user 32 | }) 33 | }) 34 | } 35 | 36 | 37 | function deleteUser (req, res) { 38 | User.deleteOne({_id : req.body.id}, function(err, user) { 39 | Calculus.remove({user : req.body.id}, function(err, clcs) {}) 40 | Symbols.remove({user : req.body.id}, function(err, symbs) {}) 41 | Rule.remove({user : req.body.id}, function(err, rls) {}) 42 | if (err || user == null) { 43 | return res.status(400).json({ 44 | "status" : "failure", 45 | "message" : "user does not exist" 46 | }) 47 | } 48 | return res.status(200).json({ 49 | "status" : "success", 50 | "message" : "user successfully deleted" 51 | }) 52 | }) 53 | } 54 | 55 | 56 | function getUser (req, res) { 57 | User.findById(req.params.user_id, function(err, user) { 58 | if (err || user == null) { 59 | return res.status(400).json({ 60 | "status" : "failure", 61 | "message" : "user does not exist" 62 | }) 63 | } 64 | return res.status(200).json({ 65 | "status" : "success", 66 | "user" : user 67 | }) 68 | }) 69 | } 70 | 71 | 72 | function checkUser (req, res) { 73 | User.find({'username' : req.params.username}, function(err, user) { 74 | if (user.length == 0) { 75 | return res.status(200).json({ 76 | "status" : "failure", 77 | "message" : "user does not exist" 78 | }) 79 | } 80 | return res.status(200).json({ 81 | "status" : "success", 82 | "user" : user 83 | }) 84 | }) 85 | } 86 | 87 | 88 | module.exports = {createUser, deleteUser, getUser, checkUser} -------------------------------------------------------------------------------- /api/models/calculus.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var mongoose = require("mongoose") 9 | var Schema = mongoose.Schema 10 | 11 | 12 | //defining the calculus schema 13 | var calculusSchema = new Schema({ 14 | title : String, 15 | description : String, 16 | rules : [String], 17 | symbols : [String], 18 | user : String 19 | }) 20 | 21 | module.exports = mongoose.model("Calculus", calculusSchema) -------------------------------------------------------------------------------- /api/models/rule.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var mongoose = require("mongoose") 9 | var Schema = mongoose.Schema 10 | 11 | 12 | //defining the rule schema 13 | var ruleSchema = new Schema({ 14 | rule : String, 15 | premises : [String], 16 | conclusion : String, 17 | sml_prem : [String], 18 | sml_conc : String, 19 | calculus : String, 20 | connective : String, 21 | type : String, 22 | side : String, 23 | cutvar : String 24 | }) 25 | 26 | module.exports = mongoose.model("Rule", ruleSchema) 27 | -------------------------------------------------------------------------------- /api/models/symbols.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var mongoose = require("mongoose") 9 | var Schema = mongoose.Schema 10 | 11 | 12 | //defining the rule schema 13 | var symbolSchema = new Schema({ 14 | symbol : String, 15 | type : String, 16 | group : String, 17 | calculus : String 18 | }) 19 | 20 | module.exports = mongoose.model("Symbols", symbolSchema) -------------------------------------------------------------------------------- /api/models/user.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var mongoose = require("mongoose") 9 | var Schema = mongoose.Schema 10 | 11 | 12 | //defining the calculus schema 13 | var userSchema = new Schema({ 14 | username : String, 15 | password : String, 16 | email : String, 17 | occupation : String, 18 | calculi : [String] 19 | }) 20 | 21 | module.exports = mongoose.model("User", userSchema) -------------------------------------------------------------------------------- /api/routes/calculus.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var express = require("express") 9 | var router = express.Router() 10 | var controller = require("../controllers/calculus") 11 | 12 | 13 | //calculus routes 14 | router.post("/calculus", controller.createCalculus) 15 | router.put("/calculus", controller.updateCalculus) 16 | router.delete("/calculus", controller.deleteCalculus) 17 | router.get("/calculus/:calc_id", controller.getCalculus) 18 | router.get("/calculi/:user_id", controller.getCalculi) 19 | 20 | 21 | module.exports = router -------------------------------------------------------------------------------- /api/routes/rule.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var express = require("express") 9 | var router = express.Router() 10 | var controller = require("../controllers/rule") 11 | 12 | 13 | //rule routes 14 | router.post("/rule", controller.createRule) 15 | router.post("/rules_init", controller.createRules) 16 | router.put("/rule", controller.updateRule) 17 | router.delete("/rule", controller.deleteRule) 18 | router.get("/rule/:rule_id", controller.getRule) 19 | router.get("/rules/:calc_id", controller.getRules) 20 | 21 | 22 | module.exports = router 23 | -------------------------------------------------------------------------------- /api/routes/symbols.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var express = require("express") 9 | var router = express.Router() 10 | var controller = require("../controllers/symbols") 11 | 12 | 13 | //symbols routes 14 | router.post("/symbols", controller.addSymbol) 15 | router.post("/symbols_init", controller.addSymbols) 16 | router.delete("/symbols", controller.deleteSymbol) 17 | router.get("/rule_symbols/:calc_id", controller.getRuleSymbols) 18 | router.get("/seq_symbols/:calc_id", controller.getSeqSymbols) 19 | router.get("/parsing_symbols/:calc_id", controller.getParsingSymbols) 20 | router.get("/cert_symbols/:calc_id", controller.getCertainSymbols) 21 | 22 | 23 | module.exports = router -------------------------------------------------------------------------------- /api/routes/user.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | //Loading Dependencies ============================================= 8 | var express = require("express") 9 | var router = express.Router() 10 | var controller = require("../controllers/user") 11 | 12 | 13 | //user routes 14 | router.post("/user", controller.createUser) 15 | router.delete("/user", controller.deleteUser) 16 | router.get("/user/:user_id", controller.getUser) 17 | router.get("/users/:username", controller.checkUser) 18 | 19 | 20 | module.exports = router 21 | -------------------------------------------------------------------------------- /app.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/bin/node /afs/qatar.cmu.edu/course/15/logic/sequoia/server.js 4 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sequoia", 3 | "description": "Sequent calculus proof construction tool", 4 | "main": "server.js", 5 | "authors": [ 6 | "Giselle Reis" 7 | ], 8 | "license": "ISC", 9 | "homepage": "https://github.com/meta-logic/sequoia", 10 | "ignore": [ 11 | "**/.*", 12 | "node_modules", 13 | "bower_components", 14 | "test", 15 | "tests" 16 | ], 17 | "dependencies": { 18 | "semantic": "^2.2.13", 19 | "MathJax": "^2.7.7", 20 | "async": "^2.5.0", 21 | "pegjs": "^0.10.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /config/db.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | module.exports = { 8 | local : "mongodb://localhost:27017/sequoia", 9 | remote : "" 10 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sequoia", 3 | "version": "1.0.0", 4 | "description": "Sequent calculus proof construction tool", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon server.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/meta-logic/sequoia.git" 13 | }, 14 | "author": "Giselle Reis", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/meta-logic/sequoia/issues" 18 | }, 19 | "homepage": "https://github.com/meta-logic/sequoia#readme", 20 | "dependencies": { 21 | "//": "bcrypt is used for encrypting user names and passwords", 22 | "bcrypt": "^5.0.1", 23 | "body-parser": "^1.18.3", 24 | "dotenv": "^8.2.0", 25 | "express": "^4.16.4", 26 | "express-flash": "0.0.2", 27 | "//": "handlebars is used for generating the webpages", 28 | "express-handlebars": "3.0.0", 29 | "express-session": "^1.16.2", 30 | "helmet": "^3.22.0", 31 | "mongoose": "^5.9.10", 32 | "morgan": "^1.9.1", 33 | "node-cmd": "3.0.0", 34 | "nodemon": "^2.0.15", 35 | "//": "passport is for user authentication", 36 | "passport": "^0.4.0", 37 | "passport-local": "^1.0.0", 38 | "passport-local-mongoose": "^5.0.1", 39 | "serve-favicon": "^2.5.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /passport-config.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var LocalStrat = require('passport-local').Strategy 8 | var bcrypt = require('bcrypt') 9 | 10 | function initialize(passport, User) { 11 | const authenticate = (username, password, done) => { 12 | User.findOne({ 'username': username }, async function(err, user) { 13 | if (err) { return done(err); } 14 | if (!user) { 15 | return done(null, false, { message: 'Incorrect username or password' }) 16 | } 17 | try { 18 | if (await bcrypt.compare(password, user.password)) { 19 | return done(null, user) 20 | } else { 21 | return done(null, false, { message: 'Incorrect username or password' }) 22 | } 23 | } catch(e) { 24 | return done(e) 25 | } 26 | }) 27 | } 28 | passport.use(new LocalStrat({usernameField: 'username', passwordField: 'password'}, authenticate)) 29 | passport.serializeUser(function(user, done) { 30 | done(null, user.id) 31 | }) 32 | passport.deserializeUser(function(id, done) { 33 | User.findById(id, function(err, user) { 34 | done(err, user) 35 | }) 36 | }) 37 | } 38 | 39 | module.exports = initialize -------------------------------------------------------------------------------- /public/javascripts/apply/initSequent.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var parser_copy = pt 8 | var parser = "" 9 | var formula_parser = "" 10 | 11 | function useSequent() { 12 | var parser_text = parser_copy 13 | var arrow = "SeqSign = \"NO-ARROW\" " 14 | var sep = "CtxSep = \"NO-SEP\" " 15 | var conn = "Conn = \"NO-Conn\" " 16 | var set = "CtxVar = \"NO-SET\" " 17 | var form = "FormVar = \"NO-FORM\" " 18 | var atom_var = "AtomVar = \"NO-ATOMVAR\" " 19 | var atom = "Atom = \"NO-ATOM\" " 20 | $.get("/sequoia/api/parsing_symbols/"+calc_id, function(sb, status) { 21 | var syms = sb.symbols 22 | syms = syms.sort(function(a, b) { 23 | return b.symbol.length - a.symbol.length 24 | }) 25 | for (var i = 0; i < syms.length; i++) { 26 | var symbol = syms[i].symbol 27 | var type = syms[i].type 28 | symbol = symbol.replace(/\\/g, "\\\\") 29 | if (type == "sequent sign") { 30 | arrow += "/ \"" + symbol + "\" " 31 | } 32 | else if (type == "context separator") { 33 | sep += "/ \"" + symbol + "\" " 34 | } 35 | else if (type == "connective") { 36 | conn += "/ \"" + symbol + "\" " 37 | } 38 | else if (type == "context variable") { 39 | set += "/ \"" + symbol + "\" " 40 | } 41 | else if (type == "formula variable") { 42 | form += "/ \"" + symbol + "\" " 43 | } 44 | else if (type == "atom variable") { 45 | atom_var += "/ \"" + symbol + "\" " 46 | } 47 | else if (type == "atom") { 48 | atom += "/ \"" + symbol + "\" " 49 | } 50 | } 51 | var extra_text = "\n" + arrow + "\n" + sep + "\n" + conn + "\n" + set + "\n" + form + "\n" + atom_var + "\n" + atom + "\n" 52 | parser_text += extra_text 53 | var temp_parser = peg.generate(parser_text) 54 | parse_and_use(temp_parser) 55 | }) 56 | } 57 | 58 | 59 | function parse_and_use(temp_parser) { 60 | var sequent = $("#Sequent").val().replace(/\(/g, " ( ").replace(/\)/g, " ) ") 61 | try { 62 | var sml_seq = temp_parser.parse(sequent).replace(/\\/g, "\\\\") 63 | } 64 | catch(error) { 65 | $("#warning_header").html("Sequent Parsing Error") 66 | $("#warning_text").html("Sequents must be structurally valid and contain term symbols from the sequent term symbols table.") 67 | $("#warning").css("visibility", "visible") 68 | return 69 | } 70 | $("#seq").css("display", "none") 71 | $("#note").css("visibility", "hidden") 72 | $("#submit").css("visibility", "hidden") 73 | $("#warning").css("visibility", "hidden") 74 | $("#export").attr("class", "ui fluid huge icon button green") 75 | $("#undo").attr("class", "ui fluid huge icon button red") 76 | parser = temp_parser 77 | $(".leaf").click(function() { 78 | leaf_id = this.id.split("_")[1] 79 | seq_text = $(this).find("script")[0].innerText 80 | $(this).css('background-color', 'rgb(235, 235, 235)') 81 | $("#warning").css("visibility", "hidden") 82 | }) 83 | var stree = "DerTree(\"0\","+sml_seq+",NONE,[])" 84 | sml_history.push(stree) 85 | var ltree ="\\deduce[]{"+sequent+"}{0}" 86 | latex_history.push(ltree) 87 | var htree = 88 | "
"+ 89 | "
"+ 90 | "
$$"+sequent+"$$
"+ 91 | "
"+ 92 | "
" 93 | tree_history.push(htree) 94 | } 95 | -------------------------------------------------------------------------------- /public/javascripts/apply/preview.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | function preview() { 8 | $("#warning").css("visibility", "hidden") 9 | var initial_sequent = escape_latex($("#Sequent").val().trim().replace(/\(/g, " ( ").replace(/\)/g, " ) ")) 10 | if (initial_sequent == "") 11 | return 12 | $("#conc_0").html('$$'+initial_sequent+'$$') 13 | $("#conc_0").css("visibility", "visible") 14 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, $("#prooftree_0")[0]]) 15 | $("#submit").css("visibility", "visible") 16 | $("#sym_table").css("visibility", "visible") 17 | $("#typ").css("visibility", "visible") 18 | } -------------------------------------------------------------------------------- /public/javascripts/apply/prooftree.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | function insert_new_tree(cn, cz, lt, ht, st) { 8 | latex_history.push(lt) 9 | sml_history.push(st.replace(/\\/g, "\\\\")) 10 | tree_history.push(ht) 11 | var main_tree = $("#main_tree") 12 | main_tree.html(ht) 13 | $(".leaf").click(function() { 14 | leaf_id = this.id.split("_")[1] 15 | seq_text = $(this).find("script")[0].innerText 16 | $(".leaf").css('background-color', 'rgb(255, 255, 255)') 17 | $(this).css('background-color', 'rgb(235, 235, 235)') 18 | $("#warning").css("visibility", "hidden") 19 | }) 20 | constraint_history.push(cn) 21 | smlconstraint_history.push(cz.replace(/\\/g, "\\\\")) 22 | if (constraint_history.join() != "") { 23 | var the_constraints = constraint_history[constraint_history.length-1] 24 | if (the_constraints[0] != "") { 25 | var constraints = $("#side_menu_L") 26 | constraints.html("") 27 | for (var i = 0; i < the_constraints.length; i++) { 28 | if (the_constraints[i] != "") { 29 | constraints.append('

$$'+the_constraints[i]+'$$

') 30 | } 31 | } 32 | $("#left_menu").css("visibility", "visible") 33 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, constraints[0]]) 34 | } 35 | } else { 36 | $("#left_menu").css("visibility", "hidden") 37 | } 38 | seq_text = "" 39 | leaf_id = "-1" 40 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, main_tree[0]]) 41 | } 42 | 43 | 44 | function insert_old_tree() { 45 | latex_history.pop() 46 | sml_history.pop() 47 | tree_history.pop() 48 | var main_tree = $("#main_tree") 49 | main_tree.html(tree_history[tree_history.length-1]) 50 | $(".leaf").click(function() { 51 | leaf_id = this.id.split("_")[1] 52 | seq_text = $(this).find("script")[0].innerText 53 | $(this).css('background-color', 'rgb(235, 235, 235)') 54 | $("#warning").css("visibility", "hidden") 55 | }) 56 | constraint_history.pop() 57 | smlconstraint_history.pop() 58 | if (constraint_history.join() != "") { 59 | var the_constraints = constraint_history[constraint_history.length-1] 60 | if (the_constraints[0] != "") { 61 | var constraints = $("#side_menu_L") 62 | constraints.html("") 63 | for (var i = 0; i < the_constraints.length; i++) { 64 | if (the_constraints[i] != "") { 65 | constraints.append('

$$'+the_constraints[i]+'$$

') 66 | } 67 | } 68 | $("#left_menu").css("visibility", "visible") 69 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, constraints[0]]) 70 | } 71 | } else { 72 | $("#left_menu").css("visibility", "hidden") 73 | } 74 | seq_text = "" 75 | leaf_id = "-1" 76 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, main_tree[0]]) 77 | } 78 | -------------------------------------------------------------------------------- /public/javascripts/apply/rule_sidebar.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var r = 0 8 | 9 | function get_rules_toPage() { 10 | var rules_container = $("#rules") 11 | for (i = 0; i < r; i++) { 12 | entry = $("#rule_card"+i) 13 | if (entry != null) { 14 | entry.remove() 15 | } 16 | } 17 | $.get("/sequoia/api/rules/"+calc_id, function(rls, status) { 18 | var rules = rls.rules 19 | for (var i = 0; i < rules.length; i++) { 20 | var rule_cutvar = rules[i].cutvar.replace(/\\/g, "\\\\").replace(/'/g, "'").replace(/"/g, """) 21 | var rule_conc = rules[i].sml_conc.replace(/\\/g, "\\\\").replace(/'/g, "'").replace(/"/g, """) 22 | var rule_prem = list_to_string(rules[i].sml_prem).replace(/\\/g, "\\\\").replace(/'/g, "'").replace(/"/g, """) 23 | rules_container.append( 24 | '
'+ 25 | ''+ 29 | '
' 30 | ) 31 | } 32 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, rules_container[0]]) 33 | r = rules.length 34 | }) 35 | } -------------------------------------------------------------------------------- /public/javascripts/apply/setupItems.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var calc_id = $("#calc_id").text() 8 | $("#main-menu").sticky({}); 9 | $("#Prooftree_icon").attr("class", "active item") 10 | $("#Calculus_icon").attr("href", "/sequoia/calculus/"+calc_id) 11 | $("#Prooftree_icon").attr("href", "/sequoia/calculus/"+calc_id+"/apply") 12 | $("#Properties_icon").attr("href", "/sequoia/calculus/"+calc_id+"/properties") 13 | $.get("/sequoia/api/calculus/"+calc_id, function(calc, status) { 14 | get_rules_toPage() 15 | get_cert_symbols_toTable() 16 | get_symbols_toTable("seq") 17 | }) 18 | 19 | 20 | function list_to_string(item_list) { 21 | var item_string = "" 22 | for (var j = 0; j < item_list.length; j++) { 23 | item_string += item_list[j] + "," 24 | } 25 | return "["+item_string.slice(0,-1)+"]" 26 | } -------------------------------------------------------------------------------- /public/javascripts/apply/updateParser.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var parser_copy = pt 8 | var formula_parser_copy = fpt 9 | 10 | function updateParser(new_symbols, callback) { 11 | var parser_text = parser_copy 12 | var formula_parser_text = formula_parser_copy 13 | var arrow = "SeqSign = \"NO-ARROW\" " 14 | var sep = "CtxSep = \"NO-SEP\" " 15 | var conn = "Conn = \"NO-Conn\" " 16 | var set = "CtxVar = \"NO-SET\" " 17 | var form = "FormVar = \"NO-FORM\" " 18 | var atom_var = "AtomVar = \"NO-ATOMVAR\" " 19 | var atom = "Atom = \"NO-ATOM\" " 20 | var context_variables = [] 21 | for (var symbol in new_symbols) { 22 | if (symbol.includes("\\")) { 23 | symbol = symbol.replace(/\\/g, "\\\\") 24 | } 25 | context_variables.push(symbol) 26 | } 27 | $.get("/sequoia/api/parsing_symbols/"+calc_id, function(sb, status) { 28 | var syms = sb.symbols 29 | syms = syms.sort(function(a, b) { 30 | return b.symbol.length - a.symbol.length 31 | }) 32 | for (var i = 0; i < syms.length; i++) { 33 | var symbol = syms[i].symbol 34 | var type = syms[i].type 35 | symbol = symbol.replace(/\\/g, "\\\\") 36 | if (type == "sequent sign") { 37 | arrow += "/ \"" + symbol + "\" " 38 | } 39 | else if (type == "context separator") { 40 | sep += "/ \"" + symbol + "\" " 41 | } 42 | else if (type == "connective") { 43 | conn += "/ \"" + symbol + "\" " 44 | } 45 | else if (type == "context variable") { 46 | context_variables.push(symbol) 47 | } 48 | else if (type == "formula variable") { 49 | form += "/ \"" + symbol + "\" " 50 | } 51 | else if (type == "atom variable") { 52 | atom_var += "/ \"" + symbol + "\" " 53 | } 54 | else if (type == "atom") { 55 | atom += "/ \"" + symbol + "\" " 56 | } 57 | } 58 | 59 | context_variables = context_variables.sort(function(a, b) { 60 | return b.length - a.length 61 | }) 62 | for (var i = 0; i < context_variables.length; i++) { 63 | set += "/ \"" + context_variables[i] + "\" " 64 | } 65 | 66 | var extra_text = "\n" + arrow + "\n" + sep + "\n" + conn + "\n" + set + "\n" + form + "\n" + atom_var + "\n" + atom + "\n" 67 | parser_text += extra_text 68 | parser = peg.generate(parser_text) 69 | formula_parser_text += extra_text 70 | formula_parser = peg.generate(formula_parser_text) 71 | callback() 72 | }) 73 | } 74 | 75 | -------------------------------------------------------------------------------- /public/javascripts/calculus/get_set_calcs.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var c = 0 8 | 9 | function get_calculi_toPage() { 10 | var calculi_container = $("#calculi") 11 | for (var i = 0; i < c; i++) { 12 | var entry = $("#calc_"+i) 13 | if (entry != null) { 14 | entry.remove() 15 | } 16 | } 17 | $.get("/sequoia/api/calculi/"+user_id, function(calcs, status) { 18 | var calculi = calcs.calculi 19 | for (var i = 0; i < calculi.length; i++) { 20 | calculi_container.append( 21 | '
'+ 22 | '
'+ 23 | '
'+calculi[i].title+'
'+ 24 | '
'+calculi[i].description+'
'+ 25 | '
'+ 26 | '
'+ 27 | 'Select'+ 28 | 'Delete'+ 29 | '
'+ 30 | '
' 31 | ) 32 | } 33 | c = calculi.length 34 | }) 35 | } 36 | 37 | 38 | function addCalculus() { 39 | var calculi_container = $("#calculi") 40 | var title = escape_norm($("#title").val().trim()) 41 | var description = escape_norm($("#description").val().trim()) 42 | if (title != "" && description != "") { 43 | $.post("/sequoia/api/calculus", {title : title, description : description, user : user_id}, function(data, status) { 44 | calculi_container.append( 45 | '
'+ 46 | '
'+ 47 | '
'+data.calculus.title+'
'+ 48 | '
'+data.calculus.description+'
'+ 49 | '
'+ 50 | '
'+ 51 | 'Select'+ 52 | 'Delete'+ 53 | '
'+ 54 | '
' 55 | ) 56 | c++ 57 | $("#title").val("") 58 | $("#description").val("") 59 | }) 60 | } 61 | } 62 | 63 | 64 | function addSomeCalculus(num) { 65 | var calculi_container = $("#calculi") 66 | var sample = ["LJ", "LK", "S4","Lax"][num] 67 | var title = sample 68 | var description = "This is a sample calculus with some basic rules. Try it out!" 69 | $.post("/sequoia/api/calculus", {title : title, description : description, user : user_id}, function(data, status) { 70 | var sampleCalc = data.calculus 71 | var syms_rules = sample_calc(sample, sampleCalc._id) 72 | $.post("/sequoia/api/symbols_init", {items : JSON.stringify(syms_rules[0])}, function(data, status) { 73 | $.post("/sequoia/api/rules_init", {items : JSON.stringify(syms_rules[1])}, function(data, status) { 74 | calculi_container.append( 75 | '
'+ 76 | '
'+ 77 | '
'+sampleCalc.title+'
'+ 78 | '
'+sampleCalc.description+'
'+ 79 | '
'+ 80 | '
'+ 81 | 'Select'+ 82 | 'Delete'+ 83 | '
'+ 84 | '
' 85 | ) 86 | c++ 87 | $("#title").val("") 88 | $("#description").val("") 89 | }) 90 | }) 91 | }) 92 | } 93 | 94 | 95 | function deleteCalculus(card_id, mongo_id) { 96 | $("#modal1").modal({ 97 | onApprove: function() { 98 | $.ajax({ 99 | url: "/sequoia/api/calculus", 100 | type: "DELETE", 101 | data : {"id" : mongo_id}, 102 | success: function(result) { 103 | $("#calc_"+card_id).hide('slow', function() {$("#calc_"+card_id).remove()}) 104 | for (var i = card_id+1; i < c; i++) { 105 | var delete_text = $("#delete_"+i).attr("onClick").split(",")[1] 106 | var new_delete_text = "deleteCalculus("+(i-1)+","+delete_text 107 | $("#delete_"+i).attr("onClick", new_delete_text) 108 | $("#delete_"+i).attr("id", "delete_"+(i-1)) 109 | $("#calc_"+i).attr("id", "calc_"+(i-1)) 110 | } 111 | c -- 112 | console.log("Calculus sucessfully deleted.") 113 | }, 114 | error: function(result) { 115 | console.log("ERROR: Calculus could not be deleted.") 116 | } 117 | }) 118 | } 119 | }) 120 | .modal("setting", "closable", false).modal("show") 121 | } -------------------------------------------------------------------------------- /public/javascripts/calculus/setupItems.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var user_id = $("#user_id").text() 8 | $("#main-menu").sticky({}); 9 | $("#Home_icon").attr("class", "active item") 10 | get_calculi_toPage() -------------------------------------------------------------------------------- /public/javascripts/escape_text.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | function escape_norm(text) { 8 | var map = { 9 | '&': '&', 10 | '<': '<', 11 | '>': '>' 12 | }; 13 | return text.replace(/[&<>]/g, function(m) { return map[m]; }); 14 | } 15 | 16 | 17 | function escape_latex(text) { 18 | var map = { 19 | '&': '&', 20 | '<': '<', 21 | '>': '>', 22 | '"': '"', 23 | "'": ''' 24 | }; 25 | return text.replace(/[&<>"']/g, function(m) { return map[m]; }); 26 | } -------------------------------------------------------------------------------- /public/javascripts/login/addUser.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | function addUser() { 8 | $("#warning").css("visibility", "hidden") 9 | $("#p1").attr("class", "required field") 10 | $("#p2").attr("class", "required field") 11 | $("#u").attr("class", "required field") 12 | var username = escape_norm($("#username").val().trim()) 13 | var password1 = escape_norm($("#password1").val().trim()) 14 | var password2 = escape_norm($("#password2").val().trim()) 15 | var email = escape_norm($("#email").val().trim()) 16 | var occupation = escape_latex($("#occupation").val().trim()) 17 | if (username == "" || password1 == "" || password2 == "") { 18 | if (username == "") { 19 | $("#u").attr("class", "required field error") 20 | } 21 | if (password1 == "") { 22 | $("#p1").attr("class", "required field error") 23 | } 24 | if (password2 == "") { 25 | $("#p2").attr("class", "required field error") 26 | } 27 | return 28 | } else if (username.length < 3 || password1.length < 8 || password2.length < 8) { 29 | if (username.length < 3) { 30 | $("#u").attr("class", "required field error") 31 | } 32 | if (password1.length < 8 ) { 33 | $("#p1").attr("class", "required field error") 34 | } 35 | if (password2.length < 8) { 36 | $("#p2").attr("class", "required field error") 37 | } 38 | $("#warning_header").html("Usernames must be at least three characters long, and passwords must be at least eight characters long.") 39 | $("#warning").css("visibility", "visible") 40 | return 41 | } else { 42 | $.get("/sequoia/api/users/"+username, function(data, status) { 43 | if (data.status == "success") { 44 | $("#u").attr("class", "required field error") 45 | $("#warning_header").html("Username already exists.") 46 | $("#warning").css("visibility", "visible") 47 | return 48 | } else { 49 | if (password1 != password2) { 50 | $("#p1").attr("class", "required field error") 51 | $("#p2").attr("class", "required field error") 52 | $("#warning_header").html("Passwords are not the same.") 53 | $("#warning").css("visibility", "visible") 54 | return 55 | } else { 56 | $.post("/sequoia/api/user", {username : username, password : password1, 57 | email : email, occupation : occupation}, function(data, status) { 58 | window.location.href = "/sequoia/login"}) 59 | } 60 | } 61 | }) 62 | } 63 | return 64 | } -------------------------------------------------------------------------------- /public/javascripts/login/setupItems.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | 8 | $("#main-menu").sticky({}); 9 | if ($("#page").text() == "fail") { 10 | $("#warning").css("visibility", "visible") 11 | } else if ($("#page").text() == "in") { 12 | $("#go_button").html('Let\'s Go ') 13 | } 14 | -------------------------------------------------------------------------------- /public/javascripts/parser_text.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var pt = 8 | ` 9 | // Sequent 10 | SEQ 11 | = _ ctx1:CTX_STR _ seq_sign:SeqSign _ ctx2:CTX_STR _ { return "Seq (" + ctx1 + ', Con ("' + seq_sign + '"), ' + ctx2 + ")" } 12 | 13 | // Context struct 14 | CTX_STR 15 | = ctx:CTX _ ctx_sep:CtxSep _ ctx_str:CTX_STR { return 'Mult ( Con ("' + ctx_sep + '"), ' + ctx + ", " + ctx_str + ")" } 16 | / ctx:CTX { return "Single (" + ctx + ")" } 17 | 18 | // Context 19 | CTX 20 | = ctx_lst:CTX_LST { 21 | var [ctx_vars, forms] = ctx_lst 22 | var c = ctx_vars.join(", ") 23 | var f = forms.join(", ") 24 | return "Ctx ([" + c + "], [" + f + "])" 25 | } 26 | 27 | CTX_LST 28 | = ctx_var:CTX_VAR _ "," _ ctx_lst:CTX_LST { 29 | var [ctx_vars, forms] = ctx_lst 30 | ctx_vars.unshift(ctx_var) 31 | return [ctx_vars, forms] 32 | } 33 | / form:FORM _ "," _ ctx_lst:CTX_LST _ { 34 | var [ctx_vars, forms] = ctx_lst 35 | forms.unshift(form) 36 | return [ctx_vars, forms] 37 | } 38 | / ctx_var:CTX_VAR { return [[ctx_var], []] } 39 | / form:FORM { return [[], [form]] } 40 | / _ { return [[],[]] } 41 | 42 | // Formula 43 | FORM = BIFORM / GENFORM 44 | 45 | FORM_LIST 46 | = _ form:FORM _ "," _ form_lst:FORM_LIST _ { 47 | form_lst.unshift(form) 48 | return form_lst 49 | } 50 | / _ form:FORM _ { return [form] } 51 | 52 | BIFORM 53 | = fr:GENFORM _ conn:CONN _ fr2:FORM 54 | { return "Form (" + conn + ", [" + fr + "," + fr2 + "])" } 55 | 56 | GENFORM 57 | = "(" _ form:FORM _ ")" { return form } 58 | / conn:CONN _ form:GENFORM { return "Form (" + conn + ", [" + form + "])" } 59 | / conn:CONN _ "(" _ fls:FORM_LIST _ ")" {return "Form(" + conn + ",[" + fls.join(", ") + "])"} 60 | / conn:CONN { return "Form (" + conn + ", [])" } 61 | / form_var:FORM_VAR { return form_var } 62 | / atom_var:ATOM_VAR { return atom_var } 63 | / atom:ATOM { return atom } 64 | 65 | // Symbols 66 | CTX_VAR 67 | = conn:CONN _ ctx_var:CtxVar { return 'CtxVar (SOME(' + conn + '),"' + ctx_var + '")' } 68 | / ctx_var:CtxVar { return 'CtxVar (NONE,"' + ctx_var + '")' } 69 | FORM_VAR = form_var:FormVar { return 'FormVar ("' + form_var + '")' } 70 | ATOM_VAR = atom_var:AtomVar { return 'AtomVar ("' + atom_var + '")' } 71 | ATOM = atom:Atom { return 'Atom ("' + atom + '")' } 72 | CONN = conn:Conn { return 'Con ("' + conn + '")' } 73 | 74 | _ "whitespace" 75 | = [ ]* 76 | ` 77 | 78 | var fpt = 79 | ` 80 | // Formula 81 | FORM = BIFORM / GENFORM 82 | 83 | FORM_LIST 84 | = _ form:FORM _ "," _ form_lst:FORM_LIST _ { 85 | form_lst.unshift(form) 86 | return form_lst 87 | } 88 | / _ form:FORM _ { return [form] } 89 | 90 | BIFORM 91 | = fr:GENFORM _ conn:CONN _ fr2:FORM 92 | { return "Form (" + conn + ", [" + fr + "," + fr2 + "])" } 93 | 94 | GENFORM 95 | = "(" _ form:FORM _ ")" { return form } 96 | / conn:CONN _ form:GENFORM { return "Form (" + conn + ", [" + form + "])" } 97 | / conn:CONN _ "(" _ fls:FORM_LIST _ ")" {return 'Form(' + conn + ",[" + fls.join(", ") + "])"} 98 | / form_var:FORM_VAR { return form_var } 99 | / atom_var:ATOM_VAR { return atom_var } 100 | / atom:ATOM { return atom } 101 | 102 | // Symbols 103 | FORM_VAR = form_var:FormVar { return 'FormVar ("' + form_var + '")' } 104 | ATOM_VAR = atom_var:AtomVar { return 'AtomVar ("' + atom_var + '")' } 105 | ATOM = atom:Atom { return 'Atom ("' + atom + '")' } 106 | CONN = conn:Conn { return 'Con ("' + conn + '")' } 107 | 108 | _ "whitespace" 109 | = [ ]* 110 | ` -------------------------------------------------------------------------------- /public/javascripts/properties/checkPerms.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var proof_content = {"trees":[]} 8 | var rule1 = "" 9 | var rule2 = "" 10 | 11 | function selectRule(bl, i) { 12 | if (bl && (rule1 == "" || rule2 == "")) { 13 | var card_color = "" 14 | if (rule1 == "") { 15 | rule1 = "r"+i 16 | card_color = "blue" 17 | } else if (rule2 == "") { 18 | rule2 = "r"+i 19 | card_color = "red" 20 | } 21 | $("#rule_card"+i).attr("class", "ui raised card") 22 | $("#b"+i).attr("class", "ui active "+card_color+" bottom attached button") 23 | $("#b"+i).attr("onClick", "selectRule(false,"+i+")") 24 | $("#i"+i).attr("class", "close icon") 25 | } else if (!bl) { 26 | if (rule1 == "r"+i) { 27 | rule1 = "" 28 | } else if (rule2 == "r"+i) { 29 | rule2 = "" 30 | } 31 | $("#rule_card"+i).attr("class", "ui card") 32 | $("#b"+i).attr("class", "ui bottom attached button") 33 | $("#b"+i).attr("onClick", "selectRule(true,"+i+")") 34 | $("#i"+i).attr("class", "add icon") 35 | $("#perm_button").attr("class", "ui disabled teal large button") 36 | } 37 | if (rule1 != "" && rule2 != "") { 38 | $("#perm_button").attr("class", "ui teal large button") 39 | } 40 | } 41 | 42 | 43 | function permRules() { 44 | $("#loading").attr("class", "ui active inverted dimmer") 45 | $("#good_trees").html("") 46 | $("#bad_trees").html("") 47 | var ruletemp1 = $("#"+rule1) 48 | var name1 = ruletemp1.attr("rule_name") 49 | var side1 = ruletemp1.attr("side") 50 | var conclusion1 = ruletemp1.attr("conclusion") 51 | var premises1 = ruletemp1.attr("premises") 52 | var rule_sml1 = "Rule(\""+name1+"\","+side1+","+conclusion1+","+premises1+")" 53 | var ruletemp2 = $("#"+rule2) 54 | var name2 = ruletemp2.attr("rule_name") 55 | var side2 = ruletemp2.attr("side") 56 | var conclusion2 = ruletemp2.attr("conclusion") 57 | var premises2 = ruletemp2.attr("premises") 58 | var rule_sml2 = "Rule(\""+name2+"\","+side2+","+conclusion2+","+premises2+")" 59 | $.post("/sequoia/permute", {rule1 : rule_sml1, rule2 : rule_sml2, init_rules : init_strings, wL : weak_l, wR : weak_r}, function(data, status) { 60 | var output = data.output.split("%%%") 61 | var result = output[0] 62 | var answer = ["",""] 63 | if (result == "0") { 64 | answer[0] = "N/A" 65 | answer[1] = "These rules are not capable of permuting." 66 | } else if (result == "1") { 67 | answer[0] = "The rule permutes" 68 | answer[1] = "The first rule always permutes up the second. All permutation tree transformations were found and are shown below." 69 | } else if (result == "2") { 70 | answer[0] = "The rule does not permute" 71 | answer[1] = "The first rule never permutes up the second. No permutation tree transformations were found." 72 | } else if (result == "3") { 73 | answer[0] = "The rule permutes sometimes" 74 | answer[1] = "The first rule sometimes permutes up the second. Permutation tree transformations were found for some cases and are shown below, while no permutation transformations were found for the rest." 75 | } 76 | $("#info_header").html(answer[0]) 77 | $("#info_text").html(answer[1]) 78 | $("#info_answer").attr("class", "ui info message") 79 | $("#info_answer").css("visibility", "visible") 80 | var trees = output[1].split("&&&") 81 | var goodtrees = trees[0].split("###") 82 | var badtrees = trees[1].split("###") 83 | var gtrees = $("#good_trees") 84 | for (var i = 0; i < goodtrees.length; i++) { 85 | if (goodtrees[i] != "") { 86 | var display_proofs = goodtrees[i].split("~~~") 87 | proof_content["trees"].push(display_proofs[1]) 88 | gtrees.append( 89 | '
'+ 90 | '
'+display_proofs[0]+'
'+ 91 | '
' 92 | ) 93 | } 94 | } 95 | var btrees = $("#bad_trees") 96 | for (var i = 0; i < badtrees.length; i++) { 97 | if (badtrees[i] != "") { 98 | var display_proofs = badtrees[i].split("~~~") 99 | proof_content["trees"].push(display_proofs[1]) 100 | btrees.append( 101 | '
'+ 102 | '
'+display_proofs[0]+'
'+ 103 | '
' 104 | ) 105 | } 106 | } 107 | $("#download").css("display", "block") 108 | $("#download").attr("onclick", "download(\"Permutability\")") 109 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, gtrees[0]], function() { 110 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, btrees[0]], function() { 111 | $("#loading").attr("class", "ui inactive inverted dimmer") 112 | }) 113 | }) 114 | }) 115 | } -------------------------------------------------------------------------------- /public/javascripts/properties/setupItems.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var calc_id = $("#calc_id").text() 8 | $("#main-menu").sticky({}); 9 | $("#Properties_icon").attr("class", "active item") 10 | $("#Calculus_icon").attr("href", "/sequoia/calculus/"+calc_id) 11 | $("#Prooftree_icon").attr("href", "/sequoia/calculus/"+calc_id+"/apply") 12 | $("#Properties_icon").attr("href", "/sequoia/calculus/"+calc_id+"/properties") 13 | var property = $("#property").text() 14 | if (property == "Main Page") { 15 | $("#prop1").attr("href", "/sequoia/calculus/"+calc_id+"/properties/init_coherence") 16 | $("#prop2").attr("href", "/sequoia/calculus/"+calc_id+"/properties/weak_admissability") 17 | $("#prop3").attr("href", "/sequoia/calculus/"+calc_id+"/properties/permutability") 18 | $("#prop4").attr("href", "/sequoia/calculus/"+calc_id+"/properties/cut_admissability") 19 | $("#prop5").attr("href", "/sequoia/calculus/"+calc_id+"/properties/invertibility") 20 | } 21 | else { 22 | MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$']]}}); 23 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, $("#description")[0]]) 24 | if (property == "Initial Coherence") { 25 | checkInit() 26 | } else if (property == "Weak Admissability") { 27 | checkWeak() 28 | } else if (property == "Permutability") { 29 | get_rules_toPage() 30 | } else if (property == "Cut Admissibility") { 31 | get_cuts_toPage() 32 | } 33 | } 34 | 35 | 36 | 37 | function unzip(item_list) { 38 | var item1 = [] 39 | var item2 = [] 40 | for (var j = 0; j < item_list.length; j++) { 41 | item1.push(item_list[j][0]) 42 | item2.push(item_list[j][1]) 43 | } 44 | return [item1,item2] 45 | } 46 | 47 | 48 | function list_to_string(item_list) { 49 | var item_string = "" 50 | for (var j = 0; j < item_list.length; j++) { 51 | item_string += item_list[j] + "," 52 | } 53 | return "["+item_string.slice(0,-1)+"]" 54 | } -------------------------------------------------------------------------------- /public/javascripts/rule/editTitleDesc.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var calcTitle = "" 8 | var calcDesc = "" 9 | 10 | function insertTD() { 11 | $("#editArea").html( 12 | '
'+ 13 | '
'+ 14 | ''+ 15 | '
'+ 16 | '
'+ 17 | '
'+ 18 | '
'+ 19 | '
'+ 20 | ''+ 21 | ''+ 24 | '
'+ 25 | '
' 26 | ) 27 | $("#title").val(calcTitle) 28 | $("#description").val(calcDesc) 29 | } 30 | 31 | 32 | function updateTD() { 33 | var newtitle = escape_norm($("#title").val().trim()) 34 | var newdescription = escape_norm($("#description").val().trim()) 35 | if (newtitle != "" && newdescription != "") { 36 | calcTitle = newtitle 37 | calcDesc = newdescription 38 | } 39 | $("#editArea").html( 40 | '
'+calcTitle+ 41 | '
'+calcDesc+ 42 | ''+ 45 | '
'+ 46 | '
'+ 47 | '
' 48 | ) 49 | $.ajax({ 50 | url: "/sequoia/api/calculus", 51 | type: "PUT", 52 | data : {id : calc_id, title : calcTitle, description : calcDesc, function(data) {}}}) 53 | } -------------------------------------------------------------------------------- /public/javascripts/rule/fixRules.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var parser_copy = pt 8 | 9 | function fixRules(callback) { 10 | var parser_text = parser_copy 11 | var arrow = "SeqSign = \"NO-ARROW\" " 12 | var sep = "CtxSep = \"NO-SEP\" " 13 | var conn = "Conn = \"NO-Conn\" " 14 | var set = "CtxVar = \"NO-SET\" " 15 | var form = "FormVar = \"NO-FORM\" " 16 | var atom_var = "AtomVar = \"NO-ATOMVAR\" " 17 | var atom = "Atom = \"NO-ATOM\" " 18 | $.get("/sequoia/api/rule_symbols/"+calc_id, function(sb, status) { 19 | var syms = sb.symbols 20 | syms = syms.sort(function(a, b) { 21 | return b.symbol.length - a.symbol.length 22 | }) 23 | for (var i = 0; i < syms.length; i++) { 24 | var symbol = syms[i].symbol 25 | var type = syms[i].type 26 | if (symbol.includes("\\")) { 27 | symbol = "\\" + symbol 28 | } 29 | if (type == "sequent sign") { 30 | arrow += "/ \"" + symbol + "\" " 31 | } 32 | else if (type == "context separator") { 33 | sep += "/ \"" + symbol + "\" " 34 | } 35 | else if (type == "connective") { 36 | conn += "/ \"" + symbol + "\" " 37 | } 38 | else if (type == "context variable") { 39 | set += "/ \"" + symbol + "\" " 40 | } 41 | else if (type == "formula variable") { 42 | form += "/ \"" + symbol + "\" " 43 | } 44 | else if (type == "atom variable") { 45 | atom_var += "/ \"" + symbol + "\" " 46 | } 47 | else if (type == "atom") { 48 | atom += "/ \"" + symbol + "\" " 49 | } 50 | } 51 | var extra_text = "\n" + arrow + "\n" + sep + "\n" + conn + "\n" + set + "\n" + form + "\n" + atom_var + "\n" + atom + "\n" 52 | parser_text += extra_text 53 | var parser = peg.generate(parser_text) 54 | $.get("/sequoia/api/rules/"+calc_id, function(rls, status) { 55 | var rules = rls.rules 56 | for (var i = 0; i < rules.length; i++) { 57 | parse_and_fix(parser, rules[i]) 58 | } 59 | callback() 60 | }) 61 | }) 62 | } 63 | 64 | 65 | function parse_and_fix(parser, rule) { 66 | var prem = rule.premises 67 | var parsed_prem = [] 68 | if (prem[0] != "") { 69 | for (var i = 0; i < prem.length; i++) { 70 | try { 71 | parsed_prem.push(parser.parse(prem[i])) 72 | } 73 | catch(error) { 74 | deleteRule(-1,rule._id) 75 | return 76 | } 77 | } 78 | } 79 | var conc = rule.conclusion 80 | try { 81 | var conc_final = parser.parse(conc) 82 | } 83 | catch(error) { 84 | deleteRule(-1,rule._id) 85 | return 86 | } 87 | $.ajax({ 88 | url: "/sequoia/api/rule", 89 | type: "PUT", 90 | data : {id : rule._id, rule : rule.rule, 91 | conclusion : conc, premises : JSON.stringify(prem), parsed_conc : conc_final, 92 | parsed_prem : JSON.stringify(parsed_prem), calculus : calc_id, 93 | connective : rule.connective, side : rule.side, type : rule.type, cutvar : rule.cutvar, function(data) {}}}) 94 | } -------------------------------------------------------------------------------- /public/javascripts/rule/getRule.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var calc_id = $("#calc_id").text() 8 | var rule_id = "" 9 | $("#main-menu").sticky({}); 10 | $("#Calculus_icon").attr("class", "active item") 11 | $("#Calculus_icon").attr("href", "/sequoia/calculus/"+calc_id) 12 | $("#Prooftree_icon").attr("href", "/sequoia/calculus/"+calc_id+"/apply") 13 | $("#Properties_icon").attr("href", "/sequoia/calculus/"+calc_id+"/properties") 14 | if ($("#page").text() == "Update") { 15 | rule_id = $("#rule_id").text() 16 | $("#prev button").attr("onclick", "preview('Update')") 17 | $.get("/sequoia/api/rule/"+rule_id, function(data, status) { 18 | $("#rule_id").val(data.rule._id) 19 | $("#rule_name").val(data.rule.rule) 20 | $("#side").val(data.rule.side) 21 | $("#kind").val(data.rule.type) 22 | $("#connective").val(data.rule.connective) 23 | for (var i = 0; i < data.rule.premises.length; i++) { 24 | if (i > 0) { 25 | addPremise() 26 | } 27 | $("#i"+i).val(data.rule.premises[i]) 28 | } 29 | $("#conclusion").val(data.rule.conclusion) 30 | }) 31 | } 32 | get_symbols_toTable("rule") -------------------------------------------------------------------------------- /public/javascripts/rule/rules_cards.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var r = 0 8 | 9 | function get_rules_toPage() { 10 | var rules_container = $("#rules") 11 | if (rules_container[0] == null) 12 | return 13 | for (i = 0; i < r; i++) { 14 | var entry = $("#rule_"+i) 15 | if (entry != null) { 16 | entry.remove() 17 | } 18 | } 19 | $.get("/sequoia/api/rules/"+calc_id, function(rls, status) { 20 | var rules = rls.rules 21 | for (var i = 0; i < rules.length; i++) { 22 | var card_content = '$$\\frac{'+rules[i].premises.join(" \\quad \\quad ")+'}{'+rules[i].conclusion+'}'+rules[i].rule+'$$' 23 | rules_container.append( 24 | '
'+ 25 | '
'+card_content+'
'+ 26 | '
'+ 27 | 'Edit'+ 28 | 'Delete'+ 29 | '
'+ 30 | '
' 31 | ) 32 | MathJax.Hub.Queue(["Typeset", MathJax.Hub, card_content]) 33 | } 34 | r = rules.length 35 | }) 36 | } 37 | 38 | 39 | function deleteRule(card_id, mongo_id) { 40 | $.ajax({ 41 | url: "/sequoia/api/rule", 42 | type: "DELETE", 43 | data : {"id" : mongo_id}, 44 | success: function(result) { 45 | if (card_id != -1) { 46 | $("#rule_"+card_id).hide('slow', function() {$("#rule_"+card_id).remove()}) 47 | for (var i = card_id+1; i < r; i++) { 48 | var delete_text = $("#deleteR_"+i).attr("onClick").split(",")[1] 49 | var new_delete_text = "deleteRule("+(i-1)+","+delete_text 50 | $("#deleteR_"+i).attr("onClick", new_delete_text) 51 | $("#deleteR_"+i).attr("id", "deleteR_"+(i-1)) 52 | $("#rule_"+i).attr("id", "rule_"+(i-1)) 53 | } 54 | r -- 55 | } 56 | console.log("Rule sucessfully deleted.") 57 | }, 58 | error: function(result) { 59 | console.log("ERROR: rule could not be deleted.") 60 | } 61 | }) 62 | } -------------------------------------------------------------------------------- /public/javascripts/rule/setupItems.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | var calc_id = $("#calc_id").text() 8 | $("#main-menu").sticky({}); 9 | $("#Calculus_icon").attr("class", "active item") 10 | $("#Calculus_icon").attr("href", "/sequoia/calculus/"+calc_id) 11 | $("#Prooftree_icon").attr("href", "/sequoia/calculus/"+calc_id+"/apply") 12 | $("#Properties_icon").attr("href", "/sequoia/calculus/"+calc_id+"/properties") 13 | $("#add_button").attr("href", "/sequoia/calculus/"+calc_id+"/add-rule") 14 | $.get("/sequoia/api/calculus/"+calc_id, function(calc, status) { 15 | $("#title").html(calc.calculus.title+$("#title").html()) 16 | $("#description").html(calc.calculus.description+$("#description").html()) 17 | calcTitle = calc.calculus.title 18 | calcDesc = calc.calculus.description 19 | get_rules_toPage() 20 | get_symbols_toTable("rule") 21 | }) 22 | -------------------------------------------------------------------------------- /public/javascripts/sample_images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-logic/sequoia-v0/30aee191f1815b97129b7bd9c0ac130fa0b9436a/public/javascripts/sample_images/favicon.ico -------------------------------------------------------------------------------- /public/javascripts/sample_images/gif1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-logic/sequoia-v0/30aee191f1815b97129b7bd9c0ac130fa0b9436a/public/javascripts/sample_images/gif1.gif -------------------------------------------------------------------------------- /public/javascripts/sample_images/gif2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-logic/sequoia-v0/30aee191f1815b97129b7bd9c0ac130fa0b9436a/public/javascripts/sample_images/gif2.gif -------------------------------------------------------------------------------- /public/javascripts/sample_images/gif3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meta-logic/sequoia-v0/30aee191f1815b97129b7bd9c0ac130fa0b9436a/public/javascripts/sample_images/gif3.gif -------------------------------------------------------------------------------- /sml/applyunifier/applyunifier.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature APPLYUNIFIER 9 | structure applyunifierImpl 10 | is 11 | ../basics/basics.cm 12 | applyunifier.sig 13 | applyunifier.sml 14 | -------------------------------------------------------------------------------- /sml/applyunifier/applyunifier.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem, Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature APPLYUNIFIER = sig 8 | 9 | structure DAT : DATATYPES 10 | type sub = DAT.sub 11 | type form = DAT.form 12 | type ctx_var = DAT.ctx_var 13 | type ctx = DAT.ctx 14 | type ctx_struct = DAT.ctx_struct 15 | type seq = DAT.seq 16 | type der_tree = DAT.der_tree 17 | type constraint = DAT.ctx_var * DAT.ctx_var list * DAT.ctx_var list 18 | 19 | val apply_form_Unifier : form * sub list -> form 20 | val apply_formL_Unifier : form list * sub list -> form list 21 | val apply_formL_allUnifiers : form list * sub list list -> form list list 22 | 23 | val apply_ctx_var_Unifier : ctx_var * sub list -> ctx_var list * form list 24 | val apply_ctx_varL_Unifier : ctx_var list * sub list -> (ctx_var list * form list) list 25 | val apply_ctx_varL_allUnifiers : ctx_var list * sub list list -> (ctx_var list * form list) list list 26 | 27 | val apply_ctx_Unifier : ctx * sub list -> ctx 28 | val apply_ctx_allUnifier : ctx * sub list list -> ctx list 29 | 30 | val apply_ctx_struct_Unifier : ctx_struct * sub list -> ctx_struct 31 | val apply_ctx_struct_allUnifiers : ctx_struct * sub list list -> ctx_struct list 32 | 33 | (* val apply_constraint_Unifier : constraint * sub list -> constraint *) 34 | val apply_constraintL_Unifier : constraint list * sub list -> constraint list 35 | 36 | val apply_seq_Unifier : seq * sub list -> seq 37 | val apply_seq_allUnifier : seq * sub list list -> seq list 38 | 39 | val apply_der_tree_Unifier : der_tree * sub list -> der_tree 40 | 41 | val compose : sub * sub list -> sub * bool 42 | val UnifierComposition : sub list * sub list -> sub list 43 | 44 | end -------------------------------------------------------------------------------- /sml/basics/basics.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | Library($/basis.cm) 9 | Library($SMLNJ-LIB/Util/smlnj-lib.cm) 10 | signature HELPERS 11 | structure helpersImpl 12 | signature DATATYPES 13 | structure datatypesImpl 14 | structure StringKey 15 | structure CtxVarKey 16 | structure CtxVarConKey 17 | structure FormKey 18 | is 19 | helpers/helpers.cm 20 | datatypes/datatypes.cm 21 | ord_keys/string_key.sml 22 | ord_keys/ctx_var_key.sml 23 | ord_keys/ctx_var_con_key.sml 24 | ord_keys/form_key.sml 25 | -------------------------------------------------------------------------------- /sml/basics/datatypes/datatypes.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature DATATYPES 9 | structure datatypesImpl 10 | is 11 | ../helpers/helpers.cm 12 | datatypes.sig 13 | datatypes.sml 14 | 15 | -------------------------------------------------------------------------------- /sml/basics/datatypes/datatypes.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature DATATYPES = 8 | sig 9 | 10 | (* See implementation for more information about the datatypes *) 11 | 12 | datatype conn = Con of string 13 | 14 | datatype form = Atom of string 15 | | AtomVar of string 16 | | FormVar of string 17 | | Form of conn * form list 18 | 19 | datatype ctx_var = CtxVar of conn option * string 20 | 21 | datatype ctx = Ctx of ctx_var list * form list 22 | 23 | datatype ctx_struct = Empty 24 | | Single of ctx 25 | | Mult of conn * ctx * ctx_struct 26 | 27 | datatype seq = Seq of ctx_struct * conn * ctx_struct 28 | 29 | datatype side = Left 30 | | Right 31 | | None 32 | 33 | datatype rule = Rule of string * side * seq * seq list 34 | 35 | datatype sub = Fs of form * form 36 | | CTXs of ctx_var * ctx 37 | 38 | type rule_name = string option 39 | datatype der_tree = DerTree of string * seq * rule_name * der_tree list 40 | 41 | val conn_toString : conn -> string 42 | val conn_eq : conn * conn -> bool 43 | 44 | val form_toString : form -> string 45 | val form_stringify : form -> string 46 | val form_eq : form * form -> bool 47 | val form_alpha_eq : form * form -> bool 48 | val form_larger : form * form -> bool 49 | val formL_toString : form list -> string 50 | val form_update : (form -> form) -> form -> form 51 | 52 | val ctx_var_toString : ctx_var -> string 53 | val ctx_var_stringify : ctx_var -> string 54 | val ctx_var_eq : ctx_var * ctx_var -> bool 55 | val ctx_varL_toString : ctx_var list -> string 56 | val ctx_var_update : (ctx_var -> ctx_var) -> ctx_var -> ctx_var 57 | val const_toString : ctx_var * ctx_var list * ctx_var list -> string 58 | val const_stringify : ctx_var * ctx_var list * ctx_var list -> string 59 | 60 | val ctx_toString : ctx -> string 61 | val ctx_stringify : ctx -> string 62 | val ctx_eq : ctx * ctx -> bool 63 | val ctx_alpha_eq : ctx * ctx -> bool 64 | val ctx_update : ((ctx_var -> ctx_var)*(form -> form)) -> ctx -> ctx 65 | 66 | val ctx_struct_toString : ctx_struct -> string 67 | val ctx_struct_stringify : ctx_struct -> string 68 | val ctx_struct_eq : ctx_struct * ctx_struct -> bool 69 | val ctx_struct_alpha_eq : ctx_struct * ctx_struct -> bool 70 | val ctx_struct_update : ((ctx_var -> ctx_var)*(form -> form)) -> ctx_struct -> ctx_struct 71 | 72 | val seq_toString : seq -> string 73 | val seq_stringify : seq -> string 74 | val seq_eq : seq * seq -> bool 75 | val seq_alpha_eq : seq * seq -> bool 76 | val seq_update : ((ctx_var -> ctx_var)*(form -> form)) -> seq -> seq 77 | 78 | val rule_eq : rule * rule -> bool 79 | 80 | val sub_eq : sub * sub -> bool 81 | val sub_prefix_eq : sub * sub -> bool 82 | val sub_to_string : sub -> string 83 | val subs_to_string : sub list -> string 84 | end 85 | -------------------------------------------------------------------------------- /sml/basics/helpers/helpers.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature HELPERS 9 | structure helpersImpl 10 | Library($/basis.cm) 11 | Library($SMLNJ-LIB/Util/smlnj-lib.cm) 12 | is 13 | helpers.sig 14 | helpers.sml 15 | $/basis.cm 16 | $SMLNJ-LIB/Util/smlnj-lib.cm 17 | 18 | -------------------------------------------------------------------------------- /sml/basics/helpers/helpers.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature HELPERS = sig 8 | 9 | val remove : 'a * 'a list * ('a * 'a -> bool) -> 'a list 10 | val mset_eq : 'a list * 'a list * ('a * 'a -> bool) -> bool 11 | val mset_subset : 'a list * 'a list * ('a * 'a -> bool) -> bool 12 | val chooseK : 'a list * int * ('a * 'a -> bool) -> ('a list * 'a list) list 13 | val chooseDP : 'a list * int -> 'a list list 14 | val permutations : 'a list -> 'a list list 15 | val distribute : 'a list list * 'a -> 'a list list list 16 | val partition_into : int * 'a list -> 'a list list list 17 | val remove_similar : 'a list * 'a list * ('a * 'a -> bool) -> ('a list * 'a list) 18 | val remove_duplicates : ('a list * 'b) list * ('a * 'a -> bool) -> ('a list * 'b) list 19 | 20 | end 21 | -------------------------------------------------------------------------------- /sml/basics/helpers/helpers.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem, Giselle Reis, Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | structure helpersImpl : HELPERS = 8 | struct 9 | 10 | fun remove (_, [], _) = [] 11 | | remove (f, e::ls, cmpf) = if cmpf(f,e) then ls else e::remove (f, ls, cmpf) 12 | 13 | (* Checks if two multisets, encoded as lists, are the same *) 14 | fun mset_eq ([], [], _) = true 15 | | mset_eq (a :: l1, l2, eq) = 16 | let val l1' = List.filter (fn x => not (eq (x, a)) ) l1 17 | val l2' = List.filter (fn x => not (eq (x, a)) ) l2 18 | in 19 | List.length (a::l1) = List.length l2 andalso 20 | mset_eq (l1', l2', eq) 21 | end 22 | | mset_eq _ = false 23 | 24 | fun mset_subset ([],_,_) = true 25 | | mset_subset (a::l1,l2,eq) = 26 | let val eq' = (fn x => eq(a,x)) 27 | val (a1,l1') = List.partition eq' (a::l1) 28 | val (a2,l2') = List.partition eq' (l2) 29 | in 30 | (List.length(a1) <= List.length(a2)) andalso mset_subset(l1',l2',eq) 31 | end 32 | 33 | fun chooseK (forms, k, cmpf) = 34 | let 35 | fun set_chosen ([], cmpf) = [] 36 | | set_chosen ((x,y)::ls, cmpf) = 37 | let 38 | val filtered = List.filter(fn (ck, _) => not (mset_eq (ck, x, cmpf)))ls 39 | in 40 | (x,y) :: set_chosen (filtered, cmpf) 41 | end 42 | val formSize = List.length(forms) 43 | fun choose (forms, 0, rest) = [(nil, rest@forms)] 44 | | choose (nil, k, rest) = [] 45 | | choose (f::forms', k, rest) = 46 | case List.length(f::forms') < k of 47 | true => [] 48 | | false => 49 | let val f_picked = choose (forms', k-1, rest) 50 | val f_skipped = choose (forms', k, rest@[f]) 51 | in 52 | (List.map(fn (c,r) => (f::c, r))f_picked) @ f_skipped 53 | end 54 | in 55 | case Int.compare(k, Int.div(formSize, 2)) of 56 | GREATER => set_chosen(choose(forms, k, []), cmpf) 57 | | _ => set_chosen(List.map(fn (a,b) => (b,a))(choose(forms, formSize-k, [])), cmpf) 58 | end 59 | 60 | fun chooseDP (forms, k) = 61 | let val DPA = Array2.tabulate (Array2.RowMajor) (k+1, List.length(forms)+1, 62 | fn(i,j) => if i = 0 then SOME([nil]) else if i > j then SOME([]) else NONE) 63 | fun choose (_, 0) = [[]] 64 | | choose ([],_) = [] 65 | | choose (f::forms', k) = 66 | case Array2.sub(DPA, k, List.length(f::forms')) of 67 | SOME(a) => a 68 | | NONE => 69 | (let 70 | val sub_chosen = choose (forms', k-1) 71 | val () = Array2.update(DPA, k-1, List.length(forms'), SOME(sub_chosen)) 72 | val sub_skipped = choose (forms', k) 73 | val () = Array2.update(DPA, k, List.length(forms'), SOME(sub_skipped)) 74 | in 75 | (List.map(fn ls => f::ls)sub_chosen) @ sub_skipped 76 | end) 77 | in 78 | choose (forms, k) 79 | end 80 | 81 | (* Returns a list with all possible permutations of the argument *) 82 | fun permutations [] = [[]] 83 | | permutations (x :: l) = 84 | let 85 | fun ins_x [] = [[x]] 86 | | ins_x (a :: l) = (x :: a :: l) :: List.map (fn lx => a :: lx) (ins_x l) 87 | in 88 | List.foldl (fn (p, ps) => ps @ (ins_x p)) [] (permutations l) 89 | end 90 | 91 | fun distribute (ctx, f) = List.tabulate (List.length(ctx), 92 | fn i => 93 | List.take(ctx, i) @ [List.nth(ctx, i) @ [f]] @ List.drop(ctx, i+1)) 94 | 95 | fun partition_into (n, forms) = 96 | let 97 | fun partition (ctxs, []) = ctxs 98 | | partition (ctxs, f::forms) = 99 | partition(List.concat(List.map(fn c => distribute(c, f))ctxs), forms) 100 | in 101 | partition([List.tabulate(n, fn _ => [])], forms) 102 | end 103 | 104 | fun remove_similar ([], ls2, _) = ([], ls2) 105 | | remove_similar (x::ls1, ls2, cmpf) = 106 | let val lsp2 = remove (x, ls2, cmpf) in 107 | if List.length(lsp2) = List.length(ls2) then 108 | let val (a,b) = remove_similar (ls1, ls2, cmpf) in (x::a,b) end 109 | else remove_similar (ls1, lsp2, cmpf) end 110 | 111 | fun remove_duplicates ([], _) = [] 112 | | remove_duplicates ((x,y)::ls, cmpf) = 113 | let val filtered = List.filter(fn (ck, _) => not (mset_eq (ck, x, cmpf)))ls in 114 | (x,y) :: remove_duplicates (filtered, cmpf) end 115 | 116 | end 117 | -------------------------------------------------------------------------------- /sml/basics/ord_keys/ctx_var_con_key.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | structure CtxVarConKey : ORD_KEY = 8 | struct 9 | structure D = datatypesImpl 10 | type ord_key = D.ctx_var 11 | fun compare (D.CtxVar(a,_),D.CtxVar(b,_)) = 12 | (case (a,b) of 13 | (NONE,NONE) => EQUAL 14 | | (SOME (D.Con a'),SOME (D.Con b')) => String.compare(a',b') 15 | | (NONE, SOME _) => LESS 16 | | _ => GREATER ) 17 | end -------------------------------------------------------------------------------- /sml/basics/ord_keys/ctx_var_key.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | structure CtxVarKey : ORD_KEY = 8 | struct 9 | structure D = datatypesImpl 10 | type ord_key = D.ctx_var 11 | fun compare_con (D.CtxVar(a,_),D.CtxVar(b,_)) = 12 | (case (a,b) of 13 | (NONE,NONE) => EQUAL 14 | | (SOME (D.Con a'),SOME (D.Con b')) => String.compare(a',b') 15 | | (NONE, SOME _) => LESS 16 | | _ => GREATER ) 17 | fun compare (a as D.CtxVar(_,na),b as D.CtxVar(_,nb)) = 18 | (case compare_con(a,b) of 19 | LESS => LESS 20 | | GREATER => GREATER 21 | | _ => String.compare(na,nb)) 22 | end -------------------------------------------------------------------------------- /sml/basics/ord_keys/form_key.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | (*order: Atom, AtomVar, FormVar, Form (connective then formulas)*) 8 | 9 | structure FormKey : ORD_KEY = 10 | struct 11 | structure Dat = datatypesImpl 12 | type ord_key = Dat.form 13 | val cmp = String.compare 14 | fun compare (A,B) = 15 | (case (A,B) of 16 | (Dat.Atom(a),Dat.Atom(b))=> cmp(a,b) 17 | | (Dat.AtomVar(a),Dat.AtomVar(b))=> cmp(a,b) 18 | | (Dat.FormVar(a),Dat.FormVar(b))=> cmp(a,b) 19 | | (Dat.Form(Dat.Con(c1),fl1),Dat.Form(Dat.Con(c2),fl2)) => 20 | (case cmp(c1,c2) of 21 | EQUAL => compare_form_list(fl1,fl2) 22 | | res => res 23 | ) 24 | | (Dat.Atom(_),_) => LESS 25 | | (_, Dat.Atom(_)) => GREATER 26 | | (Dat.AtomVar(_),_) => LESS 27 | | (_,Dat.AtomVar(_)) => GREATER 28 | | (Dat.FormVar(_),_) => LESS 29 | | (_,Dat.FormVar(_)) => GREATER 30 | ) 31 | and compare_form_list (l1,l2) = 32 | (case (l1,l2) of 33 | ([],[]) => EQUAL 34 | | ([],_) => LESS 35 | | (_,[]) => GREATER 36 | | (a::l1',b::l2') => 37 | (case compare(a,b) of 38 | EQUAL => compare_form_list(l1',l2') 39 | | res => res) 40 | ) 41 | end 42 | -------------------------------------------------------------------------------- /sml/basics/ord_keys/string_key.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | structure StringKey:ORD_KEY = 8 | struct 9 | type ord_key = string 10 | val compare = String.compare 11 | end -------------------------------------------------------------------------------- /sml/calculi/README: -------------------------------------------------------------------------------- 1 | SML structures for proof system rules. 2 | each system has a file 3 | 4 | files: 5 | linear logic 6 | constructive logic 7 | 8 | 9 | TODO 10 | multi conclusion sequent calculus 11 | -------------------------------------------------------------------------------- /sml/calculi/calculi.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group is 8 | ../basics/basics.cm 9 | ../properties/properties.cm 10 | ../latex_exporter/latex_exporter.cm 11 | constructive_logic.sml 12 | lin_logic.sml 13 | -------------------------------------------------------------------------------- /sml/equiv/check.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | structure Popen :> 8 | sig 9 | (* Parent wants to write to stdin, read stdout, or read stdout + stderr *) 10 | datatype pipe_type = PIPE_W | PIPE_R | PIPE_RW 11 | type my_fd = {infd : Posix.IO.file_desc, outfd : Posix.IO.file_desc} 12 | val popen : string * pipe_type -> my_fd 13 | val pclose : my_fd -> (Posix.Process.pid*Posix.Process.exit_status) option 14 | end = 15 | struct 16 | 17 | datatype pipe_type = PIPE_W | PIPE_R | PIPE_RW 18 | type my_fd = {infd : Posix.IO.file_desc, outfd : Posix.IO.file_desc} 19 | type pinfo = { fd :my_fd, pid : Posix.Process.pid , t : pipe_type} 20 | 21 | val pids : pinfo list ref = ref [] 22 | 23 | (* Implements popen(3) *) 24 | fun popen (cmd, t) = 25 | let val { infd = readfd, outfd = writefd } = Posix.IO.pipe () 26 | val { infd = readfd2, outfd = writefd2 } = Posix.IO.pipe () 27 | val base = {outfd = readfd, infd = writefd2 } 28 | in case (Posix.Process.fork (), t) 29 | of (NONE, t) => (* Child *) 30 | (( case t 31 | of PIPE_W => Posix.IO.dup2 { old = readfd2, new = Posix.FileSys.stdin } 32 | | PIPE_R => Posix.IO.dup2 { old = writefd, new = 33 | Posix.FileSys.wordToFD 0w10 } 34 | | PIPE_RW => ( Posix.IO.dup2 { old = writefd, new = 35 | Posix.FileSys.wordToFD 0w10 } 36 | ; Posix.IO.dup2 { old = readfd2, new = Posix.FileSys.stdin }) 37 | ; Posix.IO.close writefd 38 | ; Posix.IO.close readfd 39 | ; Posix.IO.close writefd2 40 | ; Posix.IO.close readfd2 41 | ; Posix.Process.execp ("/bin/sh", ["sh", "-c", cmd])) 42 | handle OS.SysErr (err, _) => 43 | ( print ("Fatal error in child: " ^ err ^ "\n") 44 | ; OS.Process.exit OS.Process.failure )) 45 | | (SOME pid, t) => (* Parent *) 46 | let val fd = case t of PIPE_W => (Posix.IO.close readfd2 47 | ;Posix.IO.close writefd 48 | ;Posix.IO.close readfd 49 | ; base) 50 | | PIPE_R => (Posix.IO.close writefd 51 | ;Posix.IO.close writefd2 52 | ;Posix.IO.close readfd2 53 | ; base) 54 | | PIPE_RW => (Posix.IO.close writefd 55 | ; Posix.IO.close readfd2 56 | ; base) 57 | val _ = pids := ({ fd = fd, pid = pid, t=t } :: !pids) 58 | in fd end 59 | end 60 | 61 | (* Implements pclose(3) *) 62 | fun pclose fd = 63 | case List.partition (fn { fd = f, pid = _, t=t } => f = fd) (!pids) 64 | of ([], _) => NONE 65 | | ([{ fd = _, pid = pid ,t = t}], pids') => 66 | let val _ = pids := pids' 67 | val status = Posix.Process.waitpid_nh (Posix.Process.W_CHILD pid, []) 68 | val _ = (case t of 69 | PIPE_W => Posix.IO.close (#infd fd) 70 | | PIPE_R => Posix.IO.close (#outfd fd) 71 | | PIPE_RW => (Posix.IO.close (#outfd fd);Posix.IO.close (#infd fd))) 72 | in status end 73 | | _ => raise Bind (* This should be impossible. *) 74 | end 75 | 76 | (*TODO proper name*) 77 | structure Check :> 78 | sig 79 | val main_check : string ref -> bool 80 | val test : string 81 | end 82 | = 83 | struct 84 | 85 | fun check (inp)= let 86 | val cmd = "python3 sml/equiv/milp/milp.py" 87 | val f = Popen.popen(cmd, Popen.PIPE_RW) 88 | val _ = Posix.IO.writeVec (#infd f, Word8VectorSlice.full (Byte.stringToBytes (!inp))); 89 | val _ = Posix.Process.waitpid_nh (Posix.Process.W_ANY_CHILD, []) 90 | val output = Byte.bytesToString (Posix.IO.readVec (#outfd f,10000)) 91 | val output_substring = Substring.full output 92 | val _ = Popen.pclose f 93 | val res = Substring.isSubstring "1" output_substring 94 | in 95 | res 96 | end 97 | 98 | 99 | (*given a file with the starting facts, checks for a condition (defined in the starting facts)*) 100 | val main_check = check 101 | (*can be used to test stuff*) 102 | val test = "currently unused" 103 | end 104 | -------------------------------------------------------------------------------- /sml/equiv/equiv.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature EQUIVALENCE 9 | structure Equivalence 10 | is 11 | ../basics/basics.cm 12 | ../unification/unification.cm 13 | check.sml 14 | equiv.sml 15 | equiv.sig 16 | -------------------------------------------------------------------------------- /sml/equiv/equiv.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature EQUIVALENCE = 8 | sig 9 | structure Dat : DATATYPES 10 | 11 | type constraint = (Dat.ctx_var * Dat.ctx_var list * Dat.ctx_var list) 12 | 13 | val ctx_equiv : Dat.ctx * Dat.ctx -> bool 14 | 15 | val ctx_struct_equiv : Dat.ctx_struct * Dat.ctx_struct -> bool 16 | 17 | val seq_equiv : Dat.seq*Dat.seq -> bool 18 | 19 | val check_consistent : (Dat.ctx_var * Dat.ctx_var list * Dat.ctx_var list) list * 20 | Dat.ctx_var list * Dat.ctx_var list-> bool 21 | 22 | val extract_constraints : (Dat.seq * Dat.seq) -> constraint list 23 | val check_premises : ((string * Dat.seq) list * Dat.der_tree * 24 | (Dat.ctx_var * Dat.ctx_var list * Dat.ctx_var list) list* 25 | Dat.ctx_var list * Dat.ctx_var list) -> Dat.der_tree option 26 | 27 | val check_premises_wk : ((string * Dat.seq) list * Dat.der_tree * 28 | (Dat.ctx_var * Dat.ctx_var list * Dat.ctx_var list) list* 29 | (bool list * bool list) * Dat.ctx_var list * Dat.ctx_var list) -> Dat.der_tree option 30 | 31 | end -------------------------------------------------------------------------------- /sml/equiv/equiv_test.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | structure EquivTest 9 | is 10 | ../basics/basics.cm 11 | equiv.cm 12 | equiv_test.sml 13 | -------------------------------------------------------------------------------- /sml/equiv/equiv_test.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | structure EquivTest = 8 | struct 9 | structure Dat = datatypesImpl 10 | 11 | structure E = Equivalence 12 | 13 | 14 | val t1_vars = [Dat.CtxVar("g"),Dat.CtxVar("1"),Dat.CtxVar("2"),Dat.CtxVar("3"),Dat.CtxVar("4")] 15 | val t2_vars = [Dat.CtxVar("p"),Dat.CtxVar("p1"),Dat.CtxVar("p2"),Dat.CtxVar("p3"),Dat.CtxVar("p4")] 16 | val constraints = [(Dat.CtxVar("test"),[Dat.CtxVar("g")],[Dat.CtxVar("1"),Dat.CtxVar("2")]), 17 | (Dat.CtxVar("test"),[Dat.CtxVar("2")],[Dat.CtxVar("3"),Dat.CtxVar("4")]), 18 | (Dat.CtxVar("test"),[Dat.CtxVar("p")],[Dat.CtxVar("p1"),Dat.CtxVar("p2")]), 19 | (Dat.CtxVar("test"),[Dat.CtxVar("p1")],[Dat.CtxVar("p3"),Dat.CtxVar("p4")]), 20 | (Dat.CtxVar("test"),[Dat.CtxVar("1")],[Dat.CtxVar("p3")]), 21 | (Dat.CtxVar("test"),[Dat.CtxVar("3")],[Dat.CtxVar("p4")]), 22 | (Dat.CtxVar("test"),[Dat.CtxVar("4")],[Dat.CtxVar("p2")])] 23 | val goal = [(Dat.CtxVar("test"),[Dat.CtxVar("g")],[Dat.CtxVar("p")])] 24 | 25 | (*test 1, should succeed. G = G1,G2| G2 = G3,G4 | G' = G1',G2' | G1' =G3',G4' | G1 = G3' | G3 = G4' | G4 = G2'*) 26 | (*checking if G = G'*) 27 | 28 | val test1 = E.check_consistent (constraints,t1_vars,t2_vars) 29 | 30 | val t1_vars2 = [Dat.CtxVar("g"),Dat.CtxVar("1"),Dat.CtxVar("2")] 31 | val t2_vars2 = [Dat.CtxVar("p")] 32 | val constraints2 = [(Dat.CtxVar("test"),[Dat.CtxVar("g")],[Dat.CtxVar("1"),Dat.CtxVar("2")]), 33 | (Dat.CtxVar("test"),[Dat.CtxVar("1")],[Dat.CtxVar("p")]), 34 | (Dat.CtxVar("test"),[Dat.CtxVar("2")],[Dat.CtxVar("p")])] 35 | (*test 2, should fail. G = G1,G2 | G1 = G' | G2 = G' |, checking if G = G'*) 36 | val test2 = E.check_consistent (constraints2,t1_vars2,t2_vars2) 37 | 38 | 39 | val constraints3 = [(Dat.CtxVar("test"),[Dat.CtxVar("g")],[Dat.CtxVar("1"),Dat.CtxVar("2")]), 40 | (Dat.CtxVar("test"),[Dat.CtxVar("2")],[Dat.CtxVar("3"),Dat.CtxVar("4")]), 41 | (Dat.CtxVar("test"),[Dat.CtxVar("p")],[Dat.CtxVar("p1"),Dat.CtxVar("p2")]), 42 | (Dat.CtxVar("test"),[Dat.CtxVar("p1")],[Dat.CtxVar("p3"),Dat.CtxVar("p4")]), 43 | (Dat.CtxVar("test"),[Dat.CtxVar("1")],[Dat.CtxVar("p3")]), 44 | (Dat.CtxVar("test"),[Dat.CtxVar("3")],[Dat.CtxVar("p4")]), 45 | (Dat.CtxVar("test"),[Dat.CtxVar("4")],[Dat.CtxVar("p2")]), 46 | (Dat.CtxVar("test"),[Dat.CtxVar("g")],[Dat.CtxVar("p3")])] 47 | val test3 = E.check_consistent (constraints3,t1_vars,t2_vars) 48 | 49 | val goal4 = [(Dat.CtxVar("left"),[Dat.CtxVar("g")],[Dat.CtxVar "gp"]),(Dat.CtxVar("right"),[Dat.CtxVar("d")],[Dat.CtxVar "dp"])] 50 | val constraints4 = [(Dat.CtxVar("test4"),[Dat.CtxVar("g")],[Dat.CtxVar("g1"),Dat.CtxVar("g2")]), 51 | (Dat.CtxVar("test4"),[Dat.CtxVar("d")],[Dat.CtxVar("d1"),Dat.CtxVar("d2")]), 52 | (Dat.CtxVar("test4"),[Dat.CtxVar("gp")],[Dat.CtxVar("gp1"),Dat.CtxVar("gp2")]), 53 | (Dat.CtxVar("test4"),[Dat.CtxVar("dp")],[Dat.CtxVar("dp1"),Dat.CtxVar("dp2")]), 54 | (Dat.CtxVar("match"),[Dat.CtxVar("g1")],[Dat.CtxVar("gp1")]), 55 | (Dat.CtxVar("match"),[Dat.CtxVar("d1")],[]), 56 | (Dat.CtxVar("match"),[Dat.CtxVar("g2")],[Dat.CtxVar("gp2")])] 57 | val t_left_vars = [Dat.CtxVar("g"),Dat.CtxVar("g1"),Dat.CtxVar("g2"),Dat.CtxVar("d"),Dat.CtxVar("d1"),Dat.CtxVar("d2")] 58 | val t_right_vars = [Dat.CtxVar("gp"),Dat.CtxVar("gp1"),Dat.CtxVar("gp2"),Dat.CtxVar("dp"),Dat.CtxVar("dp1"),Dat.CtxVar("dp2")] 59 | 60 | 61 | val test4 = E.check_consistent (constraints4,t_left_vars,t_right_vars) 62 | val test5 = E.check_consistent (constraints4,t_right_vars,t_left_vars) 63 | 64 | 65 | val true = test1 66 | val false = test2 67 | val false = test3 68 | val false = test4 69 | val true = test5 70 | 71 | end -------------------------------------------------------------------------------- /sml/equiv/milp/README: -------------------------------------------------------------------------------- 1 | input for milp: 2 | 1st row: 3 | R N M 4 | where R is the number of rows 5 | N is the number of variables 6 | M is the number of variables that come from the first tree 7 | 2nd row: 8 | variable names in order (N nonempty strings seperated by a space) 9 | 10 | this line should be followed by an RxN matrix, where each row is a 11 | constraint in the problem, and the variables from the first tree should 12 | be in the columns to the left 13 | -------------------------------------------------------------------------------- /sml/equiv/milp/milp.py: -------------------------------------------------------------------------------- 1 | # Sequoia Copyright (C) 2020 Mohammed Hashim 2 | # This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | # This is free software, and you are welcome to redistribute it 4 | # under certain conditions; see LICENSE for details. 5 | 6 | 7 | 8 | import sys 9 | import os 10 | 11 | 12 | def get_out(): 13 | try: 14 | return os.fdopen(10,'w') 15 | except OSError: 16 | return os.fdopen(1,'w') 17 | 18 | 19 | nl = os.open(os.devnull,os.O_WRONLY) 20 | temp = 15 21 | temp2 = 16 22 | 23 | stdout = 1 24 | stderr = 2 25 | 26 | os.dup2(stdout,temp) 27 | os.dup2(nl,stdout) 28 | 29 | os.dup2(stderr,temp2) 30 | os.dup2(nl,stderr) 31 | 32 | 33 | 34 | from mip.model import * 35 | from mip.constants import * 36 | 37 | 38 | 39 | #print(os.listdir('/proc/self/fd')) 40 | 41 | 42 | 43 | 44 | f = sys.stdin 45 | if (len(sys.argv)>=3): 46 | file = sys.argv[2] 47 | f = open(file,"r") 48 | 49 | w = os.fdopen(nl,'w') 50 | if len(sys.argv)>=2: 51 | log = sys.argv[1] 52 | w = open(log,"a") 53 | 54 | 55 | w.write("_________________________________________________\n") 56 | 57 | 58 | 59 | 60 | 61 | 62 | row_num, var_num, t1_num = list(map(int,f.readline().split(" "))) 63 | 64 | # variables = f.readline().strip().split(" ") 65 | # w.write(" ".join(variables)+"\n") 66 | # assert(len(variables)==var_num) 67 | 68 | 69 | 70 | 71 | def get_model(): 72 | m = Model("test",solver_name='cbc') 73 | return m 74 | 75 | m = get_model() 76 | 77 | 78 | m.verbose = 0 79 | 80 | 81 | 82 | #m.setParam("OutputFlag",0) 83 | 84 | rows = [0]*row_num 85 | for i in range(row_num): 86 | rows[i] = list(map(int,f.readline().split(" "))) 87 | 88 | f.close() 89 | # each row : (g,gp,g1p,g2p) 90 | 91 | #always square 92 | unifier = [0]*var_num 93 | for i in range(var_num): 94 | unifier[i] = [0]*var_num 95 | 96 | for i in range(t1_num): 97 | for j in range(var_num): 98 | unifier[i][j] = m.add_var(var_type=BINARY,name = 't1, var: %d to %d'%(i,j)) 99 | for i in range(t1_num,var_num): 100 | for j in range(var_num): 101 | unifier [i][j] = m.add_var(var_type = INTEGER,lb=0,name = 't2, var: %d to %d'%(i,j)) 102 | 103 | for i in range(row_num): 104 | for j in range(var_num): 105 | m += xsum(rows[i][var]*unifier[var][j] for var in range(var_num))==0 106 | for i in range(t1_num): 107 | m+= xsum(unifier[i][j] for j in range(var_num)) >= 1 108 | 109 | m.emphasis=1 110 | status = m.optimize() 111 | 112 | os.dup2(temp,stdout) 113 | os.dup2(temp2,stderr) 114 | 115 | 116 | solved = (status == OptimizationStatus.OPTIMAL) or (status == OptimizationStatus.FEASIBLE) 117 | 118 | sml_out = get_out() 119 | res = ("%d\n"%(int(solved))) 120 | sml_out.write(res) 121 | sml_out.close() 122 | w.write(str(solved) + "\n") 123 | if (solved): 124 | unifier = list(map((lambda x : list(map(lambda y: int(y.x),x))),unifier)) 125 | for i in range(len(unifier)): 126 | w.write(" ".join(map(str,unifier[i])) +"\n") 127 | 128 | w.close() 129 | if (os.isatty(nl)): 130 | os.close(nl) 131 | -------------------------------------------------------------------------------- /sml/equiv/milp/test1.txt: -------------------------------------------------------------------------------- 1 | 4 4 1 2 | 1 -1 0 0 3 | 0 1 -1 -1 4 | 1 0 -1 0 5 | 1 0 0 -1 6 | -------------------------------------------------------------------------------- /sml/equiv/milp/test2.txt: -------------------------------------------------------------------------------- 1 | 4 6 3 2 | 1 -1 -1 0 0 0 3 | 0 0 0 1 -1 -1 4 | 0 1 0 0 -1 0 5 | 0 0 1 0 0 -1 6 | -------------------------------------------------------------------------------- /sml/equiv/milp/test3.txt: -------------------------------------------------------------------------------- 1 | 1 3 2 2 | 1 1 -2 3 | -------------------------------------------------------------------------------- /sml/equiv/milp/test4.txt: -------------------------------------------------------------------------------- 1 | 1 5 0 2 | 2 1 1 2 1 3 | -------------------------------------------------------------------------------- /sml/html_exporter/html_exporter.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature EXPORTHTML 9 | structure htmlImpl 10 | is 11 | ../basics/basics.cm 12 | ../applyunifier/applyunifier.cm 13 | html_exporter.sig 14 | html_exporter.sml 15 | -------------------------------------------------------------------------------- /sml/html_exporter/html_exporter.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature EXPORTHTML = sig 8 | 9 | structure Dat : DATATYPES 10 | type der_tree = Dat.der_tree 11 | 12 | val der_tree_toHtml : der_tree -> string 13 | 14 | val der_tree_toHtml2 : der_tree -> string 15 | 16 | end 17 | -------------------------------------------------------------------------------- /sml/html_exporter/html_exporter.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | structure htmlImpl : EXPORTHTML = struct 8 | 9 | structure Dat = datatypesImpl 10 | structure D = Dat 11 | 12 | type der_tree = Dat.der_tree 13 | 14 | structure App = applyunifierImpl 15 | 16 | fun der_tree_toHtml (D.DerTree(id, s, NONE, pq)) = 17 | "
"^ 18 | "
"^ 19 | "
$$"^(D.seq_toString s)^"$$
"^ 20 | "
"^ 21 | "
" 22 | | der_tree_toHtml (D.DerTree(id, s, SOME nm, [])) = 23 | "
"^ 24 | "
"^ 25 | "
"^ 26 | "
$$"^(D.seq_toString s)^"$$
"^ 27 | "
"^ 28 | "
$$\\scriptsize{"^nm^"}$$
"^ 29 | "
" 30 | | der_tree_toHtml (D.DerTree(id, s, SOME nm, pq)) = 31 | "
"^ 32 | "
"^ 33 | "
"^(List.foldl(fn (prem, st) => st^(der_tree_toHtml prem))("")pq)^"
"^ 34 | "
$$"^(D.seq_toString s)^"$$
"^ 35 | "
"^ 36 | "
$$\\scriptsize{"^nm^"}$$
"^ 37 | "
" 38 | 39 | fun der_tree_toHtml2 (D.DerTree(id, s, NONE, pq)) = 40 | "DerTree(\""^id^"\", "^(D.seq_stringify s)^", NONE, [])" 41 | | der_tree_toHtml2 (D.DerTree(id, s, SOME nm, [])) = 42 | "DerTree(\""^id^"\", "^(D.seq_stringify s)^", SOME(\""^nm^"\"), [])" 43 | | der_tree_toHtml2 (D.DerTree(id, s, SOME nm, pq)) = 44 | "DerTree(\""^id^"\", "^(D.seq_stringify s)^", SOME(\""^nm^"\"), ["^(String.concatWith (",") (List.map(der_tree_toHtml2)pq))^"])" 45 | 46 | end -------------------------------------------------------------------------------- /sml/latex_exporter/latex_exporter.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature EXPORTLATEX 9 | structure latexImpl 10 | is 11 | ../basics/basics.cm 12 | ../applyunifier/applyunifier.cm 13 | latex_exporter.sig 14 | latex_exporter.sml 15 | -------------------------------------------------------------------------------- /sml/latex_exporter/latex_exporter.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature EXPORTLATEX = sig 8 | 9 | structure Dat : DATATYPES 10 | type der_tree = Dat.der_tree 11 | 12 | val der_tree_toLatex : der_tree -> string 13 | 14 | val der_tree_toLatex2 : der_tree -> string 15 | 16 | val export_string_toLatex : string -> string -> unit 17 | 18 | val export_toLatex : string -> der_tree -> unit 19 | 20 | end -------------------------------------------------------------------------------- /sml/latex_exporter/latex_exporter.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | structure latexImpl : EXPORTLATEX = struct 8 | 9 | structure Dat = datatypesImpl 10 | structure D = Dat 11 | 12 | type der_tree = Dat.der_tree 13 | 14 | structure App = applyunifierImpl 15 | 16 | fun der_tree_toLatex (D.DerTree(id, s, NONE, pq)) = "\\deduce[]{"^(D.seq_toString s)^"}{"^id^"}" 17 | | der_tree_toLatex (D.DerTree(id, s, SOME nm, [])) = "\\infer["^nm^"]{"^(D.seq_toString s)^"}{}" 18 | | der_tree_toLatex (D.DerTree(id, s, SOME nm, pq)) = 19 | let val fst = der_tree_toLatex (List.hd pq) 20 | val rest = List.tl(pq) 21 | val prem_latex = List.foldl(fn (prem, st) => st^" & \\quad"^(der_tree_toLatex prem))(fst)rest 22 | val conclusion = "\\infer["^nm^"]{"^(D.seq_toString s)^"}" 23 | in conclusion^"{"^prem_latex^"}" end 24 | 25 | fun der_tree_toLatex2 (D.DerTree(id, s, NONE, pq)) = "\\cfrac{"^id^"}{"^(D.seq_toString s)^"} " 26 | | der_tree_toLatex2 (D.DerTree(id, s, SOME nm, [])) = "\\cfrac{}{"^(D.seq_toString s)^"} "^nm 27 | | der_tree_toLatex2 (D.DerTree(id, s, SOME nm, pq)) = 28 | let val fst = der_tree_toLatex2 (List.hd pq) 29 | val rest = List.tl(pq) 30 | val prem_latex = List.foldl(fn (prem, st) => st^" \\quad \\quad "^(der_tree_toLatex2 prem))(fst)rest 31 | val conclusion = D.seq_toString s 32 | in "\\cfrac{"^prem_latex^"}{"^conclusion^"} "^nm end 33 | 34 | fun export_string_toLatex filename str = 35 | let 36 | val fd = TextIO.openOut filename 37 | val packages = 38 | "\\documentclass[10pt]{article}\n"^ 39 | "\\usepackage{amsmath}\n"^ 40 | "\\usepackage{amsfonts}\n"^ 41 | "\\usepackage{amssymb}\n"^ 42 | "\\usepackage{proof}\n"^ 43 | "\\usepackage{latexsym}\n" 44 | val document = "\\begin{document}\n\\begin{align*}\n"^ 45 | str^"\\end{align*}\n\\end{document}\n" 46 | val _ = TextIO.output (fd, packages^document) handle e => (TextIO.closeOut fd; raise e) 47 | val _ = TextIO.closeOut fd 48 | in 49 | () 50 | end 51 | 52 | fun export_toLatex filename tree = 53 | let val fd = TextIO.openOut filename 54 | val packages = 55 | "\\documentclass[10pt]{article}\n"^ 56 | "\\usepackage{amsmath}\n"^ 57 | "\\usepackage{amsfonts}\n"^ 58 | "\\usepackage{amssymb}\n"^ 59 | "\\usepackage{proof}\n"^ 60 | "\\usepackage{latexsym}\n" 61 | val latex_tree = "\\begin{document}\n\\begin{align*}\n"^ 62 | (der_tree_toLatex tree)^"\\end{align*}\n\\end{document}\n" 63 | val _ = TextIO.output (fd, packages^latex_tree) handle e => (TextIO.closeOut fd; raise e) 64 | val _ = TextIO.closeOut fd 65 | in () end 66 | 67 | end -------------------------------------------------------------------------------- /sml/properties/properties.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature PROPERTIES 9 | structure Properties 10 | is 11 | ../basics/basics.cm 12 | ../tree_func/tree_func.cm 13 | ../applyunifier/applyunifier.cm 14 | ../unification/unification.cm 15 | ../latex_exporter/latex_exporter.cm 16 | ../equiv/equiv.cm 17 | utilities/utilities.sml 18 | id_expansion/id_expansion.sml 19 | weakening/weakening.sml 20 | permute/permute.sml 21 | cut_elim/cut_elim.sml 22 | properties.sig 23 | properties.sml 24 | -------------------------------------------------------------------------------- /sml/properties/properties.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem, Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature PROPERTIES = 8 | sig 9 | structure D : DATATYPES 10 | type constraint = D.ctx_var * (D.ctx_var list) * (D.ctx_var list) 11 | type tree = constraint list * D.der_tree 12 | type proof = tree * (tree option) 13 | 14 | (* formula with connective * (left rules * right rules) * init rule * axioms*) 15 | val init_coherence_con : ((D.conn * D.rule list * D.rule list) * D.rule * D.rule list * D.rule list) -> bool * proof 16 | 17 | (* formula with connective * (left rules * right rules) * init rules * axioms*) 18 | (* checks init_coherence_con for each init rule *) 19 | val init_coherence_mult_init : ((D.conn * D.rule list * D.rule list) * D.rule list* D.rule list) -> (bool * proof list) 20 | 21 | (* checks if init_coherence_con is true for all connectives for each init rule *) 22 | val init_coherence : ((D.conn * D.rule list * D.rule list) list * D.rule list* D.rule list) -> bool * (bool * proof list) list 23 | val init_coherence_print' : int -> ((D.conn * D.rule list * D.rule list) list * D.rule list* D.rule list) -> unit 24 | val init_coherence_print : ((D.conn * D.rule list * D.rule list) list * D.rule list* D.rule list) -> unit 25 | 26 | val weakening_rule_context : (D.rule * (D.side * int)) -> bool * proof list 27 | val weakening_context : (D.rule list * (D.side * int)) -> bool * proof list 28 | val weakening_proofs : D.rule list -> ((bool * proof list) list) * ((bool * proof list) list) 29 | val weakening : D.rule list -> (bool list) * (bool list) 30 | val weakening_print : D.rule list -> unit 31 | 32 | val check_premises' : (constraint list * D.der_tree)*(constraint list * D.der_tree) * (bool list * bool list) -> tree option 33 | val permute : D.rule * D.rule * D.rule list * (bool list * bool list) -> 34 | (((((constraint list * D.der_tree) * (constraint list * D.der_tree)) list) * 35 | ((constraint list * D.der_tree) list)) * (constraint list * D.der_tree) list) list 36 | val permute_final : D.rule * D.rule * D.rule list * (bool list * bool list) -> string 37 | val permute_print : D.rule * D.rule * D.rule list * (bool list * bool list) -> unit 38 | 39 | 40 | val cut_axiom : D.rule * D.form * D.rule * (bool list * bool list) -> bool * proof list 41 | val cut_rank_reduction : D.rule * D.form * D.rule * (bool list * bool list) -> bool * proof list 42 | val cut_grade_reduction : D.rule * (D.conn * D.rule list * D.rule list) * 43 | D.form * (bool list * bool list) -> bool * proof list 44 | 45 | val cut_elim: (D.rule * D.form) list * (D.conn * D.rule list * D.rule list) list * (D.rule list) * (bool list * bool list) 46 | -> (bool * ((bool * proof list) list) * 47 | ((bool * proof list) list) * 48 | ((bool * proof list) list)) list 49 | 50 | val cut_elim_print' : int -> (D.rule * D.form) * (D.conn * D.rule list * D.rule list) list * (D.rule list) * (bool list * bool list) -> unit 51 | val cut_elim_print : (D.rule * D.form) * (D.conn * D.rule list * D.rule list) list * (D.rule list) * (bool list * bool list) -> unit 52 | 53 | 54 | end 55 | 56 | -------------------------------------------------------------------------------- /sml/recompile-sml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Deletes all .cm folders 4 | find . -type d -name "\.cm" -exec rm -rf {} + 5 | 6 | # Recompiles the whole code 7 | sml -m unify.cm 8 | -------------------------------------------------------------------------------- /sml/smlCommands.js: -------------------------------------------------------------------------------- 1 | // Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | // This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | // This is free software, and you are welcome to redistribute it 4 | // under certain conditions; see LICENSE for details. 5 | 6 | 7 | const cmd2 = require("child_process") 8 | 9 | function smlInvoke(sml_command, res) { 10 | const smlTerminalInput = 11 | "CM.make \"sml/unify.cm\";\n" 12 | +"Control.Print.printDepth :=100;\n" 13 | +"open datatypesImpl;\n" 14 | +sml_command 15 | +"OS.Process.exit(OS.Process.success);\n" 16 | var answer = ''; 17 | var processRef = cmd2.spawn("sml",[],{stdio: ['pipe' , 'inherit' , 'ignore' , 'pipe' ] }) 18 | processRef.stdio[3].on('end' , () => { 19 | try { 20 | try { 21 | return res.status(200).json({ 22 | status: 'success', 23 | output: answer 24 | }) 25 | } catch(err) { 26 | console.error(err) 27 | } 28 | } catch(err) { 29 | console.error(err) 30 | } 31 | }) 32 | processRef.stdio[3].on('data' , (data) => {answer += data.toString()}) 33 | processRef.stdin.write(smlTerminalInput) 34 | } 35 | 36 | function applyRule(rule, constraints, tree, id, index, subs, res) { 37 | var sml_command = "treefuncImpl.translate_premises("+constraints+","+tree+","+rule+","+id+","+index+","+subs+");\n" 38 | smlInvoke(sml_command, res) 39 | } 40 | 41 | function initRules(connective_rules, init_rules, axiom_rules, res) { 42 | var sml_command = "Properties.init_coherence_print("+connective_rules+","+init_rules+","+axiom_rules+");\n" 43 | smlInvoke(sml_command, res) 44 | } 45 | 46 | function weakenSides(rules, res) { 47 | var sml_command = "Properties.weakening_print("+rules+");\n" 48 | smlInvoke(sml_command, res) 49 | } 50 | 51 | function permuteRules(rule1, rule2, init_rules, wL, wR, res) { 52 | var sml_command = "Properties.permute_print("+rule1+","+rule2+","+init_rules+",("+wL+","+wR+"));\n" 53 | smlInvoke(sml_command, res) 54 | } 55 | 56 | function permuteRules(rule1, rule2, init_rules, wL, wR, res) { 57 | var sml_command = "Properties.permute_print("+rule1+","+rule2+","+init_rules+",("+wL+","+wR+"));\n" 58 | smlInvoke(sml_command, res) 59 | } 60 | 61 | function cutElim(rule1, formula, init_rules, conn_rules, wL, wR, res) { 62 | var sml_command = "Properties.cut_elim_print(("+rule1+","+formula+"),"+conn_rules+",("+init_rules+"),("+wL+","+wR+"));\n" 63 | smlInvoke(sml_command, res) 64 | } 65 | 66 | module.exports = { smlInvoke, applyRule, initRules, weakenSides, permuteRules, cutElim } -------------------------------------------------------------------------------- /sml/tree_func/tree_func.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature TREEFUNC 9 | structure treefuncImpl 10 | is 11 | ../basics/basics.cm 12 | ../applyunifier/applyunifier.cm 13 | ../unification/unification.cm 14 | ../latex_exporter/latex_exporter.cm 15 | ../html_exporter/html_exporter.cm 16 | ../equiv/equiv.cm 17 | tree_func.sig 18 | tree_func.sml 19 | 20 | -------------------------------------------------------------------------------- /sml/tree_func/tree_func.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem, Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature TREEFUNC = sig 8 | 9 | structure Dat : DATATYPES 10 | type conn = Dat.conn 11 | type form = Dat.form 12 | type ctx_var = Dat.ctx_var 13 | type ctx = Dat.ctx 14 | type ctx_struct = Dat.ctx_struct 15 | type seq = Dat.seq 16 | type side = Dat.side 17 | type rule = Dat.rule 18 | type sub = Dat.sub 19 | type rule_name = Dat.rule_name 20 | type der_tree = Dat.der_tree 21 | 22 | 23 | val get_tree_height : der_tree -> int 24 | val get_open_prems : der_tree -> der_tree list 25 | val closed_tree : der_tree -> bool 26 | val atomic_transform : seq -> seq 27 | val get_forms : seq -> form list 28 | val get_ctx_vars : seq -> ctx_var list 29 | val filter_bad_subs : (sub list * 'a) list * seq -> (sub list * 'a) list 30 | val get_premises_of : der_tree * string -> seq list 31 | val check_rule_of : (ctx_var * ctx_var list * ctx_var list) list * der_tree * string -> bool 32 | val apply_rule : (form list * (ctx_var * ctx_var list * ctx_var list) list * der_tree) * 33 | rule * string 34 | -> (form list * (ctx_var * ctx_var list * ctx_var list) list * der_tree) 35 | list 36 | val apply_rule_everywhere : (form list * (ctx_var * ctx_var list * ctx_var list) list * der_tree) * 37 | rule 38 | -> (form list * (ctx_var * ctx_var list * ctx_var list) list * der_tree) 39 | list 40 | val apply_rule_all_ways : (form list * (ctx_var * ctx_var list * ctx_var list) list * der_tree) * 41 | rule * bool 42 | -> (form list * (ctx_var * ctx_var list * ctx_var list) list * der_tree) 43 | list 44 | val apply_multiple_rules_all_ways : (form list * (ctx_var * ctx_var list * ctx_var list) list * der_tree) * 45 | rule list 46 | -> (form list * (ctx_var * ctx_var list * ctx_var list) list * der_tree) 47 | list 48 | val translate_premises' : int -> (ctx_var * ctx_var list * ctx_var list) list * der_tree * rule * string * int -> unit 49 | val translate_premises_cut' : int -> (ctx_var * ctx_var list * ctx_var list) list * der_tree * rule * string * int * sub list -> unit 50 | val translate_premises : (ctx_var * ctx_var list * ctx_var list) list * der_tree * rule * string * int * sub list-> unit 51 | end -------------------------------------------------------------------------------- /sml/unification/ac_unification/ac_unification.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature ACUNIFICATION 9 | structure ACUnify 10 | is 11 | ../../basics/basics.cm 12 | ac_unification.sig 13 | ac_unification.sml 14 | -------------------------------------------------------------------------------- /sml/unification/ac_unification/ac_unification.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature ACUNIFICATION = 8 | sig 9 | structure D : DATATYPES 10 | 11 | type constraint = (D.ctx_var * D.ctx_var list * D.ctx_var list) 12 | val change_start_index : int -> unit 13 | 14 | 15 | (* given a constraint, return the most general unifier *) 16 | val solve_constraint : constraint -> D.sub list 17 | 18 | (* given a list of constraints, return the most general unifier *) 19 | val solve_constraints : constraint list -> D.sub list 20 | end -------------------------------------------------------------------------------- /sml/unification/constraints/constraints.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature CONSTRAINTS 9 | structure Constraints 10 | is 11 | ../../basics/basics.cm 12 | ../../applyunifier/applyunifier.cm 13 | ../fresh_var/fresh_var.sml 14 | constraints.sig 15 | constraints.sml -------------------------------------------------------------------------------- /sml/unification/constraints/constraints.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature CONSTRAINTS = 8 | sig 9 | structure Dat : DATATYPES 10 | type constraint = (Dat.ctx_var * Dat.ctx_var list * Dat.ctx_var list) 11 | 12 | val get_index : unit -> int 13 | val change_index : int -> unit 14 | val fresh : string -> string 15 | val fresh_ctx_var : Dat.ctx_var -> Dat.ctx_var 16 | val get_constraints' : Dat.ctx_var list * Dat.ctx_var list -> constraint list * constraint list 17 | val get_constraints: Dat.ctx_var list * Dat.ctx_var list -> constraint list * Dat.sub list 18 | end -------------------------------------------------------------------------------- /sml/unification/fresh_var/fresh_var.sml: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | 8 | signature FRESHVAR = 9 | sig 10 | val get_index : unit -> int 11 | val change_index : int -> unit 12 | val fresh : string -> string 13 | end 14 | 15 | structure FreshVar = 16 | struct 17 | structure Map = BinaryMapFn(StringKey) 18 | 19 | val var_index = ref 1; 20 | 21 | val map: int Map.map ref = ref (Map.empty) 22 | 23 | 24 | fun change_index (x:int): unit = (var_index := x) before (map := Map.empty) 25 | 26 | fun get_index ():int = 27 | let 28 | val inds = Map.listItems(!map) 29 | in 30 | List.foldr Int.max 0 inds 31 | end 32 | 33 | fun add_index (x:string,i:int):string = (x ^"^{"^ Int.toString(i) ^"}") 34 | 35 | fun fresh'(x:string):string = 36 | let 37 | val ind = (case Map.find(!map,x) of 38 | NONE => !var_index 39 | | SOME index => index) 40 | val new_string = add_index(x,ind) 41 | val () = map:= ( Map.insert(!map,x,ind+1) ) 42 | in 43 | new_string 44 | end 45 | 46 | val hat = #"^" 47 | 48 | fun remove_hat' (nil) = nil 49 | |remove_hat' (x::L) = (case (x=hat) of true => [] | false => x::remove_hat'(L)) 50 | 51 | fun remove_hat (x) = String.implode(remove_hat'(String.explode(x))) 52 | (* nuke version *) 53 | fun fresh(x:string):string = fresh'(remove_hat(x)) 54 | end -------------------------------------------------------------------------------- /sml/unification/unification.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group 8 | signature UNIFICATION 9 | structure unifyImpl 10 | signature CONSTRAINTS 11 | structure Constraints 12 | is 13 | ../basics/basics.cm 14 | ../applyunifier/applyunifier.cm 15 | constraints/constraints.cm 16 | unification.sig 17 | unification.sml 18 | -------------------------------------------------------------------------------- /sml/unification/unification.sig: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Zan Naeem, Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | signature UNIFICATION = sig 8 | 9 | structure DAT : DATATYPES 10 | type sub = DAT.sub 11 | type form = DAT.form 12 | type ctx_var = DAT.ctx_var 13 | type ctx_struct = DAT.ctx_struct 14 | type ctx = DAT.ctx 15 | type seq = DAT.seq 16 | 17 | val get_index : unit -> int 18 | val change_index : int -> unit 19 | 20 | val Unify_form : form * form -> sub list list option 21 | val Unify_formL : form list * form list -> sub list list option 22 | val Unify_ctx : ctx * ctx 23 | -> (sub list * (ctx_var * ctx_var list * ctx_var list) list) list option 24 | val Unify_ctx_struct : ctx_struct * ctx_struct 25 | -> (sub list * (ctx_var * ctx_var list * ctx_var list) list) list option 26 | val Unify_seq : seq * seq 27 | -> (sub list * (ctx_var * ctx_var list * ctx_var list) list) list option 28 | val print_sigs_cons : (sub list * (ctx_var * ctx_var list * ctx_var list) list) list option 29 | -> (string list * string list) list 30 | 31 | end -------------------------------------------------------------------------------- /sml/unify.cm: -------------------------------------------------------------------------------- 1 | (* Sequoia Copyright (C) 2020 Mohammed Hashim 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. 5 | *) 6 | 7 | Group is 8 | $/basis.cm 9 | $SMLNJ-LIB/Util/smlnj-lib.cm 10 | basics/basics.cm 11 | equiv/equiv.cm 12 | unification/unification.cm 13 | applyunifier/applyunifier.cm 14 | tree_func/tree_func.cm 15 | properties/properties.cm -------------------------------------------------------------------------------- /sml/unit_test/basics_tests/datatypes_test.sml: -------------------------------------------------------------------------------- 1 | structure DatatypesTest = 2 | struct 3 | structure D = datatypesImpl 4 | structure Q = QCheck 5 | structure G = Gen 6 | 7 | datatype 'a check = Same of 'a | Diff of ('a * 'a) 8 | 9 | fun eq_check cmp (Same(x)) = true = (cmp(x,x)) 10 | | eq_check cmp (Diff (x,y)) = (cmp(x,y) = (cmp(y,x))) 11 | 12 | fun gen_to_check_gen gen = 13 | let 14 | val option1 = Q.Gen.map Same gen 15 | val option2 = Q.Gen.map (Diff) (Q.Gen.zip(gen,gen)) 16 | in 17 | Q.Gen.choose' (#[(1,option1),(9,option2)]) 18 | end 19 | 20 | fun new_to_str to_str (Same x) = "SAME: "^(to_str x) 21 | | new_to_str to_str (Diff (x,y)) = "Diff: "^(to_str x)^" and "^(to_str y) 22 | 23 | fun test (gen,cmp,to_str,name) = 24 | let 25 | val new_gen = gen_to_check_gen gen 26 | val new_str_fn = new_to_str to_str 27 | val reader = (new_gen,SOME new_str_fn) 28 | 29 | val pred = (name^" test",Q.pred (eq_check cmp)) 30 | in 31 | Q.checkGen reader pred 32 | end 33 | 34 | fun form_eq_test () = 35 | let 36 | val gen = G.form_gen G.var_name_gen 37 | val cmp = D.form_eq 38 | val to_str = D.form_stringify 39 | val name = "form_eq" 40 | in 41 | test(gen,cmp,to_str,name) 42 | end 43 | 44 | fun ctx_var_eq_test () = 45 | let 46 | val gen = G.context_var_gen 47 | val cmp = D.ctx_var_eq 48 | val to_str = D.ctx_var_stringify 49 | val name = "ctx_var_eq" 50 | in 51 | test(gen,cmp,to_str,name) 52 | end 53 | 54 | fun ctx_eq_test () = 55 | let 56 | val gen = G.context_gen 57 | val cmp = D.ctx_eq 58 | val to_str = D.ctx_stringify 59 | val name = "ctx_eq" 60 | in 61 | test(gen,cmp,to_str,name) 62 | end 63 | 64 | fun ctx_struct_eq_test () = 65 | let 66 | val gen = G.context_struct_gen 67 | val cmp = D.ctx_struct_eq 68 | val to_str = D.ctx_struct_stringify 69 | val name = "ctx_struct_eq" 70 | in 71 | test(gen,cmp,to_str,name) 72 | end 73 | 74 | fun seq_eq_test () = 75 | let 76 | val gen = G.seq_gen 77 | val cmp = D.seq_eq 78 | val to_str = D.seq_stringify 79 | val name = "seq_eq" 80 | in 81 | test(gen,cmp,to_str,name) 82 | end 83 | 84 | val _ = form_eq_test () 85 | val _ = ctx_var_eq_test () 86 | val _ = ctx_eq_test () 87 | val _ = ctx_struct_eq_test () 88 | val _ = seq_eq_test () 89 | end -------------------------------------------------------------------------------- /sml/unit_test/basics_tests/helpers_test.sml: -------------------------------------------------------------------------------- 1 | structure HelpersTest = 2 | struct 3 | structure G = Gen 4 | structure Q = QCheck 5 | structure Sort = ListMergeSort 6 | structure H = helpersImpl 7 | 8 | (* for testing permutations and choose functions *) 9 | val unique_int_list_gen = Q.Gen.map (fn n => List.tabulate(n,fn n => n+1)) (Q.Gen.range(0,6)) 10 | 11 | fun all_diff eq ([]) = true 12 | | all_diff eq (x::l) = (List.all (fn y => not (eq(x,y)) ) l) andalso (all_diff eq (l)) 13 | 14 | fun int_list_same (l1,l2) = 15 | let 16 | val l1' = Sort.sort (op=) l1 17 | val l2' = Sort.sort (op=) l2 18 | in 19 | ListPair.allEq op= (l1',l2') 20 | end 21 | 22 | fun int_list_eq (l1,l2) = ListPair.allEq op= (l1,l2) 23 | 24 | 25 | (* checks that ll has num unique elements, and each element *) 26 | (* has length len and all unique elements *) 27 | fun check_all_unique list_eq_fn (ll,num,len)= 28 | let 29 | val check0 = List.length(ll) = num 30 | val check1 = check0 andalso (List.all (fn l => List.length(l) = len) ll) 31 | val check2 = check1 andalso (List.all (all_diff op=) ll) 32 | val check3 = check2 andalso (all_diff (list_eq_fn) ll) 33 | in 34 | check3 35 | end 36 | 37 | fun factorial' (0,res) = res 38 | | factorial' (1,res) = res 39 | | factorial' (n,res) = factorial'(n-1,n*res) 40 | 41 | fun factorial (n) = factorial'(n,1) 42 | 43 | fun permutations_check (l) = 44 | let 45 | val res = H.permutations(l) 46 | val len = List.length(l) 47 | val num = factorial(len) 48 | in 49 | check_all_unique int_list_eq (res,num,len) 50 | end 51 | 52 | fun choose_check (l,n) = 53 | let 54 | val list_length = List.length(l) 55 | (* we want the option to get the same len as list_length *) 56 | val len = n mod (list_length + 1) 57 | val res = H.chooseDP (l,len) 58 | val f1 = factorial(list_length) 59 | val f2 = factorial(len) * factorial(list_length - len) 60 | val num = f1 div f2 61 | in 62 | check_all_unique int_list_same (res,num,len) 63 | end 64 | 65 | fun test(gen,to_str,check,name)= 66 | let 67 | val reader = (gen,SOME to_str) 68 | val prop = (name^" test",Q.pred check) 69 | in 70 | Q.checkGen reader prop 71 | end 72 | 73 | fun permutations_test() = 74 | let 75 | val gen = unique_int_list_gen 76 | val to_str = ListFormat.listToString (Int.toString) 77 | val name = "permutations" 78 | val check = permutations_check 79 | in 80 | test(gen,to_str,check,name) 81 | end 82 | 83 | fun chooseDP_test() = 84 | let 85 | val gen = Q.Gen.zip (unique_int_list_gen,Q.Gen.Int.int) 86 | val to_str' = ListFormat.listToString (Int.toString) 87 | fun to_str (l,x) = (to_str'(l)) ^" and "^ (Int.toString x) 88 | val name = "chooseDP" 89 | val check = choose_check 90 | in 91 | test(gen,to_str,check,name) 92 | end 93 | 94 | 95 | val _ = permutations_test() 96 | val _ = chooseDP_test() 97 | 98 | 99 | end -------------------------------------------------------------------------------- /sml/unit_test/basics_tests/ord_keys_test.sml: -------------------------------------------------------------------------------- 1 | structure OrdKeysTest = 2 | struct 3 | structure D = datatypesImpl 4 | structure Q = QCheck 5 | structure G = Gen 6 | structure CVK = CtxVarKey 7 | structure CVCK = CtxVarConKey 8 | structure ForK = FormKey 9 | 10 | fun transitivity_check compare_func (x,y,z) = 11 | let 12 | 13 | (* ordering x,y,z to be inorder *) 14 | val (x,y) = (case compare_func(x,y) of 15 | GREATER => (y,x) 16 | | _ => (x,y)) 17 | val (y,z) = (case compare_func(y,z) of 18 | GREATER => (z,y) 19 | | _ => (y,z)) 20 | val (x,y) = (case compare_func(x,y) of 21 | GREATER => (y,x) 22 | | _ => (x,y)) 23 | 24 | in 25 | (case (compare_func(x,y),compare_func(y,z),compare_func(x,z)) of 26 | (EQUAL,a,b) => a = b 27 | | (a,EQUAL,b) => a = b 28 | | (a,b,EQUAL) => (a = b) andalso (a = EQUAL) 29 | | (LESS,LESS,LESS) => true 30 | | (GREATER, GREATER, GREATER) => true 31 | | _ => false) 32 | end 33 | 34 | fun order_check compare_func (x,y) = 35 | (case (compare_func(x,y),compare_func(y,x)) of 36 | (EQUAL,EQUAL) => true 37 | | (EQUAL,_) => false 38 | | (_,EQUAL) => false 39 | | (a,b) => a<>b) 40 | 41 | 42 | 43 | fun test_struct (gen,cmp_func,name,to_str) = 44 | let 45 | val order_gen = Q.Gen.zip (gen,gen) 46 | fun order_to_str (x,y) = (to_str(x))^" and "^(to_str(y)) 47 | val order_reader = (order_gen,SOME order_to_str) 48 | 49 | val transitivity_gen = Q.Gen.zip3 (gen,gen,gen) 50 | fun transitivity_to_str (x,y,z) = (to_str(x))^" and "^(to_str(y))^" and "^(to_str(z)) 51 | val transitivity_reader = (transitivity_gen,SOME transitivity_to_str) 52 | 53 | val order_test = order_check cmp_func 54 | val transitivity_test = transitivity_check cmp_func 55 | 56 | val order_pred = (name ^" order test", Q.pred order_test) 57 | val transitivity_pred = (name ^" transitivity test", Q.pred transitivity_test) 58 | in 59 | (Q.checkGen order_reader order_pred ; Q.checkGen transitivity_reader transitivity_pred) 60 | end 61 | 62 | fun test_CtxVarKey () = 63 | let 64 | val gen = G.context_var_gen 65 | val cmp = CVK.compare 66 | val name = "CtxVarKey" 67 | val to_str = D.ctx_var_stringify 68 | in 69 | test_struct (gen,cmp,name,to_str) 70 | end 71 | 72 | fun test_CtxVarConKey () = 73 | let 74 | val gen = G.context_var_gen 75 | val cmp = CVCK.compare 76 | val name = "CtxVarConKey" 77 | val to_str = D.ctx_var_stringify 78 | in 79 | test_struct (gen,cmp,name,to_str) 80 | end 81 | 82 | fun test_FormKey () = 83 | let 84 | val gen = G.form_gen G.var_name_gen 85 | val cmp = ForK.compare 86 | val name = "FormKey" 87 | val to_str = D.form_stringify 88 | in 89 | test_struct (gen,cmp,name,to_str) 90 | end 91 | 92 | val _ = test_CtxVarKey () 93 | val _ = test_CtxVarConKey () 94 | val _ = test_FormKey () 95 | end -------------------------------------------------------------------------------- /sml/unit_test/generators/gen.sig: -------------------------------------------------------------------------------- 1 | signature UNITTEST = 2 | sig 3 | 4 | end 5 | -------------------------------------------------------------------------------- /sml/unit_test/generators/gen.sml: -------------------------------------------------------------------------------- 1 | structure Gen = 2 | struct 3 | structure Q = QCheck 4 | structure Set = SplaySetFn(FormKey); 5 | structure D = datatypesImpl 6 | structure V = Vector 7 | structure R = Rules 8 | 9 | 10 | (*takes 2 generators and appends them*) 11 | fun gen_composition (g2) (g1) r = 12 | let 13 | val (res,r') = g1 r 14 | in 15 | (g2 res) r' 16 | end 17 | fun vec_to_L v = V.foldr op:: [] v 18 | fun gen_to_L range g = Q.Gen.map (fn v => vec_to_L v) (Q.Gen.vector 19 | Vector.tabulate (Q.Gen.range range,g)) 20 | 21 | (*list of variable names*) 22 | val var_names = #["A","B","C","D","E"] 23 | val var_name_gen = Q.Gen.select var_names 24 | val sub_var_names = #["C","D","E"] 25 | val sub_var_name_gen = Q.Gen.select sub_var_names 26 | (* (con,arity) pairs*) 27 | val (con1,con2,con3) = ((D.Con("\\wedge"),2), (D.Con("\\vee"),2), (D.Con("\\supset"),2)) 28 | val connectives = #[con1,con2,con3] 29 | 30 | val con_gen = Q.Gen.select connectives 31 | 32 | fun atom_gen name_gen = Q.Gen.map (fn nm => D.Atom(nm)) name_gen 33 | 34 | fun atom_var_gen name_gen = Q.Gen.map (fn nm => D.AtomVar(nm)) name_gen 35 | 36 | fun form_var_gen name_gen = Q.Gen.map (fn nm => D.FormVar(nm)) name_gen 37 | 38 | val context_var_names = #["\\Gamma","\\Delta","\\Lambda","\\Theta"] 39 | 40 | val context_var_name_gen = Q.Gen.select context_var_names 41 | 42 | val context_con_gen = Q.Gen.choose' #[(5,Q.Gen.lift NONE),(1,Q.Gen.lift (SOME (D.Con("!"))))] 43 | 44 | val context_var_gen = Q.Gen.map (D.CtxVar) (Q.Gen.zip 45 | (context_con_gen,context_var_name_gen)) 46 | 47 | fun form_gen' name_gen 0 = Q.Gen.choose #[atom_gen name_gen,atom_var_gen 48 | name_gen,form_var_gen name_gen] 49 | | form_gen' name_gen n = Q.Gen.choose' #[(1,form_gen' name_gen 0),(9,Q.Gen.map D.Form 50 | (con_to_gen name_gen n))] 51 | and con_to_gen name_gen n= gen_composition (len_to_list name_gen n) (con_gen) 52 | and len_to_list name_gen n (con,arity) = Q.Gen.map (fn l => (con,vec_to_L l)) (Q.Gen.vector 53 | Vector.tabulate (Q.Gen.range(arity,arity),form_gen' name_gen (n-1))) 54 | 55 | fun form_gen name_gen r = 56 | let 57 | val (i,r') = Q.Gen.range(0,2) r 58 | in 59 | form_gen' name_gen i r' 60 | end 61 | 62 | (*list generators*) 63 | fun ctx_var_l_gen range = Q.Gen.choose (#[ gen_to_L (1,1) context_var_gen ,gen_to_L (0,2) context_var_gen]) 64 | 65 | fun form_l_gen range = gen_to_L range (form_gen var_name_gen) 66 | 67 | fun context_gen' range = Q.Gen.map (D.Ctx) (Q.Gen.zip (ctx_var_l_gen range, 68 | form_l_gen range)) 69 | 70 | val context_gen = context_gen' (0,4) 71 | 72 | 73 | fun context_struct_gen' 0 = Q.Gen.choose' (#[ 74 | (1,Q.Gen.lift D.Empty), 75 | (8,Q.Gen.map (D.Single) (context_gen))]) 76 | | context_struct_gen' n = Q.Gen.choose' (#[ 77 | (9,context_struct_gen' 0), 78 | (1,Q.Gen.map (D.Mult) (Q.Gen.zip3 ( 79 | Q.Gen.lift (D.Con(";")), 80 | context_gen, 81 | context_struct_gen' (n-1) 82 | ))) ]) 83 | val context_struct_gen = context_struct_gen' 2 84 | 85 | val seq_gen = Q.Gen.map (D.Seq) 86 | (Q.Gen.zip3(context_struct_gen,Q.Gen.lift (D.Con("\\vdash")),context_struct_gen)) 87 | 88 | 89 | val sub_var_gen = Q.Gen.choose' #[(1,atom_var_gen sub_var_name_gen),(5,form_var_gen 90 | sub_var_name_gen)] 91 | val form_sub_gen = Q.Gen.map D.Fs (Q.Gen.zip (sub_var_gen, form_gen 92 | var_name_gen)) 93 | 94 | val ctx_var_sub_gen = Q.Gen.map D.CTXs (Q.Gen.zip (context_var_gen,context_gen)) 95 | 96 | val sub_gen = Q.Gen.choose' (#[ 97 | (4,form_sub_gen), 98 | (1,ctx_var_sub_gen) 99 | ]) 100 | 101 | 102 | 103 | end 104 | -------------------------------------------------------------------------------- /sml/unit_test/properties_tests/result_type.sml: -------------------------------------------------------------------------------- 1 | structure RT = 2 | struct 3 | (* yes if all the cases are positive *) 4 | (* no if all the cases are negative *) 5 | (* maybe for some positive and some negative cases *) 6 | datatype results = Yes | No | Maybe 7 | end -------------------------------------------------------------------------------- /sml/unit_test/properties_tests/test_cases.sml: -------------------------------------------------------------------------------- 1 | structure TestCases = 2 | struct 3 | structure R = Rules 4 | structure D = datatypesImpl 5 | 6 | 7 | type results = RT.results 8 | 9 | val permute_cases = PTCases.permute_cases 10 | val weakening_cases = WTCases.weakening_cases 11 | val id_expansion_cases = IDTCases.id_expansion_cases 12 | val cut_elim_axiom_cases = CETCases.cut_elim_axiom_cases 13 | val cut_elim_rank_cases = CETCases.cut_elim_rank_cases 14 | val cut_elim_grade_cases = CETCases.cut_elim_grade_cases 15 | val cut_elim_cases = CETCases.cut_elim_cases 16 | end -------------------------------------------------------------------------------- /sml/unit_test/properties_tests/test_cases/cut_elim_test_cases.sml: -------------------------------------------------------------------------------- 1 | structure CETCases = 2 | struct 3 | structure R = Rules 4 | 5 | val weakening = ([true],[false]) 6 | val axiom_r1 = R.id 7 | val axiom_r2 = R.id_no_ctx 8 | val (cut_pair as (cut_rule,cut_form)) = (R.cut,R.cut_form) 9 | val and_tuple = (R.and_con,[R.andL],[R.andR]) 10 | val or_tuple_c = (R.or_con,[R.orLc],[R.orR1,R.orR2]) 11 | val or_tuple_s = (R.or_con,[R.orLs],[R.orR1,R.orR2]) 12 | val imp_tuple = (R.imp_con,[R.impL],[R.impR]) 13 | val imp_tuple_s = (R.imp_con,[R.impLs],[R.impR]) 14 | 15 | (* cut_r * cut_f * axiom * weakening *) 16 | val (axiom_case1 as (exp_axiom1,inp_axiom1)) = 17 | let 18 | val inp' = (cut_rule,cut_form,axiom_r1,weakening) 19 | val exp' = RT.Yes 20 | in 21 | (exp',inp') 22 | end 23 | 24 | val (axiom_case2 as (exp_axiom2,inp_axiom2)) = 25 | let 26 | val inp' = (cut_rule,cut_form,axiom_r2,weakening) 27 | val exp' = RT.Yes 28 | in 29 | (exp',inp') 30 | end 31 | 32 | (* cut_r * cut_f * rule * weakening *) 33 | val (rank_case1 as (exp_rank_andL,_)) = 34 | let 35 | val inp' = (cut_rule,cut_form,R.andL,weakening) 36 | val exp' = RT.Yes 37 | in 38 | (exp',inp') 39 | end 40 | 41 | val (rank_case2 as (exp_rank_andR,_)) = 42 | let 43 | val inp' = (cut_rule,cut_form,R.andR,weakening) 44 | val exp' = RT.Yes 45 | in 46 | (exp',inp') 47 | end 48 | 49 | val (rank_case3 as (exp_rank_orLc,_)) = 50 | let 51 | val inp' = (cut_rule,cut_form,R.orLc,weakening) 52 | val exp' = RT.Yes 53 | in 54 | (exp',inp') 55 | end 56 | 57 | val (rank_case4 as (exp_rank_orLs,_)) = 58 | let 59 | val inp' = (cut_rule,cut_form,R.orLs,weakening) 60 | val exp' = RT.Maybe 61 | in 62 | (exp',inp') 63 | end 64 | 65 | 66 | 67 | (* cut_r * conn_tuple * cut_f * weakening *) 68 | 69 | 70 | val (grade_case1 as (exp_grade_and,_)) = 71 | let 72 | val inp' = (cut_rule,and_tuple,cut_form,weakening) 73 | val exp' = RT.No 74 | in 75 | (exp',inp') 76 | end 77 | 78 | val (grade_case2 as (exp_grade_or_c,_)) = 79 | let 80 | val inp' = (cut_rule,or_tuple_c,cut_form,weakening) 81 | val exp' = RT.Yes 82 | in 83 | (exp',inp') 84 | end 85 | 86 | val (grade_case3 as (exp_grade_or_s_no_wk,_)) = 87 | let 88 | val inp' = (cut_rule, or_tuple_s ,cut_form, ([false],[false])) 89 | val exp' = RT.No 90 | in 91 | (exp',inp') 92 | end 93 | 94 | val (grade_case4 as (exp_grade_or_s,_)) = 95 | let 96 | val inp' = (cut_rule, or_tuple_s ,cut_form, weakening) 97 | val exp' = RT.Yes 98 | in 99 | (exp',inp') 100 | end 101 | 102 | val (grade_case5 as (exp_grade_imp_s,_)) = 103 | let 104 | val inp' = (cut_rule,imp_tuple_s,cut_form,weakening) 105 | val exp' = RT.Yes 106 | in 107 | (exp',inp') 108 | end 109 | 110 | val (grade_case6 as (exp_grade_imp,_)) = 111 | let 112 | val inp' = (cut_rule,imp_tuple,cut_form,weakening) 113 | val exp' = RT.No 114 | in 115 | (exp',inp') 116 | end 117 | 118 | (* cut_pair list * conn tuple list * axiom list * weakening *) 119 | (* [bool * 120 | ((bool * proof list) list) * 121 | ((bool * proof list) list) * 122 | ((bool * proof list) list)] *) 123 | 124 | val cut_elim_case1 = 125 | let 126 | val cut_pair_list = [cut_pair] 127 | val conn_tuple_list = [and_tuple,or_tuple_s,imp_tuple_s] 128 | val axiom_list = [axiom_r1] 129 | val inp = (cut_pair_list,conn_tuple_list,axiom_list,weakening) 130 | 131 | val axiom_exp = [exp_axiom1] 132 | val grade_exp = [exp_grade_and,exp_grade_or_s,exp_grade_imp_s] 133 | (* rule order : andL, andR, orLs, orR1 , orR2, impLs, impR *) 134 | val rank_exp = [exp_rank_andL,exp_rank_andR,exp_rank_orLs,RT.Yes,RT.Yes,RT.Yes,RT.Yes] 135 | val expectations = [(RT.Maybe,axiom_exp,rank_exp,grade_exp)] 136 | in 137 | (expectations,inp) 138 | end 139 | 140 | val cut_elim_axiom_cases = [axiom_case1 , axiom_case2] 141 | val cut_elim_rank_cases = [rank_case1, rank_case2, rank_case3,rank_case4] 142 | val cut_elim_grade_cases = [grade_case1, grade_case2, grade_case3, grade_case4, grade_case5, grade_case6] 143 | val cut_elim_cases = [cut_elim_case1] 144 | end -------------------------------------------------------------------------------- /sml/unit_test/properties_tests/test_cases/id_expansion_test_cases.sml: -------------------------------------------------------------------------------- 1 | structure IDTCases = 2 | struct 3 | 4 | structure R = Rules 5 | structure D = datatypesImpl 6 | (* val init_coherence : ((conn * left rules *right rules) list * id_rules* axioms) *) 7 | 8 | val and_tuple = (R.and_con,[R.andL],[R.andR]) 9 | val or_tuple_c = (R.or_con,[R.orLc],[R.orR1,R.orR2]) 10 | val or_tuple_s = (R.or_con,[R.orLs],[R.orR1,R.orR2]) 11 | val imp_tuple = (R.imp_con,[R.impL],[R.impR]) 12 | val imp_tuple_s = (R.imp_con,[R.impLs],[R.impR]) 13 | val axioms : D.rule list = [] 14 | val id_rules1 = [R.id] 15 | val id_rules2 = [R.id_no_ctx] 16 | 17 | val id_case1 = 18 | let 19 | val conns = [and_tuple] 20 | val id = id_rules2 21 | val expectation = (RT.No,[RT.No]) 22 | in 23 | (expectation,(conns,id,axioms)) 24 | end 25 | val id_case2 = 26 | let 27 | val conns = [or_tuple_c] 28 | val id = id_rules2 29 | val expectation = (RT.Yes,[RT.Yes]) 30 | in 31 | (expectation,(conns,id,axioms)) 32 | end 33 | val id_case3 = 34 | let 35 | val conns = [imp_tuple_s] 36 | val id = id_rules2 37 | val expectation = (RT.Yes,[RT.Yes]) 38 | in 39 | (expectation,(conns,id,axioms)) 40 | end 41 | 42 | val id_case4 = 43 | let 44 | val conns = [and_tuple] 45 | val id = id_rules1 46 | val expectation = (RT.Yes,[RT.Yes]) 47 | in 48 | (expectation,(conns,id,axioms)) 49 | end 50 | val id_case5 = 51 | let 52 | val conns = [or_tuple_c] 53 | val id = id_rules1 54 | val expectation = (RT.Yes,[RT.Yes]) 55 | in 56 | (expectation,(conns,id,axioms)) 57 | end 58 | val id_case6 = 59 | let 60 | val conns = [imp_tuple_s] 61 | val id = id_rules1 62 | val expectation = (RT.Yes,[RT.Yes]) 63 | in 64 | (expectation,(conns,id,axioms)) 65 | end 66 | 67 | val id_case7 = 68 | let 69 | val conns = [imp_tuple] 70 | val id = id_rules1 71 | val expectation = (RT.Yes,[RT.Yes]) 72 | in 73 | (expectation,(conns,id,axioms)) 74 | end 75 | 76 | val id_case8 = 77 | let 78 | val conns = [imp_tuple] 79 | val id = id_rules2 80 | val expectation = (RT.No,[RT.No]) 81 | in 82 | (expectation,(conns,id,axioms)) 83 | end 84 | 85 | val id_case9 = 86 | let 87 | val conns = [and_tuple,or_tuple_c,imp_tuple_s,imp_tuple] 88 | val id = id_rules1 89 | val expectation = (RT.Yes,[RT.Yes,RT.Yes,RT.Yes,RT.Yes]) 90 | in 91 | (expectation,(conns,id,axioms)) 92 | end 93 | 94 | val id_case10 = 95 | let 96 | val conns = [and_tuple,or_tuple_c,imp_tuple_s,imp_tuple] 97 | val id = id_rules2 98 | val expectation = (RT.Maybe,[RT.No,RT.Yes,RT.Yes,RT.No]) 99 | in 100 | (expectation,(conns,id,axioms)) 101 | end 102 | 103 | val id_expansion_cases = [id_case1,id_case2,id_case3,id_case4,id_case5, 104 | id_case6,id_case7,id_case8,id_case9,id_case10] 105 | end -------------------------------------------------------------------------------- /sml/unit_test/properties_tests/test_cases/permute_test_cases.sml: -------------------------------------------------------------------------------- 1 | structure PTCases = 2 | struct 3 | structure R = Rules 4 | 5 | 6 | val permute_case1 = 7 | let 8 | val expectation = RT.Yes 9 | val weakening = ([true],[false]) 10 | val init_rules = [R.id] 11 | val rule1 = R.orR1 12 | val rule2 = R.andL 13 | in 14 | (expectation,(rule1,rule2,init_rules,weakening)) 15 | end 16 | 17 | val permute_case2 = 18 | let 19 | val expectation = RT.Yes 20 | val weakening = ([true],[false]) 21 | val init_rules = [R.id] 22 | val rule1 = R.orR2 23 | val rule2 = R.andL 24 | in 25 | (expectation,(rule1,rule2,init_rules,weakening)) 26 | end 27 | 28 | val permute_case3 = 29 | let 30 | val expectation = RT.No 31 | val weakening = ([true],[false]) 32 | val init_rules = [R.id] 33 | val rule1 = R.andRs 34 | val rule2 = R.orLs 35 | in 36 | (expectation,(rule1,rule2,init_rules,weakening)) 37 | end 38 | 39 | val permute_case4 = 40 | let 41 | val expectation = RT.Yes 42 | val weakening = ([true],[false]) 43 | val init_rules = [R.id] 44 | val rule1 = R.andRs 45 | val rule2 = R.orLc 46 | in 47 | (expectation,(rule1,rule2,init_rules,weakening)) 48 | end 49 | 50 | val permute_case5 = 51 | let 52 | val expectation = RT.Maybe 53 | val weakening = ([true],[false]) 54 | val init_rules = [R.id] 55 | val rule1 = R.andR 56 | val rule2 = R.orLc 57 | in 58 | (expectation,(rule1,rule2,init_rules,weakening)) 59 | end 60 | 61 | val permute_case5 = 62 | let 63 | val expectation = RT.Maybe 64 | val weakening = ([true],[false]) 65 | val init_rules = [R.id] 66 | val rule2 = R.andR 67 | val rule1 = R.orLc 68 | in 69 | (expectation,(rule1,rule2,init_rules,weakening)) 70 | end 71 | 72 | val permute_cases = [permute_case1,permute_case2,permute_case3,permute_case4,permute_case5] 73 | end -------------------------------------------------------------------------------- /sml/unit_test/properties_tests/test_cases/weakening_test_cases.sml: -------------------------------------------------------------------------------- 1 | structure WTCases = 2 | struct 3 | 4 | structure R = Rules 5 | 6 | val wk_case1 = 7 | let 8 | val expectations = ([RT.Yes],[RT.No]) 9 | val rules = [R.id,R.andR,R.andL,R.orR1,R.orR2,R.orLc,R.impR,R.impL] 10 | in 11 | (expectations,rules) 12 | end 13 | val wk_case2 = 14 | let 15 | val expectations = ([RT.Maybe],[RT.No]) 16 | val rules = [R.id_no_ctx,R.andR,R.andL,R.orR1,R.orR2,R.orLc,R.impR,R.impL] 17 | in 18 | (expectations,rules) 19 | end 20 | 21 | val weakening_cases = [wk_case1,wk_case2] 22 | end -------------------------------------------------------------------------------- /sml/unit_test/unit_test.cm: -------------------------------------------------------------------------------- 1 | Group 2 | structure Gen 3 | structure Rules 4 | structure UnitTest 5 | structure U_Pred 6 | structure App_Pred 7 | structure T_Pred 8 | structure OrdKeysTest 9 | structure DatatypesTest 10 | structure HelpersTest 11 | structure PropertiesTest 12 | is 13 | ../basics/basics.cm 14 | ../applyunifier/applyunifier.cm 15 | ../unification/unification.cm 16 | ../equiv/equiv.cm 17 | ../qcheck/qcheck.cm 18 | ../tree_func/tree_func.cm 19 | ../properties/properties.cm 20 | generators/gen.sml 21 | generators/rules.sml 22 | unification_pred/unification_pred.sml 23 | apply_sub_pred/apply_sub_pred.sml 24 | tree_func_pred/tree_func_pred.sml 25 | basics_tests/datatypes_test.sml 26 | basics_tests/helpers_test.sml 27 | basics_tests/ord_keys_test.sml 28 | properties_tests/test_cases.sml 29 | properties_tests/properties_tests.sml 30 | properties_tests/result_type.sml 31 | properties_tests/test_cases/id_expansion_test_cases.sml 32 | properties_tests/test_cases/permute_test_cases.sml 33 | properties_tests/test_cases/weakening_test_cases.sml 34 | properties_tests/test_cases/cut_elim_test_cases.sml 35 | unit_test.sml 36 | -------------------------------------------------------------------------------- /sml/unit_test/unit_test.sml: -------------------------------------------------------------------------------- 1 | structure UnitTest = 2 | struct 3 | structure D = DatatypesTest 4 | structure Q = QCheck 5 | structure G = Gen 6 | structure U = U_Pred 7 | structure AP = App_Pred 8 | structure TP = T_Pred 9 | structure D = datatypesImpl 10 | structure OK = OrdKeysTest 11 | structure DT = DatatypesTest 12 | structure HT = HelpersTest 13 | structure PT = PropertiesTest 14 | 15 | (* needed for QCheck function: *) 16 | (* reader: ('a gen * ('a -> string) option) *) 17 | (* 'a pred: 'a -> bool *) 18 | (* 'a prop: (string * 'a pred) *) 19 | 20 | 21 | 22 | end 23 | -------------------------------------------------------------------------------- /tempProofs/silly.txt: -------------------------------------------------------------------------------- 1 | Some Silly File -------------------------------------------------------------------------------- /views/calculus/index.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
8 |
9 |
10 |
11 | 14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Add Rule 23 |
24 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 |
Rule SymbolsTypes
34 |
35 | 36 |
37 |
39 | 48 | 49 |
atom variable
formula variable
context variable
connective
sequent sign
context separator
77 |


78 |
79 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /views/layouts/apply.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{title}} 12 | 13 | 14 |
15 | 100 |
101 | 102 | 103 | {{> navbar}} 104 | {{{body}}} 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /views/layouts/calculus.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 20 |
21 | 22 | {{> navbar}} 23 | {{{body}}} 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /views/layouts/cutadmiss.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 32 |
33 | 34 | {{> navbar}} 35 | {{{body}}} 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /views/layouts/initcoherence.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 32 |
33 | 34 | {{> navbar}} 35 | {{{body}}} 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /views/layouts/landing_in.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 83 |
84 | 85 | {{> main_navbar}} 86 | {{{body}}} 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /views/layouts/landing_out.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 82 |
83 | 84 | {{> log_navbar}} 85 | {{{body}}} 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /views/layouts/layout.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Abdulrahman Alfayad 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 | {{{body}}} 14 | 15 | -------------------------------------------------------------------------------- /views/layouts/login.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 20 |
21 | 22 | {{> log_navbar}} 23 | {{{body}}} 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /views/layouts/main.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 20 |
21 | 22 | {{> main_navbar}} 23 | {{{body}}} 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /views/layouts/permutability.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 32 |
33 | 34 | {{> navbar}} 35 | {{{body}}} 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /views/layouts/properties.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 20 |
21 | 22 | {{> navbar}} 23 | {{{body}}} 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /views/layouts/rule.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 20 |
21 | 22 | {{> navbar}} 23 | {{{body}}} 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /views/layouts/temporary.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 20 |
21 | 22 | {{> main_navbar}} 23 | {{{body}}} 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /views/layouts/weakadmiss.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 | 8 | 9 | 10 | {{title}} 11 | 12 | 13 |
14 | 32 |
33 | 34 | {{> navbar}} 35 | {{{body}}} 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /views/login/index.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Login
8 |
9 |
10 |
11 |
12 |
13 |
Username:
14 | 15 |
16 |
17 |
18 |
19 |
20 |
Password:
21 | 22 |
23 |
24 |
25 | 28 |
29 | 32 |
33 | New to Sequoia? You can sign up here! 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /views/login/landing.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
8 |
9 |

Welcome to Sequoia!

10 |

Design, play with, and analyze sequent calculus proof systems.

11 |
12 | Get Started 13 |
14 |
15 |
16 |
17 | 18 |
19 |
20 |
21 |
22 |
23 |
24 |

DESIGN

25 |

Create, save, modify, and manage your own calculi.

26 |
27 |
28 | 29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 38 |
39 |
40 |

PLAY

41 |

Build proof trees in your calculus and understand how the rules 42 | interact. You can use concrete or schematic sequents.

43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |

ANALYZE

52 |

Investigate meta-theoretical properties for your calculus systems (such as 53 | identity expansion, weakening admissibility, and permutability of 54 | rules). Sequoia is able to infer most of the trivial cases 55 | automatically.

56 |
57 |
58 | 59 |
60 |
61 |
62 |
63 |
64 |
65 | Sequoia is developed by: 66 | 69 | Past team members: 70 | 75 |
76 |
77 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /views/login/register.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Create an Account
8 |
9 |
10 |
11 |
12 | 13 | 14 |
15 |
16 | 17 | 18 |
19 |
20 | 21 | 22 |
23 |
24 |
25 |
26 | 27 | 28 |
29 |
30 | 31 | 37 |
38 |
39 | 40 | Sign up 41 | 42 |
43 | 46 |
47 | Already have an account? You can login here! 48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /views/main/index.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
{{username}}'s Calculi
8 |
9 |
10 |
11 |

Create your own calculus:

12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 |
20 | 21 |
22 |
23 |
24 | Add Custom Calculus 25 |
OR
26 |

Try one of the built-in calculi (you can edit them as you like):

27 |
28 | LJ System 29 | LK System 30 | S4 System 31 | Lax System 32 |



33 |
34 | 45 | 46 | -------------------------------------------------------------------------------- /views/partials/log_navbar.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
8 | 21 |
22 | -------------------------------------------------------------------------------- /views/partials/main_navbar.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
8 | 21 |
22 | -------------------------------------------------------------------------------- /views/partials/navbar.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem, Abdulrahman Alfayad 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
8 | 30 |
31 | -------------------------------------------------------------------------------- /views/properties/cutadmiss.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Cut Admissibility
8 |

9 |
10 |
11 |
12 | Any sequent provable using (one of) the cut rule(s) can be proved 13 | without the use of this rule. 14 |
15 |
16 |

17 |
18 | Select a cut rule to check if it is admissibile in your calculus using 19 | Gentzen's proof strategy. 20 |
21 |
22 |
23 |
24 |
Perform Check
25 | 29 |
30 | 33 |
34 | 42 |

43 |
44 |
45 |
Loading
46 |
47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /views/properties/index.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Calculus Properties
8 |
9 | 10 | Identity Expansion 11 | 12 |
13 | 14 | Weakening Admissibility 15 | 16 |
17 | 18 | Permutability 19 | 20 |
21 | 22 | Cut Admissibility 23 | 24 |
25 | 26 | Invertibility 27 | 28 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /views/properties/initcoherence.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Identity Expansion
8 |

9 |
10 |
11 |
12 | If the identity rules are restricted to atomic formulas, then for any 13 | proposition $P$ there are proofs of $P \vdash P$. 14 |
15 |
16 |
17 | 21 |
22 | 25 |
26 | 32 |

33 |
34 |
35 |
Loading
36 |
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /views/properties/invertibility.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Invertibility 8 |
Select a rule to check if it is invertible to all other rules in your calculus
9 |
10 |

11 |
12 |
13 |
14 |
Perform Check
15 | 19 |
20 | 23 |
24 |
25 |
26 |

27 |
28 |
29 |
Loading
30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /views/properties/permutability.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Permutability
8 |
9 |
10 |
11 | Let $T_1$ be the proof tree $\cfrac{\cfrac{\cdots}{\cdots} r_2}{S} r_1$. 12 | If $T_1$ implies the existence of a proof tree $T_2$ = $\cfrac{\cfrac{\cdots}{\cdots} r_1}{S} r_2$, 13 | then we say that $r_1$ permutes up $r_2$. 14 |
15 |
16 |
17 |
18 | Select two rules to check if the first permutes up the second. 19 |
20 |
21 |
22 |
23 |
Perform Check
24 | 28 |
29 | 32 |
33 |
34 |
35 |

36 |
37 |
38 |
Loading
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /views/properties/weakadmiss.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Weakening Admissibility
8 |

9 |
10 |
11 |
12 | If $\Gamma \vdash \Delta$, then $\Gamma, W^* \vdash \Delta$. 13 |
14 |
15 |
16 | 20 |
21 | 24 |
25 |
26 |
27 |

28 |
29 |
30 |
Loading
31 |
32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /views/temporary/index.hbs: -------------------------------------------------------------------------------- 1 | {{!-- Sequoia Copyright (C) 2020 Zan Naeem 2 | This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE. 3 | This is free software, and you are welcome to redistribute it 4 | under certain conditions; see LICENSE for details. --}} 5 | 6 | 7 |
Page still under construction.
8 |
9 |





10 | 11 |







12 | 13 | Back 14 | 15 |
16 | --------------------------------------------------------------------------------