Simple expression transformer that is not Coq.

Related tags

Text processing Noq
Overview

Noq

Not Coq. Simple expression transformer that is not Coq.

Quick Start

$ cargo run ./examples/add.noq

Main Idea

The Main Idea is being able to define transformation rules of symbolic algebraic expressions and sequentially applying them.

Expression

Current expression syntax:

<expression> ::= <symbol> | <functor> | <var>
<var> ::= [A-Z][a-zA-Z0-9]*
<symbol> ::= [a-z0-9][a-zA-Z0-9]*
<functor> ::= <expression> ( [<expression>],* )

Rules and Shapes

The two main entities of the languare are Rules and Shapes. A rule defines pattern (head) and it's corresponding substitution (body). The rule definition has the following syntax:

rule <name:symbol> <head:expression> = <body:expression>

Here is an example of a rule that swaps elements of a pair:

rule swap swap(pair(A, B)) = pair(B, A)

Shaping is a process of sequential applying of rules to an expression transforming it into a different expression. Shaping has the following syntax:

shape <expression>
  ... sequence of rule applications ...
done

For example here is how you shape expression swap(pair(f(a), g(b))) with the swap rule defined above:

shape swap(pair(f(a), g(b)))
  apply all swap
done

The result of this shaping is pair(g(b), f(a)).

Anonymous rules

You don't have to define a rule to use it in shaping. You can directly describe it after the apply keyword:

shape swap(pair(f(a), g(b)))
  apply all rule swap(pair(A, B)) = pair(B, A)
done

Notice that we do not provide the rule name after the rule keyword.

Comments
  • Cannot Compile On Windows

    Cannot Compile On Windows

    Hello, I am a applied mathematician. I wanted to compile and give a try your interesting project but the compiling process fails on Windows due to Termion library. I am new to Rust and dont have any experience on it. Can somebody help me, please?

    opened by semihartan 4
  • Cannot compile on windows

    Cannot compile on windows

    I've cloned the repo, but running 'cargo run' seems to be failing on my windows.

       Compiling termion v1.5.6
    error[E0433]: failed to resolve: maybe a missing crate `sys`?
      --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\lib.rs:24:9
       |
    24 | pub use sys::size::terminal_size;
       |         ^^^ maybe a missing crate `sys`?
    
    error[E0433]: failed to resolve: maybe a missing crate `sys`?
      --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\lib.rs:27:9
       |
    27 | pub use sys::tty::{is_tty, get_tty};
       |         ^^^ maybe a missing crate `sys`?
    
    error[E0433]: failed to resolve: maybe a missing crate `sys`?
     --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\async.rs:5:5
      |
    5 | use sys::tty::get_tty;
      |     ^^^ maybe a missing crate `sys`?
    
    error[E0433]: failed to resolve: maybe a missing crate `sys`?
      --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:28:5
       |
    28 | use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
       |     ^^^ maybe a missing crate `sys`?
    
    error[E0432]: unresolved import `sys`
      --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:29:5
       |
    29 | use sys::Termios;
       |     ^^^ maybe a missing crate `sys`?
    
    error[E0425]: cannot find function `get_tty` in this scope
      --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\async.rs:14:36
       |
    14 |     thread::spawn(move || for i in get_tty().unwrap().bytes() {
       |                                    ^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `get_tty` in this scope
      --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\async.rs:43:36
       |
    43 |     thread::spawn(move || for i in get_tty().unwrap().bytes() {
       |                                    ^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `set_terminal_attr` in this scope
      --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:45:9
       |
    45 |         set_terminal_attr(&self.prev_ios).unwrap();
       |         ^^^^^^^^^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `get_terminal_attr` in this scope
       --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:102:23
        |
    102 |         let mut ios = get_terminal_attr()?;
        |                       ^^^^^^^^^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `raw_terminal_attr` in this scope
       --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:105:9
        |
    105 |         raw_terminal_attr(&mut ios);
        |         ^^^^^^^^^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `set_terminal_attr` in this scope
       --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:107:9
        |
    107 |         set_terminal_attr(&ios)?;
        |         ^^^^^^^^^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `set_terminal_attr` in this scope
       --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:119:9
        |
    119 |         set_terminal_attr(&self.prev_ios)?;
        |         ^^^^^^^^^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `get_terminal_attr` in this scope
       --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:125:23
        |
    125 |         let mut ios = get_terminal_attr()?;
        |                       ^^^^^^^^^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `raw_terminal_attr` in this scope
       --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:126:9
        |
    126 |         raw_terminal_attr(&mut ios);
        |         ^^^^^^^^^^^^^^^^^ not found in this scope
    
    error[E0425]: cannot find function `set_terminal_attr` in this scope
       --> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.5.6\src\raw.rs:127:9
        |
    127 |         set_terminal_attr(&ios)?;
        |         ^^^^^^^^^^^^^^^^^ not found in this scope
    
    Some errors have detailed explanations: E0425, E0432, E0433.
    For more information about an error, try `rustc --explain E0425`.
    error: could not compile `termion` due to 15 previous errors
    
    opened by mdrwsh 3
  • Added loading std from any location

    Added loading std from any location

    Now you can set NOQ_STD_PATH env variable to a path to folder with standard library you wanna use. When loading path is prefixed with std/ it will be replaced with this variable(if it's not set, the standard loading would start).

    opened by farkon00 0
  • No instruction for building

    No instruction for building

    Hi, For those who are not familiar with rust, can you provide instructions for compilation of Noq, especially under Windows? I am getting an error when running cargo build:

    note: LINK : fatal error LNK1181: cannot open input file 'advapi32.lib'

    When running rustc main.rs, I get an error regarding termion:

    error[E0433]: failed to resolve: maybe a missing crate termion?

    Thanks.

    opened by ghaspias 3
  • Request for procedures

    Request for procedures

    Description

    A shaping applies rules 'at compile time' whereas a procedure would apply the rules 'at runtime'.

    Example

    Disclaimer: This example assumes the usage of the 'all' strategy as described in #11, because I could not come up with a different example.

    eq_f :: eq(bool(true), bool(false)) = bool(false)
    eq_t :: eq(bool(A), bool(A)) = bool(true)
    
    basic_comm :: B(X, Y) = B(Y, X)
    
    # eq_resolve :: eq(bool(A), bool(B)) {
    #     eq_t | all
    #     eq_f | all
    #     basic_comm | all
    #     eq_f | all
    # }
    # 
    # result: eq(bool(A), bool(B))
    
    proc eq_resolve :: eq(bool(A), bool(B)) {
        eq_t | all
        eq_f | all
        basic_comm | all
        eq_f | all
    }
    
    eq(bool(false), bool(true)) {
        eq_resolve | all
    }
    
    # expected result: bool(false)
    
    opened by wiebecommajonas 0
Owner
Tsoding
Recreational Programming
Tsoding
Text Expression Runner – Readable and easy to use text expressions

ter - Text Expression Runner ter is a cli to run text expressions and perform basic text operations such as filtering, ignoring and replacing on the c

Maximilian Schulke 72 Jul 31, 2022
🔴〰️🔵〰️⚫ Not Only a Translator

?? Not Only a Translator ?? English·中文 ?? This program is not just a translation software, it is not named yet. Supports conversion of input character

Breaker 12 Dec 5, 2022
Simple NLP in Rust with Python bindings

vtext NLP in Rust with Python bindings This package aims to provide a high performance toolkit for ingesting textual data for machine learning applica

Roman Yurchak 133 Jan 3, 2023
Simple, extendable and embeddable scripting language.

duckscript duckscript SDK CLI Simple, extendable and embeddable scripting language. Overview Language Goals Installation Homebrew Binary Release Ducks

Sagie Gur-Ari 356 Dec 24, 2022
Simple STM32F103 based glitcher FW

Airtag glitcher (Bluepill firmware) Simple glitcher firmware running on an STM32F103 on a bluepill board. See https://github.com/pd0wm/airtag-dump for

Willem Melching 27 Dec 22, 2022
Simple Data Stealer

helfsteal Simple Data Stealer Hi All, I published basic data stealer malware with Rust. FOR EDUCATIONAL PURPOSES. You can use it for Red Team operatio

Ahmet Güler 7 Jul 7, 2022
A sweet n' simple pastebin with syntax highlighting and no client-side code!

sweetpaste sweetpaste is a sweet n' simple pastebin server. It's completely server-side, with zero client-side code. Configuration The configuration w

Lucy 0 Sep 4, 2022
A simple and fast linear algebra library for games and graphics

glam A simple and fast 3D math library for games and graphics. Development status glam is in beta stage. Base functionality has been implemented and t

Cameron Hart 953 Jan 3, 2023
A simple OpenAI (GPT-3) client written in Rust.

A simple OpenAI (GPT-3) client written in Rust. It works by making HTTP requests to OpenAI's API and consuming the results.

Apostolos Kiraleos 3 Oct 28, 2022
SEFF - Simple Embeddable Font Format

SEFF - Simple Embeddable Font Format This crate is designed to allow decent text rendering in resource-constrained environments like microcontrollers.

Cliff L. Biffle 3 May 2, 2022
Simple, robust, BitTorrent's Mainline DHT implementation

Mainline Simple, robust, BitTorrent's Mainline DHT implementation. This library is focused on being the best and simplest Rust client for Mainline, es

Nuh 4 Nov 21, 2023
Conditional compilation using boolean expression syntax, rather than any(), all(), not()

Conditional compilation expressions Conditional compilation using boolean expression syntax, rather than any(), all(), not(). [dependencies] efg = "0.

David Tolnay 298 Dec 28, 2022
Rust native ready-to-use NLP pipelines and transformer-based models (BERT, DistilBERT, GPT2,...)

rust-bert Rust native Transformer-based models implementation. Port of Hugging Face's Transformers library, using the tch-rs crate and pre-processing

null 1.3k Jan 8, 2023
Jest preprocessor/transformer for Rust

rs-jest tl;dr -- see examples This is a jest transformer that loads Rust code so it can be interop with Javascript base project. Currently, the Rust c

Fahmi Akbar Wildana 13 May 19, 2022
A CSS parser, transformer, and minifier written in Rust.

@parcel/css A CSS parser, transformer, and minifier written in Rust. Features Extremely fast – Parsing and minifying large files is completed in milli

Parcel 3.1k Jan 9, 2023
Tutorial for Porting PyTorch Transformer Models to Candle (Rust)

Candle Tutorial - Convert Pytorch Models to Candle Candle is an ML framework written in rust that takes advantage of the speed and memory safety Rust

Ogundepo Odunayo 28 Oct 23, 2023
Extract tokens by simple condition expression.

Condex Extract tokens by simple condition expression. | Docs | Latest Note | [dependencies]

Doha Lee 2 Jun 1, 2022
LR(1) grammar parser of simple expression

LR(1)语法分析程序 实验内容 编写LR(1)语法分析程序,实现对算术表达式的语法分析。要求所分析算数表达式由如下的文法产生: E -> E+T | E-T | T T -> T*F | T/F | F F -> (E) | num 程序设计与实现 使用方式:运行.\lr1-parser.exe

Gao Keyong 1 Nov 24, 2021
Parsing Expression Grammar (PEG) parser generator for Rust

Parsing Expression Grammars in Rust Documentation | Release Notes rust-peg is a simple yet flexible parser generator that makes it easy to write robus

Kevin Mehall 1.2k Dec 30, 2022