Compare commits

...

41 Commits

Author SHA1 Message Date
Chris Cromer d86b1e7dbd
Merge pull request #2 from cromerc/develop
Develop
2023-11-14 13:26:47 -03:00
Chris Cromer b9e8ca4157
Merge pull request #1 from cromerc/docker
Docker
2023-11-14 13:26:21 -03:00
Chris Cromer fd696a87d4
add docker build and instructions 2023-11-14 13:25:38 -03:00
Chris Cromer c0e93e5e27
add out directory to ignore file for git 2023-11-14 13:25:12 -03:00
Chris Cromer 56f9cf6e31
make it clear that it's the sqlite3 library and not the cli 2023-11-14 11:00:01 -03:00
Chris Cromer bac041dd60 Merge pull request 'develop' (#29) from develop into master
Reviewed-on: #29
2023-05-02 23:27:50 -04:00
Chris Cromer 2671e92b01 Merge branch 'master' into develop 2023-05-02 23:27:19 -04:00
Chris Cromer f91930c41d Merge pull request 'feature/remove_sqlite' (#28) from feature/remove_sqlite into develop
Reviewed-on: #28
2023-05-02 23:26:54 -04:00
Chris Cromer df31fda99c
Prepare 1.0.4. 2023-05-02 23:26:01 -04:00
Chris Cromer 819bcebce0
Add script and instructions to download SQLite when building. 2023-05-02 23:24:43 -04:00
Chris Cromer edc0e2a39f
Ignore SQLite source and header files. 2023-05-02 23:23:08 -04:00
Chris Cromer 7f49c1c065
Remove SQLite from repo. 2023-05-02 23:21:56 -04:00
Chris Cromer 20c9a0c1a5 Merge pull request 'develop' (#27) from develop into master
Reviewed-on: #27
2023-04-17 20:49:03 -04:00
Chris Cromer 42d1ac9bb7 Merge pull request 'prepare 1.0.3' (#26) from feature/add_readme into develop
Reviewed-on: #26
2023-04-17 20:48:39 -04:00
Chris Cromer 9869d369c4 Merge branch 'develop' into feature/add_readme 2023-04-17 20:48:32 -04:00
Chris Cromer 5d8b7af28d
prepare 1.0.3 2023-04-17 20:47:59 -04:00
Chris Cromer efc00f3473 Merge pull request 'develop' (#25) from develop into master
Reviewed-on: #25
2023-04-17 20:44:00 -04:00
Chris Cromer 578c350b7b Merge branch 'master' into develop 2023-04-17 20:43:53 -04:00
Chris Cromer f85f8a4637 Merge pull request 'add readme' (#24) from feature/add_readme into develop
Reviewed-on: #24
2023-04-17 20:43:23 -04:00
Chris Cromer 7d57800046
add readme 2023-04-17 20:42:26 -04:00
Chris Cromer bdc69ceea7 Merge pull request 'develop' (#23) from develop into master
Reviewed-on: #23
2023-03-05 23:06:26 -03:00
Chris Cromer 5f9af90e80 Merge branch 'master' into develop 2023-03-05 23:06:20 -03:00
Chris Cromer 4d7ecf8258 Merge pull request 'feature/fix_recursive_rules' (#22) from feature/fix_recursive_rules into develop
Reviewed-on: #22
2023-03-05 23:06:02 -03:00
Chris Cromer 04902214b7
prepare 1.0.2 2023-03-05 23:05:18 -03:00
Chris Cromer 0bfd93150f
update facts and rules recursively 2023-03-05 23:04:17 -03:00
Chris Cromer 96a5f25e02 Merge pull request 'develop' (#21) from develop into master
Reviewed-on: #21
2023-03-05 22:20:21 -03:00
Chris Cromer d4c4d3fe75 Merge pull request 'typo' (#20) from typo into develop
Reviewed-on: #20
2023-03-05 22:19:56 -03:00
Chris Cromer 33808b4906
fix typo 2023-03-05 22:18:52 -03:00
Chris Cromer 44262df885 Merge pull request 'develop' (#19) from develop into master
Reviewed-on: #19
2023-02-28 22:17:52 -03:00
Chris Cromer 5db2343b23 Merge branch 'master' into develop 2023-02-28 22:17:45 -03:00
Chris Cromer a07b94a228 Merge pull request 'feature/finishing_touches' (#18) from feature/finishing_touches into develop
Reviewed-on: #18
2023-02-28 22:17:19 -03:00
Chris Cromer 7e3cd0af75
prepare 1.0.1 2023-02-28 22:15:55 -03:00
Chris Cromer 97a91a0d6d
add 2 examples 2023-02-28 22:15:01 -03:00
Chris Cromer a91bc9b579
enable example files to be commited 2023-02-28 22:14:51 -03:00
Chris Cromer f2108492b8
make it clearer what is being returned 2023-02-28 22:11:48 -03:00
Chris Cromer 6a922e7464 Merge pull request 'restructure the includes to work in external programs' (#17) from develop into master
Reviewed-on: #17
2023-02-26 02:04:58 -03:00
Chris Cromer 69ce8faad7 Merge branch 'master' into develop 2023-02-26 02:04:52 -03:00
Chris Cromer 6ba11f1cc9
restructure the includes to work in external programs 2023-02-26 02:04:07 -03:00
Chris Cromer cf9b5a02e1 Merge pull request 'build a static obelisk library for easier linking with other software' (#16) from develop into master
Reviewed-on: #16
2023-02-25 21:29:52 -03:00
Chris Cromer 60b920bc86 Merge branch 'master' into develop 2023-02-25 21:29:23 -03:00
Chris Cromer 402862b54a
build a static obelisk library for easier linking with other software 2023-02-25 21:27:32 -03:00
21 changed files with 172 additions and 13 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
README.md
LICENSE
.pre-commit-config.yaml
.gitignore
.clang-format
examples
Dockerfile
build
builddir
out

4
.gitignore vendored
View File

@ -3,3 +3,7 @@
builddir
*.kb
*.obk
!examples/*.obk
sqlite/*.c
sqlite/*.h
out

26
Dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM ubuntu:22.04 AS build-prep
RUN apt update && apt upgrade -y
RUN apt install -y llvm clangd meson ninja-build pkg-config libsqlite3-dev doxygen graphviz wget unzip
WORKDIR /obelisk
COPY . .
RUN ./sqlite.sh
FROM build-prep AS build-machine
RUN meson --prefix=/usr build
RUN cd build && ninja -v
FROM build-machine AS build-machine-intermediate
RUN cd /obelisk/build/src/lib && rm -rf *.h *.p models
FROM scratch AS obelisk
COPY --from=build-machine-intermediate /obelisk/build/src /bin/
COPY --from=build-machine-intermediate /obelisk/build/src/lib /lib/
COPY --from=build-machine-intermediate /obelisk/build/doc/man /man/
COPY --from=build-machine-intermediate /obelisk/build/doc/html /doc/
ENTRYPOINT [ "/bin/obelisk" ]
FROM scratch AS binaries
COPY --from=obelisk /bin/obelisk /bin/
COPY --from=obelisk /lib /lib/
COPY --from=obelisk /man /man/
COPY --from=obelisk /doc /doc/

52
README.md Normal file
View File

@ -0,0 +1,52 @@
# Obelisk
The Obelisk project is a declarative language designed to help with the implementation of Artificial Intelligence using an easy to use logical programming language.
## Build requirements
- Meson
- Ninja
- LLVM 14
- sqlite 3 library and headers(in debian libsqlite3-dev)
- C++ 17
- C 17
## Build
### Normal build
```
./sqlite.sh
meson builddir
cd buildir
ninja
```
This process will generate the binary "obelisk", a shared library "libobelisk.so", and a static library "libobelisk.a".
The binary is used to compile and create obelisk knowledge bases and the the libraries can be linked against to consult the Obelisk knowledge base from any software that can link with the libraries.
### Build in docker image
```
docker build ./ --output=out
```
This will create a directory called out which will contain the binaries, libraries, and generated documentation.
## Install
```
ninja install
```
This will install the Obelisk cli and the Obelisk library globally. You can also copy the resulting shared and/or static library to a project to link against and use an Obelisk knowledge base.
## License
Obelisk is licensed under the [The 3-Clause BSD License](LICENSE).
## Authors
- Christopher Cromer
- Martín Araneda

2
examples/multi-fact.obk Normal file
View File

@ -0,0 +1,2 @@
# this is a comment
fact("chris cromer" and "martin" and "Isabella" can "program" and "speak english");

19
examples/obelisk.obk Normal file
View File

@ -0,0 +1,19 @@
// an incomplete rule, this one stays false
rule("chris" is "happy" if "chris" plays "playstation");
// a rule that gets inserted as true right away
fact("this" is "madness");
rule("this" is "sparta" if "this" is "madness");
// a rule that is inserted as false then updated at a later stage
rule("bruce" is "batman" if "the waynes" are "dead");
fact("the waynes" are "dead");
// an action that will be false because the fact doesn't exist, should return ignore
action(if "tom" is "dangerous" then "avoid" else "ignore");
// an action that will be true, should return die
action(if "this" is "sparta" then "die" else "live");
fact("what" is "love");
rule("baby" dont "hurt me" if "what" is "love");

View File

@ -1,7 +1,7 @@
project('obelisk',
'c',
'cpp',
version : '1.0.0',
version : '1.0.4',
license : 'BSD-3-Clause',
default_options : [
'warning_level=3',
@ -30,4 +30,5 @@ if docs_enabled
endif
endif
subdir('sqlite')
subdir('src')

11
sqlite.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
VERSION=sqlite-amalgamation-3410000
pushd sqlite
wget https://sqlite.org/2023/${VERSION}.zip
unzip ${VERSION}.zip
cp ${VERSION}/sqlite3.c .
cp ${VERSION}/sqlite3.h .
rm -rf ${VERSION} ${VERSION}.zip
popd

20
sqlite/meson.build Normal file
View File

@ -0,0 +1,20 @@
sqlite_sources = files(
'sqlite3.c'
)
sqlite_include_directories = include_directories(['.'])
sqlite_args = [
'-DSQLITE_OMIT_DESERIALIZE',
'-DSQLITE_OMIT_DEPRECATED',
'-DSQLITE_OMIT_JSON',
'-DSQLITE_OMIT_LOAD_EXTENSION',
'-DSQLITE_OMIT_PROGRESS_CALLBACK',
'-DSQLITE_DEFAULT_FOREIGN_KEYS=1',
'-DSQLITE_DEFAULT_AUTOVACUUM=1',
'-DSQLITE_DISABLE_LFS',
'-DSQLITE_OMIT_TEMPDB',
'-DSQLITE_OMIT_GET_TABLE',
'-DSQLITE_OMIT_COMPLETE',
'-DSQLITE_OMIT_COMPILEOPTION_DIAGS'
]

View File

@ -56,10 +56,10 @@ int obelisk::Lexer::getToken()
if (getIdentifier() == "extern")
{
return kTokenExtern;
return Token::kTokenExtern;
}
return kTokenIdentifier;
return Token::kTokenIdentifier;
}
if (isdigit(lastChar))

View File

@ -80,23 +80,27 @@ namespace obelisk
* @brief A fact which is a relationship between 2 entities.
*
*/
kTokenFact = -2,
kTokenFact = -2,
/**
* @brief A rule which is a relationship between a new fact a
* existing fact.
*
*/
kTokenRule = -3,
kTokenRule = -3,
/**
* @brief An action to take if a fact is true.
*
*/
kTokenAction = -4,
/**
* @brief A definition of a new function.
*
*/
kTokenDef = -5,
kTokenDef = -5,
/**
* @brief An external function that will be linked to.
*
@ -108,16 +112,18 @@ namespace obelisk
*
*/
kTokenIdentifier = -7,
/**
* @brief A double floating point value.
*
*/
kTokenNumber = -8,
kTokenNumber = -8,
/**
* @brief A string.
*
*/
kTokenString = -9
kTokenString = -9
};
/**

View File

@ -250,6 +250,7 @@ void obelisk::KnowledgeBase::checkRule(obelisk::Fact& fact)
auto updateFact = rule.getFact();
updateFact.setIsTrue(1.0);
updateFact.updateIsTrue(dbConnection_);
checkRule(updateFact);
}
}
}

View File

@ -16,14 +16,21 @@ obelisk_lib_sources = files(
)
obelisk_lib_sources += obelisk_model_sources
sqlite3 = dependency('sqlite3')
obelisk_lib_sources += sqlite_sources
incdirs = include_directories(['.', 'include'])
lib = library('obelisk',
lib = static_library('obelisk',
obelisk_lib_sources,
c_args : sqlite_args,
include_directories: [incdirs, sqlite_include_directories],
install : true
)
shared_library('obelisk',
obelisk_lib_sources,
c_args : sqlite_args,
include_directories: incdirs,
dependencies : [sqlite3],
version : meson.project_version(),
soversion : project_version_lib,
install : true

View File

@ -15,7 +15,7 @@ namespace obelisk
*
*/
std::string usageMessage = R"(Usage: obelisk [OPTION]... [FILE]...
Compile the obelisk source FILE(s) into knoweldge base and library.
Compile the obelisk source FILE(s) into knowledge base and library.
Options:
-h, --help shows this help/usage message