DFA

Struct DFA 

Source
pub struct DFA { /* private fields */ }
Expand description

Automate a état fini déterministe

Implementations§

Source§

impl DFA

Source

pub fn new( _start: State, _delta: HashMap<Transition<State>, State>, _fsm: FSM, ) -> Self

Créer un automate a état fini déterministe

§Arguments
  • _start - L’état initial de l’automate
  • _delta - Une HashMap decrivant les differentes transition de l’automate
  • _fsm - Une machine à état fini décrivant l’automate
§Examples

Le contenu du json

{
    "states" : ["q_0","q_1"],
    "alphabet" : ["b","a"],
    "ends" : ["q_0"],
    "start" : "q_0", 
    "delta" : [
    	{
    		"state" : "q_0",         
    		"symbol" : "a",         
    		"image" : "q_1"         
    	},         
    	{         
    		"state" : "q_1",         
    		"symbol" : "b",         
    		"image" : "q_0"        
    	}
    ] 
}
 

Le chargement dans le code

use automaters::*;
use std::fs;
use serde_json::{Value, from_str};
fn main() {
 
    let link_file: &str = "src/automates/DFA1.json";
    let content_json: Value = {
        // Charge le contenu du fichier en tant que String
        let content : String = fs::read_to_string(link_file).unwrap();
        // Parse le texte en structure Json
        from_str::<Value>(&content).unwrap()
    };
    //creation depuis un lien
    let dfa : DFA = DFA::from_json_file(link_file);  
    //creation depuis du json
    let dfa2 : DFA = DFA::from_json(&content_json);
    let fsm: FSM = FSM::from_json(&content_json);
    //creation depuis new
    let dfa3 : DFA = DFA::new(dfa.get_start().clone(), dfa.get_delta().clone(), fsm.clone());  
 
}
§Return
  • DFA - L’automate déterministe à état fini correspondante
Source

pub fn apply_delta(&self, transition: Transition<State>) -> Option<&State>

Source

pub fn to_transpose(&self) -> NDFA

Réalise la transposition de l’automate

use automaters::*;
use std::fs;
use serde_json::{Value, from_str};
fn main() {
    let link_file: &str = "src/automates/DFA1.json";
    let content_json: Value = {
        // Charge le contenu du fichier en tant que String
        let content : String = fs::read_to_string(link_file).unwrap();
        // Parse le texte en structure Json
        from_str::<Value>(&content).unwrap()
    };
    //creation depuis un lien
    let dfa : DFA = DFA::from_json_file(link_file);  
    let nfa : NDFA = dfa.to_transpose();
}
§Return
  • NDFA - Un NDFA correspondant a la transposition de self
Source

pub fn to_minimize(&self) -> DFA

Renvoie la version minimize de l’automate

use automaters::*;
use std::fs;
use serde_json::{Value, from_str};
fn main() {
    let link_file: &str = "src/automates/DFA1.json";
    let content_json: Value = {
        // Charge le contenu du fichier en tant que String
        let content : String = fs::read_to_string(link_file).unwrap();
        // Parse le texte en structure Json
        from_str::<Value>(&content).unwrap()
    };
    //creation depuis un lien
    let mut dfa : DFA = DFA::from_json_file(link_file);  
    // minimisation
    dfa = dfa.to_minimize();
}
§Return
  • DFA - Le DFA apres avoir été minimizé

Trait Implementations§

Source§

impl AutomateJsonIO for DFA

Source§

fn from_json(content_json: &Value) -> Self

Créer un automate à état fini détérministe depuis un chemin du json

§Arguments
  • _start - L’état initial de l’automate
  • _delta - Une HashMap decrivant les differentes transition de l’automate
  • _fsm - Une machine à état fini décrivant l’automate
§Examples

Le contenu du json

{
    "states" : ["q_0","q_1"],
    "alphabet" : ["b","a"],
    "ends" : ["q_0"],
    "start" : "q_0", 
    "delta" : [
    	{
    		"state" : "q_0",         
    		"symbol" : "a",         
    		"image" : "q_1"         
    	},         
    	{         
    		"state" : "q_1",         
    		"symbol" : "b",         
    		"image" : "q_0"        
    	}
    ] 
}
 

Le chargement dans le code

use automaters::*;
use std::fs;
use serde_json::{Value, from_str};
fn main() {
 
    let link_file: &str = "src/automates/DFA1.json";
    let content_json: Value = {
        // Charge le contenu du fichier en tant que String
        let content : String = fs::read_to_string(link_file).unwrap();
        // Parse le texte en structure Json
        from_str::<Value>(&content).unwrap()
    };
    //creation depuis du json
    let dfa : DFA = DFA::from_json(&content_json);
 
}
§Return
  • DFA - L’automate déterministe à état fini correspondante
Source§

fn from_json_file(path: &str) -> Self

Créer un automate à état fini détérministe depuis un chemin vers un fichier json

§Arguments
  • _start - L’état initial de l’automate
  • _delta - Une HashMap decrivant les differentes transition de l’automate
  • _fsm - Une machine à état fini décrivant l’automate
§Examples

Le contenu du json

{
    "states" : ["q_0","q_1"],
    "alphabet" : ["b","a"],
    "ends" : ["q_0"],
    "start" : "q_0", 
    "delta" : [
    	{
    		"state" : "q_0",         
    		"symbol" : "a",         
    		"image" : "q_1"         
    	},         
    	{         
    		"state" : "q_1",         
    		"symbol" : "b",         
    		"image" : "q_0"        
    	}
    ] 
}
 

Le chargement dans le code

use automaters::*;
use std::fs;
use serde_json::{Value, from_str};
fn main() {
 
    let link_file: &str = "src/automates/DFA1.json";
    let content_json: Value = {
        // Charge le contenu du fichier en tant que String
        let content : String = fs::read_to_string(link_file).unwrap();
        // Parse le texte en structure Json
        from_str::<Value>(&content).unwrap()
    };
    //creation depuis un lien
    let dfa : DFA = DFA::from_json_file(link_file);  
 
}
§Return
  • DFA - L’automate déterministe à état fini correspondante
Source§

impl AutomateTrait<State> for DFA

Source§

fn get_start(&self) -> &State

Retourne l’état de départ de l’automate

Source§

fn get_starts(&self) -> &State

Aliases of self.get_start

Source§

fn get_fsm(&self) -> &FSM

Retourne la machine de l’automate

Source§

fn get_delta(&self) -> &HashMap<Transition<State>, State>

Retourne les transitions de l’automate

Source§

fn get_states(&self) -> &BTSet<State>

Retournes les differents états de l’automate

Source§

fn get_alphabet(&self) -> &BTSet<Symbol>

Retourne l’alphabet de l’automate

Source§

fn get_ends(&self) -> &BTSet<State>

Retourne les états finaux de l’automate

Source§

fn accept(&self, _word: &str) -> bool

indique si un mot est accepté dans la langue de l’automate

Source§

fn to_dfa(&self) -> DFA

renvoie un clone de l’automate actuel puisqu’il est déjà determinist

Source§

impl Clone for DFA

Source§

fn clone(&self) -> DFA

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DFA

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for DFA

§

impl RefUnwindSafe for DFA

§

impl Send for DFA

§

impl Sync for DFA

§

impl Unpin for DFA

§

impl UnwindSafe for DFA

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.